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