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

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.

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
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.

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.

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
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

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
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

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
=== added directory 'data/images/wui/editor/menus'
=== added file 'data/images/wui/editor/menus/load_map.png'
0Binary 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 differ0Binary 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
=== added file 'data/images/wui/editor/menus/main_menu.png'
1Binary 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 differ1Binary 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
=== added file 'data/images/wui/editor/menus/map_options.png'
2Binary 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 differ2Binary 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
=== added file 'data/images/wui/editor/menus/new_map.png'
3Binary 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 differ3Binary 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
=== added file 'data/images/wui/editor/menus/new_random_map.png'
4Binary 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 differ4Binary 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
=== renamed file 'data/images/wui/editor/editor_redo.png' => 'data/images/wui/editor/menus/redo.png'
=== added file 'data/images/wui/editor/menus/save_map.png'
5Binary 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 differ5Binary 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
=== renamed file 'data/images/wui/editor/editor_menu_toggle_tool_menu.png' => 'data/images/wui/editor/menus/tools.png'
=== renamed file 'data/images/wui/editor/editor_menu_set_toolsize_menu.png' => 'data/images/wui/editor/menus/toolsize.png'
=== renamed file 'data/images/wui/editor/editor_undo.png' => 'data/images/wui/editor/menus/undo.png'
=== added directory 'data/images/wui/editor/tools'
=== renamed file 'data/images/wui/editor/editor_menu_tool_place_bob.png' => 'data/images/wui/editor/tools/critters.png'
=== renamed file 'data/images/wui/editor/editor_menu_tool_change_height.png' => 'data/images/wui/editor/tools/height.png'
=== renamed file 'data/images/wui/editor/editor_menu_tool_place_immovable.png' => 'data/images/wui/editor/tools/immovables.png'
=== renamed file 'data/images/wui/editor/editor_menu_tool_set_origin.png' => 'data/images/wui/editor/tools/map_origin.png'
=== renamed file 'data/images/wui/editor/editor_menu_tool_noise_height.png' => 'data/images/wui/editor/tools/noise_height.png'
=== renamed file 'data/images/wui/editor/editor_menu_player_menu.png' => 'data/images/wui/editor/tools/players.png'
=== renamed file 'data/images/wui/editor/editor_menu_tool_set_port_space.png' => 'data/images/wui/editor/tools/port_spaces.png'
=== renamed file 'data/images/wui/editor/editor_menu_tool_resize.png' => 'data/images/wui/editor/tools/resize_map.png'
=== renamed file 'data/images/wui/editor/editor_menu_tool_change_resources.png' => 'data/images/wui/editor/tools/resources.png'
=== renamed file 'data/images/wui/editor/editor_menu_tool_set_terrain.png' => 'data/images/wui/editor/tools/terrain.png'
=== added file 'data/images/wui/menus/CREDITS.txt'
--- data/images/wui/menus/CREDITS.txt 1970-01-01 00:00:00 +0000
+++ data/images/wui/menus/CREDITS.txt 2019-08-10 10:01:32 +0000
@@ -0,0 +1,1 @@
1lua.png Copyright © 1998 Lua.org. Graphic design by Alexandre Nakonechnyj.
02
=== renamed file 'data/images/wui/menus/menu_chat.png' => 'data/images/wui/menus/chat.png'
=== renamed file 'data/images/wui/menus/menu_exit_game.png' => 'data/images/wui/menus/exit.png'
=== added file 'data/images/wui/menus/gamespeed.png'
1Binary 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 differ3Binary 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
=== added file 'data/images/wui/menus/gamespeed_decrease.png'
2Binary 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 differ4Binary 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
=== added file 'data/images/wui/menus/gamespeed_increase.png'
3Binary 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 differ5Binary 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
=== added file 'data/images/wui/menus/gamespeed_pause.png'
4Binary 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 differ6Binary 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
=== added file 'data/images/wui/menus/gamespeed_resume.png'
5Binary 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 differ7Binary 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
=== renamed file 'data/images/wui/menus/menu_goto.png' => 'data/images/wui/menus/goto.png'
=== added file 'data/images/wui/menus/lua.png'
6Binary 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 differ8Binary 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
=== renamed file 'data/images/wui/menus/menu_options_menu.png' => 'data/images/wui/menus/main_menu.png'
=== modified file 'data/images/wui/menus/menu_toggle_grid.png'
7Binary 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 differ9Binary 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
=== renamed file 'data/images/wui/menus/menu_toggle_newmessage_menu.png' => 'data/images/wui/menus/message_new.png'
=== renamed file 'data/images/wui/menus/menu_toggle_oldmessage_menu.png' => 'data/images/wui/menus/message_old.png'
=== renamed file 'data/images/wui/menus/menu_objectives.png' => 'data/images/wui/menus/objectives.png'
=== added file 'data/images/wui/menus/options.png'
8Binary 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 differ10Binary 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
=== renamed file 'data/images/wui/menus/menu_save_game.png' => 'data/images/wui/menus/save_game.png'
=== renamed file 'data/images/wui/fieldaction/menu_show_workarea_overlap.png' => 'data/images/wui/menus/show_workarea_overlap.png'
=== added file 'data/images/wui/menus/showhide.png'
9Binary 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 differ11Binary 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
=== renamed file 'data/images/wui/menus/menu_toggle_menu.png' => 'data/images/wui/menus/statistics.png'
=== renamed file 'data/images/wui/menus/menu_building_stats.png' => 'data/images/wui/menus/statistics_buildings.png'
=== renamed file 'data/images/wui/menus/menu_general_stats.png' => 'data/images/wui/menus/statistics_general.png'
=== added file 'data/images/wui/menus/statistics_seafaring.png'
10Binary 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 differ12Binary 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
=== renamed file 'data/images/wui/menus/menu_stock.png' => 'data/images/wui/menus/statistics_stock.png'
=== renamed file 'data/images/wui/menus/menu_ware_stats.png' => 'data/images/wui/menus/statistics_wares.png'
=== renamed file 'data/images/wui/menus/menu_toggle_bobs.png' => 'data/images/wui/menus/toggle_bobs.png'
=== renamed file 'data/images/wui/menus/menu_toggle_buildhelp.png' => 'data/images/wui/menus/toggle_buildhelp.png'
=== renamed file 'data/images/wui/fieldaction/menu_show_census.png' => 'data/images/wui/menus/toggle_census.png'
=== renamed file 'data/images/wui/menus/menu_toggle_immovables.png' => 'data/images/wui/menus/toggle_immovables.png'
=== renamed file 'data/images/wui/menus/menu_toggle_minimap.png' => 'data/images/wui/menus/toggle_minimap.png'
=== renamed file 'data/images/wui/menus/menu_toggle_resources.png' => 'data/images/wui/menus/toggle_resources.png'
=== renamed file 'data/images/wui/fieldaction/menu_show_statistics.png' => 'data/images/wui/menus/toggle_statistics.png'
=== renamed file 'data/images/wui/menus/menu_watch_follow.png' => 'data/images/wui/menus/watch_follow.png'
=== added file 'data/images/wui/menus/zoom_decrease.png'
11Binary 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 differ13Binary 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
=== added file 'data/images/wui/menus/zoom_increase.png'
12Binary 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 differ14Binary 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
=== renamed file 'data/images/wui/menus/menu_reset_zoom.png' => 'data/images/wui/menus/zoom_reset.png'
=== added directory 'data/images/wui/toolbar'
=== added file 'data/images/wui/toolbar/center.png'
13Binary 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 differ15Binary 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
=== added file 'data/images/wui/toolbar/left.png'
14Binary 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 differ16Binary 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
=== added file 'data/images/wui/toolbar/left_corner.png'
15Binary 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 differ17Binary 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
=== added file 'data/images/wui/toolbar/right.png'
16Binary 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 differ18Binary 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
=== added file 'data/images/wui/toolbar/right_corner.png'
17Binary 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 differ19Binary 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
=== modified file 'data/tribes/atlanteans.lua'
--- data/tribes/atlanteans.lua 2019-05-25 08:51:42 +0000
+++ data/tribes/atlanteans.lua 2019-08-10 10:01:32 +0000
@@ -44,6 +44,19 @@
44-- **ship**: The internal name of the tribe's ship.44-- **ship**: The internal name of the tribe's ship.
45--45--
46-- **port**: The internal name of the tribe's port building. This unit needs to be defined in the ``buildings`` table too.46-- **port**: The internal name of the tribe's port building. This unit needs to be defined in the ``buildings`` table too.
47--
48-- **toolbar**: *Optional*. Replace the default toolbar images with these custom images. Example:
49--
50-- .. code-block:: lua
51--
52-- toolbar = {
53-- left_corner = dirname .. "images/atlanteans/toolbar_left_corner.png",
54-- left = dirname .. "images/atlanteans/toolbar_left.png", -- Will be tiled
55-- center = dirname .. "images/atlanteans/toolbar_center.png",
56-- right = dirname .. "images/atlanteans/toolbar_right.png", -- Will be tiled
57-- right_corner = dirname .. "images/atlanteans/toolbar_right_corner.png"
58-- }
59--
4760
48image_dirname = path.dirname(__file__) .. "images/atlanteans/"61image_dirname = path.dirname(__file__) .. "images/atlanteans/"
4962
@@ -370,4 +383,12 @@
370 rawlog = "log",383 rawlog = "log",
371 refinedlog = "planks",384 refinedlog = "planks",
372 granite = "granite",385 granite = "granite",
386
387 toolbar = {
388 left_corner = image_dirname .. "toolbar_left_corner.png",
389 left = image_dirname .. "toolbar_left.png",
390 center = image_dirname .. "toolbar_center.png",
391 right = image_dirname .. "toolbar_right.png",
392 right_corner = image_dirname .. "toolbar_right_corner.png"
393 }
373}394}
374395
=== added file 'data/tribes/images/atlanteans/toolbar_center.png'
375Binary 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 differ396Binary 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
=== added file 'data/tribes/images/atlanteans/toolbar_left.png'
376Binary 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 differ397Binary 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
=== added file 'data/tribes/images/atlanteans/toolbar_left_corner.png'
377Binary 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 differ398Binary 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
=== added file 'data/tribes/images/atlanteans/toolbar_right.png'
378Binary 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 differ399Binary 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
=== added file 'data/tribes/images/atlanteans/toolbar_right_corner.png'
379Binary 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 differ400Binary 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
=== modified file 'regression_test.py'
--- regression_test.py 2019-03-15 19:37:37 +0000
+++ regression_test.py 2019-08-10 10:01:32 +0000
@@ -137,6 +137,9 @@
137 self.assertTrue("All Tests passed" in stdout,137 self.assertTrue("All Tests passed" in stdout,
138 "Not all tests pass. {}.".format(common_msg)138 "Not all tests pass. {}.".format(common_msg)
139 )139 )
140 self.assertFalse("lua_errors.cc" in stdout,
141 "Not all tests pass. {}.".format(common_msg)
142 )
140 out("done.\n")143 out("done.\n")
141 if self.keep_output_around:144 if self.keep_output_around:
142 out(" stdout: {}\n".format(stdout_filename))145 out(" stdout: {}\n".format(stdout_filename))
143146
=== modified file 'src/editor/CMakeLists.txt'
--- src/editor/CMakeLists.txt 2019-06-01 08:18:58 +0000
+++ src/editor/CMakeLists.txt 2019-08-10 10:01:32 +0000
@@ -49,8 +49,6 @@
49 ui_menus/categorized_item_selection_menu.h49 ui_menus/categorized_item_selection_menu.h
50 ui_menus/help.cc50 ui_menus/help.cc
51 ui_menus/help.h51 ui_menus/help.h
52 ui_menus/main_menu.cc
53 ui_menus/main_menu.h
54 ui_menus/main_menu_load_map.cc52 ui_menus/main_menu_load_map.cc
55 ui_menus/main_menu_load_map.h53 ui_menus/main_menu_load_map.h
56 ui_menus/main_menu_load_or_save_map.cc54 ui_menus/main_menu_load_or_save_map.cc
@@ -73,8 +71,6 @@
73 ui_menus/tool_change_height_options_menu.h71 ui_menus/tool_change_height_options_menu.h
74 ui_menus/tool_change_resources_options_menu.cc72 ui_menus/tool_change_resources_options_menu.cc
75 ui_menus/tool_change_resources_options_menu.h73 ui_menus/tool_change_resources_options_menu.h
76 ui_menus/tool_menu.cc
77 ui_menus/tool_menu.h
78 ui_menus/tool_noise_height_options_menu.cc74 ui_menus/tool_noise_height_options_menu.cc
79 ui_menus/tool_noise_height_options_menu.h75 ui_menus/tool_noise_height_options_menu.h
80 ui_menus/tool_options_menu.cc76 ui_menus/tool_options_menu.cc
8177
=== modified file 'src/editor/editorinteractive.cc'
--- src/editor/editorinteractive.cc 2019-04-26 05:52:49 +0000
+++ src/editor/editorinteractive.cc 2019-08-10 10:01:32 +0000
@@ -29,13 +29,29 @@
29#include "base/i18n.h"29#include "base/i18n.h"
30#include "base/scoped_timer.h"30#include "base/scoped_timer.h"
31#include "base/warning.h"31#include "base/warning.h"
32#include "editor/tools/delete_immovable_tool.h"32#include "editor/tools/decrease_height_tool.h"
33#include "editor/tools/decrease_resources_tool.h"
34#include "editor/tools/increase_height_tool.h"
35#include "editor/tools/increase_resources_tool.h"
36#include "editor/tools/noise_height_tool.h"
37#include "editor/tools/place_critter_tool.h"
38#include "editor/tools/place_immovable_tool.h"
39#include "editor/tools/set_port_space_tool.h"
40#include "editor/tools/set_terrain_tool.h"
33#include "editor/ui_menus/help.h"41#include "editor/ui_menus/help.h"
34#include "editor/ui_menus/main_menu.h"
35#include "editor/ui_menus/main_menu_load_map.h"42#include "editor/ui_menus/main_menu_load_map.h"
43#include "editor/ui_menus/main_menu_map_options.h"
44#include "editor/ui_menus/main_menu_new_map.h"
45#include "editor/ui_menus/main_menu_random_map.h"
36#include "editor/ui_menus/main_menu_save_map.h"46#include "editor/ui_menus/main_menu_save_map.h"
37#include "editor/ui_menus/player_menu.h"47#include "editor/ui_menus/player_menu.h"
38#include "editor/ui_menus/tool_menu.h"48#include "editor/ui_menus/tool_change_height_options_menu.h"
49#include "editor/ui_menus/tool_change_resources_options_menu.h"
50#include "editor/ui_menus/tool_noise_height_options_menu.h"
51#include "editor/ui_menus/tool_place_critter_options_menu.h"
52#include "editor/ui_menus/tool_place_immovable_options_menu.h"
53#include "editor/ui_menus/tool_resize_options_menu.h"
54#include "editor/ui_menus/tool_set_terrain_options_menu.h"
39#include "editor/ui_menus/toolsize_menu.h"55#include "editor/ui_menus/toolsize_menu.h"
40#include "graphic/graphic.h"56#include "graphic/graphic.h"
41#include "graphic/playercolor.h"57#include "graphic/playercolor.h"
@@ -70,66 +86,45 @@
70 need_save_(false),86 need_save_(false),
71 realtime_(SDL_GetTicks()),87 realtime_(SDL_GetTicks()),
72 is_painting_(false),88 is_painting_(false),
89 mainmenu_(
90 toolbar(), "dropdown_menu_main", 0, 0, 34U, 10, 34U,
91 /** TRANSLATORS: Title for the main menu button in the editor */
92 as_tooltip_text_with_hotkey(_("Main Menu"), "h"),
93 UI::DropdownType::kPictorialMenu,
94 UI::PanelStyle::kWui, UI::ButtonStyle::kWuiPrimary),
95 toolmenu_(
96 toolbar(), "dropdown_menu_tools", 0, 0, 34U, 12, 34U,
97 /** TRANSLATORS: Title for the tool menu button in the editor */
98 as_tooltip_text_with_hotkey(_("Tools"), "t"),
99 UI::DropdownType::kPictorialMenu,
100 UI::PanelStyle::kWui, UI::ButtonStyle::kWuiPrimary),
101 showhidemenu_(
102 toolbar(), "dropdown_menu_showhide", 0, 0, 34U, 10, 34U,
103 /** TRANSLATORS: Title for a menu button in the editor. This menu will show/hide building spaces, animals, immovables, resources */
104 _("Show / Hide"),
105 UI::DropdownType::kPictorialMenu,
106 UI::PanelStyle::kWui, UI::ButtonStyle::kWuiPrimary),
73 undo_(nullptr),107 undo_(nullptr),
74 redo_(nullptr),108 redo_(nullptr),
75 tools_(new Tools(e.map())),109 tools_(new Tools(e.map())),
76 history_(nullptr) // history needs the undo/redo buttons110 history_(nullptr) // history needs the undo/redo buttons
77{111{
78 add_toolbar_button("wui/menus/menu_toggle_menu", "menu", _("Main menu"), &mainmenu_, true);112 add_main_menu();
79 mainmenu_.open_window = [this] { new EditorMainMenu(*this, mainmenu_); };113 add_tool_menu();
80114
81 add_toolbar_button(115 add_toolbar_button(
82 "wui/editor/editor_menu_toggle_tool_menu", "tools", _("Tools"), &toolmenu_, true);116 "wui/editor/menus/toolsize", "toolsize", _("Tool size"), &menu_windows_.toolsize, true);
83 toolmenu_.open_window = [this] { new EditorToolMenu(*this, toolmenu_); };117 menu_windows_.toolsize.open_window = [this] { new EditorToolsizeMenu(*this, menu_windows_.toolsize); };
84118
85 add_toolbar_button(119 toolbar()->add_space(15);
86 "wui/editor/editor_menu_set_toolsize_menu", "toolsize", _("Tool size"), &toolsizemenu_, true);120
87 toolsizemenu_.open_window = [this] { new EditorToolsizeMenu(*this, toolsizemenu_); };121 add_mapview_menu(MiniMapType::kStaticMap);
88122 add_showhide_menu();
89 add_toolbar_button(123
90 "wui/editor/editor_menu_player_menu", "players", _("Players"), &playermenu_, true);124 toolbar()->add_space(15);
91 playermenu_.open_window = [this] {125
92 select_tool(tools_->set_starting_pos, EditorTool::First);126 undo_ = add_toolbar_button("wui/editor/menus/undo", "undo", _("Undo"));
93 new EditorPlayerMenu(*this, playermenu_);127 redo_ = add_toolbar_button("wui/editor/menus/redo", "redo", _("Redo"));
94 };
95
96 toolbar()->add_space(15);
97
98 toggle_buildhelp_ = add_toolbar_button(
99 "wui/menus/menu_toggle_buildhelp", "buildhelp", _("Show building spaces (on/off)"));
100 toggle_buildhelp_->sigclicked.connect(boost::bind(&EditorInteractive::toggle_buildhelp, this));
101 toggle_grid_ = add_toolbar_button("wui/menus/menu_toggle_grid", "grid", _("Show grid (on/off)"));
102 toggle_grid_->set_perm_pressed(true);
103 toggle_grid_->sigclicked.connect([this]() { toggle_grid(); });
104 toggle_immovables_ = add_toolbar_button(
105 "wui/menus/menu_toggle_immovables", "immovables", _("Show immovables (on/off)"));
106 toggle_immovables_->set_perm_pressed(true);
107 toggle_immovables_->sigclicked.connect([this]() { toggle_immovables(); });
108 toggle_bobs_ =
109 add_toolbar_button("wui/menus/menu_toggle_bobs", "animals", _("Show animals (on/off)"));
110 toggle_bobs_->set_perm_pressed(true);
111 toggle_bobs_->sigclicked.connect([this]() { toggle_bobs(); });
112 toggle_resources_ = add_toolbar_button(
113 "wui/menus/menu_toggle_resources", "resources", _("Show resources (on/off)"));
114 toggle_resources_->set_perm_pressed(true);
115 toggle_resources_->sigclicked.connect([this]() { toggle_resources(); });
116
117 toolbar()->add_space(15);
118
119 add_toolbar_button(
120 "wui/menus/menu_toggle_minimap", "minimap", _("Minimap"), &minimap_registry(), true);
121 minimap_registry().open_window = [this] { toggle_minimap(); };
122
123 auto zoom = add_toolbar_button("wui/menus/menu_reset_zoom", "reset_zoom", _("Reset zoom"));
124 zoom->sigclicked.connect([this] {
125 map_view()->zoom_around(
126 1.f, Vector2f(get_w() / 2.f, get_h() / 2.f), MapView::Transition::Smooth);
127 });
128
129 toolbar()->add_space(15);
130
131 undo_ = add_toolbar_button("wui/editor/editor_undo", "undo", _("Undo"));
132 redo_ = add_toolbar_button("wui/editor/editor_redo", "redo", _("Redo"));
133128
134 history_.reset(new EditorHistory(*undo_, *redo_));129 history_.reset(new EditorHistory(*undo_, *redo_));
135130
@@ -138,10 +133,10 @@
138133
139 toolbar()->add_space(15);134 toolbar()->add_space(15);
140135
141 add_toolbar_button("ui_basic/menu_help", "help", _("Help"), &helpmenu_, true);136 add_toolbar_button("ui_basic/menu_help", "help", _("Help"), &menu_windows_.help, true);
142 helpmenu_.open_window = [this] { new EditorHelp(*this, helpmenu_, &egbase().lua()); };137 menu_windows_.help.open_window = [this] { new EditorHelp(*this, menu_windows_.help, &egbase().lua()); };
143138
144 adjust_toolbar_position();139 finalize_toolbar();
145140
146#ifndef NDEBUG141#ifndef NDEBUG
147 set_display_flag(InteractiveBase::dfDebug, true);142 set_display_flag(InteractiveBase::dfDebug, true);
@@ -152,8 +147,269 @@
152 map_view()->field_clicked.connect([this](const Widelands::NodeAndTriangle<>& node_and_triangle) {147 map_view()->field_clicked.connect([this](const Widelands::NodeAndTriangle<>& node_and_triangle) {
153 map_clicked(node_and_triangle, false);148 map_clicked(node_and_triangle, false);
154 });149 });
155150}
156 minimap_registry().minimap_type = MiniMapType::kStaticMap;151
152
153void EditorInteractive::add_main_menu() {
154 mainmenu_.set_image(g_gr->images().get("images/wui/editor/menus/main_menu.png"));
155
156 menu_windows_.newmap.open_window = [this] {
157 new MainMenuNewMap(*this, menu_windows_.newmap);
158 };
159 /** TRANSLATORS: An entry in the editor's main menu */
160 mainmenu_.add(_("New Map"), MainMenuEntry::kNewMap,
161 g_gr->images().get("images/wui/editor/menus/new_map.png"));
162
163 menu_windows_.newrandommap.open_window = [this] {
164 new MainMenuNewRandomMap(*this, menu_windows_.newrandommap);
165 };
166 /** TRANSLATORS: An entry in the editor's main menu */
167 mainmenu_.add(_("New Random Map"), MainMenuEntry::kNewRandomMap,
168 g_gr->images().get("images/wui/editor/menus/new_random_map.png"));
169
170 menu_windows_.loadmap.open_window = [this] {
171 new MainMenuLoadMap(*this, menu_windows_.loadmap);
172 };
173 /** TRANSLATORS: An entry in the editor's main menu */
174 mainmenu_.add(_("Load Map"), MainMenuEntry::kLoadMap,
175 g_gr->images().get("images/wui/editor/menus/load_map.png"),
176 false, "", pgettext("hotkey", "Ctrl+l"));
177
178 menu_windows_.savemap.open_window = [this] {
179 new MainMenuSaveMap(*this, menu_windows_.savemap, menu_windows_.mapoptions);
180 };
181 /** TRANSLATORS: An entry in the editor's main menu */
182 mainmenu_.add(_("Save Map"), MainMenuEntry::kSaveMap,
183 g_gr->images().get("images/wui/editor/menus/save_map.png"),
184 false, "", pgettext("hotkey", "Ctrl+s"));
185
186 menu_windows_.mapoptions.open_window = [this] {
187 new MainMenuMapOptions(*this, menu_windows_.mapoptions);
188 };
189 /** TRANSLATORS: An entry in the editor's main menu */
190 mainmenu_.add(_("Map Options"), MainMenuEntry::kMapOptions,
191 g_gr->images().get("images/wui/editor/menus/map_options.png"));
192
193 /** TRANSLATORS: An entry in the editor's main menu */
194 mainmenu_.add(_("Exit Editor"), MainMenuEntry::kExitEditor,
195 g_gr->images().get("images/wui/menus/exit.png"));
196 mainmenu_.selected.connect([this] { main_menu_selected(mainmenu_.get_selected()); });
197 toolbar()->add(&mainmenu_);
198}
199
200void EditorInteractive::main_menu_selected(MainMenuEntry entry) {
201 switch (entry) {
202 case MainMenuEntry::kNewMap: {
203 menu_windows_.newmap.toggle();
204 } break;
205 case MainMenuEntry::kNewRandomMap: {
206 menu_windows_.newrandommap.toggle();
207 } break;
208 case MainMenuEntry::kLoadMap: {
209 menu_windows_.loadmap.toggle();
210 } break;
211 case MainMenuEntry::kSaveMap: {
212 menu_windows_.savemap.toggle();
213 } break;
214 case MainMenuEntry::kMapOptions: {
215 menu_windows_.mapoptions.toggle();
216 } break;
217 case MainMenuEntry::kExitEditor: {
218 exit();
219 }
220 }
221}
222
223void EditorInteractive::add_tool_menu() {
224 toolmenu_.set_image(g_gr->images().get("images/wui/editor/menus/tools.png"));
225
226 tool_windows_.height.open_window = [this] {
227 new EditorToolChangeHeightOptionsMenu(*this, tools()->increase_height, tool_windows_.height);
228 };
229 /** TRANSLATORS: An entry in the editor's tool menu */
230 toolmenu_.add(_("Change height"), ToolMenuEntry::kChangeHeight,
231 g_gr->images().get("images/wui/editor/tools/height.png"), false,
232 /** TRANSLATORS: Tooltip for the change height tool in the editor */
233 _("Change the terrain height"));
234
235 tool_windows_.noiseheight.open_window = [this] {
236 new EditorToolNoiseHeightOptionsMenu(*this, tools()->noise_height, tool_windows_.noiseheight);
237 };
238 /** TRANSLATORS: An entry in the editor's tool menu */
239 toolmenu_.add(_("Random height"), ToolMenuEntry::kRandomHeight,
240 g_gr->images().get("images/wui/editor/tools/noise_height.png"), false,
241 /** TRANSLATORS: Tooltip for the random height tool in the editor */
242 _("Set the terrain height to random values"));
243
244 tool_windows_.terrain.open_window = [this] {
245 new EditorToolSetTerrainOptionsMenu(*this, tools()->set_terrain, tool_windows_.terrain);
246 };
247 /** TRANSLATORS: An entry in the editor's tool menu */
248 toolmenu_.add(_("Terrain"), ToolMenuEntry::kTerrain,
249 g_gr->images().get("images/wui/editor/tools/terrain.png"), false,
250 /** TRANSLATORS: Tooltip for the terrain tool in the editor */
251 _("Change the map’s terrain"));
252
253 tool_windows_.immovables.open_window = [this] {
254 new EditorToolPlaceImmovableOptionsMenu(*this, tools()->place_immovable, tool_windows_.immovables);
255 };
256 /** TRANSLATORS: An entry in the editor's tool menu */
257 toolmenu_.add(_("Immovables"), ToolMenuEntry::kImmovables,
258 g_gr->images().get("images/wui/editor/tools/immovables.png"), false,
259 /** TRANSLATORS: Tooltip for the immovables tool in the editor */
260 _("Add or remove immovables"));
261
262 tool_windows_.critters.open_window = [this] {
263 new EditorToolPlaceCritterOptionsMenu(*this, tools()->place_critter, tool_windows_.critters);
264 };
265 /** TRANSLATORS: An entry in the editor's tool menu */
266 toolmenu_.add(_("Animals"), ToolMenuEntry::kAnimals,
267 g_gr->images().get("images/wui/editor/tools/critters.png"), false,
268 /** TRANSLATORS: Tooltip for the animals tool in the editor */
269 _("Add or remove animals"));
270
271 tool_windows_.resources.open_window = [this] {
272 new EditorToolChangeResourcesOptionsMenu(*this, tools()->increase_resources, tool_windows_.resources);
273 };
274 /** TRANSLATORS: An entry in the editor's tool menu */
275 toolmenu_.add(_("Resources"), ToolMenuEntry::kResources,
276 g_gr->images().get("images/wui/editor/tools/resources.png"), false,
277 /** TRANSLATORS: Tooltip for the resources tool in the editor */
278 _("Set or change resources"));
279
280 /** TRANSLATORS: An entry in the editor's tool menu */
281 toolmenu_.add(_("Port spaces"), ToolMenuEntry::kPortSpace,
282 g_gr->images().get("images/wui/editor/tools/port_spaces.png"), false,
283 /** TRANSLATORS: Tooltip for the port spaces tool in the editor */
284 _("Add or remove port spaces"));
285
286 tool_windows_.players.open_window = [this] {
287 new EditorPlayerMenu(*this, tools()->set_starting_pos, tool_windows_.players);
288 };
289 /** TRANSLATORS: An entry in the editor's tool menu */
290 toolmenu_.add(_("Players"), ToolMenuEntry::kPlayers,
291 g_gr->images().get("images/wui/editor/tools/players.png"), false,
292 /** TRANSLATORS: Tooltip for the map size tool in the editor */
293 _("Set number of players and their names, tribes and starting positions"), "p");
294
295 /** TRANSLATORS: An entry in the editor's tool menu */
296 toolmenu_.add(_("Map origin"), ToolMenuEntry::kMapOrigin,
297 g_gr->images().get("images/wui/editor/tools/map_origin.png"), false,
298 /** TRANSLATORS: Tooltip for the map origin tool in the editor */
299 _("Set the position that will have the coordinates (0, 0). This will be the top-left corner of a generated minimap."));
300
301 tool_windows_.resizemap.open_window = [this] {
302 new EditorToolResizeOptionsMenu(*this, tools()->resize, tool_windows_.resizemap);
303 };
304 /** TRANSLATORS: An entry in the editor's tool menu */
305 toolmenu_.add(_("Map size"), ToolMenuEntry::kMapSize,
306 g_gr->images().get("images/wui/editor/tools/resize_map.png"), false,
307 /** TRANSLATORS: Tooltip for the map size tool in the editor */
308 _("Change the map’s size"));
309
310 /** TRANSLATORS: An entry in the editor's tool menu */
311 toolmenu_.add(_("Information"), ToolMenuEntry::kFieldInfo,
312 g_gr->images().get("images/wui/editor/fsel_editor_info.png"), false,
313 /** TRANSLATORS: Tooltip for the map information tool in the editor */
314 _("Click on a field to show information about it"), "i");
315 toolmenu_.selected.connect([this] { tool_menu_selected(toolmenu_.get_selected()); });
316 toolbar()->add(&toolmenu_);
317}
318
319void EditorInteractive::tool_menu_selected(ToolMenuEntry entry) {
320 switch (entry) {
321 case ToolMenuEntry::kChangeHeight:
322 tool_windows_.height.toggle();
323 break;
324 case ToolMenuEntry::kRandomHeight:
325 tool_windows_.noiseheight.toggle();
326 break;
327 case ToolMenuEntry::kTerrain:
328 tool_windows_.terrain.toggle();
329 break;
330 case ToolMenuEntry::kImmovables:
331 tool_windows_.immovables.toggle();
332 break;
333 case ToolMenuEntry::kAnimals:
334 tool_windows_.critters.toggle();
335 break;
336 case ToolMenuEntry::kResources:
337 tool_windows_.resources.toggle();
338 break;
339 case ToolMenuEntry::kPortSpace:
340 select_tool(tools()->set_port_space, EditorTool::First);
341 break;
342 case ToolMenuEntry::kPlayers:
343 tool_windows_.players.toggle();
344 break;
345 case ToolMenuEntry::kMapOrigin:
346 select_tool(tools()->set_origin, EditorTool::First);
347 break;
348 case ToolMenuEntry::kMapSize:
349 tool_windows_.resizemap.toggle();
350 break;
351 case ToolMenuEntry::kFieldInfo:
352 select_tool(tools()->info, EditorTool::First);
353 break;
354 }
355 toolmenu_.toggle();
356}
357
358void EditorInteractive::add_showhide_menu() {
359 showhidemenu_.set_image(g_gr->images().get("images/wui/menus/showhide.png"));
360 toolbar()->add(&showhidemenu_);
361
362 rebuild_showhide_menu();
363
364 showhidemenu_.selected.connect([this] { showhide_menu_selected(showhidemenu_.get_selected()); });
365}
366
367void EditorInteractive::rebuild_showhide_menu() {
368 showhidemenu_.clear();
369
370 /** TRANSLATORS: An entry in the editor's show/hide menu to toggle whether building spaces are shown */
371 showhidemenu_.add(buildhelp() ? _("Hide Building Spaces") : _("Show Building Spaces"),
372 ShowHideEntry::kBuildingSpaces, g_gr->images().get("images/wui/menus/toggle_buildhelp.png"),
373 false, "", pgettext("hotkey", "Space"));
374
375 /** TRANSLATORS: An entry in the editor's show/hide menu to toggle whether the map grid is shown */
376 showhidemenu_.add(draw_grid_ ? _("Hide Grid") : _("Show Grid"),
377 ShowHideEntry::kGrid, g_gr->images().get("images/wui/menus/menu_toggle_grid.png"),
378 false, "", "G");
379
380 /** TRANSLATORS: An entry in the editor's show/hide menu to toggle whether immovables (trees, rocks etc.) are shown */
381 showhidemenu_.add(draw_immovables_ ? _("Hide Immovables") : _("Show Immovables"), ShowHideEntry::kImmovables,
382 g_gr->images().get("images/wui/menus/toggle_immovables.png"));
383
384 /** TRANSLATORS: An entry in the editor's show/hide menu to toggle whether animals are shown */
385 showhidemenu_.add(draw_bobs_ ? _("Hide Animals") : _("Show Animals"), ShowHideEntry::kAnimals,
386 g_gr->images().get("images/wui/menus/toggle_bobs.png"));
387
388 /** TRANSLATORS: An entry in the editor's show/hide menu to toggle whether resources are shown */
389 showhidemenu_.add(draw_resources_ ? _("Hide Resources") : _("Show Resources"), ShowHideEntry::kResources,
390 g_gr->images().get("images/wui/menus/toggle_resources.png"));
391
392}
393
394void EditorInteractive::showhide_menu_selected(ShowHideEntry entry) {
395 switch (entry) {
396 case ShowHideEntry::kBuildingSpaces: {
397 toggle_buildhelp();
398 } break;
399 case ShowHideEntry::kGrid: {
400 toggle_grid();
401 } break;
402 case ShowHideEntry::kImmovables: {
403 toggle_immovables();
404 } break;
405 case ShowHideEntry::kAnimals: {
406 toggle_bobs();
407 } break;
408 case ShowHideEntry::kResources: {
409 toggle_resources();
410 } break;
411 }
412 rebuild_showhide_menu();
157}413}
158414
159void EditorInteractive::load(const std::string& filename) {415void EditorInteractive::load(const std::string& filename) {
@@ -399,7 +655,7 @@
399 set_sel_radius(0);655 set_sel_radius(0);
400 return;656 return;
401 }657 }
402 if (UI::UniqueWindow* const w = toolsizemenu_.window) {658 if (UI::UniqueWindow* const w = menu_windows_.toolsize.window) {
403 dynamic_cast<EditorToolsizeMenu&>(*w).update(val);659 dynamic_cast<EditorToolsizeMenu&>(*w).update(val);
404 } else {660 } else {
405 set_sel_radius(val);661 set_sel_radius(val);
@@ -414,28 +670,20 @@
414 return true;670 return true;
415}671}
416672
417void EditorInteractive::on_buildhelp_changed(const bool value) {
418 toggle_buildhelp_->set_perm_pressed(value);
419}
420
421void EditorInteractive::toggle_resources() {673void EditorInteractive::toggle_resources() {
422 draw_resources_ = !draw_resources_;674 draw_resources_ = !draw_resources_;
423 toggle_resources_->set_perm_pressed(draw_resources_);
424}675}
425676
426void EditorInteractive::toggle_immovables() {677void EditorInteractive::toggle_immovables() {
427 draw_immovables_ = !draw_immovables_;678 draw_immovables_ = !draw_immovables_;
428 toggle_immovables_->set_perm_pressed(draw_immovables_);
429}679}
430680
431void EditorInteractive::toggle_bobs() {681void EditorInteractive::toggle_bobs() {
432 draw_bobs_ = !draw_bobs_;682 draw_bobs_ = !draw_bobs_;
433 toggle_bobs_->set_perm_pressed(draw_bobs_);
434}683}
435684
436void EditorInteractive::toggle_grid() {685void EditorInteractive::toggle_grid() {
437 draw_grid_ = !draw_grid_;686 draw_grid_ = !draw_grid_;
438 toggle_grid_->set_perm_pressed(draw_grid_);
439}687}
440688
441bool EditorInteractive::handle_key(bool const down, SDL_Keysym const code) {689bool EditorInteractive::handle_key(bool const down, SDL_Keysym const code) {
@@ -530,21 +778,19 @@
530 return true;778 return true;
531779
532 case SDLK_l:780 case SDLK_l:
533 if (code.mod & (KMOD_LCTRL | KMOD_RCTRL))781 if (code.mod & (KMOD_LCTRL | KMOD_RCTRL)) {
534 new MainMenuLoadMap(*this);782 menu_windows_.loadmap.toggle();
535 return true;783 }
536
537 case SDLK_m:
538 minimap_registry().toggle();
539 return true;784 return true;
540785
541 case SDLK_p:786 case SDLK_p:
542 playermenu_.toggle();787 tool_windows_.players.toggle();
543 return true;788 return true;
544789
545 case SDLK_s:790 case SDLK_s:
546 if (code.mod & (KMOD_LCTRL | KMOD_RCTRL))791 if (code.mod & (KMOD_LCTRL | KMOD_RCTRL)) {
547 new MainMenuSaveMap(*this);792 menu_windows_.savemap.toggle();
793 }
548 return true;794 return true;
549795
550 case SDLK_t:796 case SDLK_t:
@@ -564,7 +810,7 @@
564 return true;810 return true;
565811
566 case SDLK_F1:812 case SDLK_F1:
567 helpmenu_.toggle();813 menu_windows_.help.toggle();
568 return true;814 return true;
569815
570 default:816 default:
@@ -595,12 +841,12 @@
595 if (which == EditorTool::First && &primary != tools_->current_pointer) {841 if (which == EditorTool::First && &primary != tools_->current_pointer) {
596 if (primary.has_size_one()) {842 if (primary.has_size_one()) {
597 set_sel_radius(0);843 set_sel_radius(0);
598 if (UI::UniqueWindow* const w = toolsizemenu_.window) {844 if (UI::UniqueWindow* const w = menu_windows_.toolsize.window) {
599 EditorToolsizeMenu& toolsize_menu = dynamic_cast<EditorToolsizeMenu&>(*w);845 EditorToolsizeMenu& toolsize_menu = dynamic_cast<EditorToolsizeMenu&>(*w);
600 toolsize_menu.set_buttons_enabled(false);846 toolsize_menu.set_buttons_enabled(false);
601 }847 }
602 } else {848 } else {
603 if (UI::UniqueWindow* const w = toolsizemenu_.window) {849 if (UI::UniqueWindow* const w = menu_windows_.toolsize.window) {
604 EditorToolsizeMenu& toolsize_menu = dynamic_cast<EditorToolsizeMenu&>(*w);850 EditorToolsizeMenu& toolsize_menu = dynamic_cast<EditorToolsizeMenu&>(*w);
605 toolsize_menu.update(toolsize_menu.value());851 toolsize_menu.update(toolsize_menu.value());
606 }852 }
607853
=== modified file 'src/editor/editorinteractive.h'
--- src/editor/editorinteractive.h 2019-04-24 16:59:23 +0000
+++ src/editor/editorinteractive.h 2019-08-10 10:01:32 +0000
@@ -37,10 +37,10 @@
37#include "logic/map.h"37#include "logic/map.h"
38#include "notifications/notifications.h"38#include "notifications/notifications.h"
39#include "ui_basic/button.h"39#include "ui_basic/button.h"
40#include "ui_basic/dropdown.h"
40#include "ui_basic/unique_window.h"41#include "ui_basic/unique_window.h"
41#include "wui/interactive_base.h"42#include "wui/interactive_base.h"
4243
43class Editor;
44class EditorTool;44class EditorTool;
4545
46/**46/**
@@ -138,16 +138,63 @@
138 // Access to the tools.138 // Access to the tools.
139 Tools* tools();139 Tools* tools();
140140
141 UI::UniqueWindow::Registry window_help;
142
143private:141private:
144 friend struct EditorToolMenu;142 // For referencing the items in mainmenu_
143 enum class MainMenuEntry {
144 kNewMap,
145 kNewRandomMap,
146 kLoadMap,
147 kSaveMap,
148 kMapOptions,
149 kExitEditor,
150 };
151
152 // For referencing the items in toolmenu_
153 enum class ToolMenuEntry {
154 kChangeHeight,
155 kRandomHeight,
156 kTerrain,
157 kImmovables,
158 kAnimals,
159 kResources,
160 kPortSpace,
161 kPlayers,
162 kMapOrigin,
163 kMapSize,
164 kFieldInfo
165 };
166
167 // For referencing the items in showhidemenu_
168 enum class ShowHideEntry {
169 kBuildingSpaces,
170 kGrid,
171 kAnimals,
172 kImmovables,
173 kResources
174 };
175
176 // Adds the mainmenu_ to the toolbar
177 void add_main_menu();
178 // Takes the appropriate action when an item in the mainmenu_ is selected
179 void main_menu_selected(MainMenuEntry entry);
180 // Adds the toolmenu_ to the toolbar
181 void add_tool_menu();
182 // Takes the appropriate action when an item in the toolmenu_ is selected
183 void tool_menu_selected(ToolMenuEntry entry);
184
185 // Adds the showhidemenu_ to the toolbar
186 void add_showhide_menu();
187 void rebuild_showhide_menu() override;
188 // Takes the appropriate action when an item in the showhidemenu_ is selected
189 void showhide_menu_selected(ShowHideEntry entry);
145190
146 bool player_hears_field(const Widelands::Coords& coords) const override;191 bool player_hears_field(const Widelands::Coords& coords) const override;
147 void on_buildhelp_changed(const bool value) override;
148192
193 // Show / hide the resources overlays in the mapview
149 void toggle_resources();194 void toggle_resources();
195 // Show / hide the immovables in the mapview
150 void toggle_immovables();196 void toggle_immovables();
197 // Show / hide the bobs in the mapview
151 void toggle_bobs();198 void toggle_bobs();
152 void toggle_grid();199 void toggle_grid();
153200
@@ -156,25 +203,38 @@
156 uint32_t realtime_;203 uint32_t realtime_;
157 bool is_painting_;204 bool is_painting_;
158205
159 UI::UniqueWindow::Registry toolmenu_;206 // All unique menu windows
160207 struct EditorMenuWindows {
161 UI::UniqueWindow::Registry toolsizemenu_;208 UI::UniqueWindow::Registry newmap;
162 UI::UniqueWindow::Registry playermenu_;209 UI::UniqueWindow::Registry newrandommap;
163 UI::UniqueWindow::Registry mainmenu_;210 UI::UniqueWindow::Registry savemap;
164 UI::UniqueWindow::Registry heightmenu_;211 UI::UniqueWindow::Registry loadmap;
165 UI::UniqueWindow::Registry noise_heightmenu_;212 UI::UniqueWindow::Registry mapoptions;
166 UI::UniqueWindow::Registry terrainmenu_;213
167 UI::UniqueWindow::Registry immovablemenu_;214 UI::UniqueWindow::Registry toolsize;
168 UI::UniqueWindow::Registry crittermenu_;215
169 UI::UniqueWindow::Registry resourcesmenu_;216 UI::UniqueWindow::Registry help;
170 UI::UniqueWindow::Registry resizemenu_;217 } menu_windows_;
171 UI::UniqueWindow::Registry helpmenu_;218
172219 // All unique tool windows for those tools that have them
173 UI::Button* toggle_buildhelp_;220 struct EditorToolWindows {
174 UI::Button* toggle_grid_;221 UI::UniqueWindow::Registry height;
175 UI::Button* toggle_resources_;222 UI::UniqueWindow::Registry noiseheight;
176 UI::Button* toggle_immovables_;223 UI::UniqueWindow::Registry terrain;
177 UI::Button* toggle_bobs_;224 UI::UniqueWindow::Registry immovables;
225 UI::UniqueWindow::Registry critters;
226 UI::UniqueWindow::Registry resources;
227 UI::UniqueWindow::Registry players;
228 UI::UniqueWindow::Registry resizemap;
229 } tool_windows_;
230
231 // Main menu on the toolbar
232 UI::Dropdown<MainMenuEntry> mainmenu_;
233 // Tools menu on the toolbar
234 UI::Dropdown<ToolMenuEntry> toolmenu_;
235 // Show / Hide menu on the toolbar
236 UI::Dropdown<ShowHideEntry> showhidemenu_;
237
178 UI::Button* undo_;238 UI::Button* undo_;
179 UI::Button* redo_;239 UI::Button* redo_;
180240
181241
=== removed file 'src/editor/ui_menus/main_menu.cc'
--- src/editor/ui_menus/main_menu.cc 2019-02-23 11:00:49 +0000
+++ src/editor/ui_menus/main_menu.cc 1970-01-01 00:00:00 +0000
@@ -1,110 +0,0 @@
1/*
2 * Copyright (C) 2002-2019 by the Widelands Development Team
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 *
18 */
19
20#include "editor/ui_menus/main_menu.h"
21
22#include "base/i18n.h"
23#include "editor/editorinteractive.h"
24#include "editor/ui_menus/main_menu_load_map.h"
25#include "editor/ui_menus/main_menu_map_options.h"
26#include "editor/ui_menus/main_menu_new_map.h"
27#include "editor/ui_menus/main_menu_random_map.h"
28#include "editor/ui_menus/main_menu_save_map.h"
29
30// TODO(unknown): these should be defined globally for the whole UI
31#define width 200
32#define margin 15
33#define vspacing 15
34
35inline EditorInteractive& EditorMainMenu::eia() {
36 return dynamic_cast<EditorInteractive&>(*get_parent());
37}
38
39/**
40 * Create all the buttons etc...
41 */
42EditorMainMenu::EditorMainMenu(EditorInteractive& parent, UI::UniqueWindow::Registry& registry)
43 : UI::UniqueWindow(&parent, "main_menu", &registry, 2 * margin + width, 0, _("Main Menu")),
44 box_(this, margin, margin, UI::Box::Vertical, width, get_h() - 2 * margin, vspacing),
45 button_new_map_(
46 &box_, "new_map", 0, 0, width, 0, UI::ButtonStyle::kWuiSecondary, _("New Map")),
47 button_new_random_map_(&box_,
48 "new_random_map",
49 0,
50 0,
51 width,
52 0,
53 UI::ButtonStyle::kWuiSecondary,
54 _("New Random Map")),
55 button_load_map_(
56 &box_, "load_map", 0, 0, width, 0, UI::ButtonStyle::kWuiSecondary, _("Load Map")),
57 button_save_map_(
58 &box_, "save_map", 0, 0, width, 0, UI::ButtonStyle::kWuiSecondary, _("Save Map")),
59 button_map_options_(
60 &box_, "map_options", 0, 0, width, 0, UI::ButtonStyle::kWuiSecondary, _("Map Options")),
61 button_exit_editor_(
62 &box_, "exit", 0, 0, width, 0, UI::ButtonStyle::kWuiPrimary, _("Exit Editor")) {
63 box_.add(&button_new_map_);
64 box_.add(&button_new_random_map_);
65 box_.add(&button_load_map_);
66 box_.add(&button_save_map_);
67 box_.add(&button_map_options_);
68 box_.add(&button_exit_editor_);
69 box_.set_size(width, 6 * button_new_map_.get_h() + 5 * vspacing);
70 set_inner_size(get_inner_w(), box_.get_h() + 2 * margin);
71
72 button_new_map_.sigclicked.connect(boost::bind(&EditorMainMenu::new_map_btn, this));
73 button_new_random_map_.sigclicked.connect(
74 boost::bind(&EditorMainMenu::new_random_map_btn, this));
75 button_load_map_.sigclicked.connect(boost::bind(&EditorMainMenu::load_btn, this));
76 button_save_map_.sigclicked.connect(boost::bind(&EditorMainMenu::save_btn, this));
77 button_map_options_.sigclicked.connect(boost::bind(&EditorMainMenu::map_options_btn, this));
78 button_exit_editor_.sigclicked.connect(boost::bind(&EditorMainMenu::exit_btn, this));
79
80 // Put in the default position, if necessary
81 if (get_usedefaultpos())
82 center_to_parent();
83}
84
85void EditorMainMenu::new_map_btn() {
86 new MainMenuNewMap(eia());
87 die();
88}
89
90void EditorMainMenu::new_random_map_btn() {
91 new MainMenuNewRandomMap(eia());
92 die();
93}
94
95void EditorMainMenu::load_btn() {
96 new MainMenuLoadMap(eia());
97 die();
98}
99
100void EditorMainMenu::save_btn() {
101 new MainMenuSaveMap(eia());
102 die();
103}
104void EditorMainMenu::map_options_btn() {
105 new MainMenuMapOptions(eia());
106 die();
107}
108void EditorMainMenu::exit_btn() {
109 eia().exit();
110}
1110
=== removed file 'src/editor/ui_menus/main_menu.h'
--- src/editor/ui_menus/main_menu.h 2019-02-23 11:00:49 +0000
+++ src/editor/ui_menus/main_menu.h 1970-01-01 00:00:00 +0000
@@ -1,53 +0,0 @@
1/*
2 * Copyright (C) 2002-2019 by the Widelands Development Team
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 *
18 */
19
20#ifndef WL_EDITOR_UI_MENUS_MAIN_MENU_H
21#define WL_EDITOR_UI_MENUS_MAIN_MENU_H
22
23#include "ui_basic/box.h"
24#include "ui_basic/button.h"
25#include "ui_basic/unique_window.h"
26
27class EditorInteractive;
28
29/**
30 * This represents the main menu
31 */
32struct EditorMainMenu : public UI::UniqueWindow {
33 EditorMainMenu(EditorInteractive&, UI::UniqueWindow::Registry&);
34
35private:
36 EditorInteractive& eia();
37 UI::Box box_;
38 UI::Button button_new_map_;
39 UI::Button button_new_random_map_;
40 UI::Button button_load_map_;
41 UI::Button button_save_map_;
42 UI::Button button_map_options_;
43 UI::Button button_exit_editor_;
44
45 void exit_btn();
46 void load_btn();
47 void save_btn();
48 void new_map_btn();
49 void new_random_map_btn();
50 void map_options_btn();
51};
52
53#endif // end of include guard: WL_EDITOR_UI_MENUS_MAIN_MENU_H
540
=== modified file 'src/editor/ui_menus/main_menu_load_map.cc'
--- src/editor/ui_menus/main_menu_load_map.cc 2019-02-23 11:00:49 +0000
+++ src/editor/ui_menus/main_menu_load_map.cc 2019-08-10 10:01:32 +0000
@@ -32,8 +32,8 @@
32/**32/**
33 * Create all the buttons etc...33 * Create all the buttons etc...
34 */34 */
35MainMenuLoadMap::MainMenuLoadMap(EditorInteractive& parent)35MainMenuLoadMap::MainMenuLoadMap(EditorInteractive& parent, UI::UniqueWindow::Registry& registry)
36 : MainMenuLoadOrSaveMap(parent, 2, "load_map_menu", _("Load Map")) {36 : MainMenuLoadOrSaveMap(parent, registry, 2, "load_map_menu", _("Load Map")) {
37 set_current_directory(curdir_);37 set_current_directory(curdir_);
3838
39 table_.selected.connect(boost::bind(&MainMenuLoadMap::entry_selected, this));39 table_.selected.connect(boost::bind(&MainMenuLoadMap::entry_selected, this));
4040
=== modified file 'src/editor/ui_menus/main_menu_load_map.h'
--- src/editor/ui_menus/main_menu_load_map.h 2019-02-23 11:00:49 +0000
+++ src/editor/ui_menus/main_menu_load_map.h 2019-08-10 10:01:32 +0000
@@ -29,7 +29,7 @@
29 * Choose a filename and save your brand new created map29 * Choose a filename and save your brand new created map
30 */30 */
31struct MainMenuLoadMap : public MainMenuLoadOrSaveMap {31struct MainMenuLoadMap : public MainMenuLoadOrSaveMap {
32 explicit MainMenuLoadMap(EditorInteractive& parent);32 explicit MainMenuLoadMap(EditorInteractive& parent, UI::UniqueWindow::Registry& registry);
3333
34protected:34protected:
35 void clicked_ok() override;35 void clicked_ok() override;
3636
=== modified file 'src/editor/ui_menus/main_menu_load_or_save_map.cc'
--- src/editor/ui_menus/main_menu_load_or_save_map.cc 2019-04-19 05:13:02 +0000
+++ src/editor/ui_menus/main_menu_load_or_save_map.cc 2019-08-10 10:01:32 +0000
@@ -30,12 +30,12 @@
30#include "io/filesystem/layered_filesystem.h"30#include "io/filesystem/layered_filesystem.h"
31#include "map_io/widelands_map_loader.h"31#include "map_io/widelands_map_loader.h"
3232
33MainMenuLoadOrSaveMap::MainMenuLoadOrSaveMap(EditorInteractive& parent,33MainMenuLoadOrSaveMap::MainMenuLoadOrSaveMap(EditorInteractive& parent, Registry& registry,
34 int no_of_bottom_rows,34 int no_of_bottom_rows,
35 const std::string& name,35 const std::string& name,
36 const std::string& title,36 const std::string& title,
37 const std::string& basedir)37 const std::string& basedir)
38 : UI::Window(&parent, name, 0, 0, parent.get_inner_w() - 40, parent.get_inner_h() - 40, title),38 : UI::UniqueWindow(&parent, name, &registry, parent.get_inner_w() - 40, parent.get_inner_h() - 40, title),
3939
40 // Values for alignment and size40 // Values for alignment and size
41 padding_(4),41 padding_(4),
4242
=== modified file 'src/editor/ui_menus/main_menu_load_or_save_map.h'
--- src/editor/ui_menus/main_menu_load_or_save_map.h 2019-02-23 11:00:49 +0000
+++ src/editor/ui_menus/main_menu_load_or_save_map.h 2019-08-10 10:01:32 +0000
@@ -27,15 +27,16 @@
27#include "ui_basic/button.h"27#include "ui_basic/button.h"
28#include "ui_basic/checkbox.h"28#include "ui_basic/checkbox.h"
29#include "ui_basic/textarea.h"29#include "ui_basic/textarea.h"
30#include "ui_basic/window.h"30#include "ui_basic/unique_window.h"
31#include "wui/mapdetails.h"31#include "wui/mapdetails.h"
32#include "wui/maptable.h"32#include "wui/maptable.h"
3333
34/**34/**
35 * Choose a filename and save your brand new created map35 * Choose a filename and save your brand new created map
36 */36 */
37struct MainMenuLoadOrSaveMap : public UI::Window {37struct MainMenuLoadOrSaveMap : public UI::UniqueWindow {
38 MainMenuLoadOrSaveMap(EditorInteractive& parent,38 MainMenuLoadOrSaveMap(EditorInteractive& parent,
39 UI::UniqueWindow::Registry& registry,
39 int no_of_bottom_rows,40 int no_of_bottom_rows,
40 const std::string& name,41 const std::string& name,
41 const std::string& title,42 const std::string& title,
4243
=== modified file 'src/editor/ui_menus/main_menu_map_options.cc'
--- src/editor/ui_menus/main_menu_map_options.cc 2019-04-18 08:32:25 +0000
+++ src/editor/ui_menus/main_menu_map_options.cc 2019-08-10 10:01:32 +0000
@@ -42,8 +42,8 @@
42/**42/**
43 * Create all the buttons etc...43 * Create all the buttons etc...
44 */44 */
45MainMenuMapOptions::MainMenuMapOptions(EditorInteractive& parent, bool modal)45MainMenuMapOptions::MainMenuMapOptions(EditorInteractive& parent, Registry& registry)
46 : UI::Window(&parent, "map_options", 0, 0, 350, parent.get_inner_h() - 80, _("Map Options")),46 : UI::UniqueWindow(&parent, "map_options", &registry, 350, parent.get_inner_h() - 80, _("Map Options")),
47 padding_(4),47 padding_(4),
48 indent_(10),48 indent_(10),
49 labelh_(text_height(UI::FontStyle::kLabel) + 4),49 labelh_(text_height(UI::FontStyle::kLabel) + 4),
@@ -80,7 +80,7 @@
80 teams_list_(80 teams_list_(
81 &teams_box_, 0, 0, max_w_, 60, UI::PanelStyle::kWui, UI::ListselectLayout::kShowCheck),81 &teams_box_, 0, 0, max_w_, 60, UI::PanelStyle::kWui, UI::ListselectLayout::kShowCheck),
8282
83 modal_(modal) {83 registry_(registry) {
8484
85 tab_box_.set_size(max_w_, get_inner_h() - labelh_ - 2 * padding_);85 tab_box_.set_size(max_w_, get_inner_h() - labelh_ - 2 * padding_);
86 tabs_.set_size(max_w_, tab_box_.get_inner_h());86 tabs_.set_size(max_w_, tab_box_.get_inner_h());
@@ -139,11 +139,11 @@
139 teams_box_.add(new UI::Textarea(&teams_box_, 0, 0, max_w_, labelh_, players));139 teams_box_.add(new UI::Textarea(&teams_box_, 0, 0, max_w_, labelh_, players));
140140
141 tab_box_.add(&tabs_, UI::Box::Resizing::kFullSize);141 tab_box_.add(&tabs_, UI::Box::Resizing::kFullSize);
142 tabs_.add("main_map_options", g_gr->images().get("images/wui/menus/menu_toggle_minimap.png"),142 tabs_.add("main_map_options", g_gr->images().get("images/wui/menus/toggle_minimap.png"),
143 &main_box_, _("Main Options"));143 &main_box_, _("Main Options"));
144 tabs_.add("map_tags", g_gr->images().get("images/ui_basic/checkbox_checked.png"), &tags_box_,144 tabs_.add("map_tags", g_gr->images().get("images/ui_basic/checkbox_checked.png"), &tags_box_,
145 _("Tags"));145 _("Tags"));
146 tabs_.add("map_teams", g_gr->images().get("images/wui/editor/editor_menu_player_menu.png"),146 tabs_.add("map_teams", g_gr->images().get("images/wui/editor/tools/players.png"),
147 &teams_box_, _("Teams"));147 &teams_box_, _("Teams"));
148148
149 name_.changed.connect(boost::bind(&MainMenuMapOptions::changed, this));149 name_.changed.connect(boost::bind(&MainMenuMapOptions::changed, this));
@@ -203,20 +203,12 @@
203 eia().egbase().mutable_map()->add_tag(tag.first);203 eia().egbase().mutable_map()->add_tag(tag.first);
204 }204 }
205 }205 }
206206 Notifications::publish(NoteMapOptions());
207 if (modal_) {207 registry_.destroy();
208 end_modal<UI::Panel::Returncodes>(UI::Panel::Returncodes::kOk);
209 } else {
210 die();
211 }
212}208}
213209
214void MainMenuMapOptions::clicked_cancel() {210void MainMenuMapOptions::clicked_cancel() {
215 if (modal_) {211 registry_.destroy();
216 end_modal<UI::Panel::Returncodes>(UI::Panel::Returncodes::kBack);
217 } else {
218 die();
219 }
220}212}
221213
222/*214/*
223215
=== modified file 'src/editor/ui_menus/main_menu_map_options.h'
--- src/editor/ui_menus/main_menu_map_options.h 2019-02-23 11:00:49 +0000
+++ src/editor/ui_menus/main_menu_map_options.h 2019-08-10 10:01:32 +0000
@@ -20,6 +20,7 @@
20#ifndef WL_EDITOR_UI_MENUS_MAIN_MENU_MAP_OPTIONS_H20#ifndef WL_EDITOR_UI_MENUS_MAIN_MENU_MAP_OPTIONS_H
21#define WL_EDITOR_UI_MENUS_MAIN_MENU_MAP_OPTIONS_H21#define WL_EDITOR_UI_MENUS_MAIN_MENU_MAP_OPTIONS_H
2222
23#include "logic/note_map_options.h"
23#include "ui_basic/box.h"24#include "ui_basic/box.h"
24#include "ui_basic/button.h"25#include "ui_basic/button.h"
25#include "ui_basic/checkbox.h"26#include "ui_basic/checkbox.h"
@@ -28,7 +29,7 @@
28#include "ui_basic/multilineeditbox.h"29#include "ui_basic/multilineeditbox.h"
29#include "ui_basic/tabpanel.h"30#include "ui_basic/tabpanel.h"
30#include "ui_basic/textarea.h"31#include "ui_basic/textarea.h"
31#include "ui_basic/window.h"32#include "ui_basic/unique_window.h"
3233
33class EditorInteractive;34class EditorInteractive;
3435
@@ -37,8 +38,8 @@
37 * about the current map are displayed and you can change38 * about the current map are displayed and you can change
38 * author, name and description39 * author, name and description
39 */40 */
40struct MainMenuMapOptions : public UI::Window {41struct MainMenuMapOptions : public UI::UniqueWindow {
41 MainMenuMapOptions(EditorInteractive&, bool modal = false);42 MainMenuMapOptions(EditorInteractive&, UI::UniqueWindow::Registry& registry);
4243
43private:44private:
44 EditorInteractive& eia();45 EditorInteractive& eia();
@@ -66,7 +67,7 @@
6667
67 // Tag, Checkbox68 // Tag, Checkbox
68 std::map<std::string, UI::Checkbox*> tags_checkboxes_;69 std::map<std::string, UI::Checkbox*> tags_checkboxes_;
69 bool modal_;70 UI::UniqueWindow::Registry& registry_;
70};71};
7172
72#endif // end of include guard: WL_EDITOR_UI_MENUS_MAIN_MENU_MAP_OPTIONS_H73#endif // end of include guard: WL_EDITOR_UI_MENUS_MAIN_MENU_MAP_OPTIONS_H
7374
=== modified file 'src/editor/ui_menus/main_menu_new_map.cc'
--- src/editor/ui_menus/main_menu_new_map.cc 2019-06-25 07:34:58 +0000
+++ src/editor/ui_menus/main_menu_new_map.cc 2019-08-10 10:01:32 +0000
@@ -41,8 +41,8 @@
41 return dynamic_cast<EditorInteractive&>(*get_parent());41 return dynamic_cast<EditorInteractive&>(*get_parent());
42}42}
4343
44MainMenuNewMap::MainMenuNewMap(EditorInteractive& parent)44MainMenuNewMap::MainMenuNewMap(EditorInteractive& parent, Registry& registry)
45 : UI::Window(&parent, "new_map_menu", 0, 0, 360, 150, _("New Map")),45 : UI::UniqueWindow(&parent, "new_map_menu", &registry, 360, 150, _("New Map")),
46 margin_(4),46 margin_(4),
47 box_width_(get_inner_w() - 2 * margin_),47 box_width_(get_inner_w() - 2 * margin_),
48 box_(this, margin_, margin_, UI::Box::Vertical, 0, 0, margin_),48 box_(this, margin_, margin_, UI::Box::Vertical, 0, 0, margin_),
4949
=== modified file 'src/editor/ui_menus/main_menu_new_map.h'
--- src/editor/ui_menus/main_menu_new_map.h 2019-06-01 08:18:58 +0000
+++ src/editor/ui_menus/main_menu_new_map.h 2019-08-10 10:01:32 +0000
@@ -25,7 +25,7 @@
25#include "ui_basic/box.h"25#include "ui_basic/box.h"
26#include "ui_basic/button.h"26#include "ui_basic/button.h"
27#include "ui_basic/listselect.h"27#include "ui_basic/listselect.h"
28#include "ui_basic/window.h"28#include "ui_basic/unique_window.h"
2929
30class EditorInteractive;30class EditorInteractive;
3131
@@ -34,8 +34,8 @@
34 * the user to choose the new world and a few other34 * the user to choose the new world and a few other
35 * things like size, world ....35 * things like size, world ....
36 */36 */
37struct MainMenuNewMap : public UI::Window {37struct MainMenuNewMap : public UI::UniqueWindow {
38 explicit MainMenuNewMap(EditorInteractive&);38 explicit MainMenuNewMap(EditorInteractive&, UI::UniqueWindow::Registry&);
3939
40private:40private:
41 EditorInteractive& eia();41 EditorInteractive& eia();
4242
=== modified file 'src/editor/ui_menus/main_menu_random_map.cc'
--- src/editor/ui_menus/main_menu_random_map.cc 2019-06-25 07:34:58 +0000
+++ src/editor/ui_menus/main_menu_random_map.cc 2019-08-10 10:01:32 +0000
@@ -47,8 +47,8 @@
4747
48using namespace Widelands;48using namespace Widelands;
4949
50MainMenuNewRandomMap::MainMenuNewRandomMap(EditorInteractive& parent)50MainMenuNewRandomMap::MainMenuNewRandomMap(EditorInteractive& parent, UI::UniqueWindow::Registry& registry)
51 : UI::Window(&parent, "random_map_menu", 0, 0, 400, 500, _("New Random Map")),51 : UI::UniqueWindow(&parent, "random_map_menu", &registry, 400, 500, _("New Random Map")),
52 // UI elements52 // UI elements
53 margin_(4),53 margin_(4),
54 box_width_(get_inner_w() - 2 * margin_),54 box_width_(get_inner_w() - 2 * margin_),
5555
=== modified file 'src/editor/ui_menus/main_menu_random_map.h'
--- src/editor/ui_menus/main_menu_random_map.h 2019-06-01 08:18:58 +0000
+++ src/editor/ui_menus/main_menu_random_map.h 2019-08-10 10:01:32 +0000
@@ -30,7 +30,7 @@
30#include "ui_basic/editbox.h"30#include "ui_basic/editbox.h"
31#include "ui_basic/spinbox.h"31#include "ui_basic/spinbox.h"
32#include "ui_basic/textarea.h"32#include "ui_basic/textarea.h"
33#include "ui_basic/window.h"33#include "ui_basic/unique_window.h"
3434
35namespace Widelands {35namespace Widelands {
36struct UniqueRandomMapInfo;36struct UniqueRandomMapInfo;
@@ -46,8 +46,8 @@
46 * the user to choose the new world and a few other46 * the user to choose the new world and a few other
47 * things like size, world ....47 * things like size, world ....
48 */48 */
49struct MainMenuNewRandomMap : public UI::Window {49struct MainMenuNewRandomMap : public UI::UniqueWindow {
50 explicit MainMenuNewRandomMap(EditorInteractive&);50 explicit MainMenuNewRandomMap(EditorInteractive&, UI::UniqueWindow::Registry&);
5151
52 enum class ButtonId : uint8_t {52 enum class ButtonId : uint8_t {
53 kNone,53 kNone,
5454
=== modified file 'src/editor/ui_menus/main_menu_save_map.cc'
--- src/editor/ui_menus/main_menu_save_map.cc 2019-04-18 08:32:25 +0000
+++ src/editor/ui_menus/main_menu_save_map.cc 2019-08-10 10:01:32 +0000
@@ -31,7 +31,6 @@
31#include "base/macros.h"31#include "base/macros.h"
32#include "base/wexception.h"32#include "base/wexception.h"
33#include "editor/editorinteractive.h"33#include "editor/editorinteractive.h"
34#include "editor/ui_menus/main_menu_map_options.h"
35#include "editor/ui_menus/main_menu_save_map_make_directory.h"34#include "editor/ui_menus/main_menu_save_map_make_directory.h"
36#include "io/filesystem/filesystem.h"35#include "io/filesystem/filesystem.h"
37#include "io/filesystem/layered_filesystem.h"36#include "io/filesystem/layered_filesystem.h"
@@ -49,9 +48,9 @@
49}48}
5049
51// TODO(GunChleoc): Arabic: Make directory dialog: buttons need more height for Arabic.50// TODO(GunChleoc): Arabic: Make directory dialog: buttons need more height for Arabic.
52MainMenuSaveMap::MainMenuSaveMap(EditorInteractive& parent)51MainMenuSaveMap::MainMenuSaveMap(EditorInteractive& parent, UI::UniqueWindow::Registry& registry, Registry& map_options_registry)
53 : MainMenuLoadOrSaveMap(parent, 3, "save_map_menu", _("Save Map"), "maps/My_Maps"),52 : MainMenuLoadOrSaveMap(parent, registry, 3, "save_map_menu", _("Save Map"), "maps/My_Maps"),
5453 map_options_registry_(map_options_registry),
55 make_directory_(this,54 make_directory_(this,
56 "make_directory",55 "make_directory",
57 right_column_x_,56 right_column_x_,
@@ -114,6 +113,10 @@
114 MapData mapdata(map, "", maptype, MapData::DisplayType::kMapnames);113 MapData mapdata(map, "", maptype, MapData::DisplayType::kMapnames);
115114
116 map_details_.update(mapdata, false);115 map_details_.update(mapdata, false);
116
117 subscriber_ = Notifications::subscribe<NoteMapOptions>([this](const NoteMapOptions&) {
118 update_map_options();
119 });
117}120}
118121
119/**122/**
@@ -196,24 +199,29 @@
196}199}
197200
198void MainMenuSaveMap::clicked_edit_options() {201void MainMenuSaveMap::clicked_edit_options() {
199 MainMenuMapOptions mo(eia(), true);202 map_options_registry_.create();
200 if (mo.run<UI::Panel::Returncodes>() == UI::Panel::Returncodes::kOk) {203}
201 const Widelands::Map& map = eia().egbase().map();204
202 MapData::MapType maptype;205void MainMenuSaveMap::update_map_options() {
203206 const Widelands::Map& map = eia().egbase().map();
204 if (map.scenario_types() & Widelands::Map::MP_SCENARIO ||207 MapData::MapType maptype;
205 map.scenario_types() & Widelands::Map::SP_SCENARIO) {208
206 maptype = MapData::MapType::kScenario;209 const std::string old_name = map_details_.name();
207 } else {210
208 maptype = MapData::MapType::kNormal;211 if (map.scenario_types() & Widelands::Map::MP_SCENARIO ||
209 }212 map.scenario_types() & Widelands::Map::SP_SCENARIO) {
210213 maptype = MapData::MapType::kScenario;
211 MapData mapdata(map, editbox_->text(), maptype, MapData::DisplayType::kMapnames);214 } else {
212215 maptype = MapData::MapType::kNormal;
213 map_details_.update(mapdata, false);216 }
214 }217
215}218 MapData mapdata(map, editbox_->text(), maptype, MapData::DisplayType::kMapnames);
216219
220 map_details_.update(mapdata, false);
221 if (old_name == editbox_->text()) {
222 editbox_->set_text(map_details_.name());
223 }
224}
217/**225/**
218 * called when an item was selected226 * called when an item was selected
219 */227 */
220228
=== modified file 'src/editor/ui_menus/main_menu_save_map.h'
--- src/editor/ui_menus/main_menu_save_map.h 2019-02-23 11:00:49 +0000
+++ src/editor/ui_menus/main_menu_save_map.h 2019-08-10 10:01:32 +0000
@@ -20,10 +20,12 @@
20#ifndef WL_EDITOR_UI_MENUS_MAIN_MENU_SAVE_MAP_H20#ifndef WL_EDITOR_UI_MENUS_MAIN_MENU_SAVE_MAP_H
21#define WL_EDITOR_UI_MENUS_MAIN_MENU_SAVE_MAP_H21#define WL_EDITOR_UI_MENUS_MAIN_MENU_SAVE_MAP_H
2222
23#include <memory>
23#include <string>24#include <string>
2425
25#include "editor/editorinteractive.h"26#include "editor/editorinteractive.h"
26#include "editor/ui_menus/main_menu_load_or_save_map.h"27#include "editor/ui_menus/main_menu_load_or_save_map.h"
28#include "editor/ui_menus/main_menu_map_options.h"
27#include "ui_basic/button.h"29#include "ui_basic/button.h"
28#include "ui_basic/editbox.h"30#include "ui_basic/editbox.h"
29#include "ui_basic/textarea.h"31#include "ui_basic/textarea.h"
@@ -32,7 +34,7 @@
32 * Choose a filename and save your brand new created map34 * Choose a filename and save your brand new created map
33 */35 */
34struct MainMenuSaveMap : public MainMenuLoadOrSaveMap {36struct MainMenuSaveMap : public MainMenuLoadOrSaveMap {
35 explicit MainMenuSaveMap(EditorInteractive& parent);37 explicit MainMenuSaveMap(EditorInteractive& parent, UI::UniqueWindow::Registry& registry, UI::UniqueWindow::Registry& map_options_registry);
3638
37protected:39protected:
38 // Sets the current dir and updates labels.40 // Sets the current dir and updates labels.
@@ -40,6 +42,8 @@
4042
41private:43private:
42 EditorInteractive& eia();44 EditorInteractive& eia();
45 Registry& map_options_registry_;
46
43 void clicked_ok() override;47 void clicked_ok() override;
44 void clicked_make_directory();48 void clicked_make_directory();
45 void clicked_edit_options();49 void clicked_edit_options();
@@ -49,6 +53,8 @@
49 /// Resets the map's filename in the editbox. If mapname didn't change, die().53 /// Resets the map's filename in the editbox. If mapname didn't change, die().
50 void reset_editbox_or_die(const std::string& current_filename);54 void reset_editbox_or_die(const std::string& current_filename);
5155
56 void update_map_options();
57
52 bool save_map(std::string, bool);58 bool save_map(std::string, bool);
5359
54 UI::Button make_directory_, edit_options_;60 UI::Button make_directory_, edit_options_;
@@ -56,6 +62,8 @@
56 UI::Textarea editbox_label_;62 UI::Textarea editbox_label_;
57 UI::EditBox* editbox_;63 UI::EditBox* editbox_;
58 const std::string illegal_filename_tooltip_;64 const std::string illegal_filename_tooltip_;
65
66 std::unique_ptr<Notifications::Subscriber<NoteMapOptions>> subscriber_;
59};67};
6068
61#endif // end of include guard: WL_EDITOR_UI_MENUS_MAIN_MENU_SAVE_MAP_H69#endif // end of include guard: WL_EDITOR_UI_MENUS_MAIN_MENU_SAVE_MAP_H
6270
=== modified file 'src/editor/ui_menus/player_menu.cc'
--- src/editor/ui_menus/player_menu.cc 2019-06-25 07:34:58 +0000
+++ src/editor/ui_menus/player_menu.cc 2019-08-10 10:01:32 +0000
@@ -119,8 +119,8 @@
119 return dynamic_cast<EditorInteractive&>(*get_parent());119 return dynamic_cast<EditorInteractive&>(*get_parent());
120}120}
121121
122EditorPlayerMenu::EditorPlayerMenu(EditorInteractive& parent, UI::UniqueWindow::Registry& registry)122EditorPlayerMenu::EditorPlayerMenu(EditorInteractive& parent, EditorSetStartingPosTool& tool, UI::UniqueWindow::Registry& registry)
123 : UI::UniqueWindow(&parent, "players_menu", &registry, 100, 100, _("Player Options")),123 : EditorToolOptionsMenu(parent, registry, 0, 0, _("Player Options"), tool),
124 box_(this, kMargin, kMargin, UI::Box::Vertical),124 box_(this, kMargin, kMargin, UI::Box::Vertical),
125 no_of_players_(&box_,125 no_of_players_(&box_,
126 "dropdown_map_players",126 "dropdown_map_players",
127127
=== modified file 'src/editor/ui_menus/player_menu.h'
--- src/editor/ui_menus/player_menu.h 2019-02-27 19:00:36 +0000
+++ src/editor/ui_menus/player_menu.h 2019-08-10 10:01:32 +0000
@@ -24,6 +24,7 @@
24#include <string>24#include <string>
25#include <vector>25#include <vector>
2626
27#include "editor/ui_menus/tool_options_menu.h"
27#include "ui_basic/box.h"28#include "ui_basic/box.h"
28#include "ui_basic/button.h"29#include "ui_basic/button.h"
29#include "ui_basic/dropdown.h"30#include "ui_basic/dropdown.h"
@@ -32,9 +33,9 @@
3233
33class EditorInteractive;34class EditorInteractive;
3435
35class EditorPlayerMenu : public UI::UniqueWindow {36class EditorPlayerMenu : public EditorToolOptionsMenu {
36public:37public:
37 EditorPlayerMenu(EditorInteractive&, UI::UniqueWindow::Registry&);38 EditorPlayerMenu(EditorInteractive&, EditorSetStartingPosTool& tool, UI::UniqueWindow::Registry&);
38 ~EditorPlayerMenu() override {39 ~EditorPlayerMenu() override {
39 }40 }
4041
4142
=== modified file 'src/editor/ui_menus/tool_change_height_options_menu.cc'
--- src/editor/ui_menus/tool_change_height_options_menu.cc 2019-02-23 11:00:49 +0000
+++ src/editor/ui_menus/tool_change_height_options_menu.cc 2019-08-10 10:01:32 +0000
@@ -32,7 +32,7 @@
32 EditorInteractive& parent,32 EditorInteractive& parent,
33 EditorIncreaseHeightTool& increase_tool,33 EditorIncreaseHeightTool& increase_tool,
34 UI::UniqueWindow::Registry& registry)34 UI::UniqueWindow::Registry& registry)
35 : EditorToolOptionsMenu(parent, registry, 350, 100, _("Height Tools Options")),35 : EditorToolOptionsMenu(parent, registry, 350, 100, _("Height Tools Options"), increase_tool),
36 increase_tool_(increase_tool),36 increase_tool_(increase_tool),
37 box_(this, hmargin(), vmargin(), UI::Box::Vertical, 0, 0, vspacing()),37 box_(this, hmargin(), vmargin(), UI::Box::Vertical, 0, 0, vspacing()),
38 change_by_(&box_,38 change_by_(&box_,
3939
=== modified file 'src/editor/ui_menus/tool_change_resources_options_menu.cc'
--- src/editor/ui_menus/tool_change_resources_options_menu.cc 2019-05-12 07:45:59 +0000
+++ src/editor/ui_menus/tool_change_resources_options_menu.cc 2019-08-10 10:01:32 +0000
@@ -45,7 +45,7 @@
45 EditorInteractive& parent,45 EditorInteractive& parent,
46 EditorIncreaseResourcesTool& increase_tool,46 EditorIncreaseResourcesTool& increase_tool,
47 UI::UniqueWindow::Registry& registry)47 UI::UniqueWindow::Registry& registry)
48 : EditorToolOptionsMenu(parent, registry, 370, 120, _("Resources")),48 : EditorToolOptionsMenu(parent, registry, 370, 120, _("Resources"), increase_tool),
49 increase_tool_(increase_tool),49 increase_tool_(increase_tool),
50 box_(this, hmargin(), vmargin(), UI::Box::Vertical, 0, 0, vspacing()),50 box_(this, hmargin(), vmargin(), UI::Box::Vertical, 0, 0, vspacing()),
51 change_by_(&box_,51 change_by_(&box_,
5252
=== removed file 'src/editor/ui_menus/tool_menu.cc'
--- src/editor/ui_menus/tool_menu.cc 2019-04-24 07:09:29 +0000
+++ src/editor/ui_menus/tool_menu.cc 1970-01-01 00:00:00 +0000
@@ -1,193 +0,0 @@
1/*
2 * Copyright (C) 2002-2019 by the Widelands Development Team
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 *
18 */
19
20#include "editor/ui_menus/tool_menu.h"
21
22#include "base/i18n.h"
23#include "base/wexception.h"
24#include "editor/editorinteractive.h"
25#include "editor/tools/decrease_height_tool.h"
26#include "editor/tools/decrease_resources_tool.h"
27#include "editor/tools/increase_height_tool.h"
28#include "editor/tools/increase_resources_tool.h"
29#include "editor/tools/noise_height_tool.h"
30#include "editor/tools/place_critter_tool.h"
31#include "editor/tools/place_immovable_tool.h"
32#include "editor/tools/set_port_space_tool.h"
33#include "editor/tools/set_terrain_tool.h"
34#include "editor/ui_menus/tool_change_height_options_menu.h"
35#include "editor/ui_menus/tool_change_resources_options_menu.h"
36#include "editor/ui_menus/tool_noise_height_options_menu.h"
37#include "editor/ui_menus/tool_place_critter_options_menu.h"
38#include "editor/ui_menus/tool_place_immovable_options_menu.h"
39#include "editor/ui_menus/tool_resize_options_menu.h"
40#include "editor/ui_menus/tool_set_terrain_options_menu.h"
41#include "graphic/graphic.h"
42#include "ui_basic/radiobutton.h"
43#include "ui_basic/textarea.h"
44
45EditorToolMenu::EditorToolMenu(EditorInteractive& parent, UI::UniqueWindow::Registry& registry)
46 : UI::UniqueWindow(&parent, "tool_menu", &registry, 350, 400, _("Tools")) {
47
48#define spacing 5
49 Vector2i const offs(spacing, spacing);
50 Vector2i pos = offs;
51 int32_t const width = 34;
52 int32_t const height = 34;
53
54 int32_t const num_tools = 9;
55#define ADD_BUTTON(pic, tooltip) \
56 radioselect_.add_button( \
57 this, pos, g_gr->images().get("images/wui/editor/editor_menu_tool_" pic ".png"), tooltip); \
58 pos.x += width + spacing;
59
60 ADD_BUTTON("change_height", _("Change height"))
61 ADD_BUTTON("noise_height", _("Random height"))
62 ADD_BUTTON("set_terrain", _("Terrain"))
63 ADD_BUTTON("place_immovable", _("Immovables"))
64 ADD_BUTTON("place_bob", _("Animals"))
65 ADD_BUTTON("change_resources", _("Resources"))
66 ADD_BUTTON("set_port_space", _("Set port space"))
67 ADD_BUTTON("set_origin", _("Set the position that will have the coordinates (0, 0). This will "
68 "be the top-left corner of a generated minimap."));
69 ADD_BUTTON("resize", _("Change the map’s size"));
70
71 set_inner_size(offs.x + (width + spacing) * num_tools, offs.y + (height + spacing));
72
73 {
74 const EditorTool* current = &parent.tools()->current();
75 radioselect_.set_state(current == &parent.tools()->noise_height ?
76 1 :
77 current == &parent.tools()->set_terrain ?
78 2 :
79 current == &parent.tools()->place_immovable ?
80 3 :
81 current == &parent.tools()->place_critter ?
82 4 :
83 current == &parent.tools()->increase_resources ?
84 5 :
85 current == &parent.tools()->set_port_space ?
86 6 :
87 current == &parent.tools()->set_origin ?
88 7 :
89 current == &parent.tools()->resize ? 8 : 0);
90 }
91
92 radioselect_.changed.connect(boost::bind(&EditorToolMenu::changed_to, this));
93 radioselect_.clicked.connect(boost::bind(&EditorToolMenu::changed_to, this));
94
95 if (get_usedefaultpos())
96 center_to_parent();
97}
98
99/**
100 * Called when the radiogroup changes or is reclicked
101 */
102void EditorToolMenu::changed_to() {
103 const int32_t n = radioselect_.get_state();
104
105 EditorInteractive& parent = dynamic_cast<EditorInteractive&>(*get_parent());
106
107 EditorTool* current_tool_pointer = nullptr;
108 UI::UniqueWindow::Registry* current_registry_pointer = nullptr;
109 switch (n) {
110 case 0:
111 current_tool_pointer = &parent.tools()->increase_height;
112 current_registry_pointer = &parent.heightmenu_;
113 break;
114 case 1:
115 current_tool_pointer = &parent.tools()->noise_height;
116 current_registry_pointer = &parent.noise_heightmenu_;
117 break;
118 case 2:
119 current_tool_pointer = &parent.tools()->set_terrain;
120 current_registry_pointer = &parent.terrainmenu_;
121 break;
122 case 3:
123 current_tool_pointer = &parent.tools()->place_immovable;
124 current_registry_pointer = &parent.immovablemenu_;
125 break;
126 case 4:
127 current_tool_pointer = &parent.tools()->place_critter;
128 current_registry_pointer = &parent.crittermenu_;
129 break;
130 case 5:
131 current_tool_pointer = &parent.tools()->increase_resources;
132 current_registry_pointer = &parent.resourcesmenu_;
133 break;
134 case 6:
135 current_tool_pointer = &parent.tools()->set_port_space;
136 current_registry_pointer = nullptr; // no need for a window
137 break;
138 case 7:
139 current_tool_pointer = &parent.tools()->set_origin;
140 current_registry_pointer = nullptr; // no need for a window
141 break;
142 case 8:
143 current_tool_pointer = &parent.tools()->resize;
144 current_registry_pointer = &parent.resizemenu_;
145 break;
146 default:
147 NEVER_HERE();
148 }
149
150 parent.select_tool(*current_tool_pointer, EditorTool::First);
151
152 if (current_registry_pointer) {
153 if (UI::Window* const window = current_registry_pointer->window) {
154 // There is already a window. If it is minimal, restore it.
155 if (window->is_minimal())
156 window->restore();
157 else
158 delete window;
159 } else
160 switch (n) { // create window
161 case 0:
162 new EditorToolChangeHeightOptionsMenu(
163 parent, parent.tools()->increase_height, *current_registry_pointer);
164 break;
165 case 1:
166 new EditorToolNoiseHeightOptionsMenu(
167 parent, parent.tools()->noise_height, *current_registry_pointer);
168 break;
169 case 2:
170 new EditorToolSetTerrainOptionsMenu(
171 parent, parent.tools()->set_terrain, *current_registry_pointer);
172 break;
173 case 3:
174 new EditorToolPlaceImmovableOptionsMenu(
175 parent, parent.tools()->place_immovable, *current_registry_pointer);
176 break;
177 case 4:
178 new EditorToolPlaceCritterOptionsMenu(
179 parent, parent.tools()->place_critter, *current_registry_pointer);
180 break;
181 case 5:
182 new EditorToolChangeResourcesOptionsMenu(
183 parent, parent.tools()->increase_resources, *current_registry_pointer);
184 break;
185 case 8:
186 new EditorToolResizeOptionsMenu(
187 parent, parent.tools()->resize, *current_registry_pointer);
188 break;
189 default:
190 NEVER_HERE();
191 }
192 }
193}
1940
=== removed file 'src/editor/ui_menus/tool_menu.h'
--- src/editor/ui_menus/tool_menu.h 2019-02-23 11:00:49 +0000
+++ src/editor/ui_menus/tool_menu.h 1970-01-01 00:00:00 +0000
@@ -1,37 +0,0 @@
1/*
2 * Copyright (C) 2002-2019 by the Widelands Development Team
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 *
18 */
19
20#ifndef WL_EDITOR_UI_MENUS_TOOL_MENU_H
21#define WL_EDITOR_UI_MENUS_TOOL_MENU_H
22
23#include "editor/editorinteractive.h"
24#include "ui_basic/radiobutton.h"
25#include "ui_basic/unique_window.h"
26
27/// The tool selection window/menu.
28struct EditorToolMenu : public UI::UniqueWindow {
29 EditorToolMenu(EditorInteractive&, UI::UniqueWindow::Registry&);
30
31private:
32 UI::Radiogroup radioselect_;
33
34 void changed_to();
35};
36
37#endif // end of include guard: WL_EDITOR_UI_MENUS_TOOL_MENU_H
380
=== modified file 'src/editor/ui_menus/tool_noise_height_options_menu.cc'
--- src/editor/ui_menus/tool_noise_height_options_menu.cc 2019-02-23 11:00:49 +0000
+++ src/editor/ui_menus/tool_noise_height_options_menu.cc 2019-08-10 10:01:32 +0000
@@ -35,7 +35,7 @@
35 EditorInteractive& parent,35 EditorInteractive& parent,
36 EditorNoiseHeightTool& noise_tool,36 EditorNoiseHeightTool& noise_tool,
37 UI::UniqueWindow::Registry& registry)37 UI::UniqueWindow::Registry& registry)
38 : EditorToolOptionsMenu(parent, registry, 300, 120, _("Random Height Options")),38 : EditorToolOptionsMenu(parent, registry, 300, 120, _("Random Height Options"), noise_tool),
39 noise_tool_(noise_tool),39 noise_tool_(noise_tool),
40 box_(this, hmargin(), vmargin(), UI::Box::Vertical, 0, 0, vspacing()),40 box_(this, hmargin(), vmargin(), UI::Box::Vertical, 0, 0, vspacing()),
41 lower_(&box_,41 lower_(&box_,
4242
=== modified file 'src/editor/ui_menus/tool_options_menu.cc'
--- src/editor/ui_menus/tool_options_menu.cc 2019-02-23 11:00:49 +0000
+++ src/editor/ui_menus/tool_options_menu.cc 2019-08-10 10:01:32 +0000
@@ -23,14 +23,14 @@
23 UI::UniqueWindow::Registry& registry,23 UI::UniqueWindow::Registry& registry,
24 uint32_t const width,24 uint32_t const width,
25 uint32_t const height,25 uint32_t const height,
26 char const* const title)26 const std::string& title, EditorTool& tool)
27 : UI::UniqueWindow(&parent, "tool_options_menu", &registry, width, height, title),27 : UI::UniqueWindow(&parent, "tool_options_menu", &registry, width, height, title),
28 current_pointer_(parent.tools()->current_pointer) {28 parent_(parent),
29 if (get_usedefaultpos())29 current_tool_(tool) {
30 center_to_parent();30 select_correct_tool();
31 clicked.connect([this] { select_correct_tool(); });
31}32}
3233
33void EditorToolOptionsMenu::select_correct_tool() {34void EditorToolOptionsMenu::select_correct_tool() {
34 dynamic_cast<EditorInteractive&>(*get_parent())35 parent_.select_tool(current_tool_, EditorTool::First);
35 .select_tool(*current_pointer_, EditorTool::First);
36}36}
3737
=== modified file 'src/editor/ui_menus/tool_options_menu.h'
--- src/editor/ui_menus/tool_options_menu.h 2019-02-23 11:00:49 +0000
+++ src/editor/ui_menus/tool_options_menu.h 2019-08-10 10:01:32 +0000
@@ -28,7 +28,8 @@
28 UI::UniqueWindow::Registry&,28 UI::UniqueWindow::Registry&,
29 const uint32_t width,29 const uint32_t width,
30 const uint32_t height,30 const uint32_t height,
31 char const* title);31 const std::string& title,
32 EditorTool& tool);
3233
33 /**34 /**
34 * Selects the correct tool from the parent.35 * Selects the correct tool from the parent.
@@ -53,7 +54,8 @@
53 }54 }
5455
55private:56private:
56 EditorTool* current_pointer_;57 EditorInteractive& parent_;
58 EditorTool& current_tool_;
57};59};
5860
59#endif // end of include guard: WL_EDITOR_UI_MENUS_TOOL_OPTIONS_MENU_H61#endif // end of include guard: WL_EDITOR_UI_MENUS_TOOL_OPTIONS_MENU_H
6062
=== modified file 'src/editor/ui_menus/tool_place_critter_options_menu.cc'
--- src/editor/ui_menus/tool_place_critter_options_menu.cc 2019-02-23 11:00:49 +0000
+++ src/editor/ui_menus/tool_place_critter_options_menu.cc 2019-08-10 10:01:32 +0000
@@ -47,7 +47,7 @@
4747
48EditorToolPlaceCritterOptionsMenu::EditorToolPlaceCritterOptionsMenu(48EditorToolPlaceCritterOptionsMenu::EditorToolPlaceCritterOptionsMenu(
49 EditorInteractive& parent, EditorPlaceCritterTool& tool, UI::UniqueWindow::Registry& registry)49 EditorInteractive& parent, EditorPlaceCritterTool& tool, UI::UniqueWindow::Registry& registry)
50 : EditorToolOptionsMenu(parent, registry, 0, 0, _("Animals")) {50 : EditorToolOptionsMenu(parent, registry, 0, 0, _("Animals"), tool) {
51 const Widelands::World& world = parent.egbase().world();51 const Widelands::World& world = parent.egbase().world();
52 multi_select_menu_.reset(52 multi_select_menu_.reset(
53 new CategorizedItemSelectionMenu<Widelands::CritterDescr, EditorPlaceCritterTool>(53 new CategorizedItemSelectionMenu<Widelands::CritterDescr, EditorPlaceCritterTool>(
5454
=== modified file 'src/editor/ui_menus/tool_place_immovable_options_menu.cc'
--- src/editor/ui_menus/tool_place_immovable_options_menu.cc 2019-02-23 11:00:49 +0000
+++ src/editor/ui_menus/tool_place_immovable_options_menu.cc 2019-08-10 10:01:32 +0000
@@ -48,7 +48,7 @@
4848
49EditorToolPlaceImmovableOptionsMenu::EditorToolPlaceImmovableOptionsMenu(49EditorToolPlaceImmovableOptionsMenu::EditorToolPlaceImmovableOptionsMenu(
50 EditorInteractive& parent, EditorPlaceImmovableTool& tool, UI::UniqueWindow::Registry& registry)50 EditorInteractive& parent, EditorPlaceImmovableTool& tool, UI::UniqueWindow::Registry& registry)
51 : EditorToolOptionsMenu(parent, registry, 0, 0, _("Immovables")) {51 : EditorToolOptionsMenu(parent, registry, 0, 0, _("Immovables"), tool) {
52 const Widelands::World& world = parent.egbase().world();52 const Widelands::World& world = parent.egbase().world();
53 multi_select_menu_.reset(53 multi_select_menu_.reset(
54 new CategorizedItemSelectionMenu<Widelands::ImmovableDescr, EditorPlaceImmovableTool>(54 new CategorizedItemSelectionMenu<Widelands::ImmovableDescr, EditorPlaceImmovableTool>(
5555
=== modified file 'src/editor/ui_menus/tool_resize_options_menu.cc'
--- src/editor/ui_menus/tool_resize_options_menu.cc 2019-06-25 07:34:58 +0000
+++ src/editor/ui_menus/tool_resize_options_menu.cc 2019-08-10 10:01:32 +0000
@@ -33,10 +33,11 @@
33 return dynamic_cast<EditorInteractive&>(*get_parent());33 return dynamic_cast<EditorInteractive&>(*get_parent());
34}34}
3535
36EditorToolResizeOptionsMenu::EditorToolResizeOptionsMenu(EditorInteractive& parent,36EditorToolResizeOptionsMenu::EditorToolResizeOptionsMenu(
37 EditorResizeTool& resize_tool,37 EditorInteractive& parent,
38 UI::UniqueWindow::Registry& registry)38 EditorResizeTool& resize_tool,
39 : EditorToolOptionsMenu(parent, registry, 260, 200, _("Resize")),39 UI::UniqueWindow::Registry& registry)
40 : EditorToolOptionsMenu(parent, registry, 260, 200, _("Resize"), resize_tool),
40 resize_tool_(resize_tool),41 resize_tool_(resize_tool),
41 box_(this, hmargin(), vmargin(), UI::Box::Vertical, 0, 0, vspacing()),42 box_(this, hmargin(), vmargin(), UI::Box::Vertical, 0, 0, vspacing()),
42 map_size_box_(box_,43 map_size_box_(box_,
4344
=== modified file 'src/editor/ui_menus/tool_set_terrain_options_menu.cc'
--- src/editor/ui_menus/tool_set_terrain_options_menu.cc 2019-02-23 11:00:49 +0000
+++ src/editor/ui_menus/tool_set_terrain_options_menu.cc 2019-08-10 10:01:32 +0000
@@ -86,7 +86,7 @@
8686
87EditorToolSetTerrainOptionsMenu::EditorToolSetTerrainOptionsMenu(87EditorToolSetTerrainOptionsMenu::EditorToolSetTerrainOptionsMenu(
88 EditorInteractive& parent, EditorSetTerrainTool& tool, UI::UniqueWindow::Registry& registry)88 EditorInteractive& parent, EditorSetTerrainTool& tool, UI::UniqueWindow::Registry& registry)
89 : EditorToolOptionsMenu(parent, registry, 0, 0, _("Terrain")) {89 : EditorToolOptionsMenu(parent, registry, 0, 0, _("Terrain"), tool) {
90 const Widelands::World& world = parent.egbase().world();90 const Widelands::World& world = parent.egbase().world();
91 multi_select_menu_.reset(91 multi_select_menu_.reset(
92 new CategorizedItemSelectionMenu<Widelands::TerrainDescription, EditorSetTerrainTool>(92 new CategorizedItemSelectionMenu<Widelands::TerrainDescription, EditorSetTerrainTool>(
9393
=== modified file 'src/graphic/CMakeLists.txt'
--- src/graphic/CMakeLists.txt 2019-05-31 07:39:22 +0000
+++ src/graphic/CMakeLists.txt 2019-08-10 10:01:32 +0000
@@ -6,6 +6,16 @@
66
7# Align and color7# Align and color
88
9wl_library(graphic_toolbar_imageset
10 SRCS
11 toolbar_imageset.cc
12 toolbar_imageset.h
13 DEPENDS
14 graphic
15 graphic_surface
16 scripting_lua_table
17)
18
9wl_library(graphic_align19wl_library(graphic_align
10 SRCS20 SRCS
11 align.h21 align.h
1222
=== added file 'src/graphic/toolbar_imageset.cc'
--- src/graphic/toolbar_imageset.cc 1970-01-01 00:00:00 +0000
+++ src/graphic/toolbar_imageset.cc 2019-08-10 10:01:32 +0000
@@ -0,0 +1,38 @@
1/*
2 * Copyright (C) 2019 by the Widelands Development Team
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 *
18 */
19
20#include "graphic/toolbar_imageset.h"
21
22#include "graphic/graphic.h"
23
24ToolbarImageset::ToolbarImageset() :
25 left_corner(g_gr->images().get("images/wui/toolbar/left_corner.png")),
26 left(g_gr->images().get("images/wui/toolbar/left.png")),
27 center(g_gr->images().get("images/wui/toolbar/center.png")),
28 right(g_gr->images().get("images/wui/toolbar/right.png")),
29 right_corner(g_gr->images().get("images/wui/toolbar/right_corner.png")) {
30}
31
32ToolbarImageset::ToolbarImageset(const LuaTable& table) :
33 left_corner(g_gr->images().get(table.get_string("left_corner"))),
34 left(g_gr->images().get(table.get_string("left"))),
35 center(g_gr->images().get(table.get_string("center"))),
36 right(g_gr->images().get(table.get_string("right"))),
37 right_corner(g_gr->images().get(table.get_string("right_corner"))) {
38}
039
=== added file 'src/graphic/toolbar_imageset.h'
--- src/graphic/toolbar_imageset.h 1970-01-01 00:00:00 +0000
+++ src/graphic/toolbar_imageset.h 2019-08-10 10:01:32 +0000
@@ -0,0 +1,43 @@
1/*
2 * Copyright (C) 2019 by the Widelands Development Team
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 *
18 */
19
20#ifndef WL_GRAPHIC_TOOLBAR_IMAGESET_H
21#define WL_GRAPHIC_TOOLBAR_IMAGESET_H
22
23#include "graphic/image.h"
24#include "scripting/lua_table.h"
25
26/// An imageset for a horizontal toolbar
27struct ToolbarImageset {
28 ToolbarImageset();
29 ToolbarImageset(const LuaTable& table);
30
31 /// Will be painted beyond the left corner of the toolbar
32 const Image* left_corner;
33 /// Will be repeated between the left corner and the center
34 const Image* left;
35 /// Will be painted at the center
36 const Image* center;
37 /// Will be repeated between the right corner and the center
38 const Image* right;
39 /// Will be painted beyond the right corner of the toolbar
40 const Image* right_corner;
41};
42
43#endif // end of include guard: WL_GRAPHIC_TOOLBAR_IMAGESET_H
044
=== modified file 'src/logic/CMakeLists.txt'
--- src/logic/CMakeLists.txt 2019-05-26 01:58:59 +0000
+++ src/logic/CMakeLists.txt 2019-08-10 10:01:32 +0000
@@ -124,6 +124,7 @@
124 maptriangleregion.cc124 maptriangleregion.cc
125 maptriangleregion.h125 maptriangleregion.h
126 nodecaps.h126 nodecaps.h
127 note_map_options.h
127 path.cc128 path.cc
128 path.h129 path.h
129 pathfield.cc130 pathfield.cc
130131
=== modified file 'src/logic/map.cc'
--- src/logic/map.cc 2019-06-22 11:22:14 +0000
+++ src/logic/map.cc 2019-08-10 10:01:32 +0000
@@ -46,6 +46,7 @@
46#include "logic/mapfringeregion.h"46#include "logic/mapfringeregion.h"
47#include "logic/maphollowregion.h"47#include "logic/maphollowregion.h"
48#include "logic/mapregion.h"48#include "logic/mapregion.h"
49#include "logic/note_map_options.h"
49#include "logic/objective.h"50#include "logic/objective.h"
50#include "logic/pathfield.h"51#include "logic/pathfield.h"
51#include "map_io/s2map.h"52#include "map_io/s2map.h"
@@ -2315,6 +2316,7 @@
2315 // There need to be at least 2 port spaces for seafaring to make sense2316 // There need to be at least 2 port spaces for seafaring to make sense
2316 if (get_port_spaces().size() < 2) {2317 if (get_port_spaces().size() < 2) {
2317 allows_seafaring_ = false;2318 allows_seafaring_ = false;
2319 Notifications::publish(NoteMapOptions());
2318 return;2320 return;
2319 }2321 }
23202322
@@ -2340,6 +2342,7 @@
2340 // Found one2342 // Found one
2341 if (reachable_from_previous_ports.count(current_position) > 0) {2343 if (reachable_from_previous_ports.count(current_position) > 0) {
2342 allows_seafaring_ = true;2344 allows_seafaring_ = true;
2345 Notifications::publish(NoteMapOptions());
2343 return;2346 return;
2344 }2347 }
23452348
@@ -2362,6 +2365,7 @@
2362 }2365 }
2363 }2366 }
2364 allows_seafaring_ = false;2367 allows_seafaring_ = false;
2368 Notifications::publish(NoteMapOptions());
2365}2369}
23662370
2367void Map::cleanup_port_spaces(const World& world) {2371void Map::cleanup_port_spaces(const World& world) {
23682372
=== modified file 'src/logic/map.h'
--- src/logic/map.h 2019-06-23 10:30:26 +0000
+++ src/logic/map.h 2019-08-10 10:01:32 +0000
@@ -131,7 +131,6 @@
131 */131 */
132class Map : public ITransportCostCalculator {132class Map : public ITransportCostCalculator {
133public:133public:
134 friend class Editor;
135 friend class EditorGameBase;134 friend class EditorGameBase;
136 friend class MapLoader;135 friend class MapLoader;
137 friend class MapVersionPacket;136 friend class MapVersionPacket;
138137
=== modified file 'src/logic/map_objects/CMakeLists.txt'
--- src/logic/map_objects/CMakeLists.txt 2019-05-28 11:45:38 +0000
+++ src/logic/map_objects/CMakeLists.txt 2019-08-10 10:01:32 +0000
@@ -128,6 +128,7 @@
128 graphic_image_io128 graphic_image_io
129 graphic_surface129 graphic_surface
130 graphic_text_layout130 graphic_text_layout
131 graphic_toolbar_imageset
131 helper132 helper
132 io_fileread133 io_fileread
133 io_filesystem134 io_filesystem
134135
=== modified file 'src/logic/map_objects/tribes/tribe_descr.cc'
--- src/logic/map_objects/tribes/tribe_descr.cc 2019-05-29 06:24:42 +0000
+++ src/logic/map_objects/tribes/tribe_descr.cc 2019-08-10 10:01:32 +0000
@@ -203,6 +203,9 @@
203 refinedlog_ = add_special_ware(table.get_string("refinedlog"));203 refinedlog_ = add_special_ware(table.get_string("refinedlog"));
204 granite_ = add_special_ware(table.get_string("granite"));204 granite_ = add_special_ware(table.get_string("granite"));
205205
206 if (table.has_key<std::string>("toolbar")) {
207 toolbar_image_set_.reset(new ToolbarImageset(*table.get_table("toolbar")));
208 }
206 } catch (const GameDataError& e) {209 } catch (const GameDataError& e) {
207 throw GameDataError("tribe %s: %s", name_.c_str(), e.what());210 throw GameDataError("tribe %s: %s", name_.c_str(), e.what());
208 }211 }
@@ -445,6 +448,10 @@
445 }448 }
446}449}
447450
451ToolbarImageset* TribeDescr::toolbar_image_set() const {
452 return toolbar_image_set_.get();
453}
454
448/**455/**
449 * Helper functions456 * Helper functions
450 */457 */
451458
=== modified file 'src/logic/map_objects/tribes/tribe_descr.h'
--- src/logic/map_objects/tribes/tribe_descr.h 2019-05-29 06:24:42 +0000
+++ src/logic/map_objects/tribes/tribe_descr.h 2019-08-10 10:01:32 +0000
@@ -26,6 +26,7 @@
2626
27#include "base/macros.h"27#include "base/macros.h"
28#include "graphic/animation.h"28#include "graphic/animation.h"
29#include "graphic/toolbar_imageset.h"
29#include "logic/map_objects/immovable.h"30#include "logic/map_objects/immovable.h"
30#include "logic/map_objects/tribes/building.h"31#include "logic/map_objects/tribes/building.h"
31#include "logic/map_objects/tribes/road_textures.h"32#include "logic/map_objects/tribes/road_textures.h"
@@ -162,6 +163,9 @@
162163
163 void add_building(const std::string& buildingname);164 void add_building(const std::string& buildingname);
164165
166 // The custom toolbar imageset if any. Can be nullptr.
167 ToolbarImageset* toolbar_image_set() const;
168
165private:169private:
166 // Helper function for adding a special worker type (carriers etc.)170 // Helper function for adding a special worker type (carriers etc.)
167 DescriptionIndex add_special_worker(const std::string& workername);171 DescriptionIndex add_special_worker(const std::string& workername);
@@ -206,6 +210,9 @@
206 WaresOrder wares_order_;210 WaresOrder wares_order_;
207 WaresOrder workers_order_;211 WaresOrder workers_order_;
208212
213 // An optional custom imageset for the in-game menu toolbar
214 std::unique_ptr<ToolbarImageset> toolbar_image_set_;
215
209 std::vector<Widelands::TribeBasicInfo::Initialization> initializations_;216 std::vector<Widelands::TribeBasicInfo::Initialization> initializations_;
210217
211 DISALLOW_COPY_AND_ASSIGN(TribeDescr);218 DISALLOW_COPY_AND_ASSIGN(TribeDescr);
212219
=== added file 'src/logic/note_map_options.h'
--- src/logic/note_map_options.h 1970-01-01 00:00:00 +0000
+++ src/logic/note_map_options.h 2019-08-10 10:01:32 +0000
@@ -0,0 +1,32 @@
1/*
2 * Copyright (C) 2019 by the Widelands Development Team
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 *
18 */
19
20#ifndef WL_LOGIC_NOTE_MAP_OPTIONS_H
21#define WL_LOGIC_NOTE_MAP_OPTIONS_H
22
23#include "notifications/note_ids.h"
24#include "notifications/notifications.h"
25
26struct NoteMapOptions {
27 CAN_BE_SENT_AS_NOTE(NoteId::MapOptions)
28
29 NoteMapOptions() = default;
30};
31
32#endif // end of include guard: WL_LOGIC_NOTE_MAP_OPTIONS_H
033
=== modified file 'src/notifications/note_ids.h'
--- src/notifications/note_ids.h 2019-06-19 07:34:19 +0000
+++ src/notifications/note_ids.h 2019-08-10 10:01:32 +0000
@@ -42,7 +42,8 @@
42 NoteExpeditionCanceled,42 NoteExpeditionCanceled,
43 Sound,43 Sound,
44 Dropdown,44 Dropdown,
45 GameSettings45 GameSettings,
46 MapOptions
46};47};
4748
48#endif // end of include guard: WL_NOTIFICATIONS_NOTE_IDS_H49#endif // end of include guard: WL_NOTIFICATIONS_NOTE_IDS_H
4950
=== modified file 'src/scripting/lua_game.cc'
--- src/scripting/lua_game.cc 2019-04-26 16:52:39 +0000
+++ src/scripting/lua_game.cc 2019-08-10 10:01:32 +0000
@@ -108,7 +108,7 @@
108 PROP_RO(LuaPlayer, name), PROP_RO(LuaPlayer, allowed_buildings),108 PROP_RO(LuaPlayer, name), PROP_RO(LuaPlayer, allowed_buildings),
109 PROP_RO(LuaPlayer, objectives), PROP_RO(LuaPlayer, defeated),109 PROP_RO(LuaPlayer, objectives), PROP_RO(LuaPlayer, defeated),
110 PROP_RO(LuaPlayer, messages), PROP_RO(LuaPlayer, inbox),110 PROP_RO(LuaPlayer, messages), PROP_RO(LuaPlayer, inbox),
111 PROP_RW(LuaPlayer, team), PROP_RO(LuaPlayer, tribe),111 PROP_RO(LuaPlayer, color), PROP_RW(LuaPlayer, team), PROP_RO(LuaPlayer, tribe),
112 PROP_RW(LuaPlayer, see_all), {nullptr, nullptr, nullptr},112 PROP_RW(LuaPlayer, see_all), {nullptr, nullptr, nullptr},
113};113};
114114
@@ -222,6 +222,17 @@
222}222}
223223
224/* RST224/* RST
225 .. attribute:: color
226
227 (RO) The playercolor assigned to this player, in hex notation.
228*/
229int LuaPlayer::get_color(lua_State* L) {
230 const PlayerNumber pnumber = get(L, get_egbase(L)).player_number();
231 lua_pushstring(L, kPlayerColors[pnumber - 1].hex_value());
232 return 1;
233}
234
235/* RST
225 .. attribute:: team236 .. attribute:: team
226237
227 (RW) The team number of this player (0 means player is not in a team)238 (RW) The team number of this player (0 means player is not in a team)
228239
=== modified file 'src/scripting/lua_game.h'
--- src/scripting/lua_game.h 2019-04-26 16:52:39 +0000
+++ src/scripting/lua_game.h 2019-08-10 10:01:32 +0000
@@ -71,6 +71,7 @@
71 int get_defeated(lua_State* L);71 int get_defeated(lua_State* L);
72 int get_messages(lua_State* L);72 int get_messages(lua_State* L);
73 int get_inbox(lua_State* L);73 int get_inbox(lua_State* L);
74 int get_color(lua_State* L);
74 int get_team(lua_State* L);75 int get_team(lua_State* L);
75 int get_tribe(lua_State* L);76 int get_tribe(lua_State* L);
76 int set_team(lua_State* L);77 int set_team(lua_State* L);
7778
=== modified file 'src/scripting/lua_ui.cc'
--- src/scripting/lua_ui.cc 2019-06-25 07:34:58 +0000
+++ src/scripting/lua_ui.cc 2019-08-10 10:01:32 +0000
@@ -365,6 +365,7 @@
365};365};
366const PropertyType<LuaDropdown> LuaDropdown::Properties[] = {366const PropertyType<LuaDropdown> LuaDropdown::Properties[] = {
367 PROP_RO(LuaDropdown, name),367 PROP_RO(LuaDropdown, name),
368 PROP_RO(LuaDropdown, no_of_items),
368 {nullptr, nullptr, nullptr},369 {nullptr, nullptr, nullptr},
369};370};
370371
@@ -378,6 +379,16 @@
378 return 1;379 return 1;
379}380}
380381
382/* RST
383 .. attribute:: no_of_items
384
385 (RO) The number of items his dropdown has.
386*/
387int LuaDropdown::get_no_of_items(lua_State* L) {
388 lua_pushinteger(L, get()->size());
389 return 1;
390}
391
381/*392/*
382 * Lua Functions393 * Lua Functions
383 */394 */
@@ -411,8 +422,14 @@
411 log("Highlighting item %d in dropdown '%s'\n", desired_item, get()->get_name().c_str());422 log("Highlighting item %d in dropdown '%s'\n", desired_item, get()->get_name().c_str());
412 // Open the dropdown423 // Open the dropdown
413 get()->set_list_visibility(true);424 get()->set_list_visibility(true);
425
426 SDL_Keysym code;
427 // Ensure that we're at the top
428 code.sym = SDLK_UP;
429 for (size_t i = 1; i < get()->size(); ++i) {
430 get()->handle_key(true, code);
431 }
414 // Press arrow down until the desired item is highlighted432 // Press arrow down until the desired item is highlighted
415 SDL_Keysym code;
416 code.sym = SDLK_DOWN;433 code.sym = SDLK_DOWN;
417 for (size_t i = 1; i < desired_item; ++i) {434 for (size_t i = 1; i < desired_item; ++i) {
418 get()->handle_key(true, code);435 get()->handle_key(true, code);
419436
=== modified file 'src/scripting/lua_ui.h'
--- src/scripting/lua_ui.h 2019-06-25 07:34:58 +0000
+++ src/scripting/lua_ui.h 2019-08-10 10:01:32 +0000
@@ -140,6 +140,7 @@
140 * Properties140 * Properties
141 */141 */
142 int get_name(lua_State* L);142 int get_name(lua_State* L);
143 int get_no_of_items(lua_State* L);
143144
144 /*145 /*
145 * Lua Methods146 * Lua Methods
146147
=== modified file 'src/ui_basic/dropdown.cc'
--- src/ui_basic/dropdown.cc 2019-06-25 07:34:58 +0000
+++ src/ui_basic/dropdown.cc 2019-08-10 10:01:32 +0000
@@ -39,13 +39,6 @@
39 std::max(button_dimension, text_height(g_gr->styles().table_style(style).enabled()) + 2);39 std::max(button_dimension, text_height(g_gr->styles().table_style(style).enabled()) + 2);
40 return result;40 return result;
41}41}
42
43/*
44int BaseDropdown::base_height(int button_dimension) const {
45 return std::max(button_dimension,
46text_height(g_gr->styles().table_style(UI::PanelStyle::kWui).enabled()) + 2);
47}
48*/
49} // namespace42} // namespace
5043
51namespace UI {44namespace UI {
@@ -432,13 +425,6 @@
432 return true;425 return true;
433 }426 }
434 break;427 break;
435 case SDLK_DOWN:
436 case SDLK_UP:
437 if (!list_->is_visible() && !is_mouse_away()) {
438 toggle_list();
439 return true;
440 }
441 break;
442 default:428 default:
443 break; // not handled429 break; // not handled
444 }430 }
445431
=== modified file 'src/ui_fsmenu/internet_lobby.cc'
--- src/ui_fsmenu/internet_lobby.cc 2019-06-20 13:09:18 +0000
+++ src/ui_fsmenu/internet_lobby.cc 2019-08-10 10:01:32 +0000
@@ -241,17 +241,14 @@
241241
242 if (games != nullptr) { // If no communication error occurred, fill the list.242 if (games != nullptr) { // If no communication error occurred, fill the list.
243 for (const InternetGame& game : *games) {243 for (const InternetGame& game : *games) {
244 const Image* pic;
245 if (game.connectable == INTERNET_GAME_SETUP && game.build_id == localbuildid) {244 if (game.connectable == INTERNET_GAME_SETUP && game.build_id == localbuildid) {
246 // only clients with the same build number are displayed245 // only clients with the same build number are displayed
247 pic = g_gr->images().get("images/ui_basic/continue.png");246 opengames_list_.add(richtext_escape(game.name), game, g_gr->images().get("images/ui_basic/continue.png"), false, game.build_id);
248 opengames_list_.add(game.name, game, pic, false, game.build_id);
249 } else if (game.connectable == INTERNET_GAME_SETUP &&247 } else if (game.connectable == INTERNET_GAME_SETUP &&
250 game.build_id.compare(0, 6, "build-") != 0 &&248 game.build_id.compare(0, 6, "build-") != 0 &&
251 localbuildid.compare(0, 6, "build-") != 0) {249 localbuildid.compare(0, 6, "build-") != 0) {
252 // only development clients are allowed to see games openend by such250 // only development clients are allowed to see games openend by such
253 pic = g_gr->images().get("images/ui_basic/different.png");251 opengames_list_.add(richtext_escape(game.name), game, g_gr->images().get("images/ui_basic/different.png"), false, game.build_id);
254 opengames_list_.add(game.name, game, pic, false, game.build_id);
255 }252 }
256 }253 }
257 }254 }
258255
=== modified file 'src/ui_fsmenu/launch_mpg.cc'
--- src/ui_fsmenu/launch_mpg.cc 2019-05-26 17:21:15 +0000
+++ src/ui_fsmenu/launch_mpg.cc 2019-08-10 10:01:32 +0000
@@ -113,7 +113,7 @@
113 buth_,113 buth_,
114 buth_,114 buth_,
115 UI::ButtonStyle::kFsMenuSecondary,115 UI::ButtonStyle::kFsMenuSecondary,
116 g_gr->images().get("images/wui/menus/menu_toggle_minimap.png"),116 g_gr->images().get("images/wui/menus/toggle_minimap.png"),
117 _("Change map or saved game")),117 _("Change map or saved game")),
118 help_button_(this,118 help_button_(this,
119 "help",119 "help",
120120
=== modified file 'src/wui/CMakeLists.txt'
--- src/wui/CMakeLists.txt 2019-06-24 18:57:51 +0000
+++ src/wui/CMakeLists.txt 2019-08-10 10:01:32 +0000
@@ -200,16 +200,12 @@
200 game_debug_ui.h200 game_debug_ui.h
201 game_exit_confirm_box.cc201 game_exit_confirm_box.cc
202 game_exit_confirm_box.h202 game_exit_confirm_box.h
203 game_statistics_menu.cc
204 game_statistics_menu.h
205 game_main_menu_save_game.cc203 game_main_menu_save_game.cc
206 game_main_menu_save_game.h204 game_main_menu_save_game.h
207 game_message_menu.cc205 game_message_menu.cc
208 game_message_menu.h206 game_message_menu.h
209 game_objectives_menu.cc207 game_objectives_menu.cc
210 game_objectives_menu.h208 game_objectives_menu.h
211 game_options_menu.cc
212 game_options_menu.h
213 game_options_sound_menu.cc209 game_options_sound_menu.cc
214 game_options_sound_menu.h210 game_options_sound_menu.h
215 game_summary.cc211 game_summary.cc
@@ -295,6 +291,7 @@
295 graphic_surface291 graphic_surface
296 graphic_text292 graphic_text
297 graphic_text_layout293 graphic_text_layout
294 graphic_toolbar_imageset
298 io_fileread295 io_fileread
299 io_filesystem296 io_filesystem
300 logic297 logic
301298
=== modified file 'src/wui/buildingwindow.cc'
--- src/wui/buildingwindow.cc 2019-05-28 11:45:38 +0000
+++ src/wui/buildingwindow.cc 2019-08-10 10:01:32 +0000
@@ -348,7 +348,7 @@
348348
349 UI::Button* gotobtn = new UI::Button(349 UI::Button* gotobtn = new UI::Button(
350 capsbuttons, "goto", 0, 0, 34, 34, UI::ButtonStyle::kWuiMenu,350 capsbuttons, "goto", 0, 0, 34, 34, UI::ButtonStyle::kWuiMenu,
351 g_gr->images().get("images/wui/menus/menu_goto.png"), _("Center view on this"));351 g_gr->images().get("images/wui/menus/goto.png"), _("Center view on this"));
352 gotobtn->sigclicked.connect(boost::bind(&BuildingWindow::clicked_goto, boost::ref(*this)));352 gotobtn->sigclicked.connect(boost::bind(&BuildingWindow::clicked_goto, boost::ref(*this)));
353 capsbuttons->add(gotobtn);353 capsbuttons->add(gotobtn);
354354
355355
=== modified file 'src/wui/constructionsitewindow.cc'
--- src/wui/constructionsitewindow.cc 2019-06-25 08:13:54 +0000
+++ src/wui/constructionsitewindow.cc 2019-08-10 10:01:32 +0000
@@ -27,7 +27,7 @@
27#include "wui/interactive_player.h"27#include "wui/interactive_player.h"
2828
29static const char pic_tab_wares[] = "images/wui/buildings/menu_tab_wares.png";29static const char pic_tab_wares[] = "images/wui/buildings/menu_tab_wares.png";
30static const char pic_tab_settings[] = "images/wui/menus/menu_stock.png";30static const char pic_tab_settings[] = "images/wui/menus/statistics_stock.png";
31static const char pic_tab_settings_wares[] = "images/wui/stats/menu_tab_wares_warehouse.png";31static const char pic_tab_settings_wares[] = "images/wui/stats/menu_tab_wares_warehouse.png";
32static const char pic_tab_settings_workers[] = "images/wui/stats/menu_tab_workers_warehouse.png";32static const char pic_tab_settings_workers[] = "images/wui/stats/menu_tab_workers_warehouse.png";
33static const char pic_max_fill_indicator[] = "images/wui/buildings/max_fill_indicator.png";33static const char pic_max_fill_indicator[] = "images/wui/buildings/max_fill_indicator.png";
3434
=== modified file 'src/wui/economy_options_window.cc'
--- src/wui/economy_options_window.cc 2019-06-25 07:34:58 +0000
+++ src/wui/economy_options_window.cc 2019-08-10 10:01:32 +0000
@@ -51,18 +51,8 @@
51 worker_panel_(new EconomyOptionsPanel(51 worker_panel_(new EconomyOptionsPanel(
52 &tabpanel_, this, serial_, player_, can_act, Widelands::wwWORKER, kDesiredWidth)),52 &tabpanel_, this, serial_, player_, can_act, Widelands::wwWORKER, kDesiredWidth)),
53 dropdown_box_(this, 0, 0, UI::Box::Horizontal),53 dropdown_box_(this, 0, 0, UI::Box::Horizontal),
54 dropdown_(&dropdown_box_,54 dropdown_(
55 "economy_profiles",55 &dropdown_box_, "economy_profiles", 0, 0, 174, 10, 34, "", UI::DropdownType::kTextual, UI::PanelStyle::kWui, UI::ButtonStyle::kWuiSecondary),
56 0,
57 0,
58 174,
59 10,
60 34,
61 "",
62 UI::DropdownType::kTextual,
63 UI::PanelStyle::kWui,
64 UI::ButtonStyle::kWuiSecondary), // NOCOM test if this is the correct button style.
65 // heap-use-after-free somewhere too.
66 time_last_thought_(0),56 time_last_thought_(0),
67 save_profile_dialog_(nullptr) {57 save_profile_dialog_(nullptr) {
68 set_center_panel(&main_box_);58 set_center_panel(&main_box_);
@@ -105,7 +95,7 @@
105 dropdown_.selected.connect([this] { reset_target(); });95 dropdown_.selected.connect([this] { reset_target(); });
10696
107 b = new UI::Button(&dropdown_box_, "save_targets", 0, 0, 34, 34, UI::ButtonStyle::kWuiMenu,97 b = new UI::Button(&dropdown_box_, "save_targets", 0, 0, 34, 34, UI::ButtonStyle::kWuiMenu,
108 g_gr->images().get("images/wui/menus/menu_save_game.png"),98 g_gr->images().get("images/wui/menus/save_game.png"),
109 _("Save target settings"));99 _("Save target settings"));
110 b->sigclicked.connect([this] { create_target(); });100 b->sigclicked.connect([this] { create_target(); });
111 dropdown_box_.add_space(8);101 dropdown_box_.add_space(8);
112102
=== modified file 'src/wui/fieldaction.cc'
--- src/wui/fieldaction.cc 2019-06-24 10:03:47 +0000
+++ src/wui/fieldaction.cc 2019-08-10 10:01:32 +0000
@@ -163,9 +163,6 @@
163 void add_buttons_attack();163 void add_buttons_attack();
164164
165 void act_watch();165 void act_watch();
166 void act_show_census();
167 void act_show_statistics();
168 void act_show_workarea_overlap();
169 void act_debug();166 void act_debug();
170 void act_buildflag();167 void act_buildflag();
171 void act_configure_economy();168 void act_configure_economy();
@@ -232,10 +229,6 @@
232static const char* const pic_buildflag = "images/wui/fieldaction/menu_build_flag.png";229static const char* const pic_buildflag = "images/wui/fieldaction/menu_build_flag.png";
233static const char* const pic_ripflag = "images/wui/fieldaction/menu_rip_flag.png";230static const char* const pic_ripflag = "images/wui/fieldaction/menu_rip_flag.png";
234static const char* const pic_watchfield = "images/wui/fieldaction/menu_watch_field.png";231static const char* const pic_watchfield = "images/wui/fieldaction/menu_watch_field.png";
235static const char* const pic_showcensus = "images/wui/fieldaction/menu_show_census.png";
236static const char* const pic_showstatistics = "images/wui/fieldaction/menu_show_statistics.png";
237static const char* const pic_showworkareaoverlap =
238 "images/wui/fieldaction/menu_show_workarea_overlap.png";
239static const char* const pic_debug = "images/wui/fieldaction/menu_debug.png";232static const char* const pic_debug = "images/wui/fieldaction/menu_debug.png";
240static const char* const pic_abort = "images/wui/menu_abort.png";233static const char* const pic_abort = "images/wui/menu_abort.png";
241static const char* const pic_geologist = "images/wui/fieldaction/menu_geologist.png";234static const char* const pic_geologist = "images/wui/fieldaction/menu_geologist.png";
@@ -385,21 +378,10 @@
385 node_, ibase().egbase().map().get_width())))378 node_, ibase().egbase().map().get_width())))
386 add_buttons_attack();379 add_buttons_attack();
387380
388 // Watch actions, only when game (no use in editor) same for statistics.381 // Watch actions, only when in game (no use in editor).
389 // census is ok
390 if (dynamic_cast<const Game*>(&ibase().egbase())) {382 if (dynamic_cast<const Game*>(&ibase().egbase())) {
391 add_button(&watchbox, "watch", pic_watchfield, &FieldActionWindow::act_watch,383 add_button(&watchbox, "watch", pic_watchfield, &FieldActionWindow::act_watch,
392 _("Watch field in a separate window"));384 _("Watch field in a separate window"));
393 add_button(&watchbox, "statistics", pic_showstatistics,
394 &FieldActionWindow::act_show_statistics, _("Toggle building statistics display"));
395 }
396 add_button(&watchbox, "census", pic_showcensus, &FieldActionWindow::act_show_census,
397 _("Toggle building label display"));
398 if (is_a(InteractivePlayer, &ibase())) {
399 add_button(
400 &watchbox, "workarea_overlap", pic_showworkareaoverlap,
401 &FieldActionWindow::act_show_workarea_overlap,
402 _("Toggle whether overlapping workareas are indicated when placing a constructionsite"));
403 }385 }
404386
405 if (ibase().get_display_flag(InteractiveBase::dfDebug))387 if (ibase().get_display_flag(InteractiveBase::dfDebug))
@@ -584,29 +566,6 @@
584566
585/*567/*
586===============568===============
587Toggle display of census and statistics for buildings, respectively.
588===============
589*/
590void FieldActionWindow::act_show_census() {
591 ibase().set_display_flag(
592 InteractiveBase::dfShowCensus, !ibase().get_display_flag(InteractiveBase::dfShowCensus));
593 reset_mouse_and_die();
594}
595
596void FieldActionWindow::act_show_statistics() {
597 ibase().set_display_flag(InteractiveBase::dfShowStatistics,
598 !ibase().get_display_flag(InteractiveBase::dfShowStatistics));
599 reset_mouse_and_die();
600}
601
602void FieldActionWindow::act_show_workarea_overlap() {
603 ibase().set_display_flag(InteractiveBase::dfShowWorkareaOverlap,
604 !ibase().get_display_flag(InteractiveBase::dfShowWorkareaOverlap));
605 reset_mouse_and_die();
606}
607
608/*
609===============
610Show a debug widow for this field.569Show a debug widow for this field.
611===============570===============
612*/571*/
613572
=== modified file 'src/wui/game_chat_menu.cc'
--- src/wui/game_chat_menu.cc 2019-02-23 11:00:49 +0000
+++ src/wui/game_chat_menu.cc 2019-08-10 10:01:32 +0000
@@ -53,11 +53,13 @@
53 return new GameChatMenu(parent, registry, chat, _("Chat"));53 return new GameChatMenu(parent, registry, chat, _("Chat"));
54}54}
5555
56#ifndef NDEBUG // only in debug builds
56GameChatMenu* GameChatMenu::create_script_console(UI::Panel* parent,57GameChatMenu* GameChatMenu::create_script_console(UI::Panel* parent,
57 UI::UniqueWindow::Registry& registry,58 UI::UniqueWindow::Registry& registry,
58 ChatProvider& chat) {59 ChatProvider& chat) {
59 return new GameChatMenu(parent, registry, chat, _("Script console"));60 return new GameChatMenu(parent, registry, chat, _("Script Console"));
60}61}
62#endif
6163
62bool GameChatMenu::enter_chat_message(bool close_on_send) {64bool GameChatMenu::enter_chat_message(bool close_on_send) {
63 if (is_minimal()) {65 if (is_minimal()) {
6466
=== modified file 'src/wui/game_chat_menu.h'
--- src/wui/game_chat_menu.h 2019-02-23 11:00:49 +0000
+++ src/wui/game_chat_menu.h 2019-08-10 10:01:32 +0000
@@ -34,11 +34,13 @@
34 */34 */
35 static GameChatMenu* create_chat_console(UI::Panel*, UI::UniqueWindow::Registry&, ChatProvider&);35 static GameChatMenu* create_chat_console(UI::Panel*, UI::UniqueWindow::Registry&, ChatProvider&);
3636
37#ifndef NDEBUG // only in debug builds
37 /**38 /**
38 * Creates a chat window only for scripting in debug mode39 * Creates a chat window only for scripting in debug mode
39 */40 */
40 static GameChatMenu*41 static GameChatMenu*
41 create_script_console(UI::Panel*, UI::UniqueWindow::Registry&, ChatProvider&);42 create_script_console(UI::Panel*, UI::UniqueWindow::Registry&, ChatProvider&);
43#endif
4244
43 /**45 /**
44 * Configure the menu so that it is useful for writing chat messages.46 * Configure the menu so that it is useful for writing chat messages.
4547
=== modified file 'src/wui/game_client_disconnected.cc'
--- src/wui/game_client_disconnected.cc 2019-06-25 07:34:58 +0000
+++ src/wui/game_client_disconnected.cc 2019-08-10 10:01:32 +0000
@@ -93,7 +93,7 @@
93 width,93 width,
94 35,94 35,
95 UI::ButtonStyle::kWuiMenu,95 UI::ButtonStyle::kWuiMenu,
96 g_gr->images().get("images/wui/menus/menu_exit_game.png"),96 g_gr->images().get("images/wui/menus/exit.png"),
97 /** TRANSLATORS: Button tooltip */97 /** TRANSLATORS: Button tooltip */
98 _("Exit Game")) {98 _("Exit Game")) {
9999
100100
=== modified file 'src/wui/game_message_menu.cc'
--- src/wui/game_message_menu.cc 2019-06-25 07:34:58 +0000
+++ src/wui/game_message_menu.cc 2019-08-10 10:01:32 +0000
@@ -104,7 +104,7 @@
104104
105 scenariobtn_ = new UI::Button(this, "filter_scenario_messages", 5 * kPadding + 4 * kButtonSize,105 scenariobtn_ = new UI::Button(this, "filter_scenario_messages", 5 * kPadding + 4 * kButtonSize,
106 kPadding, kButtonSize, kButtonSize, UI::ButtonStyle::kWuiSecondary,106 kPadding, kButtonSize, kButtonSize, UI::ButtonStyle::kWuiSecondary,
107 g_gr->images().get("images/wui/menus/menu_objectives.png"));107 g_gr->images().get("images/wui/menus/objectives.png"));
108 scenariobtn_->sigclicked.connect(108 scenariobtn_->sigclicked.connect(
109 boost::bind(&GameMessageMenu::filter_messages, this, Widelands::Message::Type::kScenario));109 boost::bind(&GameMessageMenu::filter_messages, this, Widelands::Message::Type::kScenario));
110110
@@ -129,7 +129,7 @@
129 centerviewbtn_ =129 centerviewbtn_ =
130 new UI::Button(this, "center_main_mapview_on_location", kWindowWidth - kPadding - kButtonSize,130 new UI::Button(this, "center_main_mapview_on_location", kWindowWidth - kPadding - kButtonSize,
131 archivebtn_->get_y(), kButtonSize, kButtonSize, UI::ButtonStyle::kWuiPrimary,131 archivebtn_->get_y(), kButtonSize, kButtonSize, UI::ButtonStyle::kWuiPrimary,
132 g_gr->images().get("images/wui/menus/menu_goto.png"),132 g_gr->images().get("images/wui/menus/goto.png"),
133 as_tooltip_text_with_hotkey(133 as_tooltip_text_with_hotkey(
134 /** TRANSLATORS: Tooltip in the messages window */134 /** TRANSLATORS: Tooltip in the messages window */
135 _("Center main mapview on location"), "g"));135 _("Center main mapview on location"), "g"));
@@ -563,7 +563,7 @@
563 case Widelands::Message::Type::kWarfare:563 case Widelands::Message::Type::kWarfare:
564 return "images/wui/messages/messages_warfare.png";564 return "images/wui/messages/messages_warfare.png";
565 case Widelands::Message::Type::kScenario:565 case Widelands::Message::Type::kScenario:
566 return "images/wui/menus/menu_objectives.png";566 return "images/wui/menus/objectives.png";
567 case Widelands::Message::Type::kGameLogic:567 case Widelands::Message::Type::kGameLogic:
568 return "images/ui_basic/menu_help.png";568 return "images/ui_basic/menu_help.png";
569 case Widelands::Message::Type::kNoMessages:569 case Widelands::Message::Type::kNoMessages:
570570
=== removed file 'src/wui/game_options_menu.cc'
--- src/wui/game_options_menu.cc 2019-03-18 07:11:02 +0000
+++ src/wui/game_options_menu.cc 1970-01-01 00:00:00 +0000
@@ -1,119 +0,0 @@
1/*
2 * Copyright (C) 2002-2019 by the Widelands Development Team
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 *
18 */
19
20#include "wui/game_options_menu.h"
21
22#include <boost/bind.hpp>
23#include <boost/lambda/bind.hpp>
24#include <boost/lambda/construct.hpp>
25#include <boost/type_traits.hpp>
26
27#include "base/i18n.h"
28#include "graphic/graphic.h"
29#include "wui/game_exit_confirm_box.h"
30#include "wui/game_main_menu_save_game.h"
31#include "wui/game_options_sound_menu.h"
32#include "wui/unique_window_handler.h"
33
34#define width 200
35#define margin 10
36#define vspacing 5
37#define vgap 3
38
39GameOptionsMenu::GameOptionsMenu(InteractiveGameBase& gb,
40 UI::UniqueWindow::Registry& registry,
41 InteractiveGameBase::GameMainMenuWindows& windows)
42 : UI::UniqueWindow(&gb, "options", &registry, 2 * margin + width, 0, _("Main Menu")),
43 igb_(gb),
44 windows_(windows),
45 box_(this, margin, margin, UI::Box::Vertical, width, get_h() - 2 * margin, vspacing),
46 sound_(&box_,
47 "sound_options",
48 0,
49 0,
50 width,
51 0,
52 UI::ButtonStyle::kWuiMenu,
53 _("Sound Options"),
54 /** TRANSLATORS: Button tooltip */
55 _("Set sound effect and music options")),
56 save_game_(&box_,
57 "save_game",
58 0,
59 0,
60 width,
61 35,
62 UI::ButtonStyle::kWuiMenu,
63 g_gr->images().get("images/wui/menus/menu_save_game.png"),
64 /** TRANSLATORS: Button tooltip */
65 _("Save Game")),
66 exit_game_(&box_,
67 "exit_game",
68 0,
69 0,
70 width,
71 35,
72 UI::ButtonStyle::kWuiMenu,
73 g_gr->images().get("images/wui/menus/menu_exit_game.png"),
74 /** TRANSLATORS: Button tooltip */
75 _("Exit Game")) {
76 box_.add(&sound_);
77 box_.add_space(vgap);
78 box_.add(&save_game_);
79 box_.add(&exit_game_);
80 box_.set_size(width, sound_.get_h() + 2 * save_game_.get_h() + vgap + 3 * vspacing);
81 set_inner_size(get_inner_w(), box_.get_h() + 2 * margin);
82
83 windows_.sound_options.open_window = [this] {
84 new GameOptionsSoundMenu(igb_, windows_.sound_options);
85 };
86 sound_.sigclicked.connect(
87 boost::bind(&UI::UniqueWindow::Registry::toggle, boost::ref(windows_.sound_options)));
88 save_game_.sigclicked.connect(
89 boost::bind(&GameOptionsMenu::clicked_save_game, boost::ref(*this)));
90 exit_game_.sigclicked.connect(
91 boost::bind(&GameOptionsMenu::clicked_exit_game, boost::ref(*this)));
92
93 if (windows_.sound_options.window) {
94 sound_.set_perm_pressed(true);
95 }
96 windows_.sound_options.opened.connect(boost::bind(&UI::Button::set_perm_pressed, &sound_, true));
97 windows_.sound_options.closed.connect(
98 boost::bind(&UI::Button::set_perm_pressed, &sound_, false));
99
100 if (get_usedefaultpos())
101 center_to_parent();
102}
103
104GameOptionsMenu::~GameOptionsMenu() {
105}
106
107void GameOptionsMenu::clicked_save_game() {
108 new GameMainMenuSaveGame(igb_, windows_.savegame);
109 die();
110}
111
112void GameOptionsMenu::clicked_exit_game() {
113 if (SDL_GetModState() & KMOD_CTRL) {
114 igb_.end_modal<UI::Panel::Returncodes>(UI::Panel::Returncodes::kBack);
115 } else {
116 new GameExitConfirmBox(*get_parent(), igb_);
117 die();
118 }
119}
1200
=== removed file 'src/wui/game_options_menu.h'
--- src/wui/game_options_menu.h 2019-02-23 11:00:49 +0000
+++ src/wui/game_options_menu.h 1970-01-01 00:00:00 +0000
@@ -1,49 +0,0 @@
1/*
2 * Copyright (C) 2002-2019 by the Widelands Development Team
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 *
18 */
19
20#ifndef WL_WUI_GAME_OPTIONS_MENU_H
21#define WL_WUI_GAME_OPTIONS_MENU_H
22
23#include "ui_basic/box.h"
24#include "ui_basic/button.h"
25#include "ui_basic/messagebox.h"
26#include "ui_basic/textarea.h"
27#include "ui_basic/unique_window.h"
28#include "wui/interactive_gamebase.h"
29
30// The GameOptionsMenu is a rather dumb window with lots of buttons
31struct GameOptionsMenu : public UI::UniqueWindow {
32 GameOptionsMenu(InteractiveGameBase&,
33 UI::UniqueWindow::Registry&,
34 InteractiveGameBase::GameMainMenuWindows&);
35 ~GameOptionsMenu();
36
37private:
38 InteractiveGameBase& igb_;
39 InteractiveGameBase::GameMainMenuWindows& windows_;
40 UI::Box box_;
41 UI::Button sound_;
42 UI::Button save_game_;
43 UI::Button exit_game_;
44
45 void clicked_save_game();
46 void clicked_exit_game();
47};
48
49#endif // end of include guard: WL_WUI_GAME_OPTIONS_MENU_H
500
=== removed file 'src/wui/game_statistics_menu.cc'
--- src/wui/game_statistics_menu.cc 2019-02-23 11:00:49 +0000
+++ src/wui/game_statistics_menu.cc 1970-01-01 00:00:00 +0000
@@ -1,98 +0,0 @@
1/*
2 * Copyright (C) 2002-2019 by the Widelands Development Team
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 *
18 */
19
20#include "wui/game_statistics_menu.h"
21
22#include <boost/bind.hpp>
23
24#include "base/i18n.h"
25#include "graphic/graphic.h"
26#include "ui_basic/unique_window.h"
27#include "wui/building_statistics_menu.h"
28#include "wui/general_statistics_menu.h"
29#include "wui/interactive_player.h"
30#include "wui/seafaring_statistics_menu.h"
31#include "wui/stock_menu.h"
32#include "wui/ware_statistics_menu.h"
33
34GameStatisticsMenu::GameStatisticsMenu(InteractivePlayer& plr,
35 UI::UniqueWindow::Registry& registry,
36 InteractivePlayer::GameMainMenuWindows& windows)
37 : UI::UniqueWindow(&plr, "main_menu", &registry, 0, 0, _("Statistics Menu")),
38 player_(plr),
39 windows_(windows),
40 box_(this, 0, 0, UI::Box::Horizontal, 0, 0, 5) {
41 const bool is_seafaring = plr.egbase().mutable_map()->allows_seafaring();
42 add_button("wui/menus/menu_general_stats", "general_stats", _("General statistics"),
43 &windows_.general_stats);
44 add_button(
45 "wui/menus/menu_ware_stats", "ware_stats", _("Ware statistics"), &windows_.ware_stats);
46 add_button("wui/menus/menu_building_stats", "building_stats", _("Building statistics"),
47 &windows_.building_stats);
48 add_button("wui/menus/menu_stock", "stock", _("Stock"), &windows_.stock);
49 if (is_seafaring) {
50 add_button("wui/buildings/start_expedition", "seafaring_stats", _("Seafaring Statistics"),
51 &windows_.seafaring_stats);
52 }
53 box_.set_pos(Vector2i(10, 10));
54 box_.set_size((34 + 5) * (is_seafaring ? 5 : 4), 34);
55 set_inner_size(box_.get_w() + 20, box_.get_h() + 20);
56
57 windows_.general_stats.open_window = [this] {
58 new GeneralStatisticsMenu(player_, windows_.general_stats);
59 };
60 windows_.ware_stats.open_window = [this] {
61 new WareStatisticsMenu(player_, windows_.ware_stats);
62 };
63 windows_.building_stats.open_window = [this] {
64 new BuildingStatisticsMenu(player_, windows_.building_stats);
65 };
66 // The stock window is defined in InteractivePlayer because of the keyboard shortcut.
67 if (is_seafaring) {
68 windows_.seafaring_stats.open_window = [this] {
69 new SeafaringStatisticsMenu(player_, windows_.seafaring_stats);
70 };
71 }
72
73 if (get_usedefaultpos())
74 center_to_parent();
75}
76
77UI::Button* GameStatisticsMenu::add_button(const std::string& image_basename,
78 const std::string& name,
79 const std::string& tooltip_text,
80 UI::UniqueWindow::Registry* window) {
81 UI::Button* button =
82 new UI::Button(&box_, name, 0, 0, 34U, 34U, UI::ButtonStyle::kWuiMenu,
83 g_gr->images().get("images/" + image_basename + ".png"), tooltip_text);
84 box_.add(button);
85 if (window) {
86 if (window->window) {
87 button->set_perm_pressed(true);
88 }
89 window->opened.connect(boost::bind(&UI::Button::set_perm_pressed, button, true));
90 window->closed.connect(boost::bind(&UI::Button::set_perm_pressed, button, false));
91 button->sigclicked.connect(
92 boost::bind(&UI::UniqueWindow::Registry::toggle, boost::ref(*window)));
93 }
94 return button;
95}
96
97GameStatisticsMenu::~GameStatisticsMenu() {
98}
990
=== removed file 'src/wui/game_statistics_menu.h'
--- src/wui/game_statistics_menu.h 2019-02-23 11:00:49 +0000
+++ src/wui/game_statistics_menu.h 1970-01-01 00:00:00 +0000
@@ -1,52 +0,0 @@
1/*
2 * Copyright (C) 2002-2019 by the Widelands Development Team
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 *
18 */
19
20#ifndef WL_WUI_GAME_STATISTICS_MENU_H
21#define WL_WUI_GAME_STATISTICS_MENU_H
22
23#include "ui_basic/box.h"
24#include "ui_basic/button.h"
25#include "wui/interactive_player.h"
26
27// The GameStatisticsMenu is a row of buttons that will toggle unique windows
28struct GameStatisticsMenu : public UI::UniqueWindow {
29 GameStatisticsMenu(InteractivePlayer&,
30 UI::UniqueWindow::Registry&,
31 InteractivePlayer::GameMainMenuWindows&);
32
33 ~GameStatisticsMenu();
34
35private:
36 /// Adds a button to the menu that will toggle its window
37 /// \param image_basename: File path for button image starting from 'images' and without
38 /// file extension
39 /// \param name: Internal name of the button
40 /// \param tooltip_text: The button tooltip
41 /// \param window: The window that's associated with this button.
42 UI::Button* add_button(const std::string& image_basename,
43 const std::string& name,
44 const std::string& tooltip_text,
45 UI::UniqueWindow::Registry* window);
46
47 InteractivePlayer& player_;
48 InteractivePlayer::GameMainMenuWindows& windows_;
49 UI::Box box_;
50};
51
52#endif // end of include guard: WL_WUI_GAME_STATISTICS_MENU_H
530
=== modified file 'src/wui/game_summary.cc'
--- src/wui/game_summary.cc 2019-05-26 17:21:15 +0000
+++ src/wui/game_summary.cc 2019-08-10 10:01:32 +0000
@@ -91,7 +91,7 @@
91 bottom_box->add_space(PADDING);91 bottom_box->add_space(PADDING);
92 stop_button_ =92 stop_button_ =
93 new UI::Button(bottom_box, "stop_button", 0, 0, 35, 35, UI::ButtonStyle::kWuiMenu,93 new UI::Button(bottom_box, "stop_button", 0, 0, 35, 35, UI::ButtonStyle::kWuiMenu,
94 g_gr->images().get("images/wui/menus/menu_exit_game.png"), _("Exit Game"));94 g_gr->images().get("images/wui/menus/exit.png"), _("Exit Game"));
95 bottom_box->add(stop_button_);95 bottom_box->add(stop_button_);
96 bottom_box->add_space(PADDING);96 bottom_box->add_space(PADDING);
9797
9898
=== modified file 'src/wui/interactive_base.cc'
--- src/wui/interactive_base.cc 2019-07-27 11:32:11 +0000
+++ src/wui/interactive_base.cc 2019-08-10 10:01:32 +0000
@@ -91,13 +91,82 @@
9191
92} // namespace92} // namespace
9393
94InteractiveBase::Toolbar::Toolbar(Panel* parent) : UI::Panel(parent, 0, 0, parent->get_inner_w(), parent->get_inner_h()), box(this, 0, 0, UI::Box::Horizontal),
95 repeat(0)
96{
97}
98
99void InteractiveBase::Toolbar::change_imageset(const ToolbarImageset& images) {
100 imageset = images;
101 finalize();
102}
103
104void InteractiveBase::Toolbar::finalize() {
105 // Set box size and get minimum height
106 int box_width, height;
107 box.get_desired_size(&box_width, &height);
108 box.set_size(box_width, height);
109
110 // Calculate repetition and width
111 repeat = 1;
112 int width = imageset.left->width() + imageset.center->width() + imageset.right->width();
113 while (width < box.get_w()) {
114 ++repeat;
115 width += imageset.left->width() + imageset.right->width();
116 }
117 width += imageset.left_corner->width() + imageset.right_corner->width();
118
119 // Find the highest image
120 height = std::max(height, imageset.left_corner->height());
121 height = std::max(height, imageset.left->height());
122 height = std::max(height, imageset.center->height());
123 height = std::max(height, imageset.right->height());
124 height = std::max(height, imageset.right_corner->height());
125
126 // Set size and position
127 set_size(width, height);
128 set_pos(Vector2i((get_parent()->get_inner_w() - width) >> 1, get_parent()->get_inner_h() - height));
129 box.set_pos(Vector2i((get_w() - box.get_w()) / 2, get_h() - box.get_h()));
130
131 // Notify dropdowns
132 box.position_changed();
133}
134
135void InteractiveBase::Toolbar::draw(RenderTarget& dst) {
136 int x = 0;
137 // Left corner
138 dst.blit(Vector2i(x, get_h() - imageset.left_corner->height()), imageset.left_corner);
139 x += imageset.left_corner->width();
140 // Repeat left
141 for (int i = 0; i < repeat; ++i) {
142 dst.blit(Vector2i(x, get_h() - imageset.left->height()), imageset.left);
143 x += imageset.left->width();
144 }
145 // Center
146 dst.blit(Vector2i(x, get_h() - imageset.center->height()), imageset.center);
147 x += imageset.center->width();
148 // Repeat right
149 for (int i = 0; i < repeat; ++i) {
150 dst.blit(Vector2i(x, get_h() - imageset.right->height()), imageset.right);
151 x += imageset.right->width();
152 }
153 // Right corner
154 dst.blit(Vector2i(x, get_h() - imageset.right_corner->height()), imageset.right_corner);
155}
156
94InteractiveBase::InteractiveBase(EditorGameBase& the_egbase, Section& global_s)157InteractiveBase::InteractiveBase(EditorGameBase& the_egbase, Section& global_s)
95 : UI::Panel(nullptr, 0, 0, g_gr->get_xres(), g_gr->get_yres()),158 : UI::Panel(nullptr, 0, 0, g_gr->get_xres(), g_gr->get_yres()),
96 buildhelp_(false),159 buildhelp_(false),
97 map_view_(this, the_egbase.map(), 0, 0, g_gr->get_xres(), g_gr->get_yres()),160 map_view_(this, the_egbase.map(), 0, 0, g_gr->get_xres(), g_gr->get_yres()),
98 // Initialize chatoveraly before the toolbar so it is below161 // Initialize chatoveraly before the toolbar so it is below
99 chat_overlay_(new ChatOverlay(this, 10, 25, get_w() / 2, get_h() - 25)),162 chat_overlay_(new ChatOverlay(this, 10, 25, get_w() / 2, get_h() - 25)),
100 toolbar_(this, 0, 0, UI::Box::Horizontal),163 toolbar_(this),
164 mapviewmenu_(
165 toolbar(), "dropdown_menu_mapview", 0, 0, 34U, 10, 34U,
166 /** TRANSLATORS: Title for the map view menu button in the game */
167 _("Map View"),
168 UI::DropdownType::kPictorialMenu,
169 UI::PanelStyle::kWui, UI::ButtonStyle::kWuiPrimary),
101 quick_navigation_(&map_view_),170 quick_navigation_(&map_view_),
102 workareas_cache_(nullptr),171 workareas_cache_(nullptr),
103 egbase_(the_egbase),172 egbase_(the_egbase),
@@ -147,7 +216,7 @@
147 set_size(message.width, message.height);216 set_size(message.width, message.height);
148 map_view_.set_size(message.width, message.height);217 map_view_.set_size(message.width, message.height);
149 resize_chat_overlay();218 resize_chat_overlay();
150 adjust_toolbar_position();219 finalize_toolbar();
151 });220 });
152 sound_subscriber_ = Notifications::subscribe<NoteSound>(221 sound_subscriber_ = Notifications::subscribe<NoteSound>(
153 [this](const NoteSound& note) { play_sound_effect(note); });222 [this](const NoteSound& note) { play_sound_effect(note); });
@@ -191,6 +260,68 @@
191 }260 }
192}261}
193262
263
264void InteractiveBase::add_mapview_menu(MiniMapType minimap_type) {
265 mapviewmenu_.set_image(g_gr->images().get("images/wui/menus/toggle_minimap.png"));
266 toolbar()->add(&mapviewmenu_);
267
268 minimap_registry_.open_window = [this] { toggle_minimap(); };
269 minimap_registry_.minimap_type = minimap_type;
270 minimap_registry_.closed.connect([this] { rebuild_mapview_menu(); });
271
272 rebuild_mapview_menu();
273 mapviewmenu_.selected.connect([this] { mapview_menu_selected(mapviewmenu_.get_selected()); });
274}
275
276void InteractiveBase::rebuild_mapview_menu() {
277 mapviewmenu_.clear();
278
279 /** TRANSLATORS: An entry in the game's map view menu */
280 mapviewmenu_.add(minimap_registry_.window != nullptr ? _("Hide Minimap") : _("Show Minimap"),
281 MapviewMenuEntry::kMinimap,
282 g_gr->images().get("images/wui/menus/toggle_minimap.png"),
283 false, "", "m");
284
285 /** TRANSLATORS: An entry in the game's map view menu */
286 mapviewmenu_.add(_("Zoom +"),
287 MapviewMenuEntry::kIncreaseZoom,
288 g_gr->images().get("images/wui/menus/zoom_increase.png"),
289 false, "", pgettext("hotkey", "Ctrl++"));
290
291 /** TRANSLATORS: An entry in the game's map view menu */
292 mapviewmenu_.add(_("Reset zoom"),
293 MapviewMenuEntry::kResetZoom,
294 g_gr->images().get("images/wui/menus/zoom_reset.png"),
295 false, "", pgettext("hotkey", "Ctrl+0"));
296
297 /** TRANSLATORS: An entry in the game's map view menu */
298 mapviewmenu_.add(_("Zoom -"),
299 MapviewMenuEntry::kDecreaseZoom,
300 g_gr->images().get("images/wui/menus/zoom_decrease.png"),
301 false, "", pgettext("hotkey", "Ctrl+-"));
302}
303
304void InteractiveBase::mapview_menu_selected(MapviewMenuEntry entry) {
305 switch (entry) {
306 case MapviewMenuEntry::kMinimap : {
307 toggle_minimap();
308 } break;
309 case MapviewMenuEntry::kDecreaseZoom : {
310 map_view()->decrease_zoom();
311 mapviewmenu_.toggle();
312 } break;
313 case MapviewMenuEntry::kIncreaseZoom : {
314 map_view()->increase_zoom();
315 mapviewmenu_.toggle();
316 } break;
317
318 case MapviewMenuEntry::kResetZoom : {
319 map_view()->reset_zoom();
320 mapviewmenu_.toggle();
321 } break;
322 }
323}
324
194const InteractiveBase::BuildhelpOverlay*325const InteractiveBase::BuildhelpOverlay*
195InteractiveBase::get_buildhelp_overlay(const Widelands::NodeCaps caps) const {326InteractiveBase::get_buildhelp_overlay(const Widelands::NodeCaps caps) const {
196 const int buildhelp_overlay_index = caps_to_buildhelp(caps);327 const int buildhelp_overlay_index = caps_to_buildhelp(caps);
@@ -222,6 +353,11 @@
222 return false;353 return false;
223}354}
224355
356
357void InteractiveBase::set_toolbar_imageset(const ToolbarImageset& imageset) {
358 toolbar_.change_imageset(imageset);
359}
360
225UniqueWindowHandler& InteractiveBase::unique_windows() {361UniqueWindowHandler& InteractiveBase::unique_windows() {
226 return *unique_window_handler_;362 return *unique_window_handler_;
227}363}
@@ -230,6 +366,10 @@
230 sel_.pos = center;366 sel_.pos = center;
231}367}
232368
369void InteractiveBase::finalize_toolbar() {
370 toolbar_.finalize();
371}
372
233/*373/*
234 * Set the current sel selection radius.374 * Set the current sel selection radius.
235 */375 */
@@ -269,8 +409,11 @@
269}409}
270410
271void InteractiveBase::show_buildhelp(bool t) {411void InteractiveBase::show_buildhelp(bool t) {
412 const bool old_value = buildhelp_;
272 buildhelp_ = t;413 buildhelp_ = t;
273 on_buildhelp_changed(t);414 if (old_value != t) {
415 rebuild_showhide_menu();
416 }
274}417}
275418
276void InteractiveBase::toggle_buildhelp() {419void InteractiveBase::toggle_buildhelp() {
@@ -283,9 +426,9 @@
283 UI::UniqueWindow::Registry* window,426 UI::UniqueWindow::Registry* window,
284 bool bind_default_toggle) {427 bool bind_default_toggle) {
285 UI::Button* button =428 UI::Button* button =
286 new UI::Button(&toolbar_, name, 0, 0, 34U, 34U, UI::ButtonStyle::kWuiPrimary,429 new UI::Button(&toolbar_.box, name, 0, 0, 34U, 34U, UI::ButtonStyle::kWuiPrimary,
287 g_gr->images().get("images/" + image_basename + ".png"), tooltip_text);430 g_gr->images().get("images/" + image_basename + ".png"), tooltip_text);
288 toolbar_.add(button);431 toolbar_.box.add(button);
289 if (window) {432 if (window) {
290 window->opened.connect([button] { button->set_perm_pressed(true); });433 window->opened.connect([button] { button->set_perm_pressed(true); });
291 window->closed.connect([button] { button->set_perm_pressed(false); });434 window->closed.connect([button] { button->set_perm_pressed(false); });
@@ -298,9 +441,6 @@
298 return button;441 return button;
299}442}
300443
301void InteractiveBase::on_buildhelp_changed(bool /* value */) {
302}
303
304bool InteractiveBase::has_expedition_port_space(const Widelands::Coords& coords) const {444bool InteractiveBase::has_expedition_port_space(const Widelands::Coords& coords) const {
305 for (const auto& pair : expedition_port_spaces_) {445 for (const auto& pair : expedition_port_spaces_) {
306 if (pair.second == coords) {446 if (pair.second == coords) {
@@ -638,6 +778,7 @@
638 });778 });
639 mainview_move();779 mainview_move();
640 }780 }
781 rebuild_mapview_menu();
641}782}
642783
643const std::vector<QuickNavigation::Landmark>& InteractiveBase::landmarks() {784const std::vector<QuickNavigation::Landmark>& InteractiveBase::landmarks() {
@@ -655,17 +796,6 @@
655 minimap_registry_.destroy();796 minimap_registry_.destroy();
656}797}
657798
658/**
659===========
660InteractiveBase::minimap_registry()
661
662Exposes the Registry object of the minimap to derived classes
663===========
664*/
665MiniMap::Registry& InteractiveBase::minimap_registry() {
666 return minimap_registry_;
667}
668
669/*799/*
670===============800===============
671Return display flags (dfXXX) that modify the view of the map.801Return display flags (dfXXX) that modify the view of the map.
@@ -999,40 +1129,6 @@
9991129
1000 if (down) {1130 if (down) {
1001 switch (code.sym) {1131 switch (code.sym) {
1002 case SDLK_KP_9:
1003 if (code.mod & KMOD_NUM) {
1004 break;
1005 }
1006 FALLS_THROUGH;
1007 case SDLK_PAGEUP:
1008 if (upcast(Game, game, &egbase_)) {
1009 if (GameController* const ctrl = game->game_controller()) {
1010 ctrl->set_desired_speed(ctrl->desired_speed() + 1000);
1011 }
1012 }
1013 return true;
1014
1015 case SDLK_PAUSE:
1016 if (upcast(Game, game, &egbase_)) {
1017 if (GameController* const ctrl = game->game_controller()) {
1018 ctrl->toggle_paused();
1019 }
1020 }
1021 return true;
1022
1023 case SDLK_KP_3:
1024 if (code.mod & KMOD_NUM) {
1025 break;
1026 }
1027 FALLS_THROUGH;
1028 case SDLK_PAGEDOWN:
1029 if (upcast(Widelands::Game, game, &egbase_)) {
1030 if (GameController* const ctrl = game->game_controller()) {
1031 uint32_t const speed = ctrl->desired_speed();
1032 ctrl->set_desired_speed(1000 < speed ? speed - 1000 : 0);
1033 }
1034 }
1035 return true;
1036 // Scroll the map1132 // Scroll the map
1037 case SDLK_KP_8:1133 case SDLK_KP_8:
1038 if (SDL_GetModState() & KMOD_NUM) {1134 if (SDL_GetModState() & KMOD_NUM) {
@@ -1066,13 +1162,15 @@
1066 case SDLK_RIGHT:1162 case SDLK_RIGHT:
1067 map_view_.pan_by(Vector2i(kScrollDistance, 0));1163 map_view_.pan_by(Vector2i(kScrollDistance, 0));
1068 return true;1164 return true;
1069
1070#ifndef NDEBUG // only in debug builds1165#ifndef NDEBUG // only in debug builds
1071 case SDLK_F6:1166 case SDLK_F6:
1072 GameChatMenu::create_script_console(1167 GameChatMenu::create_script_console(
1073 this, debugconsole_, *DebugConsole::get_chat_provider());1168 this, debugconsole_, *DebugConsole::get_chat_provider());
1074 return true;1169 return true;
1075#endif1170#endif
1171 case SDLK_m:
1172 toggle_minimap();
1173 return true;
1076 default:1174 default:
1077 break;1175 break;
1078 }1176 }
10791177
=== modified file 'src/wui/interactive_base.h'
--- src/wui/interactive_base.h 2019-05-31 19:31:45 +0000
+++ src/wui/interactive_base.h 2019-08-10 10:01:32 +0000
@@ -25,12 +25,14 @@
2525
26#include <SDL_keycode.h>26#include <SDL_keycode.h>
2727
28#include "graphic/toolbar_imageset.h"
28#include "logic/editor_game_base.h"29#include "logic/editor_game_base.h"
29#include "logic/map.h"30#include "logic/map.h"
30#include "notifications/notifications.h"31#include "notifications/notifications.h"
31#include "profile/profile.h"32#include "profile/profile.h"
32#include "sound/note_sound.h"33#include "sound/note_sound.h"
33#include "ui_basic/box.h"34#include "ui_basic/box.h"
35#include "ui_basic/dropdown.h"
34#include "ui_basic/textarea.h"36#include "ui_basic/textarea.h"
35#include "ui_basic/unique_window.h"37#include "ui_basic/unique_window.h"
36#include "wui/chat_overlay.h"38#include "wui/chat_overlay.h"
@@ -116,7 +118,7 @@
116 // Returns true if the buildhelp is currently displayed.118 // Returns true if the buildhelp is currently displayed.
117 bool buildhelp() const;119 bool buildhelp() const;
118120
119 // Sets if the buildhelp should be displayed. Will also call on_buildhelp_changed().121 // Sets if the buildhelp should be displayed and then calls rebuild_showhide_menu
120 void show_buildhelp(bool t);122 void show_buildhelp(bool t);
121123
122 /**124 /**
@@ -171,6 +173,7 @@
171 }173 }
172174
173 void toggle_minimap();175 void toggle_minimap();
176 // Toggles the buildhelp and calls rebuild_showhide_menu
174 void toggle_buildhelp();177 void toggle_buildhelp();
175178
176 // Returns the list of landmarks that have been mapped to the keys 0-9179 // Returns the list of landmarks that have been mapped to the keys 0-9
@@ -184,6 +187,21 @@
184 }187 }
185188
186protected:189protected:
190 // For referencing the items in mapviewmenu_
191 enum class MapviewMenuEntry {
192 kMinimap,
193 kIncreaseZoom,
194 kDecreaseZoom,
195 kResetZoom
196 };
197
198 // Adds the mapviewmenu_ to the toolbar
199 void add_mapview_menu(MiniMapType minimap_type);
200 // Rebuilds the mapviewmenu_ according to current view settings
201 void rebuild_mapview_menu();
202 // Takes the appropriate action when an item in the mapviewmenu_ is selected
203 void mapview_menu_selected(MapviewMenuEntry entry);
204
187 /// Adds a toolbar button to the toolbar205 /// Adds a toolbar button to the toolbar
188 /// \param image_basename: File path for button image starting from 'images' and without206 /// \param image_basename: File path for button image starting from 'images' and without
189 /// file extension207 /// file extension
@@ -197,13 +215,8 @@
197 UI::UniqueWindow::Registry* window = nullptr,215 UI::UniqueWindow::Registry* window = nullptr,
198 bool bind_default_toggle = false);216 bool bind_default_toggle = false);
199217
200 // Will be called whenever the buildhelp is changed with the new 'value'.
201 virtual void on_buildhelp_changed(bool value);
202
203 void hide_minimap();218 void hide_minimap();
204219
205 MiniMap::Registry& minimap_registry();
206
207 void mainview_move();220 void mainview_move();
208221
209 void draw_overlay(RenderTarget&) override;222 void draw_overlay(RenderTarget&) override;
@@ -231,16 +244,16 @@
231 const Image* get_sel_picture() {244 const Image* get_sel_picture() {
232 return sel_.pic;245 return sel_.pic;
233 }246 }
234 void adjust_toolbar_position() {247
235 toolbar_.set_pos(Vector2i((get_inner_w() - toolbar_.get_w()) >> 1, get_inner_h() - 34));248 // Sets the toolbar's position to the bottom middle and configures its background images
236 }249 void finalize_toolbar();
237250
238 ChatOverlay* chat_overlay() {251 ChatOverlay* chat_overlay() {
239 return chat_overlay_;252 return chat_overlay_;
240 }253 }
241254
242 UI::Box* toolbar() {255 UI::Box* toolbar() {
243 return &toolbar_;256 return &toolbar_.box;
244 }257 }
245258
246 // Returns the information which overlay text should currently be drawn.259 // Returns the information which overlay text should currently be drawn.
@@ -267,6 +280,12 @@
267 /// Returns true if the current player is allowed to hear sounds from map objects on this field280 /// Returns true if the current player is allowed to hear sounds from map objects on this field
268 virtual bool player_hears_field(const Widelands::Coords& coords) const = 0;281 virtual bool player_hears_field(const Widelands::Coords& coords) const = 0;
269282
283 void set_toolbar_imageset(const ToolbarImageset& imageset);
284
285#ifndef NDEBUG // only in debug builds
286 UI::UniqueWindow::Registry debugconsole_;
287#endif
288
270private:289private:
271 void play_sound_effect(const NoteSound& note) const;290 void play_sound_effect(const NoteSound& note) const;
272 void resize_chat_overlay();291 void resize_chat_overlay();
@@ -275,6 +294,9 @@
275 void cmd_map_object(const std::vector<std::string>& args);294 void cmd_map_object(const std::vector<std::string>& args);
276 void cmd_lua(const std::vector<std::string>& args);295 void cmd_lua(const std::vector<std::string>& args);
277296
297 // Rebuilds the subclass' showhidemenu_ according to current map settings
298 virtual void rebuild_showhide_menu() = 0;
299
278 struct SelData {300 struct SelData {
279 SelData(const bool Freeze = false,301 SelData(const bool Freeze = false,
280 const bool Triangles = false,302 const bool Triangles = false,
@@ -297,7 +319,26 @@
297 MapView map_view_;319 MapView map_view_;
298 ChatOverlay* chat_overlay_;320 ChatOverlay* chat_overlay_;
299321
300 UI::Box toolbar_;322 /// A horizontal menu bar embellished with background graphics
323 struct Toolbar : UI::Panel {
324 Toolbar(UI::Panel* parent);
325
326 /// Sets the actual size and position of the toolbar
327 void finalize();
328 void draw(RenderTarget& dst) override;
329 void change_imageset(const ToolbarImageset& images);
330
331 /// A row of buttons and dropdown menus
332 UI::Box box;
333 private:
334 /// The set of background images
335 ToolbarImageset imageset;
336 /// How often the left and right images get repeated, calculated from the width of the box
337 int repeat;
338 } toolbar_;
339
340 // Map View menu on the toolbar
341 UI::Dropdown<MapviewMenuEntry> mapviewmenu_;
301 // No unique_ptr on purpose: 'minimap_' is a UniqueWindow, its parent will342 // No unique_ptr on purpose: 'minimap_' is a UniqueWindow, its parent will
302 // delete it.343 // delete it.
303 MiniMap* minimap_;344 MiniMap* minimap_;
@@ -325,7 +366,6 @@
325 Widelands::CoordPath* buildroad_; // path for the new road366 Widelands::CoordPath* buildroad_; // path for the new road
326 Widelands::PlayerNumber road_build_player_;367 Widelands::PlayerNumber road_build_player_;
327368
328 UI::UniqueWindow::Registry debugconsole_;
329 std::unique_ptr<UniqueWindowHandler> unique_window_handler_;369 std::unique_ptr<UniqueWindowHandler> unique_window_handler_;
330 BuildhelpOverlay buildhelp_overlays_[Widelands::Field::Buildhelp_None];370 BuildhelpOverlay buildhelp_overlays_[Widelands::Field::Buildhelp_None];
331};371};
332372
=== modified file 'src/wui/interactive_gamebase.cc'
--- src/wui/interactive_gamebase.cc 2019-05-26 17:21:15 +0000
+++ src/wui/interactive_gamebase.cc 2019-08-10 10:01:32 +0000
@@ -37,7 +37,11 @@
37#include "profile/profile.h"37#include "profile/profile.h"
38#include "wui/constructionsitewindow.h"38#include "wui/constructionsitewindow.h"
39#include "wui/dismantlesitewindow.h"39#include "wui/dismantlesitewindow.h"
40#include "wui/game_chat_menu.h"
40#include "wui/game_client_disconnected.h"41#include "wui/game_client_disconnected.h"
42#include "wui/game_exit_confirm_box.h"
43#include "wui/game_main_menu_save_game.h"
44#include "wui/game_options_sound_menu.h"
41#include "wui/game_summary.h"45#include "wui/game_summary.h"
42#include "wui/interactive_player.h"46#include "wui/interactive_player.h"
43#include "wui/militarysitewindow.h"47#include "wui/militarysitewindow.h"
@@ -65,7 +69,25 @@
65 : InteractiveBase(g, global_s),69 : InteractiveBase(g, global_s),
66 chat_provider_(nullptr),70 chat_provider_(nullptr),
67 multiplayer_(multiplayer),71 multiplayer_(multiplayer),
68 playertype_(pt) {72 playertype_(pt),
73 showhidemenu_(
74 toolbar(), "dropdown_menu_showhide", 0, 0, 34U, 10, 34U,
75 /** TRANSLATORS: Title for a menu button in the game. This menu will show/hide building spaces, census, statistics */
76 _("Show / Hide"),
77 UI::DropdownType::kPictorialMenu,
78 UI::PanelStyle::kWui, UI::ButtonStyle::kWuiPrimary),
79 mainmenu_(
80 toolbar(), "dropdown_menu_main", 0, 0, 34U, 10, 34U,
81 /** TRANSLATORS: Title for the main menu button in the game */
82 _("Main Menu"),
83 UI::DropdownType::kPictorialMenu,
84 UI::PanelStyle::kWui, UI::ButtonStyle::kWuiPrimary),
85 gamespeedmenu_(
86 toolbar(), "dropdown_menu_gamespeed", 0, 0, 34U, 10, 34U,
87 /** TRANSLATORS: Title for a menu button in the game. This menu will show options o increase/decrease the gamespeed, and to pause the game */
88 _("Game Speed"),
89 UI::DropdownType::kPictorialMenu,
90 UI::PanelStyle::kWui, UI::ButtonStyle::kWuiPrimary) {
69 buildingnotes_subscriber_ = Notifications::subscribe<Widelands::NoteBuilding>(91 buildingnotes_subscriber_ = Notifications::subscribe<Widelands::NoteBuilding>(
70 [this](const Widelands::NoteBuilding& note) {92 [this](const Widelands::NoteBuilding& note) {
71 switch (note.action) {93 switch (note.action) {
@@ -93,6 +115,215 @@
93 });115 });
94}116}
95117
118void InteractiveGameBase::add_main_menu() {
119 mainmenu_.set_image(g_gr->images().get("images/wui/menus/main_menu.png"));
120 toolbar()->add(&mainmenu_);
121
122#ifndef NDEBUG // only in debug builds
123 /** TRANSLATORS: An entry in the game's main menu */
124 mainmenu_.add(_("Script Console"), MainMenuEntry::kScriptConsole, g_gr->images().get("images/wui/menus/lua.png"), false,
125 /** TRANSLATORS: Tooltip for Script Console in the game's main menu */
126 "", pgettext("hotkey", "F6"));
127#endif
128
129 menu_windows_.sound_options.open_window = [this] {
130 new GameOptionsSoundMenu(*this, menu_windows_.sound_options);
131 };
132 /** TRANSLATORS: An entry in the game's main menu */
133 mainmenu_.add(_("Sound Options"), MainMenuEntry::kOptions, g_gr->images().get("images/wui/menus/options.png"), false,
134 /** TRANSLATORS: Tooltip for Sound Options in the game's main menu */
135 _("Set sound effect and music options"));
136
137 menu_windows_.savegame.open_window = [this] {
138 new GameMainMenuSaveGame(*this, menu_windows_.savegame);
139 };
140 /** TRANSLATORS: An entry in the game's main menu */
141 mainmenu_.add(_("Save Game"), MainMenuEntry::kSaveMap, g_gr->images().get("images/wui/menus/save_game.png"));
142
143 /** TRANSLATORS: An entry in the game's main menu */
144 mainmenu_.add(_("Exit Game"), MainMenuEntry::kExitGame, g_gr->images().get("images/wui/menus/exit.png"));
145
146 mainmenu_.selected.connect([this] { main_menu_selected(mainmenu_.get_selected()); });
147}
148
149void InteractiveGameBase::main_menu_selected(MainMenuEntry entry) {
150 switch (entry) {
151#ifndef NDEBUG // only in debug builds
152 case MainMenuEntry::kScriptConsole: {
153 GameChatMenu::create_script_console(
154 this, debugconsole_, *DebugConsole::get_chat_provider());
155 } break;
156#endif
157 case MainMenuEntry::kOptions: {
158 menu_windows_.sound_options.toggle();
159 } break;
160 case MainMenuEntry::kSaveMap: {
161 menu_windows_.savegame.toggle();
162 } break;
163 case MainMenuEntry::kExitGame: {
164 if (SDL_GetModState() & KMOD_CTRL) {
165 end_modal<UI::Panel::Returncodes>(UI::Panel::Returncodes::kBack);
166 } else {
167 new GameExitConfirmBox(*this, *this);
168 }
169 } break;
170 }
171}
172
173void InteractiveGameBase::add_showhide_menu() {
174 showhidemenu_.set_image(g_gr->images().get("images/wui/menus/showhide.png"));
175 toolbar()->add(&showhidemenu_);
176
177 rebuild_showhide_menu();
178 showhidemenu_.selected.connect([this] { showhide_menu_selected(showhidemenu_.get_selected()); });
179}
180
181void InteractiveGameBase::rebuild_showhide_menu() {
182 showhidemenu_.clear();
183
184 /** TRANSLATORS: An entry in the game's show/hide menu to toggle whether building spaces are shown */
185 showhidemenu_.add(buildhelp() ? _("Hide Building Spaces") : _("Show Building Spaces"),
186 ShowHideEntry::kBuildingSpaces, g_gr->images().get("images/wui/menus/toggle_buildhelp.png"),
187 false, "", pgettext("hotkey", "Space"));
188
189 /** TRANSLATORS: An entry in the game's show/hide menu to toggle whether building names are shown */
190 showhidemenu_.add(get_display_flag(dfShowCensus) ? _("Hide Census") : _("Show Census"),
191 ShowHideEntry::kCensus, g_gr->images().get("images/wui/menus/toggle_census.png"),
192 false, "", "c");
193
194 /** TRANSLATORS: An entry in the game's show/hide menu to toggle whether building staristics are shown */
195 showhidemenu_.add(get_display_flag(dfShowStatistics) ? _("Hide Statistics") : _("Show Statistics"),
196 ShowHideEntry::kStatistics, g_gr->images().get("images/wui/menus/toggle_statistics.png"),
197 false, "", "s");
198}
199
200void InteractiveGameBase::showhide_menu_selected(ShowHideEntry entry) {
201 switch (entry) {
202 case ShowHideEntry::kBuildingSpaces: {
203 toggle_buildhelp();
204 } break;
205 case ShowHideEntry::kCensus: {
206 set_display_flag(dfShowCensus, !get_display_flag(dfShowCensus));
207 } break;
208 case ShowHideEntry::kStatistics: {
209 set_display_flag(dfShowStatistics, !get_display_flag(dfShowStatistics));
210 } break;
211 case ShowHideEntry::kWorkareaOverlap: {
212 set_display_flag(dfShowWorkareaOverlap, !get_display_flag(dfShowWorkareaOverlap));
213 } break;
214 }
215 rebuild_showhide_menu();
216}
217
218
219void InteractiveGameBase::add_gamespeed_menu() {
220 gamespeedmenu_.set_image(g_gr->images().get("images/wui/menus/gamespeed.png"));
221 toolbar()->add(&gamespeedmenu_);
222 rebuild_gamespeed_menu();
223 gamespeedmenu_.selected.connect([this] { gamespeed_menu_selected(gamespeedmenu_.get_selected()); });
224}
225
226
227void InteractiveGameBase::rebuild_gamespeed_menu() {
228 gamespeedmenu_.clear();
229
230 gamespeedmenu_.add(_("Speed +"), GameSpeedEntry::kIncrease, g_gr->images().get("images/wui/menus/gamespeed_increase.png"), false,
231 /** TRANSLATORS: Tooltip for Speed + in the game's game speed menu */
232 _("Increase the game speed"), pgettext("hotkey", "Page Up"));
233
234 gamespeedmenu_.add(_("Speed -"), GameSpeedEntry::kDecrease, g_gr->images().get("images/wui/menus/gamespeed_decrease.png"), false,
235 /** TRANSLATORS: Tooltip for Speed - in the game's game speed menu */
236 _("Decrease the game speed"), pgettext("hotkey", "Page Down"));
237
238 if (!is_multiplayer()) {
239 if (get_game()->game_controller() && get_game()->game_controller()->is_paused()) {
240 gamespeedmenu_.add(_("Resume"), GameSpeedEntry::kPause, g_gr->images().get("images/wui/menus/gamespeed_resume.png"), false,
241 /** TRANSLATORS: Tooltip for Pause in the game's game speed menu */
242 _("Resume the Game"), pgettext("hotkey", "Pause"));
243 } else {
244 gamespeedmenu_.add(_("Pause"), GameSpeedEntry::kPause, g_gr->images().get("images/wui/menus/gamespeed_pause.png"), false,
245 /** TRANSLATORS: Tooltip for Pause in the game's game speed menu */
246 _("Pause the Game"), pgettext("hotkey", "Pause"));
247 }
248 }
249}
250
251void InteractiveGameBase::gamespeed_menu_selected(GameSpeedEntry entry) {
252 switch (entry) {
253 case GameSpeedEntry::kIncrease: {
254 increase_gamespeed();
255 // Keep the window open so that the player can click this multiple times
256 gamespeedmenu_.toggle();
257 } break;
258 case GameSpeedEntry::kDecrease: {
259 decrease_gamespeed();
260 // Keep the window open so that the player can click this multiple times
261 gamespeedmenu_.toggle();
262 } break;
263 case GameSpeedEntry::kPause: {
264 if (!is_multiplayer()) {
265 toggle_game_paused();
266 }
267 } break;
268 }
269}
270
271void InteractiveGameBase::increase_gamespeed() {
272 if (GameController* const ctrl = get_game()->game_controller()) {
273 ctrl->set_desired_speed(ctrl->desired_speed() + 1000);
274 }
275}
276
277void InteractiveGameBase::decrease_gamespeed() {
278 if (GameController* const ctrl = get_game()->game_controller()) {
279 uint32_t const speed = ctrl->desired_speed();
280 ctrl->set_desired_speed(1000 < speed ? speed - 1000 : 0);
281 }
282}
283
284void InteractiveGameBase::toggle_game_paused() {
285 if (GameController* const ctrl = get_game()->game_controller()) {
286 ctrl->toggle_paused();
287 // Toggle Pause / Resume in the menu
288 rebuild_gamespeed_menu();
289 }
290}
291
292bool InteractiveGameBase::handle_key(bool down, SDL_Keysym code) {
293 if (InteractiveBase::handle_key(down, code)) {
294 return true;
295 }
296
297 if (down) {
298 switch (code.sym) {
299 case SDLK_KP_9:
300 if (code.mod & KMOD_NUM) {
301 break;
302 }
303 FALLS_THROUGH;
304 case SDLK_PAGEUP:
305 increase_gamespeed();
306 return true;
307
308 case SDLK_PAUSE:
309 toggle_game_paused();
310 return true;
311
312 case SDLK_KP_3:
313 if (code.mod & KMOD_NUM) {
314 break;
315 }
316 FALLS_THROUGH;
317 case SDLK_PAGEDOWN:
318 decrease_gamespeed();
319 return true;
320 default:
321 break;
322 }
323 }
324 return false;
325}
326
96/// \return a pointer to the running \ref Game instance.327/// \return a pointer to the running \ref Game instance.
97Widelands::Game* InteractiveGameBase::get_game() const {328Widelands::Game* InteractiveGameBase::get_game() const {
98 return dynamic_cast<Widelands::Game*>(&egbase());329 return dynamic_cast<Widelands::Game*>(&egbase());
@@ -180,7 +411,6 @@
180 */411 */
181void InteractiveGameBase::postload() {412void InteractiveGameBase::postload() {
182 show_buildhelp(false);413 show_buildhelp(false);
183 on_buildhelp_changed(buildhelp());
184414
185 // Recalc whole map for changed owner stuff415 // Recalc whole map for changed owner stuff
186 egbase().mutable_map()->recalc_whole_map(egbase().world());416 egbase().mutable_map()->recalc_whole_map(egbase().world());
@@ -210,10 +440,6 @@
210 }440 }
211}441}
212442
213void InteractiveGameBase::on_buildhelp_changed(const bool value) {
214 toggle_buildhelp_->set_perm_pressed(value);
215}
216
217void InteractiveGameBase::add_wanted_building_window(const Widelands::Coords& coords,443void InteractiveGameBase::add_wanted_building_window(const Widelands::Coords& coords,
218 const Vector2i point,444 const Vector2i point,
219 bool was_minimal) {445 bool was_minimal) {
220446
=== modified file 'src/wui/interactive_gamebase.h'
--- src/wui/interactive_gamebase.h 2019-05-12 16:28:27 +0000
+++ src/wui/interactive_gamebase.h 2019-08-10 10:01:32 +0000
@@ -25,6 +25,7 @@
2525
26#include "logic/game.h"26#include "logic/game.h"
27#include "profile/profile.h"27#include "profile/profile.h"
28#include "ui_basic/dropdown.h"
28#include "ui_basic/unique_window.h"29#include "ui_basic/unique_window.h"
29#include "wui/general_statistics_menu.h"30#include "wui/general_statistics_menu.h"
30#include "wui/interactive_base.h"31#include "wui/interactive_base.h"
@@ -35,22 +36,6 @@
3536
36class InteractiveGameBase : public InteractiveBase {37class InteractiveGameBase : public InteractiveBase {
37public:38public:
38 struct GameMainMenuWindows {
39 UI::UniqueWindow::Registry loadgame;
40 UI::UniqueWindow::Registry savegame;
41 UI::UniqueWindow::Registry readme;
42 UI::UniqueWindow::Registry keys;
43 UI::UniqueWindow::Registry help;
44 UI::UniqueWindow::Registry license;
45 UI::UniqueWindow::Registry sound_options;
46
47 UI::UniqueWindow::Registry building_stats;
48 GeneralStatisticsMenu::Registry general_stats;
49 UI::UniqueWindow::Registry ware_stats;
50 UI::UniqueWindow::Registry stock;
51 UI::UniqueWindow::Registry seafaring_stats;
52 };
53
54 InteractiveGameBase(Widelands::Game&,39 InteractiveGameBase(Widelands::Game&,
55 Section& global_s,40 Section& global_s,
56 PlayerType pt = NONE,41 PlayerType pt = NONE,
@@ -104,20 +89,85 @@
104 void start() override;89 void start() override;
10590
106protected:91protected:
92 // For referencing the items in showhidemenu_
93 enum class ShowHideEntry {
94 kBuildingSpaces,
95 kCensus,
96 kStatistics,
97 kWorkareaOverlap
98 };
99
100 // Adds the mapviewmenu_ to the toolbar
101 void add_main_menu();
102 // Adds the showhidemenu_ to the toolbar
103 void add_showhide_menu();
104 void rebuild_showhide_menu() override;
105 // Adds the gamespeedmenu_ to the toolbar
106 void add_gamespeed_menu();
107
108 bool handle_key(bool down, SDL_Keysym code) override;
109
107 void draw_overlay(RenderTarget&) override;110 void draw_overlay(RenderTarget&) override;
108111
109 GameMainMenuWindows main_windows_;112 // All unique menu windows
113 struct GameMenuWindows {
114 UI::UniqueWindow::Registry sound_options;
115 UI::UniqueWindow::Registry savegame;
116
117 GeneralStatisticsMenu::Registry stats_general;
118 UI::UniqueWindow::Registry stats_wares;
119 UI::UniqueWindow::Registry stats_stock;
120 UI::UniqueWindow::Registry stats_buildings;
121 UI::UniqueWindow::Registry stats_seafaring;
122
123 UI::UniqueWindow::Registry help;
124 } menu_windows_;
125
110 ChatProvider* chat_provider_;126 ChatProvider* chat_provider_;
111 bool multiplayer_;127 bool multiplayer_;
112 PlayerType playertype_;128 PlayerType playertype_;
129
130 // Show / Hide menu on the toolbar
131 UI::Dropdown<ShowHideEntry> showhidemenu_;
132
113 UI::UniqueWindow::Registry fieldaction_;133 UI::UniqueWindow::Registry fieldaction_;
114 UI::UniqueWindow::Registry game_summary_;134 UI::UniqueWindow::Registry game_summary_;
115 UI::UniqueWindow::Registry client_disconnected_;135 UI::UniqueWindow::Registry client_disconnected_;
116 UI::Button* toggle_buildhelp_;
117 UI::Button* reset_zoom_;
118136
119private:137private:
120 void on_buildhelp_changed(const bool value) override;138 // For referencing the items in mainmenu_
139 enum class MainMenuEntry {
140#ifndef NDEBUG // only in debug builds
141 kScriptConsole,
142#endif
143 kOptions,
144 kSaveMap,
145 kExitGame
146 };
147
148 // For referencing the items in gamespeedmenu_
149 enum class GameSpeedEntry {
150 kIncrease,
151 kDecrease,
152 kPause
153 };
154
155 // Takes the appropriate action when an item in the mainmenu_ is selected
156 void main_menu_selected(MainMenuEntry entry);
157 // Takes the appropriate action when an item in the showhidemenu_ is selected
158 void showhide_menu_selected(ShowHideEntry entry);
159 // Takes the appropriate action when an item in the gamespeedmenu_ is selected
160 void gamespeed_menu_selected(GameSpeedEntry entry);
161 // Rebuilds the gamespeedmenu_ according to current game settings
162 void rebuild_gamespeed_menu();
163
164 // Increases the gamespeed
165 void increase_gamespeed();
166 // Decreases the gamespeed
167 void decrease_gamespeed();
168 // Pauses / Unpauses the game and calls rebuild_gamespeed_menu
169 void toggle_game_paused();
170
121 struct WantedBuildingWindow {171 struct WantedBuildingWindow {
122 explicit WantedBuildingWindow(const Vector2i& pos,172 explicit WantedBuildingWindow(const Vector2i& pos,
123 bool was_minimized,173 bool was_minimized,
@@ -128,6 +178,12 @@
128 const bool minimize;178 const bool minimize;
129 const bool show_workarea;179 const bool show_workarea;
130 };180 };
181
182 // Main menu on the toolbar
183 UI::Dropdown<MainMenuEntry> mainmenu_;
184 // Game speed menu on the toolbar
185 UI::Dropdown<GameSpeedEntry> gamespeedmenu_;
186
131 // Building coordinates, window position, whether the window was minimized187 // Building coordinates, window position, whether the window was minimized
132 std::map<uint32_t, std::unique_ptr<const WantedBuildingWindow>> wanted_building_windows_;188 std::map<uint32_t, std::unique_ptr<const WantedBuildingWindow>> wanted_building_windows_;
133 std::unique_ptr<Notifications::Subscriber<Widelands::NoteBuilding>> buildingnotes_subscriber_;189 std::unique_ptr<Notifications::Subscriber<Widelands::NoteBuilding>> buildingnotes_subscriber_;
134190
=== modified file 'src/wui/interactive_player.cc'
--- src/wui/interactive_player.cc 2019-05-31 19:31:45 +0000
+++ src/wui/interactive_player.cc 2019-08-10 10:01:32 +0000
@@ -48,8 +48,6 @@
48#include "wui/game_main_menu_save_game.h"48#include "wui/game_main_menu_save_game.h"
49#include "wui/game_message_menu.h"49#include "wui/game_message_menu.h"
50#include "wui/game_objectives_menu.h"50#include "wui/game_objectives_menu.h"
51#include "wui/game_options_menu.h"
52#include "wui/game_statistics_menu.h"
53#include "wui/general_statistics_menu.h"51#include "wui/general_statistics_menu.h"
54#include "wui/seafaring_statistics_menu.h"52#include "wui/seafaring_statistics_menu.h"
55#include "wui/stock_menu.h"53#include "wui/stock_menu.h"
@@ -161,36 +159,26 @@
161 : InteractiveGameBase(g, global_s, NONE, multiplayer),159 : InteractiveGameBase(g, global_s, NONE, multiplayer),
162 auto_roadbuild_mode_(global_s.get_bool("auto_roadbuild_mode", true)),160 auto_roadbuild_mode_(global_s.get_bool("auto_roadbuild_mode", true)),
163 flag_to_connect_(Widelands::Coords::null()),161 flag_to_connect_(Widelands::Coords::null()),
164 grid_marker_pic_(g_gr->images().get("images/wui/overlays/grid_marker.png")) {162 statisticsmenu_(
165 add_toolbar_button(163 toolbar(), "dropdown_menu_statistics", 0, 0, 34U, 10, 34U,
166 "wui/menus/menu_options_menu", "options_menu", _("Main menu"), &options_, true);164 /** TRANSLATORS: Title for the statistics menu button in the game */
167 options_.open_window = [this] { new GameOptionsMenu(*this, options_, main_windows_); };165 _("Statistics"),
168166 UI::DropdownType::kPictorialMenu,
169 add_toolbar_button(167 UI::PanelStyle::kWui, UI::ButtonStyle::kWuiPrimary),
170 "wui/menus/menu_toggle_menu", "statistics_menu", _("Statistics"), &statisticsmenu_, true);168 grid_marker_pic_(g_gr->images().get("images/wui/overlays/grid_marker.png")) {
171 statisticsmenu_.open_window = [this] {169 add_main_menu();
172 new GameStatisticsMenu(*this, statisticsmenu_, main_windows_);
173 };
174170
175 set_display_flag(InteractiveBase::dfShowWorkareaOverlap, true); // enable by default171 set_display_flag(InteractiveBase::dfShowWorkareaOverlap, true); // enable by default
176172
177 toolbar()->add_space(15);173 toolbar()->add_space(15);
178174
179 add_toolbar_button(175 add_mapview_menu(MiniMapType::kStaticViewWindow);
180 "wui/menus/menu_toggle_minimap", "minimap", _("Minimap"), &minimap_registry(), true);176 add_showhide_menu();
181 minimap_registry().open_window = [this] { toggle_minimap(); };177 add_gamespeed_menu();
182178
183 toggle_buildhelp_ = add_toolbar_button(
184 "wui/menus/menu_toggle_buildhelp", "buildhelp", _("Show building spaces (on/off)"));
185 toggle_buildhelp_->sigclicked.connect(boost::bind(&InteractiveBase::toggle_buildhelp, this));
186 reset_zoom_ = add_toolbar_button("wui/menus/menu_reset_zoom", "reset_zoom", _("Reset zoom"));
187 reset_zoom_->sigclicked.connect([this] {
188 map_view()->zoom_around(
189 1.f, Vector2f(get_w() / 2.f, get_h() / 2.f), MapView::Transition::Smooth);
190 });
191 toolbar()->add_space(15);179 toolbar()->add_space(15);
192 if (multiplayer) {180 if (multiplayer) {
193 toggle_chat_ = add_toolbar_button("wui/menus/menu_chat", "chat", _("Chat"), &chat_, true);181 toggle_chat_ = add_toolbar_button("wui/menus/chat", "chat", _("Chat"), &chat_, true);
194 chat_.open_window = [this] {182 chat_.open_window = [this] {
195 if (chat_provider_) {183 if (chat_provider_) {
196 GameChatMenu::create_chat_console(this, chat_, *chat_provider_);184 GameChatMenu::create_chat_console(this, chat_, *chat_provider_);
@@ -199,14 +187,18 @@
199 toolbar()->add_space(15);187 toolbar()->add_space(15);
200 }188 }
201189
190 add_statistics_menu();
191
202 add_toolbar_button(192 add_toolbar_button(
203 "wui/menus/menu_objectives", "objectives", _("Objectives"), &objectives_, true);193 "wui/menus/objectives", "objectives", _("Objectives"), &objectives_, true);
204 objectives_.open_window = [this] { new GameObjectivesMenu(this, objectives_); };194 objectives_.open_window = [this] { new GameObjectivesMenu(this, objectives_); };
205195
206 toggle_message_menu_ = add_toolbar_button(196 toggle_message_menu_ = add_toolbar_button(
207 "wui/menus/menu_toggle_oldmessage_menu", "messages", _("Messages"), &message_menu_, true);197 "wui/menus/message_old", "messages", _("Messages"), &message_menu_, true);
208 message_menu_.open_window = [this] { new GameMessageMenu(*this, message_menu_); };198 message_menu_.open_window = [this] { new GameMessageMenu(*this, message_menu_); };
209199
200 toolbar()->add_space(15);
201
210 add_toolbar_button("ui_basic/menu_help", "help", _("Help"), &encyclopedia_, true);202 add_toolbar_button("ui_basic/menu_help", "help", _("Help"), &encyclopedia_, true);
211 encyclopedia_.open_window = [this] {203 encyclopedia_.open_window = [this] {
212 new TribalEncyclopedia(*this, encyclopedia_, &game().lua());204 new TribalEncyclopedia(*this, encyclopedia_, &game().lua());
@@ -217,13 +209,106 @@
217 node_action(node_and_triangle);209 node_action(node_and_triangle);
218 });210 });
219211
220 adjust_toolbar_position();212 finalize_toolbar();
221
222 main_windows_.stock.open_window = [this] { new StockMenu(*this, main_windows_.stock); };
223213
224#ifndef NDEBUG // only in debug builds214#ifndef NDEBUG // only in debug builds
225 addCommand("switchplayer", boost::bind(&InteractivePlayer::cmdSwitchPlayer, this, _1));215 addCommand("switchplayer", boost::bind(&InteractivePlayer::cmdSwitchPlayer, this, _1));
226#endif216#endif
217
218 map_options_subscriber_ =
219 Notifications::subscribe<NoteMapOptions>([this](const NoteMapOptions&) {
220 rebuild_statistics_menu();
221 });
222}
223
224
225void InteractivePlayer::add_statistics_menu() {
226 statisticsmenu_.set_image(g_gr->images().get("images/wui/menus/statistics.png"));
227 toolbar()->add(&statisticsmenu_);
228
229 menu_windows_.stats_seafaring.open_window = [this] {
230 new SeafaringStatisticsMenu(*this, menu_windows_.stats_seafaring);
231 };
232
233 menu_windows_.stats_stock.open_window = [this] { new StockMenu(*this, menu_windows_.stats_stock); };
234
235 menu_windows_.stats_buildings.open_window = [this] {
236 new BuildingStatisticsMenu(*this, menu_windows_.stats_buildings);
237 };
238
239
240 menu_windows_.stats_wares.open_window = [this] {
241 new WareStatisticsMenu(*this, menu_windows_.stats_wares);
242 };
243
244 menu_windows_.stats_general.open_window = [this] {
245 new GeneralStatisticsMenu(*this, menu_windows_.stats_general);
246 };
247
248 // NoteMapOptions takes care of the rebuilding
249
250 statisticsmenu_.selected.connect([this] { statistics_menu_selected(statisticsmenu_.get_selected()); });
251}
252
253void InteractivePlayer::rebuild_statistics_menu() {
254 statisticsmenu_.clear();
255
256 if (egbase().map().allows_seafaring()) {
257 /** TRANSLATORS: An entry in the game's statistics menu */
258 statisticsmenu_.add(_("Seafaring"), StatisticsMenuEntry::kSeafaring,
259 g_gr->images().get("images/wui/menus/statistics_seafaring.png"),
260 false, "", "e");
261 }
262
263 /** TRANSLATORS: An entry in the game's statistics menu */
264 statisticsmenu_.add(_("Stock"), StatisticsMenuEntry::kStock,
265 g_gr->images().get("images/wui/menus/statistics_stock.png"),
266 false, "", "i");
267
268 /** TRANSLATORS: An entry in the game's statistics menu */
269 statisticsmenu_.add(_("Buildings"), StatisticsMenuEntry::kBuildings,
270 g_gr->images().get("images/wui/menus/statistics_buildings.png"),
271 false, "", "b");
272
273 /** TRANSLATORS: An entry in the game's statistics menu */
274 statisticsmenu_.add(_("Wares"), StatisticsMenuEntry::kWare, g_gr->images().get("images/wui/menus/statistics_wares.png"));
275
276
277 /** TRANSLATORS: An entry in the game's statistics menu */
278 statisticsmenu_.add(_("General"), StatisticsMenuEntry::kGeneral, g_gr->images().get("images/wui/menus/statistics_general.png"));
279}
280
281void InteractivePlayer::statistics_menu_selected(StatisticsMenuEntry entry) {
282 switch (entry) {
283 case StatisticsMenuEntry::kGeneral: {
284 menu_windows_.stats_general.toggle();
285 } break;
286 case StatisticsMenuEntry::kWare: {
287 menu_windows_.stats_wares.toggle();
288 } break;
289 case StatisticsMenuEntry::kBuildings: {
290 menu_windows_.stats_buildings.toggle();
291 } break;
292 case StatisticsMenuEntry::kStock: {
293 menu_windows_.stats_stock.toggle();
294 } break;
295 case StatisticsMenuEntry::kSeafaring: {
296 if (egbase().map().allows_seafaring()) {
297 menu_windows_.stats_seafaring.toggle();
298 }
299 } break;
300 }
301 statisticsmenu_.toggle();
302}
303
304void InteractivePlayer::rebuild_showhide_menu() {
305 InteractiveGameBase::rebuild_showhide_menu();
306
307 /** TRANSLATORS: An entry in the game's show/hide menu to toggle whether workarea overlaps are highlighted */
308 showhidemenu_.add(get_display_flag(dfShowWorkareaOverlap) ? _("Hide Workarea Overlaps") : _("Show Workarea Overlaps"),
309 ShowHideEntry::kWorkareaOverlap, g_gr->images().get("images/wui/menus/show_workarea_overlap.png"),
310 false, _("Toggle whether overlapping workareas are indicated when placing a constructionsite"),
311 "w");
227}312}
228313
229void InteractivePlayer::think() {314void InteractivePlayer::think() {
@@ -255,11 +340,11 @@
255 toggle_chat_->set_enabled(chat_provider_);340 toggle_chat_->set_enabled(chat_provider_);
256 }341 }
257 {342 {
258 char const* msg_icon = "images/wui/menus/menu_toggle_oldmessage_menu.png";343 char const* msg_icon = "images/wui/menus/message_old.png";
259 std::string msg_tooltip = _("Messages");344 std::string msg_tooltip = _("Messages");
260 if (uint32_t const nr_new_messages =345 if (uint32_t const nr_new_messages =
261 player().messages().nr_messages(Widelands::Message::Status::kNew)) {346 player().messages().nr_messages(Widelands::Message::Status::kNew)) {
262 msg_icon = "images/wui/menus/menu_toggle_newmessage_menu.png";347 msg_icon = "images/wui/menus/message_new.png";
263 msg_tooltip =348 msg_tooltip =
264 (boost::format(ngettext("%u new message", "%u new messages", nr_new_messages)) %349 (boost::format(ngettext("%u new message", "%u new messages", nr_new_messages)) %
265 nr_new_messages)350 nr_new_messages)
@@ -427,11 +512,7 @@
427 return true;512 return true;
428513
429 case SDLK_i:514 case SDLK_i:
430 main_windows_.stock.toggle();515 menu_windows_.stats_stock.toggle();
431 return true;
432
433 case SDLK_m:
434 minimap_registry().toggle();
435 return true;516 return true;
436517
437 case SDLK_n:518 case SDLK_n:
@@ -451,26 +532,26 @@
451 return true;532 return true;
452533
453 case SDLK_b:534 case SDLK_b:
454 if (main_windows_.building_stats.window == nullptr) {535 if (menu_windows_.stats_buildings.window == nullptr) {
455 new BuildingStatisticsMenu(*this, main_windows_.building_stats);536 new BuildingStatisticsMenu(*this, menu_windows_.stats_buildings);
456 } else {537 } else {
457 main_windows_.building_stats.toggle();538 menu_windows_.stats_buildings.toggle();
458 }539 }
459 return true;540 return true;
460541
461 case SDLK_e:542 case SDLK_e:
462 if (game().map().allows_seafaring()) {543 if (game().map().allows_seafaring()) {
463 if (main_windows_.seafaring_stats.window == nullptr) {544 if (menu_windows_.stats_seafaring.window == nullptr) {
464 new SeafaringStatisticsMenu(*this, main_windows_.seafaring_stats);545 new SeafaringStatisticsMenu(*this, menu_windows_.stats_seafaring);
465 } else {546 } else {
466 main_windows_.seafaring_stats.toggle();547 menu_windows_.stats_seafaring.toggle();
467 }548 }
468 }549 }
469 return true;550 return true;
470551
471 case SDLK_s:552 case SDLK_s:
472 if (code.mod & (KMOD_LCTRL | KMOD_RCTRL))553 if (code.mod & (KMOD_LCTRL | KMOD_RCTRL))
473 new GameMainMenuSaveGame(*this, main_windows_.savegame);554 new GameMainMenuSaveGame(*this, menu_windows_.savegame);
474 else555 else
475 set_display_flag(dfShowStatistics, !get_display_flag(dfShowStatistics));556 set_display_flag(dfShowStatistics, !get_display_flag(dfShowStatistics));
476 return true;557 return true;
@@ -520,12 +601,20 @@
520void InteractivePlayer::cleanup_for_load() {601void InteractivePlayer::cleanup_for_load() {
521}602}
522603
604void InteractivePlayer::postload() {
605 InteractiveGameBase::postload();
606
607 ToolbarImageset* imageset = player().tribe().toolbar_image_set();
608 if (imageset != nullptr) {
609 set_toolbar_imageset(*imageset);
610 }
611}
612
523bool InteractivePlayer::player_hears_field(const Widelands::Coords& coords) const {613bool InteractivePlayer::player_hears_field(const Widelands::Coords& coords) const {
524 const Widelands::Player& plr = player();614 const Widelands::Player& plr = player();
525 if (plr.see_all()) {615 if (plr.see_all()) {
526 return true;616 return true;
527 }617 }
528
529 const Widelands::Map& map = egbase().map();618 const Widelands::Map& map = egbase().map();
530 const Widelands::Player::Field& player_field =619 const Widelands::Player::Field& player_field =
531 plr.fields()[map.get_index(coords, map.get_width())];620 plr.fields()[map.get_index(coords, map.get_width())];
@@ -548,7 +637,7 @@
548 str(boost::format("Switching from #%1% to #%2%.") % static_cast<int>(player_number_) % n));637 str(boost::format("Switching from #%1% to #%2%.") % static_cast<int>(player_number_) % n));
549 player_number_ = n;638 player_number_ = n;
550639
551 if (UI::UniqueWindow* const building_statistics_window = main_windows_.building_stats.window) {640 if (UI::UniqueWindow* const building_statistics_window = menu_windows_.stats_buildings.window) {
552 dynamic_cast<BuildingStatisticsMenu&>(*building_statistics_window).update();641 dynamic_cast<BuildingStatisticsMenu&>(*building_statistics_window).update();
553 }642 }
554}643}
555644
=== modified file 'src/wui/interactive_player.h'
--- src/wui/interactive_player.h 2019-04-25 06:31:33 +0000
+++ src/wui/interactive_player.h 2019-08-10 10:01:32 +0000
@@ -20,11 +20,13 @@
20#ifndef WL_WUI_INTERACTIVE_PLAYER_H20#ifndef WL_WUI_INTERACTIVE_PLAYER_H
21#define WL_WUI_INTERACTIVE_PLAYER_H21#define WL_WUI_INTERACTIVE_PLAYER_H
2222
23#include <memory>
23#include <vector>24#include <vector>
2425
25#include <SDL_keyboard.h>26#include <SDL_keyboard.h>
2627
27#include "logic/message_id.h"28#include "logic/message_id.h"
29#include "logic/note_map_options.h"
28#include "profile/profile.h"30#include "profile/profile.h"
29#include "ui_basic/button.h"31#include "ui_basic/button.h"
30#include "wui/interactive_gamebase.h"32#include "wui/interactive_gamebase.h"
@@ -64,6 +66,7 @@
6466
65 // For load67 // For load
66 void cleanup_for_load() override;68 void cleanup_for_load() override;
69 void postload() override;
67 void think() override;70 void think() override;
68 void draw(RenderTarget& dst) override;71 void draw(RenderTarget& dst) override;
6972
@@ -74,6 +77,23 @@
74 void popup_message(Widelands::MessageId, const Widelands::Message&);77 void popup_message(Widelands::MessageId, const Widelands::Message&);
7578
76private:79private:
80 // For referencing the items in statisticsmenu_
81 enum class StatisticsMenuEntry {
82 kGeneral,
83 kWare,
84 kBuildings,
85 kStock,
86 kSeafaring
87 };
88
89 // Adds the statisticsmenu_ to the toolbar
90 void add_statistics_menu();
91 // Rebuilds the statisticsmenu_ according to current map settings
92 void rebuild_statistics_menu();
93 // Takes the appropriate action when an item in the statisticsmenu_ is selected
94 void statistics_menu_selected(StatisticsMenuEntry entry);
95 void rebuild_showhide_menu() override;
96
77 bool player_hears_field(const Widelands::Coords& coords) const override;97 bool player_hears_field(const Widelands::Coords& coords) const override;
7898
79 void cmdSwitchPlayer(const std::vector<std::string>& args);99 void cmdSwitchPlayer(const std::vector<std::string>& args);
@@ -85,14 +105,16 @@
85 UI::Button* toggle_chat_;105 UI::Button* toggle_chat_;
86 UI::Button* toggle_message_menu_;106 UI::Button* toggle_message_menu_;
87107
108 // Statistics menu on the toolbar
109 UI::Dropdown<StatisticsMenuEntry> statisticsmenu_;
88 UI::UniqueWindow::Registry chat_;110 UI::UniqueWindow::Registry chat_;
89 UI::UniqueWindow::Registry options_;
90 UI::UniqueWindow::Registry statisticsmenu_;
91 UI::UniqueWindow::Registry objectives_;111 UI::UniqueWindow::Registry objectives_;
92 UI::UniqueWindow::Registry encyclopedia_;112 UI::UniqueWindow::Registry encyclopedia_;
93 UI::UniqueWindow::Registry message_menu_;113 UI::UniqueWindow::Registry message_menu_;
94114
95 const Image* grid_marker_pic_;115 const Image* grid_marker_pic_;
116
117 std::unique_ptr<Notifications::Subscriber<NoteMapOptions>> map_options_subscriber_;
96};118};
97119
98#endif // end of include guard: WL_WUI_INTERACTIVE_PLAYER_H120#endif // end of include guard: WL_WUI_INTERACTIVE_PLAYER_H
99121
=== modified file 'src/wui/interactive_spectator.cc'
--- src/wui/interactive_spectator.cc 2019-04-25 21:48:17 +0000
+++ src/wui/interactive_spectator.cc 2019-08-10 10:01:32 +0000
@@ -30,7 +30,6 @@
30#include "wui/fieldaction.h"30#include "wui/fieldaction.h"
31#include "wui/game_chat_menu.h"31#include "wui/game_chat_menu.h"
32#include "wui/game_main_menu_save_game.h"32#include "wui/game_main_menu_save_game.h"
33#include "wui/game_options_menu.h"
34#include "wui/general_statistics_menu.h"33#include "wui/general_statistics_menu.h"
3534
36/**35/**
@@ -40,48 +39,24 @@
40 Section& global_s,39 Section& global_s,
41 bool const multiplayer)40 bool const multiplayer)
42 : InteractiveGameBase(g, global_s, OBSERVER, multiplayer) {41 : InteractiveGameBase(g, global_s, OBSERVER, multiplayer) {
43 if (is_multiplayer()) {42 add_main_menu();
44 add_toolbar_button(43
45 "wui/menus/menu_options_menu", "options_menu", _("Main menu"), &options_, true);44 add_toolbar_button("wui/menus/statistics_general", "general_stats", _("Statistics"),
46 options_.open_window = [this] { new GameOptionsMenu(*this, options_, main_windows_); };45 &menu_windows_.stats_general, true);
4746 menu_windows_.stats_general.open_window = [this] {
48 } else {47 new GeneralStatisticsMenu(*this, menu_windows_.stats_general);
49 UI::Button* button =
50 add_toolbar_button("wui/menus/menu_exit_game", "exit_replay", _("Exit replay"));
51 button->sigclicked.connect(boost::bind(&InteractiveSpectator::exit_btn, this));
52
53 add_toolbar_button(
54 "wui/menus/menu_save_game", "save_game", _("Save game"), &main_windows_.savegame, true);
55 main_windows_.savegame.open_window = [this] {
56 new GameMainMenuSaveGame(*this, main_windows_.savegame);
57 };
58 }
59 add_toolbar_button("wui/menus/menu_general_stats", "general_stats", _("Statistics"),
60 &main_windows_.general_stats, true);
61 main_windows_.general_stats.open_window = [this] {
62 new GeneralStatisticsMenu(*this, main_windows_.general_stats);
63 };48 };
6449
65 toolbar()->add_space(15);50 toolbar()->add_space(15);
6651
67 add_toolbar_button(52 add_mapview_menu(MiniMapType::kStaticViewWindow);
68 "wui/menus/menu_toggle_minimap", "minimap", _("Minimap"), &minimap_registry(), true);53 add_showhide_menu();
69 minimap_registry().open_window = [this] { toggle_minimap(); };54 add_gamespeed_menu();
70
71 toggle_buildhelp_ = add_toolbar_button(
72 "wui/menus/menu_toggle_buildhelp", "buildhelp", _("Show building spaces (on/off)"));
73 toggle_buildhelp_->sigclicked.connect(boost::bind(&InteractiveBase::toggle_buildhelp, this));
74
75 reset_zoom_ = add_toolbar_button("wui/menus/menu_reset_zoom", "reset_zoom", _("Reset zoom"));
76 reset_zoom_->sigclicked.connect([this] {
77 map_view()->zoom_around(
78 1.f, Vector2f(get_w() / 2.f, get_h() / 2.f), MapView::Transition::Smooth);
79 });
8055
81 toolbar()->add_space(15);56 toolbar()->add_space(15);
8257
83 if (is_multiplayer()) {58 if (is_multiplayer()) {
84 add_toolbar_button("wui/menus/menu_chat", "chat", _("Chat"), &chat_, true);59 add_toolbar_button("wui/menus/chat", "chat", _("Chat"), &chat_, true);
85 chat_.open_window = [this] {60 chat_.open_window = [this] {
86 if (chat_provider_) {61 if (chat_provider_) {
87 GameChatMenu::create_chat_console(this, chat_, *chat_provider_);62 GameChatMenu::create_chat_console(this, chat_, *chat_provider_);
@@ -89,7 +64,7 @@
89 };64 };
90 }65 }
9166
92 adjust_toolbar_position();67 finalize_toolbar();
9368
94 // Setup all screen elements69 // Setup all screen elements
95 map_view()->field_clicked.connect([this](const Widelands::NodeAndTriangle<>& node_and_triangle) {70 map_view()->field_clicked.connect([this](const Widelands::NodeAndTriangle<>& node_and_triangle) {
@@ -222,17 +197,13 @@
222 toggle_buildhelp();197 toggle_buildhelp();
223 return true;198 return true;
224199
225 case SDLK_m:
226 minimap_registry().toggle();
227 return true;
228
229 case SDLK_c:200 case SDLK_c:
230 set_display_flag(dfShowCensus, !get_display_flag(dfShowCensus));201 set_display_flag(dfShowCensus, !get_display_flag(dfShowCensus));
231 return true;202 return true;
232203
233 case SDLK_s:204 case SDLK_s:
234 if (code.mod & (KMOD_LCTRL | KMOD_RCTRL)) {205 if (code.mod & (KMOD_LCTRL | KMOD_RCTRL)) {
235 new GameMainMenuSaveGame(*this, main_windows_.savegame);206 new GameMainMenuSaveGame(*this, menu_windows_.savegame);
236 } else207 } else
237 set_display_flag(dfShowStatistics, !get_display_flag(dfShowStatistics));208 set_display_flag(dfShowStatistics, !get_display_flag(dfShowStatistics));
238 return true;209 return true;
239210
=== modified file 'src/wui/interactive_spectator.h'
--- src/wui/interactive_spectator.h 2019-03-14 23:06:02 +0000
+++ src/wui/interactive_spectator.h 2019-08-10 10:01:32 +0000
@@ -56,7 +56,6 @@
56 void node_action(const Widelands::NodeAndTriangle<>& node_and_triangle) override;56 void node_action(const Widelands::NodeAndTriangle<>& node_and_triangle) override;
5757
58 UI::UniqueWindow::Registry chat_;58 UI::UniqueWindow::Registry chat_;
59 UI::UniqueWindow::Registry options_;
60};59};
6160
62#endif // end of include guard: WL_WUI_INTERACTIVE_SPECTATOR_H61#endif // end of include guard: WL_WUI_INTERACTIVE_SPECTATOR_H
6362
=== modified file 'src/wui/mapdetails.cc'
--- src/wui/mapdetails.cc 2019-05-25 09:33:17 +0000
+++ src/wui/mapdetails.cc 2019-08-10 10:01:32 +0000
@@ -42,6 +42,7 @@
42 style_(style),42 style_(style),
43 padding_(4),43 padding_(4),
44 main_box_(this, 0, 0, UI::Box::Vertical, 0, 0, 0),44 main_box_(this, 0, 0, UI::Box::Vertical, 0, 0, 0),
45 name_(""),
45 name_label_(&main_box_,46 name_label_(&main_box_,
46 0,47 0,
47 0,48 0,
@@ -86,6 +87,7 @@
8687
87void MapDetails::update(const MapData& mapdata, bool localize_mapname) {88void MapDetails::update(const MapData& mapdata, bool localize_mapname) {
88 clear();89 clear();
90 name_= mapdata.name;
89 // Show directory information91 // Show directory information
90 if (mapdata.maptype == MapData::MapType::kDirectory) {92 if (mapdata.maptype == MapData::MapType::kDirectory) {
91 name_label_.set_text(93 name_label_.set_text(
9294
=== modified file 'src/wui/mapdetails.h'
--- src/wui/mapdetails.h 2019-04-18 16:50:35 +0000
+++ src/wui/mapdetails.h 2019-08-10 10:01:32 +0000
@@ -36,6 +36,9 @@
3636
37 void clear();37 void clear();
38 void update(const MapData& mapdata, bool localize_mapname);38 void update(const MapData& mapdata, bool localize_mapname);
39 std::string name() {
40 return name_;
41 }
3942
40private:43private:
41 void layout() override;44 void layout() override;
@@ -43,6 +46,7 @@
43 const int padding_;46 const int padding_;
4447
45 UI::Box main_box_;48 UI::Box main_box_;
49 std::string name_;
46 UI::MultilineTextarea name_label_;50 UI::MultilineTextarea name_label_;
47 UI::MultilineTextarea descr_;51 UI::MultilineTextarea descr_;
48 UI::SuggestedTeamsBox* suggested_teams_box_;52 UI::SuggestedTeamsBox* suggested_teams_box_;
4953
=== modified file 'src/wui/mapview.cc'
--- src/wui/mapview.cc 2019-04-25 06:31:33 +0000
+++ src/wui/mapview.cc 2019-08-10 10:01:32 +0000
@@ -40,6 +40,9 @@
40// value is used for automatic movements and for user controlled zoom.40// value is used for automatic movements and for user controlled zoom.
41constexpr float kMaxZoom = 4.f;41constexpr float kMaxZoom = 4.f;
4242
43// Step size for zooming by keypress or UI button
44constexpr float kZoomPercentPerKeyPress = 0.10f;
45
43// The time used for panning automated map movement only.46// The time used for panning automated map movement only.
44constexpr float kShortAnimationMs = 500.f;47constexpr float kShortAnimationMs = 500.f;
4548
@@ -556,6 +559,19 @@
556 NEVER_HERE();559 NEVER_HERE();
557}560}
558561
562
563void MapView::reset_zoom() {
564 zoom_around(1.f, Vector2f(get_w() / 2.f, get_h() / 2.f), Transition::Smooth);
565}
566void MapView::increase_zoom() {
567 zoom_around(animation_target_view().view.zoom - kZoomPercentPerKeyPress,
568 Vector2f(get_w() / 2.f, get_h() / 2.f), Transition::Smooth);
569}
570void MapView::decrease_zoom() {
571 zoom_around(animation_target_view().view.zoom + kZoomPercentPerKeyPress,
572 Vector2f(get_w() / 2.f, get_h() / 2.f), Transition::Smooth);
573}
574
559bool MapView::is_dragging() const {575bool MapView::is_dragging() const {
560 return dragging_;576 return dragging_;
561}577}
@@ -580,18 +596,15 @@
580 return false;596 return false;
581 }597 }
582598
583 constexpr float kPercentPerKeyPress = 0.10f;
584 switch (code.sym) {599 switch (code.sym) {
585 case SDLK_PLUS:600 case SDLK_PLUS:
586 zoom_around(animation_target_view().view.zoom - kPercentPerKeyPress,601 increase_zoom();
587 Vector2f(get_w() / 2.f, get_h() / 2.f), Transition::Smooth);
588 return true;602 return true;
589 case SDLK_MINUS:603 case SDLK_MINUS:
590 zoom_around(animation_target_view().view.zoom + kPercentPerKeyPress,604 decrease_zoom();
591 Vector2f(get_w() / 2.f, get_h() / 2.f), Transition::Smooth);
592 return true;605 return true;
593 case SDLK_0:606 case SDLK_0:
594 zoom_around(1.f, Vector2f(get_w() / 2.f, get_h() / 2.f), Transition::Smooth);607 reset_zoom();
595 return true;608 return true;
596 default:609 default:
597 return false;610 return false;
598611
=== modified file 'src/wui/mapview.h'
--- src/wui/mapview.h 2019-04-25 06:31:33 +0000
+++ src/wui/mapview.h 2019-08-10 10:01:32 +0000
@@ -163,6 +163,13 @@
163 // displayed at 'panel_pixel' unchanging, i.e. the center of the zoom.163 // displayed at 'panel_pixel' unchanging, i.e. the center of the zoom.
164 void zoom_around(float new_zoom, const Vector2f& panel_pixel, const Transition& transition);164 void zoom_around(float new_zoom, const Vector2f& panel_pixel, const Transition& transition);
165165
166 // Reset the zoom to 1.0f
167 void reset_zoom();
168 // Zoom in a bit
169 void increase_zoom();
170 // Zoom out a bit
171 void decrease_zoom();
172
166 // True if the user is currently dragging the map.173 // True if the user is currently dragging the map.
167 bool is_dragging() const;174 bool is_dragging() const;
168175
169176
=== modified file 'src/wui/seafaring_statistics_menu.cc'
--- src/wui/seafaring_statistics_menu.cc 2019-06-25 07:34:58 +0000
+++ src/wui/seafaring_statistics_menu.cc 2019-08-10 10:01:32 +0000
@@ -98,7 +98,7 @@
98 kButtonSize,98 kButtonSize,
99 kButtonSize,99 kButtonSize,
100 UI::ButtonStyle::kWuiPrimary,100 UI::ButtonStyle::kWuiPrimary,
101 g_gr->images().get("images/wui/menus/menu_watch_follow.png"),101 g_gr->images().get("images/wui/menus/watch_follow.png"),
102 /** TRANSLATORS: Tooltip in the seafaring statistics window */102 /** TRANSLATORS: Tooltip in the seafaring statistics window */
103 as_tooltip_text_with_hotkey(_("Watch the selected ship"), "w")),103 as_tooltip_text_with_hotkey(_("Watch the selected ship"), "w")),
104 openwindowbtn_(&navigation_box_,104 openwindowbtn_(&navigation_box_,
105105
=== modified file 'src/wui/watchwindow.cc'
--- src/wui/watchwindow.cc 2019-03-15 21:36:00 +0000
+++ src/wui/watchwindow.cc 2019-08-10 10:01:32 +0000
@@ -59,12 +59,12 @@
59 cur_index_(0) {59 cur_index_(0) {
60 UI::Button* followbtn =60 UI::Button* followbtn =
61 new UI::Button(this, "follow", 0, h - 34, 34, 34, UI::ButtonStyle::kWuiSecondary,61 new UI::Button(this, "follow", 0, h - 34, 34, 34, UI::ButtonStyle::kWuiSecondary,
62 g_gr->images().get("images/wui/menus/menu_watch_follow.png"), _("Follow"));62 g_gr->images().get("images/wui/menus/watch_follow.png"), _("Follow"));
63 followbtn->sigclicked.connect(boost::bind(&WatchWindow::do_follow, this));63 followbtn->sigclicked.connect(boost::bind(&WatchWindow::do_follow, this));
6464
65 UI::Button* gotobtn = new UI::Button(65 UI::Button* gotobtn = new UI::Button(
66 this, "center_mainview_here", 34, h - 34, 34, 34, UI::ButtonStyle::kWuiSecondary,66 this, "center_mainview_here", 34, h - 34, 34, 34, UI::ButtonStyle::kWuiSecondary,
67 g_gr->images().get("images/wui/menus/menu_goto.png"), _("Center the main view on this"));67 g_gr->images().get("images/wui/menus/goto.png"), _("Center the main view on this"));
68 gotobtn->sigclicked.connect(boost::bind(&WatchWindow::do_goto, this));68 gotobtn->sigclicked.connect(boost::bind(&WatchWindow::do_goto, this));
6969
70 if (init_single_window) {70 if (init_single_window) {
7171
=== modified file 'test/maps/lua_testsuite.wmf/scripting/ui.lua'
--- test/maps/lua_testsuite.wmf/scripting/ui.lua 2016-12-28 21:59:44 +0000
+++ test/maps/lua_testsuite.wmf/scripting/ui.lua 2019-08-10 10:01:32 +0000
@@ -23,7 +23,7 @@
23end23end
2424
25function ui_tests:test_buttons_property()25function ui_tests:test_buttons_property()
26 assert_not_equal(nil, self.mv.buttons.buildhelp)26 assert_not_nil(self.mv.buttons.help)
27end27end
2828
29function ui_tests:test_window_property()29function ui_tests:test_window_property()
@@ -33,7 +33,7 @@
33 self.mv.buttons.messages:click()33 self.mv.buttons.messages:click()
34 assert_equal(1, self:_cnt(self.mv.windows))34 assert_equal(1, self:_cnt(self.mv.windows))
3535
36 assert_not_equal(nil, self.mv.windows.messages)36 assert_not_nil(self.mv.windows.messages)
37end37end
3838
39function ui_tests:test_window_property1()39function ui_tests:test_window_property1()
@@ -42,8 +42,8 @@
42 self.mv.buttons.objectives:click()42 self.mv.buttons.objectives:click()
43 assert_equal(1, self:_cnt(self.mv.windows))43 assert_equal(1, self:_cnt(self.mv.windows))
4444
45 assert_not_equal(nil, self.mv.windows.objectives)45 assert_not_nil(self.mv.windows.objectives)
46 assert_equal(nil, self.mv.windows.messages)46 assert_nil(self.mv.windows.messages)
47end47end
4848
49function ui_tests:test_position_x()49function ui_tests:test_position_x()
@@ -78,7 +78,7 @@
78function ui_tests:test_descendant_position_not_child()78function ui_tests:test_descendant_position_not_child()
79 self.mv.buttons.messages:click()79 self.mv.buttons.messages:click()
80 local w = self.mv.windows.messages80 local w = self.mv.windows.messages
81 local b = self.mv.buttons.buildhelp81 local b = self.mv.buttons.help
8282
83 assert_error("Not a descendant!", function()83 assert_error("Not a descendant!", function()
84 w:get_descendant_position(b)84 w:get_descendant_position(b)
@@ -105,17 +105,17 @@
105-- ========105-- ========
106button_tests = lunit.TestCase("Button tests")106button_tests = lunit.TestCase("Button tests")
107function button_tests:setup()107function button_tests:setup()
108 self.b = wl.ui.MapView().buttons.buildhelp108 self.b = wl.ui.MapView().buttons.help
109 wl.ui.MapView().buildhelp = false109 for n,w in pairs(wl.ui.MapView().windows) do w:close() end
110end110end
111111
112function button_tests:test_name()112function button_tests:test_name()
113 assert_equal("buildhelp", self.b.name)113 assert_equal("help", self.b.name)
114end114end
115function button_tests:test_click()115function button_tests:test_click()
116 self.b:click()116 self.b:click()
117117
118 assert_equal(true, wl.ui.MapView().buildhelp)118 assert_not_nil(wl.ui.MapView().windows.encyclopedia)
119end119end
120120
121-- =========121-- =========
@@ -159,13 +159,13 @@
159function mv_tests:setup()159function mv_tests:setup()
160 self.mv = wl.ui.MapView()160 self.mv = wl.ui.MapView()
161 self.mv.census = false161 self.mv.census = false
162 self.mv.buildhelp = false162 self.mv.statistics = false
163 for n,w in pairs(self.mv.windows) do w:close() end163 for n,w in pairs(self.mv.windows) do w:close() end
164end164end
165165
166function mv_tests:test_click()166function mv_tests:test_click()
167 self.mv:click(map:get_field(10,10))167 self.mv:click(map:get_field(10,10))
168 assert_not_equal(nil, self.mv.windows.field_action)168 assert_not_nil(self.mv.windows.field_action)
169end169end
170170
171function mv_tests:test_census()171function mv_tests:test_census()
@@ -179,3 +179,10 @@
179 assert_equal(true, self.mv.statistics)179 assert_equal(true, self.mv.statistics)
180 assert_equal(false, self.mv.census)180 assert_equal(false, self.mv.census)
181end181end
182
183
184-- =========
185-- Dropdowns
186-- =========
187
188--[[Dropdowns are tested in plain.wmf/test_ui.lua, because we need to call sleep()]]
182189
=== added file 'test/maps/plain.wmf/scripting/test_ui.lua'
--- test/maps/plain.wmf/scripting/test_ui.lua 1970-01-01 00:00:00 +0000
+++ test/maps/plain.wmf/scripting/test_ui.lua 2019-08-10 10:01:32 +0000
@@ -0,0 +1,86 @@
1-- There are more UI test in lua_testsuite.wmf/ui.lua
2
3local function open_and_close_sound_options(dropdown, is_debug_build)
4 sleep(100)
5
6 -- Test out-of-range selection in dropdown
7 assert_error("Highlighting item 0 should have been out of range", function()
8 dropdown:highlight_item(0)
9 end)
10 assert_error("Highlighting item 2000 should have been out of range", function()
11 dropdown:highlight_item(2000)
12 end)
13
14 -- Test selecting an item in the dropdown
15 if (is_debug_build) then
16 dropdown:highlight_item(2)
17 else
18 dropdown:highlight_item(1)
19 end
20 assert_nil(wl.ui.MapView().windows.sound_options_menu, "Sound options window should not have been there yet")
21
22 dropdown:select()
23 sleep(100)
24
25 window = wl.ui.MapView().windows.sound_options_menu
26 assert_not_nil(window, "Failed to open sound options window")
27 window:close()
28
29 sleep(100)
30 assert_nil(wl.ui.MapView().windows.sound_options_menu, "Failed to close sound options window")
31end
32
33run(function()
34 sleep(100)
35
36 -- Validate listing dropdowns
37 local dropdowns = wl.ui.MapView().dropdowns
38 for name,dropdown in pairs(dropdowns) do
39 assert_equal(name, dropdown.name)
40 end
41
42 -- Validate dropdown functions
43 local dropdown = dropdowns["dropdown_menu_main"]
44 assert_not_nil(dropdown, "Failed to find main menu dropdown")
45
46 local is_debug_build = dropdown.no_of_items == 4
47
48 -- Selecting from closed dropdown should fail silently
49 dropdown:select()
50
51 -- Validate selection without opening
52 open_and_close_sound_options(dropdown, is_debug_build);
53
54 -- Validate selection with opening
55 dropdown:open()
56 sleep(100)
57 open_and_close_sound_options(dropdown, is_debug_build);
58
59 -- Exit by dropdown
60 local dropdown = dropdowns["dropdown_menu_main"]
61 if (is_debug_build) then
62 dropdown:highlight_item(4)
63 else
64 dropdown:highlight_item(3)
65 end
66 dropdown:select()
67
68 local message_box = wl.ui.MapView().windows["message_box"]
69 assert_not_nil(message_box, "Failed to find exit confirm message box")
70 local ok_button = message_box.buttons["ok"]
71 assert_not_nil(ok_button, "Exit confirm message box has no 'ok' button")
72
73 -- We have to print this before closing the main view, otherwise the test suite
74 -- will fail this test, because printing to console won't work.
75 print("# All Tests passed.")
76
77 ok_button:click()
78
79 -- Give Widelands some time to close the map view
80 sleep(10000)
81 assert_nil(wl.ui.MapView(), "Exiting by main menu did not close the map view")
82
83 if (wl.ui.MapView() ~= nil) then
84 wl.ui.MapView():close()
85 end
86end)
087
=== modified file 'utils/buildcat.py'
--- utils/buildcat.py 2019-01-12 09:44:33 +0000
+++ utils/buildcat.py 2019-08-10 10:01:32 +0000
@@ -110,7 +110,7 @@
110 ['../../data/campaigns/%(name)s/extra_data',110 ['../../data/campaigns/%(name)s/extra_data',
111 '../../data/campaigns/%(name)s/objective',111 '../../data/campaigns/%(name)s/objective',
112 '../../data/campaigns/%(name)s/scripting/*.lua',112 '../../data/campaigns/%(name)s/scripting/*.lua',
113 '../../data/scripting/format_scenario.lua'113 '../../data/scripting/richtext_scenarios.lua'
114 ]114 ]
115 ),115 ),
116 ('map_%(name)s/map_%(name)s', 'data/maps/',116 ('map_%(name)s/map_%(name)s', 'data/maps/',

Subscribers

People subscribed via source and target branches

to status/vote changes: