Merge lp:~widelands-dev/widelands/max_players into lp:widelands
- max_players
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | 8150 |
Proposed branch: | lp:~widelands-dev/widelands/max_players |
Merge into: | lp:widelands |
Diff against target: |
2091 lines (+350/-317) 65 files modified
data/txts/developers.json (+3/-3) data/txts/help/multiplayer_help.lua (+1/-1) src/editor/CMakeLists.txt (+1/-0) src/editor/editorinteractive.cc (+6/-17) src/editor/tools/decrease_height_tool.h (+2/-2) src/editor/tools/decrease_resources_tool.h (+2/-2) src/editor/tools/delete_bob_tool.h (+2/-2) src/editor/tools/delete_immovable_tool.h (+2/-2) src/editor/tools/draw_tool.h (+2/-2) src/editor/tools/history.cc (+1/-1) src/editor/tools/increase_height_tool.h (+2/-2) src/editor/tools/increase_resources_tool.h (+2/-2) src/editor/tools/info_tool.h (+2/-2) src/editor/tools/make_infrastructure_tool.h (+2/-2) src/editor/tools/noise_height_tool.h (+2/-2) src/editor/tools/place_bob_tool.h (+2/-2) src/editor/tools/place_immovable_tool.h (+2/-2) src/editor/tools/set_height_tool.h (+2/-2) src/editor/tools/set_origin_tool.h (+2/-2) src/editor/tools/set_port_space_tool.h (+4/-4) src/editor/tools/set_resources_tool.h (+2/-2) src/editor/tools/set_starting_pos_tool.cc (+27/-40) src/editor/tools/set_starting_pos_tool.h (+13/-4) src/editor/tools/set_terrain_tool.h (+2/-2) src/editor/tools/tool.h (+4/-2) src/editor/ui_menus/main_menu_random_map.cc (+7/-3) src/editor/ui_menus/player_menu.cc (+18/-28) src/editor/ui_menus/player_menu.h (+5/-5) src/game_io/game_player_info_packet.cc (+2/-3) src/graphic/CMakeLists.txt (+10/-0) src/graphic/animation.cc (+6/-8) src/graphic/playercolor.cc (+35/-0) src/graphic/playercolor.h (+55/-0) src/logic/CMakeLists.txt (+7/-1) src/logic/constants.h (+0/-6) src/logic/editor_game_base.cc (+4/-5) src/logic/field.h (+4/-4) src/logic/map_objects/immovable.cc (+1/-2) src/logic/player.cc (+1/-13) src/logic/player.h (+2/-5) src/logic/playersmanager.cc (+3/-4) src/logic/playersmanager.h (+4/-4) src/logic/widelands.h (+3/-1) src/map_io/CMakeLists.txt (+1/-0) src/map_io/map_elemental_packet.cc (+15/-6) src/map_io/map_exploration_packet.cc (+2/-3) src/map_io/map_object_saver.h (+2/-2) src/network/CMakeLists.txt (+1/-0) src/network/network_player_settings_backend.h (+3/-3) src/scripting/lua_bases.cc (+2/-3) src/scripting/lua_game.cc (+1/-2) src/ui_fsmenu/CMakeLists.txt (+1/-0) src/ui_fsmenu/launch_mpg.cc (+6/-6) src/ui_fsmenu/launch_spg.cc (+6/-17) src/ui_fsmenu/launch_spg.h (+5/-5) src/wui/CMakeLists.txt (+3/-0) src/wui/chat_msg_layout.cc (+2/-3) src/wui/game_summary.cc (+4/-9) src/wui/general_statistics_menu.cc (+4/-10) src/wui/general_statistics_menu.h (+3/-3) src/wui/interactive_base.cc (+3/-3) src/wui/interactive_base.h (+1/-1) src/wui/interactive_player.cc (+1/-2) src/wui/multiplayersetupgroup.cc (+16/-27) src/wui/suggested_teams_box.cc (+9/-16) |
To merge this branch: | bzr merge lp:~widelands-dev/widelands/max_players |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
TiborB | Approve | ||
Review via email: mp+309083@code.launchpad.net |
Commit message
Use playercolor masks for player editor/menu player icons. Increased max players to 16.
Description of the change
Tibor can use this for the AI, so proposing this early.
TiborB (tiborb95) wrote : | # |
TiborB (tiborb95) wrote : | # |
Posting the link here:
https:/
TiborB (tiborb95) wrote : | # |
And another question - have you run regression tests?
GunChleoc (gunchleoc) wrote : | # |
Thanks for the screenshot - did you load an existing 8 player map and then add a new player to get there?
I never run regression tests these days, because that would block my computer for too long. I let Travis handle those. I did have some codecheck errors though, so we will have to wait for a bit until we get the result.
TiborB (tiborb95) wrote : | # |
Yes. If I create map in my language, and post it, other peoples will see names of players in Slovak? But this is not new behaviour created in this branch, correct?
One small detail I dont think is optimal is that such important thing as number of players are set in playercolor.h - that is quite obscure file. But we can live with this...
Otherwise everything looks OK.
GunChleoc (gunchleoc) wrote : | # |
I did some testing, and I get the same thing. The English player names are what's stored in the map file, and the localized ones are those you get when you add one. I think that we should show them localized on screen, but save them in English to the map file.
The max number of players is only needed for fetching the player color really, so I thought it would make the most sense there. Anywhere else (apart from not enough space on the user interface), it could be up to 31 players.
There is one more thing that I need to do - increase a packet number when there are more than 8 players, so people won't get unexplained crashes when loading a map with > 8 players in an old Widelands version.
bunnybot (widelandsofficial) wrote : | # |
Bunnybot encountered an error while working on this merge proposal:
Running 'git fetch bzr_origin' failed. Output:
Traceback (most recent call last):
File "/usr/local/
sys.
File "/usr/local/
repo = get_repo(url, alias)
File "/usr/local/
origin = bzrlib.
File "/usr/lib/
_unsupporte
File "/usr/lib/
find_format, transport, redirected)
File "/usr/lib/
return action(transport)
File "/usr/lib/
probers=
File "/usr/lib/
raise errors.
bzrlib.
bunnybot (widelandsofficial) wrote : | # |
Continuous integration builds have changed state:
Travis build 1426. State: passed. Details: https:/
Appveyor build 1267. State: success. Details: https:/
bunnybot (widelandsofficial) wrote : | # |
Continuous integration builds have changed state:
Travis build 1426. State: passed. Details: https:/
Appveyor build 1267. State: success. Details: https:/
bunnybot (widelandsofficial) wrote : | # |
Continuous integration builds have changed state:
Travis build 1441. State: passed. Details: https:/
Appveyor build 1284. State: failed. Details: https:/
TiborB (tiborb95) wrote : | # |
OK, I think it can go, I looked also at code. As for player names issue, if it was not introduced by this branch it is no problem (for me)
GunChleoc (gunchleoc) wrote : | # |
Thanks for the review :)
@bunnybot merge
Preview Diff
1 | === removed file 'data/images/players/editor_player_01_starting_pos.png' |
2 | Binary files data/images/players/editor_player_01_starting_pos.png 2014-12-02 21:50:09 +0000 and data/images/players/editor_player_01_starting_pos.png 1970-01-01 00:00:00 +0000 differ |
3 | === removed file 'data/images/players/editor_player_02_starting_pos.png' |
4 | Binary files data/images/players/editor_player_02_starting_pos.png 2014-12-02 21:50:09 +0000 and data/images/players/editor_player_02_starting_pos.png 1970-01-01 00:00:00 +0000 differ |
5 | === removed file 'data/images/players/editor_player_03_starting_pos.png' |
6 | Binary files data/images/players/editor_player_03_starting_pos.png 2014-12-02 21:50:09 +0000 and data/images/players/editor_player_03_starting_pos.png 1970-01-01 00:00:00 +0000 differ |
7 | === removed file 'data/images/players/editor_player_04_starting_pos.png' |
8 | Binary files data/images/players/editor_player_04_starting_pos.png 2014-12-02 21:50:09 +0000 and data/images/players/editor_player_04_starting_pos.png 1970-01-01 00:00:00 +0000 differ |
9 | === removed file 'data/images/players/editor_player_05_starting_pos.png' |
10 | Binary files data/images/players/editor_player_05_starting_pos.png 2014-12-02 21:50:09 +0000 and data/images/players/editor_player_05_starting_pos.png 1970-01-01 00:00:00 +0000 differ |
11 | === removed file 'data/images/players/editor_player_06_starting_pos.png' |
12 | Binary files data/images/players/editor_player_06_starting_pos.png 2014-12-02 21:50:09 +0000 and data/images/players/editor_player_06_starting_pos.png 1970-01-01 00:00:00 +0000 differ |
13 | === removed file 'data/images/players/editor_player_07_starting_pos.png' |
14 | Binary files data/images/players/editor_player_07_starting_pos.png 2014-12-02 21:50:09 +0000 and data/images/players/editor_player_07_starting_pos.png 1970-01-01 00:00:00 +0000 differ |
15 | === removed file 'data/images/players/fsel_editor_set_player_01_pos.png' |
16 | Binary files data/images/players/fsel_editor_set_player_01_pos.png 2014-12-02 21:50:09 +0000 and data/images/players/fsel_editor_set_player_01_pos.png 1970-01-01 00:00:00 +0000 differ |
17 | === removed file 'data/images/players/fsel_editor_set_player_02_pos.png' |
18 | Binary files data/images/players/fsel_editor_set_player_02_pos.png 2014-12-02 21:50:09 +0000 and data/images/players/fsel_editor_set_player_02_pos.png 1970-01-01 00:00:00 +0000 differ |
19 | === removed file 'data/images/players/fsel_editor_set_player_03_pos.png' |
20 | Binary files data/images/players/fsel_editor_set_player_03_pos.png 2014-12-02 21:50:09 +0000 and data/images/players/fsel_editor_set_player_03_pos.png 1970-01-01 00:00:00 +0000 differ |
21 | === removed file 'data/images/players/fsel_editor_set_player_04_pos.png' |
22 | Binary files data/images/players/fsel_editor_set_player_04_pos.png 2014-12-02 21:50:09 +0000 and data/images/players/fsel_editor_set_player_04_pos.png 1970-01-01 00:00:00 +0000 differ |
23 | === removed file 'data/images/players/fsel_editor_set_player_05_pos.png' |
24 | Binary files data/images/players/fsel_editor_set_player_05_pos.png 2014-12-02 21:50:09 +0000 and data/images/players/fsel_editor_set_player_05_pos.png 1970-01-01 00:00:00 +0000 differ |
25 | === removed file 'data/images/players/fsel_editor_set_player_06_pos.png' |
26 | Binary files data/images/players/fsel_editor_set_player_06_pos.png 2014-12-02 21:50:09 +0000 and data/images/players/fsel_editor_set_player_06_pos.png 1970-01-01 00:00:00 +0000 differ |
27 | === removed file 'data/images/players/fsel_editor_set_player_07_pos.png' |
28 | Binary files data/images/players/fsel_editor_set_player_07_pos.png 2014-12-02 21:50:09 +0000 and data/images/players/fsel_editor_set_player_07_pos.png 1970-01-01 00:00:00 +0000 differ |
29 | === removed file 'data/images/players/genstats_enable_plr_01.png' |
30 | Binary files data/images/players/genstats_enable_plr_01.png 2014-12-02 21:50:09 +0000 and data/images/players/genstats_enable_plr_01.png 1970-01-01 00:00:00 +0000 differ |
31 | === removed file 'data/images/players/genstats_enable_plr_02.png' |
32 | Binary files data/images/players/genstats_enable_plr_02.png 2014-12-02 21:50:09 +0000 and data/images/players/genstats_enable_plr_02.png 1970-01-01 00:00:00 +0000 differ |
33 | === removed file 'data/images/players/genstats_enable_plr_03.png' |
34 | Binary files data/images/players/genstats_enable_plr_03.png 2014-12-02 21:50:09 +0000 and data/images/players/genstats_enable_plr_03.png 1970-01-01 00:00:00 +0000 differ |
35 | === removed file 'data/images/players/genstats_enable_plr_04.png' |
36 | Binary files data/images/players/genstats_enable_plr_04.png 2014-12-02 21:50:09 +0000 and data/images/players/genstats_enable_plr_04.png 1970-01-01 00:00:00 +0000 differ |
37 | === removed file 'data/images/players/genstats_enable_plr_05.png' |
38 | Binary files data/images/players/genstats_enable_plr_05.png 2014-12-02 21:50:09 +0000 and data/images/players/genstats_enable_plr_05.png 1970-01-01 00:00:00 +0000 differ |
39 | === removed file 'data/images/players/genstats_enable_plr_06.png' |
40 | Binary files data/images/players/genstats_enable_plr_06.png 2014-12-02 21:50:09 +0000 and data/images/players/genstats_enable_plr_06.png 1970-01-01 00:00:00 +0000 differ |
41 | === removed file 'data/images/players/genstats_enable_plr_07.png' |
42 | Binary files data/images/players/genstats_enable_plr_07.png 2014-12-02 21:50:09 +0000 and data/images/players/genstats_enable_plr_07.png 1970-01-01 00:00:00 +0000 differ |
43 | === renamed file 'data/images/players/genstats_enable_plr_08.png' => 'data/images/players/genstats_player.png' |
44 | === added file 'data/images/players/genstats_player_pc.png' |
45 | Binary files data/images/players/genstats_player_pc.png 1970-01-01 00:00:00 +0000 and data/images/players/genstats_player_pc.png 2016-10-25 07:08:37 +0000 differ |
46 | === renamed file 'data/images/players/editor_player_08_starting_pos.png' => 'data/images/players/player_position.png' |
47 | === renamed file 'data/images/players/fsel_editor_set_player_08_pos.png' => 'data/images/players/player_position_menu.png' |
48 | === added file 'data/images/players/player_position_menu_pc.png' |
49 | Binary files data/images/players/player_position_menu_pc.png 1970-01-01 00:00:00 +0000 and data/images/players/player_position_menu_pc.png 2016-10-25 07:08:37 +0000 differ |
50 | === added file 'data/images/players/player_position_pc.png' |
51 | Binary files data/images/players/player_position_pc.png 1970-01-01 00:00:00 +0000 and data/images/players/player_position_pc.png 2016-10-25 07:08:37 +0000 differ |
52 | === modified file 'data/txts/developers.json' |
53 | --- data/txts/developers.json 2016-10-05 04:24:26 +0000 |
54 | +++ data/txts/developers.json 2016-10-25 07:08:37 +0000 |
55 | @@ -2,7 +2,7 @@ |
56 | "developers":[ |
57 | { |
58 | "heading": "Chieftain", |
59 | - "image": "images/players/genstats_enable_plr_01.png", |
60 | + "image": "images/players/genstats_player.png", |
61 | "entries":[ |
62 | { |
63 | "members":[ |
64 | @@ -13,7 +13,7 @@ |
65 | }, |
66 | { |
67 | "heading": "Elders", |
68 | - "image": "images/players/genstats_enable_plr_04.png", |
69 | + "image": "images/players/genstats_player.png", |
70 | "entries":[ |
71 | { |
72 | "subheading": "Graphics", |
73 | @@ -329,7 +329,7 @@ |
74 | }, |
75 | { |
76 | "heading": "Former Elders", |
77 | - "image": "images/players/genstats_enable_plr_04.png", |
78 | + "image": "images/players/genstats_player.png", |
79 | "entries":[ |
80 | { |
81 | "subheading": "Graphics", |
82 | |
83 | === modified file 'data/txts/help/multiplayer_help.lua' |
84 | --- data/txts/help/multiplayer_help.lua 2016-03-14 11:37:49 +0000 |
85 | +++ data/txts/help/multiplayer_help.lua 2016-10-25 07:08:37 +0000 |
86 | @@ -12,7 +12,7 @@ |
87 | |
88 | result = result .. rt(h2(_"Client settings")) |
89 | result = result .. rt(p(_"On the left side is a list of all clients including you. You can set your role with the button following your nickname. Available roles are:")) |
90 | - result = result .. picture_li("images/players/genstats_enable_plr_08.png", _"The player with the color of the flag. If more than one client selected the same color, these share control over the player (‘shared kingdom mode’).") |
91 | + result = result .. picture_li("images/players/genstats_player.png", _"The player with the color of the flag. If more than one client selected the same color, these share control over the player (‘shared kingdom mode’).") |
92 | result = result .. picture_li("images/wui/fieldaction/menu_tab_watch.png", _"Spectator mode, meaning you can see everything, but cannot control any player") |
93 | |
94 | result = result .. rt(h2(_"Player settings")) |
95 | |
96 | === modified file 'src/editor/CMakeLists.txt' |
97 | --- src/editor/CMakeLists.txt 2016-05-11 19:05:05 +0000 |
98 | +++ src/editor/CMakeLists.txt 2016-10-25 07:08:37 +0000 |
99 | @@ -93,6 +93,7 @@ |
100 | base_macros |
101 | base_scoped_timer |
102 | graphic |
103 | + graphic_playercolor |
104 | graphic_surface |
105 | io_filesystem |
106 | logic |
107 | |
108 | === modified file 'src/editor/editorinteractive.cc' |
109 | --- src/editor/editorinteractive.cc 2016-10-22 18:19:22 +0000 |
110 | +++ src/editor/editorinteractive.cc 2016-10-25 07:08:37 +0000 |
111 | @@ -38,6 +38,7 @@ |
112 | #include "editor/ui_menus/tool_menu.h" |
113 | #include "editor/ui_menus/toolsize_menu.h" |
114 | #include "graphic/graphic.h" |
115 | +#include "graphic/playercolor.h" |
116 | #include "logic/map.h" |
117 | #include "logic/map_objects/tribes/tribes.h" |
118 | #include "logic/map_objects/world/resource_description.h" |
119 | @@ -55,16 +56,6 @@ |
120 | #include "wui/interactive_base.h" |
121 | |
122 | namespace { |
123 | - |
124 | -static char const* const player_pictures[] = {"images/players/editor_player_01_starting_pos.png", |
125 | - "images/players/editor_player_02_starting_pos.png", |
126 | - "images/players/editor_player_03_starting_pos.png", |
127 | - "images/players/editor_player_04_starting_pos.png", |
128 | - "images/players/editor_player_05_starting_pos.png", |
129 | - "images/players/editor_player_06_starting_pos.png", |
130 | - "images/players/editor_player_07_starting_pos.png", |
131 | - "images/players/editor_player_08_starting_pos.png"}; |
132 | - |
133 | using Widelands::Building; |
134 | |
135 | // Load all tribes from disk. |
136 | @@ -169,13 +160,10 @@ |
137 | |
138 | // Starting locations |
139 | Widelands::PlayerNumber const nr_players = map.get_nrplayers(); |
140 | - assert(nr_players <= MAX_PLAYERS); |
141 | + assert(nr_players <= kMaxPlayers); |
142 | iterate_player_numbers(p, nr_players) { |
143 | if (Widelands::Coords const sp = map.get_starting_pos(p)) { |
144 | - const Image* player_image = g_gr->images().get(player_pictures[p - 1]); |
145 | - assert(player_image); |
146 | - mutable_field_overlay_manager()->register_overlay( |
147 | - sp, player_image, 8, Vector2i(player_image->width() / 2, STARTING_POS_HOTSPOT_Y)); |
148 | + tools_->set_starting_pos.set_starting_pos(*this, p, sp, &map); |
149 | } |
150 | } |
151 | |
152 | @@ -545,10 +533,11 @@ |
153 | tools_->current_pointer = &primary; |
154 | tools_->use_tool = which; |
155 | |
156 | - if (char const* const sel_pic = primary.get_sel(which)) |
157 | + if (const Image* sel_pic = primary.get_sel(which)) { |
158 | set_sel_picture(sel_pic); |
159 | - else |
160 | + } else { |
161 | unset_sel_picture(); |
162 | + } |
163 | set_sel_triangles(primary.operates_on_triangles()); |
164 | } |
165 | |
166 | |
167 | === modified file 'src/editor/tools/decrease_height_tool.h' |
168 | --- src/editor/tools/decrease_height_tool.h 2016-08-04 15:49:05 +0000 |
169 | +++ src/editor/tools/decrease_height_tool.h 2016-10-25 07:08:37 +0000 |
170 | @@ -41,8 +41,8 @@ |
171 | |
172 | EditorActionArgs format_args_impl(EditorInteractive& parent) override; |
173 | |
174 | - char const* get_sel_impl() const override { |
175 | - return "images/wui/editor//fsel_editor_decrease_height.png"; |
176 | + const Image* get_sel_impl() const override { |
177 | + return g_gr->images().get("images/wui/editor//fsel_editor_decrease_height.png"); |
178 | } |
179 | |
180 | int32_t get_change_by() const { |
181 | |
182 | === modified file 'src/editor/tools/decrease_resources_tool.h' |
183 | --- src/editor/tools/decrease_resources_tool.h 2016-08-04 15:49:05 +0000 |
184 | +++ src/editor/tools/decrease_resources_tool.h 2016-10-25 07:08:37 +0000 |
185 | @@ -41,8 +41,8 @@ |
186 | |
187 | EditorActionArgs format_args_impl(EditorInteractive& parent) override; |
188 | |
189 | - char const* get_sel_impl() const override { |
190 | - return "images/wui/editor/fsel_editor_decrease_resources.png"; |
191 | + const Image* get_sel_impl() const override { |
192 | + return g_gr->images().get("images/wui/editor/fsel_editor_decrease_resources.png"); |
193 | } |
194 | |
195 | int32_t get_change_by() const { |
196 | |
197 | === modified file 'src/editor/tools/delete_bob_tool.h' |
198 | --- src/editor/tools/delete_bob_tool.h 2016-08-04 15:49:05 +0000 |
199 | +++ src/editor/tools/delete_bob_tool.h 2016-10-25 07:08:37 +0000 |
200 | @@ -41,8 +41,8 @@ |
201 | |
202 | EditorActionArgs format_args_impl(EditorInteractive& parent) override; |
203 | |
204 | - char const* get_sel_impl() const override { |
205 | - return "images/wui/editor/fsel_editor_delete.png"; |
206 | + const Image* get_sel_impl() const override { |
207 | + return g_gr->images().get("images/wui/editor/fsel_editor_delete.png"); |
208 | } |
209 | }; |
210 | |
211 | |
212 | === modified file 'src/editor/tools/delete_immovable_tool.h' |
213 | --- src/editor/tools/delete_immovable_tool.h 2016-08-04 15:49:05 +0000 |
214 | +++ src/editor/tools/delete_immovable_tool.h 2016-10-25 07:08:37 +0000 |
215 | @@ -41,8 +41,8 @@ |
216 | |
217 | EditorActionArgs format_args_impl(EditorInteractive& parent) override; |
218 | |
219 | - char const* get_sel_impl() const override { |
220 | - return "images/wui/editor/fsel_editor_delete.png"; |
221 | + const Image* get_sel_impl() const override { |
222 | + return g_gr->images().get("images/wui/editor/fsel_editor_delete.png"); |
223 | } |
224 | }; |
225 | |
226 | |
227 | === modified file 'src/editor/tools/draw_tool.h' |
228 | --- src/editor/tools/draw_tool.h 2016-08-04 15:49:05 +0000 |
229 | +++ src/editor/tools/draw_tool.h 2016-10-25 07:08:37 +0000 |
230 | @@ -43,8 +43,8 @@ |
231 | |
232 | EditorActionArgs format_args_impl(EditorInteractive& parent) override; |
233 | |
234 | - char const* get_sel_impl() const override { |
235 | - return "EDITOR_DRAW_TOOL"; |
236 | + const Image* get_sel_impl() const override { |
237 | + return g_gr->images().get("images/novalue.png"); |
238 | } |
239 | |
240 | void add_action(EditorToolAction ac, EditorActionArgs& args); |
241 | |
242 | === modified file 'src/editor/tools/history.cc' |
243 | --- src/editor/tools/history.cc 2016-08-04 15:49:05 +0000 |
244 | +++ src/editor/tools/history.cc 2016-10-25 07:08:37 +0000 |
245 | @@ -94,7 +94,7 @@ |
246 | tool, static_cast<uint32_t>(ind), map, center, parent, tool.format_args(ind, parent)); |
247 | if (draw && tool.is_undoable()) { |
248 | if (undo_stack_.empty() || |
249 | - undo_stack_.front().tool.get_sel_impl() != std::string(draw_tool_.get_sel_impl())) { |
250 | + undo_stack_.front().tool.get_sel_impl() != draw_tool_.get_sel_impl()) { |
251 | EditorToolAction da(draw_tool_, EditorTool::First, map, center, parent, |
252 | draw_tool_.format_args(EditorTool::First, parent)); |
253 | |
254 | |
255 | === modified file 'src/editor/tools/increase_height_tool.h' |
256 | --- src/editor/tools/increase_height_tool.h 2016-08-04 15:49:05 +0000 |
257 | +++ src/editor/tools/increase_height_tool.h 2016-10-25 07:08:37 +0000 |
258 | @@ -47,8 +47,8 @@ |
259 | |
260 | EditorActionArgs format_args_impl(EditorInteractive& parent) override; |
261 | |
262 | - char const* get_sel_impl() const override { |
263 | - return "images/wui/editor/fsel_editor_increase_height.png"; |
264 | + const Image* get_sel_impl() const override { |
265 | + return g_gr->images().get("images/wui/editor/fsel_editor_increase_height.png"); |
266 | } |
267 | |
268 | int32_t get_change_by() const { |
269 | |
270 | === modified file 'src/editor/tools/increase_resources_tool.h' |
271 | --- src/editor/tools/increase_resources_tool.h 2016-08-04 15:49:05 +0000 |
272 | +++ src/editor/tools/increase_resources_tool.h 2016-10-25 07:08:37 +0000 |
273 | @@ -53,8 +53,8 @@ |
274 | |
275 | EditorActionArgs format_args_impl(EditorInteractive& parent) override; |
276 | |
277 | - char const* get_sel_impl() const override { |
278 | - return "images/wui/editor/fsel_editor_increase_resources.png"; |
279 | + const Image* get_sel_impl() const override { |
280 | + return g_gr->images().get("images/wui/editor/fsel_editor_increase_resources.png"); |
281 | } |
282 | |
283 | int32_t get_change_by() const { |
284 | |
285 | === modified file 'src/editor/tools/info_tool.h' |
286 | --- src/editor/tools/info_tool.h 2016-08-04 15:49:05 +0000 |
287 | +++ src/editor/tools/info_tool.h 2016-10-25 07:08:37 +0000 |
288 | @@ -33,8 +33,8 @@ |
289 | EditorActionArgs* args, |
290 | Widelands::Map* map) override; |
291 | |
292 | - char const* get_sel_impl() const override { |
293 | - return "images/wui/editor/fsel_editor_info.png"; |
294 | + const Image* get_sel_impl() const override { |
295 | + return g_gr->images().get("images/wui/editor/fsel_editor_info.png"); |
296 | } |
297 | |
298 | bool has_size_one() const override { |
299 | |
300 | === modified file 'src/editor/tools/make_infrastructure_tool.h' |
301 | --- src/editor/tools/make_infrastructure_tool.h 2016-08-04 15:49:05 +0000 |
302 | +++ src/editor/tools/make_infrastructure_tool.h 2016-10-25 07:08:37 +0000 |
303 | @@ -48,8 +48,8 @@ |
304 | EditorActionArgs* args, |
305 | Widelands::Map* map) override; |
306 | |
307 | - const char* get_sel_impl() const override { |
308 | - return "images/ui_basic/fsel.png"; |
309 | + const Image* get_sel_impl() const override { |
310 | + return g_gr->images().get("images/ui_basic/fsel.png"); |
311 | } // Standard sel icon, most complex tool of all |
312 | |
313 | private: |
314 | |
315 | === modified file 'src/editor/tools/noise_height_tool.h' |
316 | --- src/editor/tools/noise_height_tool.h 2016-08-04 15:49:05 +0000 |
317 | +++ src/editor/tools/noise_height_tool.h 2016-10-25 07:08:37 +0000 |
318 | @@ -44,8 +44,8 @@ |
319 | |
320 | EditorActionArgs format_args_impl(EditorInteractive& parent) override; |
321 | |
322 | - char const* get_sel_impl() const override { |
323 | - return "images/wui/editor/fsel_editor_noise_height.png"; |
324 | + const Image* get_sel_impl() const override { |
325 | + return g_gr->images().get("images/wui/editor/fsel_editor_noise_height.png"); |
326 | } |
327 | |
328 | Widelands::HeightInterval get_interval() const { |
329 | |
330 | === modified file 'src/editor/tools/place_bob_tool.h' |
331 | --- src/editor/tools/place_bob_tool.h 2016-08-04 15:49:05 +0000 |
332 | +++ src/editor/tools/place_bob_tool.h 2016-10-25 07:08:37 +0000 |
333 | @@ -42,8 +42,8 @@ |
334 | |
335 | EditorActionArgs format_args_impl(EditorInteractive& parent) override; |
336 | |
337 | - char const* get_sel_impl() const override { |
338 | - return "images/wui/editor/fsel_editor_place_bob.png"; |
339 | + const Image* get_sel_impl() const override { |
340 | + return g_gr->images().get("images/wui/editor/fsel_editor_place_bob.png"); |
341 | } |
342 | }; |
343 | |
344 | |
345 | === modified file 'src/editor/tools/place_immovable_tool.h' |
346 | --- src/editor/tools/place_immovable_tool.h 2016-08-04 15:49:05 +0000 |
347 | +++ src/editor/tools/place_immovable_tool.h 2016-10-25 07:08:37 +0000 |
348 | @@ -44,8 +44,8 @@ |
349 | |
350 | EditorActionArgs format_args_impl(EditorInteractive& parent) override; |
351 | |
352 | - char const* get_sel_impl() const override { |
353 | - return "images/wui/editor/fsel_editor_place_immovable.png"; |
354 | + const Image* get_sel_impl() const override { |
355 | + return g_gr->images().get("images/wui/editor/fsel_editor_place_immovable.png"); |
356 | } |
357 | }; |
358 | |
359 | |
360 | === modified file 'src/editor/tools/set_height_tool.h' |
361 | --- src/editor/tools/set_height_tool.h 2016-08-04 15:49:05 +0000 |
362 | +++ src/editor/tools/set_height_tool.h 2016-10-25 07:08:37 +0000 |
363 | @@ -43,8 +43,8 @@ |
364 | |
365 | EditorActionArgs format_args_impl(EditorInteractive& parent) override; |
366 | |
367 | - char const* get_sel_impl() const override { |
368 | - return "images/wui/editor/fsel_editor_set_height.png"; |
369 | + const Image* get_sel_impl() const override { |
370 | + return g_gr->images().get("images/wui/editor/fsel_editor_set_height.png"); |
371 | } |
372 | |
373 | Widelands::HeightInterval get_interval() const { |
374 | |
375 | === modified file 'src/editor/tools/set_origin_tool.h' |
376 | --- src/editor/tools/set_origin_tool.h 2016-08-04 15:49:05 +0000 |
377 | +++ src/editor/tools/set_origin_tool.h 2016-10-25 07:08:37 +0000 |
378 | @@ -42,8 +42,8 @@ |
379 | |
380 | EditorActionArgs format_args_impl(EditorInteractive& parent) override; |
381 | |
382 | - char const* get_sel_impl() const override { |
383 | - return "images/ui_basic/fsel.png"; |
384 | + const Image* get_sel_impl() const override { |
385 | + return g_gr->images().get("images/ui_basic/fsel.png"); |
386 | } |
387 | |
388 | bool has_size_one() const override { |
389 | |
390 | === modified file 'src/editor/tools/set_port_space_tool.h' |
391 | --- src/editor/tools/set_port_space_tool.h 2016-08-04 15:49:05 +0000 |
392 | +++ src/editor/tools/set_port_space_tool.h 2016-10-25 07:08:37 +0000 |
393 | @@ -43,8 +43,8 @@ |
394 | EditorActionArgs* args, |
395 | Widelands::Map* map) override; |
396 | |
397 | - char const* get_sel_impl() const override { |
398 | - return FSEL_EUPS_FILENAME; |
399 | + const Image* get_sel_impl() const override { |
400 | + return g_gr->images().get(FSEL_EUPS_FILENAME); |
401 | } |
402 | }; |
403 | |
404 | @@ -65,8 +65,8 @@ |
405 | EditorActionArgs* args, |
406 | Widelands::Map* map) override; |
407 | |
408 | - char const* get_sel_impl() const override { |
409 | - return FSEL_ESPS_FILENAME; |
410 | + const Image* get_sel_impl() const override { |
411 | + return g_gr->images().get(FSEL_ESPS_FILENAME); |
412 | } |
413 | }; |
414 | |
415 | |
416 | === modified file 'src/editor/tools/set_resources_tool.h' |
417 | --- src/editor/tools/set_resources_tool.h 2016-08-04 15:49:05 +0000 |
418 | +++ src/editor/tools/set_resources_tool.h 2016-10-25 07:08:37 +0000 |
419 | @@ -46,8 +46,8 @@ |
420 | |
421 | EditorActionArgs format_args_impl(EditorInteractive& parent) override; |
422 | |
423 | - char const* get_sel_impl() const override { |
424 | - return "images/wui/editor/fsel_editor_set_resources.png"; |
425 | + const Image* get_sel_impl() const override { |
426 | + return g_gr->images().get("images/wui/editor/fsel_editor_set_resources.png"); |
427 | } |
428 | |
429 | Widelands::ResourceAmount get_set_to() const { |
430 | |
431 | === modified file 'src/editor/tools/set_starting_pos_tool.cc' |
432 | --- src/editor/tools/set_starting_pos_tool.cc 2016-10-16 09:31:42 +0000 |
433 | +++ src/editor/tools/set_starting_pos_tool.cc 2016-10-25 07:08:37 +0000 |
434 | @@ -22,28 +22,8 @@ |
435 | #include "editor/editorinteractive.h" |
436 | #include "editor/tools/tool.h" |
437 | #include "graphic/graphic.h" |
438 | +#include "graphic/playercolor.h" |
439 | #include "logic/map.h" |
440 | -#include "wui/field_overlay_manager.h" |
441 | - |
442 | -namespace { |
443 | -static char const* const player_pictures[] = {"images/players/editor_player_01_starting_pos.png", |
444 | - "images/players/editor_player_02_starting_pos.png", |
445 | - "images/players/editor_player_03_starting_pos.png", |
446 | - "images/players/editor_player_04_starting_pos.png", |
447 | - "images/players/editor_player_05_starting_pos.png", |
448 | - "images/players/editor_player_06_starting_pos.png", |
449 | - "images/players/editor_player_07_starting_pos.png", |
450 | - "images/players/editor_player_08_starting_pos.png"}; |
451 | -static char const* const player_pictures_small[] = { |
452 | - "images/players/fsel_editor_set_player_01_pos.png", |
453 | - "images/players/fsel_editor_set_player_02_pos.png", |
454 | - "images/players/fsel_editor_set_player_03_pos.png", |
455 | - "images/players/fsel_editor_set_player_04_pos.png", |
456 | - "images/players/fsel_editor_set_player_05_pos.png", |
457 | - "images/players/fsel_editor_set_player_06_pos.png", |
458 | - "images/players/fsel_editor_set_player_07_pos.png", |
459 | - "images/players/fsel_editor_set_player_08_pos.png"}; |
460 | -} // namespace |
461 | |
462 | // global variable to pass data from callback to class |
463 | static int32_t current_player_; |
464 | @@ -77,9 +57,8 @@ |
465 | } |
466 | |
467 | EditorSetStartingPosTool::EditorSetStartingPosTool() |
468 | - : EditorTool(*this, *this, false), current_sel_pic_(nullptr) { |
469 | + : EditorTool(*this, *this, false), overlay_ids_(kMaxPlayers, 0) { |
470 | current_player_ = 1; |
471 | - fsel_picsname_ = "images/players/fsel_editor_set_player_01_pos.png"; |
472 | } |
473 | |
474 | int32_t EditorSetStartingPosTool::handle_click_impl(const Widelands::World&, |
475 | @@ -100,34 +79,42 @@ |
476 | current_player_ = 1; |
477 | } |
478 | |
479 | - Widelands::Coords const old_sp = map->get_starting_pos(current_player_); |
480 | - |
481 | - const Image* player_image = g_gr->images().get(player_pictures[current_player_ - 1]); |
482 | - assert(player_image); |
483 | - |
484 | // check if field is valid |
485 | if (editor_tool_set_starting_pos_callback(map->get_fcoords(center.node), *map)) { |
486 | - FieldOverlayManager* overlay_manager = eia.mutable_field_overlay_manager(); |
487 | - // remove old overlay if any |
488 | - overlay_manager->remove_overlay(old_sp, player_image); |
489 | - |
490 | - // add new overlay |
491 | - overlay_manager->register_overlay( |
492 | - center.node, player_image, 4, Vector2i(player_image->width() / 2, STARTING_POS_HOTSPOT_Y)); |
493 | - |
494 | - // set new player pos |
495 | - map->set_starting_pos(current_player_, center.node); |
496 | + set_starting_pos(eia, current_player_, center.node, map); |
497 | } |
498 | } |
499 | return 1; |
500 | } |
501 | |
502 | +void EditorSetStartingPosTool::set_starting_pos(EditorInteractive& eia, |
503 | + Widelands::PlayerNumber plnum, |
504 | + const Widelands::Coords& c, |
505 | + Widelands::Map* map) { |
506 | + FieldOverlayManager* overlay_manager = eia.mutable_field_overlay_manager(); |
507 | + // remove old overlay if any |
508 | + overlay_manager->remove_overlay(overlay_ids_.at(plnum - 1)); |
509 | + |
510 | + // add new overlay |
511 | + FieldOverlayManager::OverlayId overlay_id = overlay_manager->next_overlay_id(); |
512 | + overlay_ids_[plnum - 1] = overlay_id; |
513 | + |
514 | + const Image* player_image = |
515 | + playercolor_image(plnum - 1, g_gr->images().get("images/players/player_position.png"), |
516 | + g_gr->images().get("images/players/player_position_pc.png")); |
517 | + assert(player_image); |
518 | + |
519 | + overlay_manager->register_overlay( |
520 | + c, player_image, 8, Vector2i(player_image->width() / 2, STARTING_POS_HOTSPOT_Y), overlay_id); |
521 | + |
522 | + // set new player pos |
523 | + map->set_starting_pos(plnum, c); |
524 | +} |
525 | + |
526 | Widelands::PlayerNumber EditorSetStartingPosTool::get_current_player() const { |
527 | return current_player_; |
528 | } |
529 | |
530 | void EditorSetStartingPosTool::set_current_player(int32_t const i) { |
531 | current_player_ = i; |
532 | - fsel_picsname_ = player_pictures_small[current_player_ - 1]; |
533 | - current_sel_pic_ = fsel_picsname_; |
534 | } |
535 | |
536 | === modified file 'src/editor/tools/set_starting_pos_tool.h' |
537 | --- src/editor/tools/set_starting_pos_tool.h 2016-08-04 15:49:05 +0000 |
538 | +++ src/editor/tools/set_starting_pos_tool.h 2016-10-25 07:08:37 +0000 |
539 | @@ -20,8 +20,12 @@ |
540 | #ifndef WL_EDITOR_TOOLS_SET_STARTING_POS_TOOL_H |
541 | #define WL_EDITOR_TOOLS_SET_STARTING_POS_TOOL_H |
542 | |
543 | +#include <vector> |
544 | + |
545 | #include "editor/tools/tool.h" |
546 | +#include "graphic/playercolor.h" |
547 | #include "logic/widelands.h" |
548 | +#include "wui/field_overlay_manager.h" |
549 | |
550 | // How much place should be left around a player position |
551 | // where no other player can start |
552 | @@ -37,8 +41,10 @@ |
553 | EditorInteractive&, |
554 | EditorActionArgs*, |
555 | Widelands::Map*) override; |
556 | - char const* get_sel_impl() const override { |
557 | - return current_sel_pic_; |
558 | + const Image* get_sel_impl() const override { |
559 | + return playercolor_image(get_current_player() - 1, |
560 | + g_gr->images().get("images/players/player_position_menu.png"), |
561 | + g_gr->images().get("images/players/player_position_menu_pc.png")); |
562 | } |
563 | |
564 | Widelands::PlayerNumber get_current_player() const; |
565 | @@ -46,10 +52,13 @@ |
566 | bool has_size_one() const override { |
567 | return true; |
568 | } |
569 | + void set_starting_pos(EditorInteractive& eia, |
570 | + Widelands::PlayerNumber plnum, |
571 | + const Widelands::Coords& c, |
572 | + Widelands::Map* map); |
573 | |
574 | private: |
575 | - char const* fsel_picsname_; |
576 | - char const* current_sel_pic_; |
577 | + std::vector<FieldOverlayManager::OverlayId> overlay_ids_; |
578 | }; |
579 | |
580 | int32_t editor_tool_set_starting_pos_callback(const Widelands::TCoords<Widelands::FCoords>& c, |
581 | |
582 | === modified file 'src/editor/tools/set_terrain_tool.h' |
583 | --- src/editor/tools/set_terrain_tool.h 2016-08-04 15:49:05 +0000 |
584 | +++ src/editor/tools/set_terrain_tool.h 2016-10-25 07:08:37 +0000 |
585 | @@ -41,8 +41,8 @@ |
586 | |
587 | EditorActionArgs format_args_impl(EditorInteractive& parent) override; |
588 | |
589 | - char const* get_sel_impl() const override { |
590 | - return "images/ui_basic/fsel.png"; |
591 | + const Image* get_sel_impl() const override { |
592 | + return g_gr->images().get("images/ui_basic/fsel.png"); |
593 | } |
594 | bool operates_on_triangles() const override { |
595 | return true; |
596 | |
597 | === modified file 'src/editor/tools/tool.h' |
598 | --- src/editor/tools/tool.h 2016-09-10 16:50:51 +0000 |
599 | +++ src/editor/tools/tool.h 2016-10-25 07:08:37 +0000 |
600 | @@ -23,6 +23,8 @@ |
601 | #define MAX_TOOL_AREA 9 |
602 | |
603 | #include "base/macros.h" |
604 | +#include "graphic/graphic.h" |
605 | +#include "graphic/image.h" |
606 | #include "editor/tools/action_args.h" |
607 | #include "logic/widelands_geometry.h" |
608 | |
609 | @@ -67,7 +69,7 @@ |
610 | .handle_undo_impl(world, center, parent, args, map); |
611 | } |
612 | |
613 | - const char* get_sel(const ToolIndex i) { |
614 | + const Image* get_sel(const ToolIndex i) { |
615 | return (i == First ? *this : i == Second ? second_ : third_).get_sel_impl(); |
616 | } |
617 | |
618 | @@ -96,7 +98,7 @@ |
619 | Widelands::Map*) { |
620 | return 0; |
621 | } // non unduable tools don't need to implement this. |
622 | - virtual const char* get_sel_impl() const = 0; |
623 | + virtual const Image* get_sel_impl() const = 0; |
624 | virtual bool operates_on_triangles() const { |
625 | return false; |
626 | } |
627 | |
628 | === modified file 'src/editor/ui_menus/main_menu_random_map.cc' |
629 | --- src/editor/ui_menus/main_menu_random_map.cc 2016-10-16 09:31:42 +0000 |
630 | +++ src/editor/ui_menus/main_menu_random_map.cc 2016-10-25 07:08:37 +0000 |
631 | @@ -33,7 +33,6 @@ |
632 | #include "editor/map_generator.h" |
633 | #include "graphic/font_handler1.h" |
634 | #include "graphic/graphic.h" |
635 | -#include "logic/constants.h" |
636 | #include "logic/editor_game_base.h" |
637 | #include "logic/map.h" |
638 | #include "logic/map_objects/world/world.h" |
639 | @@ -41,6 +40,11 @@ |
640 | #include "ui_basic/messagebox.h" |
641 | #include "ui_basic/progresswindow.h" |
642 | |
643 | +namespace { |
644 | +// The map generator can't find starting positions for too many players |
645 | +constexpr uint8_t kMaxMapgenPlayers = 8; |
646 | +} // namespace |
647 | + |
648 | using namespace Widelands; |
649 | |
650 | MainMenuNewRandomMap::MainMenuNewRandomMap(EditorInteractive& parent) |
651 | @@ -406,7 +410,7 @@ |
652 | case ButtonId::kMapSize: |
653 | // Restrict maximum players according to map size, but allow at least 2 players. |
654 | max_players_ = std::min( |
655 | - static_cast<size_t>(MAX_PLAYERS), |
656 | + static_cast<size_t>(kMaxMapgenPlayers), |
657 | (find_dimension_index(width_.get_value()) + find_dimension_index(height_.get_value())) / |
658 | 2 + |
659 | 2); |
660 | @@ -442,7 +446,7 @@ |
661 | case ButtonId::kNone: |
662 | // Make sure that all conditions are met |
663 | max_players_ = std::min( |
664 | - static_cast<size_t>(MAX_PLAYERS), |
665 | + static_cast<size_t>(kMaxMapgenPlayers), |
666 | (find_dimension_index(width_.get_value()) + find_dimension_index(height_.get_value())) / |
667 | 2 + |
668 | 2); |
669 | |
670 | === modified file 'src/editor/ui_menus/player_menu.cc' |
671 | --- src/editor/ui_menus/player_menu.cc 2016-10-24 14:04:00 +0000 |
672 | +++ src/editor/ui_menus/player_menu.cc 2016-10-25 07:08:37 +0000 |
673 | @@ -26,7 +26,6 @@ |
674 | #include "editor/editorinteractive.h" |
675 | #include "editor/tools/set_starting_pos_tool.h" |
676 | #include "graphic/graphic.h" |
677 | -#include "logic/constants.h" |
678 | #include "logic/map.h" |
679 | #include "logic/map_objects/tribes/tribes.h" |
680 | #include "logic/map_objects/tribes/warehouse.h" |
681 | @@ -36,26 +35,6 @@ |
682 | #include "ui_basic/textarea.h" |
683 | #include "wui/field_overlay_manager.h" |
684 | |
685 | -namespace { |
686 | -static char const* const player_pictures[] = {"images/players/editor_player_01_starting_pos.png", |
687 | - "images/players/editor_player_02_starting_pos.png", |
688 | - "images/players/editor_player_03_starting_pos.png", |
689 | - "images/players/editor_player_04_starting_pos.png", |
690 | - "images/players/editor_player_05_starting_pos.png", |
691 | - "images/players/editor_player_06_starting_pos.png", |
692 | - "images/players/editor_player_07_starting_pos.png", |
693 | - "images/players/editor_player_08_starting_pos.png"}; |
694 | -static char const* const player_pictures_small[] = { |
695 | - "images/players/fsel_editor_set_player_01_pos.png", |
696 | - "images/players/fsel_editor_set_player_02_pos.png", |
697 | - "images/players/fsel_editor_set_player_03_pos.png", |
698 | - "images/players/fsel_editor_set_player_04_pos.png", |
699 | - "images/players/fsel_editor_set_player_05_pos.png", |
700 | - "images/players/fsel_editor_set_player_06_pos.png", |
701 | - "images/players/fsel_editor_set_player_07_pos.png", |
702 | - "images/players/fsel_editor_set_player_08_pos.png"}; |
703 | -} // namespace |
704 | - |
705 | #define UNDEFINED_TRIBE_NAME "<undefined>" |
706 | |
707 | inline EditorInteractive& EditorPlayerMenu::eia() { |
708 | @@ -83,6 +62,7 @@ |
709 | g_gr->images().get("images/ui_basic/scrollbar_down.png"), |
710 | _("Remove last player")), |
711 | tribenames_(eia().egbase().tribes().get_all_tribenames()) { |
712 | + add_player_.set_enabled(parent.egbase().map().get_nrplayers() < kMaxPlayers); |
713 | add_player_.sigclicked.connect( |
714 | boost::bind(&EditorPlayerMenu::clicked_add_player, boost::ref(*this))); |
715 | remove_last_player_.sigclicked.connect( |
716 | @@ -105,7 +85,7 @@ |
717 | |
718 | posy_ = posy; |
719 | |
720 | - for (Widelands::PlayerNumber i = 0; i < MAX_PLAYERS; ++i) { |
721 | + for (Widelands::PlayerNumber i = 0; i < kMaxPlayers; ++i) { |
722 | plr_names_[i] = nullptr; |
723 | plr_set_pos_buts_[i] = nullptr; |
724 | plr_set_tribes_buts_[i] = nullptr; |
725 | @@ -148,7 +128,7 @@ |
726 | } |
727 | |
728 | // Now remove all the unneeded stuff. |
729 | - for (Widelands::PlayerNumber i = nr_players; i < MAX_PLAYERS; ++i) { |
730 | + for (Widelands::PlayerNumber i = nr_players; i < kMaxPlayers; ++i) { |
731 | delete plr_names_[i]; |
732 | plr_names_[i] = nullptr; |
733 | delete plr_set_pos_buts_[i]; |
734 | @@ -203,13 +183,15 @@ |
735 | plr_set_pos_buts_[p - 1]->sigclicked.connect( |
736 | boost::bind(&EditorPlayerMenu::set_starting_pos_clicked, boost::ref(*this), p)); |
737 | } |
738 | - const Image* player_image = g_gr->images().get(player_pictures_small[p - 1]); |
739 | + const Image* player_image = |
740 | + playercolor_image(p - 1, g_gr->images().get("images/players/player_position_menu.png"), |
741 | + g_gr->images().get("images/players/player_position_menu_pc.png")); |
742 | assert(player_image); |
743 | |
744 | plr_set_pos_buts_[p - 1]->set_pic(player_image); |
745 | posy += size + spacing; |
746 | } |
747 | - add_player_.set_enabled(nr_players < MAX_PLAYERS); |
748 | + add_player_.set_enabled(nr_players < kMaxPlayers); |
749 | remove_last_player_.set_enabled(1 < nr_players); |
750 | set_inner_size(get_inner_w(), posy + spacing); |
751 | } |
752 | @@ -217,7 +199,7 @@ |
753 | void EditorPlayerMenu::clicked_add_player() { |
754 | Widelands::Map& map = eia().egbase().map(); |
755 | Widelands::PlayerNumber const nr_players = map.get_nrplayers() + 1; |
756 | - assert(nr_players <= MAX_PLAYERS); |
757 | + assert(nr_players <= kMaxPlayers); |
758 | map.set_nrplayers(nr_players); |
759 | { // register new default name for this players |
760 | assert(nr_players <= 99); // 2 decimal digits |
761 | @@ -228,6 +210,8 @@ |
762 | } |
763 | map.set_scenario_player_tribe(nr_players, tribenames_[0]); |
764 | eia().set_need_save(true); |
765 | + add_player_.set_enabled(nr_players < kMaxPlayers); |
766 | + remove_last_player_.set_enabled(true); |
767 | update(); |
768 | } |
769 | |
770 | @@ -241,7 +225,9 @@ |
771 | if (!menu.is_player_tribe_referenced(old_nr_players)) { |
772 | if (const Widelands::Coords sp = map.get_starting_pos(old_nr_players)) { |
773 | // Remove starting position marker. |
774 | - const Image* player_image = g_gr->images().get(player_pictures[old_nr_players - 1]); |
775 | + const Image* player_image = playercolor_image( |
776 | + old_nr_players - 1, g_gr->images().get("images/players/player_position.png"), |
777 | + g_gr->images().get("images/players/player_position_pc.png")); |
778 | assert(player_image); |
779 | menu.mutable_field_overlay_manager()->remove_overlay(sp, player_image); |
780 | } |
781 | @@ -250,6 +236,8 @@ |
782 | set_starting_pos_clicked(nr_players); |
783 | } |
784 | map.set_nrplayers(nr_players); |
785 | + add_player_.set_enabled(nr_players < kMaxPlayers); |
786 | + remove_last_player_.set_enabled(1 < nr_players); |
787 | update(); |
788 | // TODO(SirVer): Take steps when the player is referenced someplace. Not |
789 | // TODO(SirVer): currently possible in the editor though. |
790 | @@ -370,7 +358,9 @@ |
791 | |
792 | // Remove the player overlay from this starting pos. |
793 | // A HQ is overlay enough |
794 | - const Image* player_image = g_gr->images().get(player_pictures[n - 1]); |
795 | + const Image* player_image = |
796 | + playercolor_image(n - 1, g_gr->images().get("images/players/player_position.png"), |
797 | + g_gr->images().get("images/players/player_position_pc.png")); |
798 | assert(player_image); |
799 | overlay_manager->remove_overlay(start_pos, player_image); |
800 | } |
801 | |
802 | === modified file 'src/editor/ui_menus/player_menu.h' |
803 | --- src/editor/ui_menus/player_menu.h 2016-09-10 16:50:51 +0000 |
804 | +++ src/editor/ui_menus/player_menu.h 2016-10-25 07:08:37 +0000 |
805 | @@ -25,7 +25,7 @@ |
806 | #include <string> |
807 | #include <vector> |
808 | |
809 | -#include "logic/constants.h" |
810 | +#include "graphic/playercolor.h" |
811 | #include "logic/widelands.h" |
812 | #include "ui_basic/button.h" |
813 | #include "ui_basic/unique_window.h" |
814 | @@ -47,15 +47,15 @@ |
815 | EditorInteractive& eia(); |
816 | UI::UniqueWindow::Registry allow_buildings_menu_; |
817 | UI::Textarea* nr_of_players_ta_; |
818 | - UI::EditBox* plr_names_[MAX_PLAYERS]; |
819 | + UI::EditBox* plr_names_[kMaxPlayers]; |
820 | UI::Button add_player_, remove_last_player_; |
821 | - UI::Button* plr_make_infrastructure_buts_[MAX_PLAYERS], *plr_set_pos_buts_[MAX_PLAYERS], |
822 | - *plr_set_tribes_buts_[MAX_PLAYERS]; |
823 | + UI::Button* plr_make_infrastructure_buts_[kMaxPlayers], *plr_set_pos_buts_[kMaxPlayers], |
824 | + *plr_set_tribes_buts_[kMaxPlayers]; |
825 | |
826 | std::vector<std::string> tribenames_; |
827 | |
828 | /// List of the tribes currently selected for all players |
829 | - std::string selected_tribes_[MAX_PLAYERS]; |
830 | + std::string selected_tribes_[kMaxPlayers]; |
831 | |
832 | int32_t posy_; |
833 | |
834 | |
835 | === modified file 'src/game_io/game_player_info_packet.cc' |
836 | --- src/game_io/game_player_info_packet.cc 2016-08-04 15:49:05 +0000 |
837 | +++ src/game_io/game_player_info_packet.cc 2016-10-25 07:08:37 +0000 |
838 | @@ -21,7 +21,6 @@ |
839 | |
840 | #include "io/fileread.h" |
841 | #include "io/filewrite.h" |
842 | -#include "logic/constants.h" |
843 | #include "logic/game.h" |
844 | #include "logic/game_data_error.h" |
845 | #include "logic/map_objects/tribes/tribe_descr.h" |
846 | @@ -46,9 +45,9 @@ |
847 | bool const see_all = fr.unsigned_8(); |
848 | |
849 | int32_t const plnum = fr.unsigned_8(); |
850 | - if (plnum < 1 || MAX_PLAYERS < plnum) |
851 | + if (plnum < 1 || kMaxPlayers < plnum) |
852 | throw GameDataError( |
853 | - "player number (%i) is out of range (1 .. %u)", plnum, MAX_PLAYERS); |
854 | + "player number (%i) is out of range (1 .. %u)", plnum, kMaxPlayers); |
855 | |
856 | Widelands::TeamNumber team = fr.unsigned_8(); |
857 | char const* const tribe_name = fr.c_string(); |
858 | |
859 | === modified file 'src/graphic/CMakeLists.txt' |
860 | --- src/graphic/CMakeLists.txt 2016-10-22 11:22:34 +0000 |
861 | +++ src/graphic/CMakeLists.txt 2016-10-25 07:08:37 +0000 |
862 | @@ -22,6 +22,15 @@ |
863 | USES_SDL2 |
864 | ) |
865 | |
866 | +wl_library(graphic_playercolor |
867 | + SRCS |
868 | + playercolor.cc |
869 | + playercolor.h |
870 | + DEPENDS |
871 | + graphic_color |
872 | + graphic_surface |
873 | +) |
874 | + |
875 | wl_library(graphic_render_queue |
876 | SRCS |
877 | render_queue.cc |
878 | @@ -255,6 +264,7 @@ |
879 | graphic_gl_utils |
880 | graphic_image_cache |
881 | graphic_image_io |
882 | + graphic_playercolor |
883 | graphic_render_queue |
884 | graphic_surface |
885 | graphic_text |
886 | |
887 | === modified file 'src/graphic/animation.cc' |
888 | --- src/graphic/animation.cc 2016-10-16 20:35:47 +0000 |
889 | +++ src/graphic/animation.cc 2016-10-25 07:08:37 +0000 |
890 | @@ -34,6 +34,7 @@ |
891 | #include "graphic/graphic.h" |
892 | #include "graphic/image.h" |
893 | #include "graphic/image_cache.h" |
894 | +#include "graphic/playercolor.h" |
895 | #include "graphic/surface.h" |
896 | #include "graphic/texture.h" |
897 | #include "io/filesystem/layered_filesystem.h" |
898 | @@ -216,21 +217,18 @@ |
899 | |
900 | Image* NonPackedAnimation::representative_image(const RGBColor* clr) const { |
901 | assert(!image_files_.empty()); |
902 | - |
903 | const Image* image = g_gr->images().get(image_files_[0]); |
904 | - int w = image->width(); |
905 | - int h = image->height(); |
906 | |
907 | - Texture* rv = new Texture(w, h); |
908 | if (!hasplrclrs_ || clr == nullptr) { |
909 | // No player color means we simply want an exact copy of the original image. |
910 | + const int w = image->width(); |
911 | + const int h = image->height(); |
912 | + Texture* rv = new Texture(w, h); |
913 | rv->blit(Rectf(0, 0, w, h), *image, Rectf(0, 0, w, h), 1., BlendMode::Copy); |
914 | + return rv; |
915 | } else { |
916 | - rv->fill_rect(Rectf(0, 0, w, h), RGBAColor(0, 0, 0, 0)); |
917 | - rv->blit_blended(Rectf(0, 0, w, h), *image, *g_gr->images().get(pc_mask_image_files_[0]), |
918 | - Rectf(0, 0, w, h), *clr); |
919 | + return playercolor_image(clr, image, g_gr->images().get(pc_mask_image_files_[0])); |
920 | } |
921 | - return rv; |
922 | } |
923 | |
924 | const std::string& NonPackedAnimation::representative_image_filename() const { |
925 | |
926 | === added file 'src/graphic/playercolor.cc' |
927 | --- src/graphic/playercolor.cc 1970-01-01 00:00:00 +0000 |
928 | +++ src/graphic/playercolor.cc 2016-10-25 07:08:37 +0000 |
929 | @@ -0,0 +1,35 @@ |
930 | +/* |
931 | + * Copyright (C) 2016 by the Widelands Development Team |
932 | + * |
933 | + * This program is free software; you can redistribute it and/or |
934 | + * modify it under the terms of the GNU General Public License |
935 | + * as published by the Free Software Foundation; either version 2 |
936 | + * of the License, or (at your option) any later version. |
937 | + * |
938 | + * This program is distributed in the hope that it will be useful, |
939 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
940 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
941 | + * GNU General Public License for more details. |
942 | + * |
943 | + * You should have received a copy of the GNU General Public License |
944 | + * along with this program; if not, write to the Free Software |
945 | + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
946 | + * |
947 | + */ |
948 | + |
949 | +#include "graphic/playercolor.h" |
950 | + |
951 | +#include "graphic/texture.h" |
952 | + |
953 | +Image* playercolor_image(const RGBColor* clr, const Image* image, const Image* color_mask) { |
954 | + int w = image->width(); |
955 | + int h = image->height(); |
956 | + Texture* rv = new Texture(w, h); |
957 | + rv->fill_rect(Rectf(0, 0, w, h), RGBAColor(0, 0, 0, 0)); |
958 | + rv->blit_blended(Rectf(0, 0, w, h), *image, *color_mask, Rectf(0, 0, w, h), *clr); |
959 | + return rv; |
960 | +} |
961 | + |
962 | +Image* playercolor_image(int player_number, const Image* image, const Image* color_mask) { |
963 | + return playercolor_image(&kPlayerColors[player_number], image, color_mask); |
964 | +} |
965 | |
966 | === added file 'src/graphic/playercolor.h' |
967 | --- src/graphic/playercolor.h 1970-01-01 00:00:00 +0000 |
968 | +++ src/graphic/playercolor.h 2016-10-25 07:08:37 +0000 |
969 | @@ -0,0 +1,55 @@ |
970 | +/* |
971 | + * Copyright (C) 2016 by the Widelands Development Team |
972 | + * |
973 | + * This program is free software; you can redistribute it and/or |
974 | + * modify it under the terms of the GNU General Public License |
975 | + * as published by the Free Software Foundation; either version 2 |
976 | + * of the License, or (at your option) any later version. |
977 | + * |
978 | + * This program is distributed in the hope that it will be useful, |
979 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
980 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
981 | + * GNU General Public License for more details. |
982 | + * |
983 | + * You should have received a copy of the GNU General Public License |
984 | + * along with this program; if not, write to the Free Software |
985 | + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
986 | + * |
987 | + */ |
988 | + |
989 | +#ifndef WL_GRAPHIC_PLAYERCOLOR_H |
990 | +#define WL_GRAPHIC_PLAYERCOLOR_H |
991 | + |
992 | +#include "graphic/color.h" |
993 | +#include "graphic/image.h" |
994 | + |
995 | +/// Maximum numbers of players in a game. The game logic code reserves 5 bits |
996 | +/// for player numbers, so it can keep track of 32 different player numbers, of |
997 | +/// which the value 0 means neutral and the values 1 .. 31 can be used as the |
998 | +/// numbers for actual players. So the upper limit of this value is 31. |
999 | +constexpr uint8_t kMaxPlayers = 16; |
1000 | + |
1001 | +// Hard coded player colors |
1002 | +const RGBColor kPlayerColors[kMaxPlayers] = { |
1003 | + RGBColor(2, 2, 198), // blue |
1004 | + RGBColor(255, 41, 0), // red |
1005 | + RGBColor(255, 232, 0), // yellow |
1006 | + RGBColor(59, 223, 3), // green |
1007 | + RGBColor(57, 57, 57), // black/dark gray |
1008 | + RGBColor(255, 172, 0), // orange |
1009 | + RGBColor(215, 0, 218), // purple |
1010 | + RGBColor(255, 255, 255), // white |
1011 | + RGBColor(0, 120, 255), // sky blue |
1012 | + RGBColor(104, 0, 40), // dark red |
1013 | + RGBColor(120, 108, 0), // dark yellow |
1014 | + RGBColor(0, 112, 0), // dark green |
1015 | + RGBColor(255, 120, 160), // rose |
1016 | + RGBColor(148, 56, 0), // brown |
1017 | + RGBColor(96, 0, 84), // dark purple |
1018 | + RGBColor(144, 144, 144), // light gray |
1019 | +}; |
1020 | + |
1021 | +Image* playercolor_image(const RGBColor* clr, const Image* image, const Image* color_mask); |
1022 | +Image* playercolor_image(int player_number, const Image* image, const Image* color_mask); |
1023 | + |
1024 | +#endif // end of include guard: WL_GRAPHIC_PLAYERCOLOR_H |
1025 | |
1026 | === modified file 'src/logic/CMakeLists.txt' |
1027 | --- src/logic/CMakeLists.txt 2016-10-22 11:20:33 +0000 |
1028 | +++ src/logic/CMakeLists.txt 2016-10-25 07:08:37 +0000 |
1029 | @@ -44,6 +44,11 @@ |
1030 | profile |
1031 | ) |
1032 | |
1033 | +wl_library(logic_constants |
1034 | + SRCS |
1035 | + constants.h |
1036 | +) |
1037 | + |
1038 | wl_library(logic |
1039 | SRCS |
1040 | backtrace.cc |
1041 | @@ -60,7 +65,6 @@ |
1042 | cmd_luascript.h |
1043 | cmd_queue.cc |
1044 | cmd_queue.h |
1045 | - constants.h |
1046 | cookie_priority_queue.h |
1047 | description_maintainer.h |
1048 | editor_game_base.cc |
1049 | @@ -221,12 +225,14 @@ |
1050 | graphic |
1051 | graphic_color |
1052 | graphic_image_io |
1053 | + graphic_playercolor |
1054 | graphic_surface |
1055 | graphic_text_layout |
1056 | helper |
1057 | io_fileread |
1058 | io_filesystem |
1059 | io_stream |
1060 | + logic_constants |
1061 | logic_game_controller |
1062 | logic_game_settings |
1063 | logic_widelands_geometry |
1064 | |
1065 | === modified file 'src/logic/constants.h' |
1066 | --- src/logic/constants.h 2016-05-19 07:51:43 +0000 |
1067 | +++ src/logic/constants.h 2016-10-25 07:08:37 +0000 |
1068 | @@ -22,12 +22,6 @@ |
1069 | |
1070 | #include <cstdint> |
1071 | |
1072 | -/// Maximum numbers of players in a game. The game logic code reserves 5 bits |
1073 | -/// for player numbers, so it can keep track of 32 different player numbers, of |
1074 | -/// which the value 0 means neutral and the values 1 .. 31 can be used as the |
1075 | -/// numbers for actual players. So the upper limit of this value is 31. |
1076 | -#define MAX_PLAYERS 8 |
1077 | - |
1078 | /// How often are statistics to be sampled. |
1079 | constexpr uint32_t kStatisticsSampleTime = 30000; |
1080 | |
1081 | |
1082 | === modified file 'src/logic/editor_game_base.cc' |
1083 | --- src/logic/editor_game_base.cc 2016-08-04 15:49:05 +0000 |
1084 | +++ src/logic/editor_game_base.cc 2016-10-25 07:08:37 +0000 |
1085 | @@ -31,7 +31,6 @@ |
1086 | #include "economy/road.h" |
1087 | #include "graphic/color.h" |
1088 | #include "graphic/graphic.h" |
1089 | -#include "logic/constants.h" |
1090 | #include "logic/findimmovable.h" |
1091 | #include "logic/game.h" |
1092 | #include "logic/game_data_error.h" |
1093 | @@ -174,7 +173,7 @@ |
1094 | |
1095 | void EditorGameBase::inform_players_about_ownership(MapIndex const i, |
1096 | PlayerNumber const new_owner) { |
1097 | - iterate_players_existing_const(plnum, MAX_PLAYERS, *this, p) { |
1098 | + iterate_players_existing_const(plnum, kMaxPlayers, *this, p) { |
1099 | Player::Field& player_field = p->fields_[i]; |
1100 | if (1 < player_field.vision) { |
1101 | player_field.owner = new_owner; |
1102 | @@ -184,7 +183,7 @@ |
1103 | void EditorGameBase::inform_players_about_immovable(MapIndex const i, |
1104 | MapObjectDescr const* const descr) { |
1105 | if (!Road::is_road_descr(descr)) |
1106 | - iterate_players_existing_const(plnum, MAX_PLAYERS, *this, p) { |
1107 | + iterate_players_existing_const(plnum, kMaxPlayers, *this, p) { |
1108 | Player::Field& player_field = p->fields_[i]; |
1109 | if (1 < player_field.vision) { |
1110 | player_field.map_object_descr[TCoords<>::None] = descr; |
1111 | @@ -206,7 +205,7 @@ |
1112 | } |
1113 | |
1114 | void EditorGameBase::allocate_player_maps() { |
1115 | - iterate_players_existing(plnum, MAX_PLAYERS, *this, p) { |
1116 | + iterate_players_existing(plnum, kMaxPlayers, *this, p) { |
1117 | p->allocate_map(); |
1118 | } |
1119 | } |
1120 | @@ -483,7 +482,7 @@ |
1121 | uint8_t const road = f.field->get_roads() & mask; |
1122 | MapIndex const i = f.field - &first_field; |
1123 | MapIndex const neighbour_i = neighbour.field - &first_field; |
1124 | - iterate_players_existing_const(plnum, MAX_PLAYERS, *this, p) { |
1125 | + iterate_players_existing_const(plnum, kMaxPlayers, *this, p) { |
1126 | Player::Field& first_player_field = *p->fields_; |
1127 | Player::Field& player_field = (&first_player_field)[i]; |
1128 | if (1 < player_field.vision || 1 < (&first_player_field)[neighbour_i].vision) { |
1129 | |
1130 | === modified file 'src/logic/field.h' |
1131 | --- src/logic/field.h 2016-08-04 15:49:05 +0000 |
1132 | +++ src/logic/field.h 2016-10-25 07:08:37 +0000 |
1133 | @@ -23,7 +23,7 @@ |
1134 | #include <cassert> |
1135 | #include <limits> |
1136 | |
1137 | -#include "logic/constants.h" |
1138 | +#include "graphic/playercolor.h" |
1139 | #include "logic/nodecaps.h" |
1140 | #include "logic/roadtype.h" |
1141 | #include "logic/widelands.h" |
1142 | @@ -145,12 +145,12 @@ |
1143 | * be done separately. |
1144 | */ |
1145 | void set_owned_by(const PlayerNumber n) { |
1146 | - assert(n <= MAX_PLAYERS); |
1147 | + assert(n <= kMaxPlayers); |
1148 | owner_info_and_selections = n | (owner_info_and_selections & ~Player_Number_Bitmask); |
1149 | } |
1150 | |
1151 | PlayerNumber get_owned_by() const { |
1152 | - assert((owner_info_and_selections & Player_Number_Bitmask) <= MAX_PLAYERS); |
1153 | + assert((owner_info_and_selections & Player_Number_Bitmask) <= kMaxPlayers); |
1154 | return owner_info_and_selections & Player_Number_Bitmask; |
1155 | } |
1156 | bool is_border() const { |
1157 | @@ -229,7 +229,7 @@ |
1158 | static const OwnerInfoAndSelectionsType Player_Number_Bitmask = Border_Bitmask - 1; |
1159 | static const OwnerInfoAndSelectionsType Owner_Info_Bitmask = |
1160 | Player_Number_Bitmask + Border_Bitmask; |
1161 | - static_assert(MAX_PLAYERS <= Player_Number_Bitmask, "Bitmask is too big."); |
1162 | + static_assert(kMaxPlayers <= Player_Number_Bitmask, "Bitmask is too big."); |
1163 | |
1164 | // Data Members |
1165 | /** linked list, \sa Bob::linknext_ */ |
1166 | |
1167 | === modified file 'src/logic/map_objects/immovable.cc' |
1168 | --- src/logic/map_objects/immovable.cc 2016-10-22 11:20:33 +0000 |
1169 | +++ src/logic/map_objects/immovable.cc 2016-10-25 07:08:37 +0000 |
1170 | @@ -35,7 +35,6 @@ |
1171 | #include "helper.h" |
1172 | #include "io/fileread.h" |
1173 | #include "io/filewrite.h" |
1174 | -#include "logic/constants.h" |
1175 | #include "logic/editor_game_base.h" |
1176 | #include "logic/field.h" |
1177 | #include "logic/game.h" |
1178 | @@ -530,7 +529,7 @@ |
1179 | |
1180 | if (packet_version >= 5) { |
1181 | PlayerNumber pn = fr.unsigned_8(); |
1182 | - if (pn && pn <= MAX_PLAYERS) { |
1183 | + if (pn && pn <= kMaxPlayers) { |
1184 | Player* plr = egbase().get_player(pn); |
1185 | if (!plr) |
1186 | throw GameDataError("Immovable::load: player %u does not exist", pn); |
1187 | |
1188 | === modified file 'src/logic/player.cc' |
1189 | --- src/logic/player.cc 2016-08-04 15:49:05 +0000 |
1190 | +++ src/logic/player.cc 2016-10-25 07:08:37 +0000 |
1191 | @@ -36,7 +36,6 @@ |
1192 | #include "io/filewrite.h" |
1193 | #include "logic/cmd_delete_message.h" |
1194 | #include "logic/cmd_luacoroutine.h" |
1195 | -#include "logic/constants.h" |
1196 | #include "logic/findimmovable.h" |
1197 | #include "logic/game.h" |
1198 | #include "logic/game_data_error.h" |
1199 | @@ -88,17 +87,6 @@ |
1200 | |
1201 | namespace Widelands { |
1202 | |
1203 | -const RGBColor Player::Colors[MAX_PLAYERS] = { |
1204 | - RGBColor(2, 2, 198), // blue |
1205 | - RGBColor(255, 41, 0), // red |
1206 | - RGBColor(255, 232, 0), // yellow |
1207 | - RGBColor(59, 223, 3), // green |
1208 | - RGBColor(57, 57, 57), // black/dark gray |
1209 | - RGBColor(255, 172, 0), // orange |
1210 | - RGBColor(215, 0, 218), // purple |
1211 | - RGBColor(255, 255, 255), // white |
1212 | -}; |
1213 | - |
1214 | /** |
1215 | * Find the longest possible enhancement chain leading to the given |
1216 | * building descr. The FormerBuildings given in reference must be empty and will be |
1217 | @@ -272,7 +260,7 @@ |
1218 | if (!team_number_) |
1219 | return; |
1220 | |
1221 | - for (PlayerNumber i = 1; i <= MAX_PLAYERS; ++i) { |
1222 | + for (PlayerNumber i = 1; i <= kMaxPlayers; ++i) { |
1223 | Player* other = egbase().get_player(i); |
1224 | if (!other) |
1225 | continue; |
1226 | |
1227 | === modified file 'src/logic/player.h' |
1228 | --- src/logic/player.h 2016-08-04 15:49:05 +0000 |
1229 | +++ src/logic/player.h 2016-10-25 07:08:37 +0000 |
1230 | @@ -25,7 +25,7 @@ |
1231 | |
1232 | #include "base/macros.h" |
1233 | #include "graphic/color.h" |
1234 | -#include "logic/constants.h" |
1235 | +#include "graphic/playercolor.h" |
1236 | #include "logic/editor_game_base.h" |
1237 | #include "logic/map_objects/tribes/building.h" |
1238 | #include "logic/map_objects/tribes/constructionsite.h" |
1239 | @@ -64,9 +64,6 @@ |
1240 | */ |
1241 | class Player { |
1242 | public: |
1243 | - // hard-coded playercolors |
1244 | - static const RGBColor Colors[MAX_PLAYERS]; |
1245 | - |
1246 | struct BuildingStats { |
1247 | bool is_constructionsite; |
1248 | Coords pos; |
1249 | @@ -130,7 +127,7 @@ |
1250 | return team_number_; |
1251 | } |
1252 | const RGBColor& get_playercolor() const { |
1253 | - return Colors[player_number_ - 1]; |
1254 | + return kPlayerColors[player_number_ - 1]; |
1255 | } |
1256 | const TribeDescr& tribe() const { |
1257 | return tribe_; |
1258 | |
1259 | === modified file 'src/logic/playersmanager.cc' |
1260 | --- src/logic/playersmanager.cc 2016-08-04 15:49:05 +0000 |
1261 | +++ src/logic/playersmanager.cc 2016-10-25 07:08:37 +0000 |
1262 | @@ -22,7 +22,6 @@ |
1263 | #include <cstring> |
1264 | |
1265 | #include "base/wexception.h" |
1266 | -#include "logic/constants.h" |
1267 | #include "logic/editor_game_base.h" |
1268 | #include "logic/game_settings.h" |
1269 | #include "logic/player.h" |
1270 | @@ -39,7 +38,7 @@ |
1271 | } |
1272 | |
1273 | void PlayersManager::cleanup() { |
1274 | - const Player* const* const players_end = players_ + MAX_PLAYERS; |
1275 | + const Player* const* const players_end = players_ + kMaxPlayers; |
1276 | for (Player** p = players_; p < players_end; ++p) { |
1277 | delete *p; |
1278 | *p = nullptr; |
1279 | @@ -49,7 +48,7 @@ |
1280 | |
1281 | void PlayersManager::remove_player(PlayerNumber plnum) { |
1282 | assert(1 <= plnum); |
1283 | - assert(plnum <= MAX_PLAYERS); |
1284 | + assert(plnum <= kMaxPlayers); |
1285 | |
1286 | Player*& p = players_[plnum - 1]; |
1287 | if (p) { |
1288 | @@ -67,7 +66,7 @@ |
1289 | const std::string& name, |
1290 | TeamNumber team) { |
1291 | assert(1 <= player_number); |
1292 | - assert(player_number <= MAX_PLAYERS); |
1293 | + assert(player_number <= kMaxPlayers); |
1294 | |
1295 | Player*& p = players_[player_number - 1]; |
1296 | if (p) { |
1297 | |
1298 | === modified file 'src/logic/playersmanager.h' |
1299 | --- src/logic/playersmanager.h 2016-08-04 15:49:05 +0000 |
1300 | +++ src/logic/playersmanager.h 2016-10-25 07:08:37 +0000 |
1301 | @@ -23,7 +23,7 @@ |
1302 | #include <string> |
1303 | #include <vector> |
1304 | |
1305 | -#include "logic/constants.h" |
1306 | +#include "graphic/playercolor.h" |
1307 | #include "logic/widelands.h" |
1308 | |
1309 | namespace Widelands { |
1310 | @@ -76,12 +76,12 @@ |
1311 | TeamNumber team = 0); |
1312 | Player* get_player(int32_t n) const { |
1313 | assert(1 <= n); |
1314 | - assert(n <= MAX_PLAYERS); |
1315 | + assert(n <= kMaxPlayers); |
1316 | return players_[n - 1]; |
1317 | } |
1318 | Player& player(int32_t n) const { |
1319 | assert(1 <= n); |
1320 | - assert(n <= MAX_PLAYERS); |
1321 | + assert(n <= kMaxPlayers); |
1322 | return *players_[n - 1]; |
1323 | } |
1324 | |
1325 | @@ -107,7 +107,7 @@ |
1326 | void set_player_end_status(const PlayerEndStatus& status); |
1327 | |
1328 | private: |
1329 | - Player* players_[MAX_PLAYERS]; |
1330 | + Player* players_[kMaxPlayers]; |
1331 | EditorGameBase& egbase_; |
1332 | uint8_t number_of_players_; |
1333 | std::vector<PlayerEndStatus> players_end_status_; |
1334 | |
1335 | === modified file 'src/logic/widelands.h' |
1336 | --- src/logic/widelands.h 2016-08-04 15:49:05 +0000 |
1337 | +++ src/logic/widelands.h 2016-10-25 07:08:37 +0000 |
1338 | @@ -33,7 +33,9 @@ |
1339 | // Type definitions for the game logic. |
1340 | using MilitaryInfluence = uint16_t; |
1341 | |
1342 | -using PlayerNumber = uint8_t; /// 5 bits used, so 0 .. 31 |
1343 | +/// 5 bits used, so 0 .. 31 |
1344 | +/// Data type must match kMaxPlayers in graphics/playercolor.h |
1345 | +using PlayerNumber = uint8_t; |
1346 | inline PlayerNumber neutral() { |
1347 | return 0; |
1348 | } |
1349 | |
1350 | === modified file 'src/map_io/CMakeLists.txt' |
1351 | --- src/map_io/CMakeLists.txt 2016-02-20 11:29:55 +0000 |
1352 | +++ src/map_io/CMakeLists.txt 2016-10-25 07:08:37 +0000 |
1353 | @@ -96,6 +96,7 @@ |
1354 | graphic |
1355 | graphic_image_io |
1356 | graphic_minimap_renderer |
1357 | + graphic_playercolor |
1358 | graphic_surface |
1359 | helper |
1360 | io_fileread |
1361 | |
1362 | === modified file 'src/map_io/map_elemental_packet.cc' |
1363 | --- src/map_io/map_elemental_packet.cc 2016-08-04 15:49:05 +0000 |
1364 | +++ src/map_io/map_elemental_packet.cc 2016-10-25 07:08:37 +0000 |
1365 | @@ -30,7 +30,8 @@ |
1366 | |
1367 | namespace Widelands { |
1368 | |
1369 | -constexpr int32_t kCurrentPacketVersion = 1; |
1370 | +constexpr int32_t kEightPlayersPacketVersion = 1; |
1371 | +constexpr int32_t kSixteenPlayersPacketVersion = 2; |
1372 | |
1373 | void MapElementalPacket::pre_read(FileSystem& fs, Map* map) { |
1374 | Profile prof; |
1375 | @@ -39,7 +40,8 @@ |
1376 | |
1377 | try { |
1378 | int32_t const packet_version = s.get_int("packet_version"); |
1379 | - if (packet_version == kCurrentPacketVersion) { |
1380 | + if (packet_version >= kEightPlayersPacketVersion && |
1381 | + packet_version <= kSixteenPlayersPacketVersion) { |
1382 | map->width_ = s.get_int("map_w"); |
1383 | map->height_ = s.get_int("map_h"); |
1384 | map->set_nrplayers(s.get_int("nr_players")); |
1385 | @@ -85,7 +87,7 @@ |
1386 | |
1387 | for (const std::string& player : players_string) { |
1388 | PlayerNumber player_number = static_cast<PlayerNumber>(atoi(player.c_str())); |
1389 | - assert(player_number < MAX_PLAYERS); |
1390 | + assert(player_number < kMaxPlayers); |
1391 | team.push_back(player_number); |
1392 | } |
1393 | |
1394 | @@ -104,7 +106,8 @@ |
1395 | teamsection_key = (boost::format("teams%02i") % team_section_id).str().c_str(); |
1396 | } |
1397 | } else |
1398 | - throw UnhandledVersionError("MapElementalPacket", packet_version, kCurrentPacketVersion); |
1399 | + throw UnhandledVersionError( |
1400 | + "MapElementalPacket", packet_version, kEightPlayersPacketVersion); |
1401 | } catch (const WException& e) { |
1402 | throw GameDataError("elemental data: %s", e.what()); |
1403 | } |
1404 | @@ -119,11 +122,17 @@ |
1405 | Profile prof; |
1406 | Section& global_section = prof.create_section("global"); |
1407 | |
1408 | - global_section.set_int("packet_version", kCurrentPacketVersion); |
1409 | const Map& map = egbase.map(); |
1410 | + Widelands::PlayerNumber nr_players = map.get_nrplayers(); |
1411 | + |
1412 | + // Maps with more than 8 players won't be compatible with older versions of Widelands. |
1413 | + // The packet format itself hasn't changed, so we always want to allow loading maps with <= 8 |
1414 | + // players. |
1415 | + global_section.set_int("packet_version", nr_players <= 8 ? kEightPlayersPacketVersion : |
1416 | + kSixteenPlayersPacketVersion); |
1417 | global_section.set_int("map_w", map.get_width()); |
1418 | global_section.set_int("map_h", map.get_height()); |
1419 | - global_section.set_int("nr_players", map.get_nrplayers()); |
1420 | + global_section.set_int("nr_players", nr_players); |
1421 | global_section.set_string("name", map.get_name()); |
1422 | global_section.set_string("author", map.get_author()); |
1423 | global_section.set_string("descr", map.get_description()); |
1424 | |
1425 | === modified file 'src/map_io/map_exploration_packet.cc' |
1426 | --- src/map_io/map_exploration_packet.cc 2016-08-04 15:49:05 +0000 |
1427 | +++ src/map_io/map_exploration_packet.cc 2016-10-25 07:08:37 +0000 |
1428 | @@ -22,7 +22,6 @@ |
1429 | #include "base/log.h" |
1430 | #include "io/fileread.h" |
1431 | #include "io/filewrite.h" |
1432 | -#include "logic/constants.h" |
1433 | #include "logic/editor_game_base.h" |
1434 | #include "logic/game_data_error.h" |
1435 | #include "logic/map.h" |
1436 | @@ -50,7 +49,7 @@ |
1437 | } |
1438 | } |
1439 | |
1440 | - static_assert(MAX_PLAYERS < 32, "assert(MAX_PLAYERS < 32) failed."); |
1441 | + static_assert(kMaxPlayers < 32, "assert(MAX_PLAYERS < 32) failed."); |
1442 | Map& map = egbase.map(); |
1443 | PlayerNumber const nr_players = map.get_nrplayers(); |
1444 | MapIndex const max_index = map.max_index(); |
1445 | @@ -82,7 +81,7 @@ |
1446 | |
1447 | fw.unsigned_16(kCurrentPacketVersion); |
1448 | |
1449 | - static_assert(MAX_PLAYERS < 32, "assert(MAX_PLAYERS < 32) failed."); |
1450 | + static_assert(kMaxPlayers < 32, "assert(MAX_PLAYERS < 32) failed."); |
1451 | Map& map = egbase.map(); |
1452 | PlayerNumber const nr_players = map.get_nrplayers(); |
1453 | MapIndex const max_index = map.max_index(); |
1454 | |
1455 | === modified file 'src/map_io/map_object_saver.h' |
1456 | --- src/map_io/map_object_saver.h 2016-08-04 15:49:05 +0000 |
1457 | +++ src/map_io/map_object_saver.h 2016-10-25 07:08:37 +0000 |
1458 | @@ -23,7 +23,7 @@ |
1459 | #include <map> |
1460 | #include <string> |
1461 | |
1462 | -#include "logic/constants.h" |
1463 | +#include "graphic/playercolor.h" |
1464 | #include "logic/widelands.h" |
1465 | #include "map_io/map_message_saver.h" |
1466 | |
1467 | @@ -76,7 +76,7 @@ |
1468 | bool is_object_saved(const MapObject&); |
1469 | |
1470 | /// \note Indexed by player number - 1. |
1471 | - MapMessageSaver message_savers[MAX_PLAYERS]; |
1472 | + MapMessageSaver message_savers[kMaxPlayers]; |
1473 | |
1474 | private: |
1475 | struct MapObjectRec { |
1476 | |
1477 | === modified file 'src/network/CMakeLists.txt' |
1478 | --- src/network/CMakeLists.txt 2016-02-06 11:11:24 +0000 |
1479 | +++ src/network/CMakeLists.txt 2016-10-25 07:08:37 +0000 |
1480 | @@ -31,6 +31,7 @@ |
1481 | build_info |
1482 | chat |
1483 | game_io |
1484 | + graphic_playercolor |
1485 | helper |
1486 | io_fileread |
1487 | io_filesystem |
1488 | |
1489 | === modified file 'src/network/network_player_settings_backend.h' |
1490 | --- src/network/network_player_settings_backend.h 2016-08-04 15:49:05 +0000 |
1491 | +++ src/network/network_player_settings_backend.h 2016-10-25 07:08:37 +0000 |
1492 | @@ -20,13 +20,13 @@ |
1493 | #ifndef WL_NETWORK_NETWORK_PLAYER_SETTINGS_BACKEND_H |
1494 | #define WL_NETWORK_NETWORK_PLAYER_SETTINGS_BACKEND_H |
1495 | |
1496 | -#include "logic/constants.h" |
1497 | +#include "graphic/playercolor.h" |
1498 | #include "logic/game_settings.h" |
1499 | |
1500 | struct NetworkPlayerSettingsBackend { |
1501 | |
1502 | NetworkPlayerSettingsBackend(GameSettingsProvider* const settings) : s(settings) { |
1503 | - for (uint8_t i = 0; i < MAX_PLAYERS; ++i) |
1504 | + for (uint8_t i = 0; i < kMaxPlayers; ++i) |
1505 | shared_in_tribe[i] = std::string(); |
1506 | } |
1507 | |
1508 | @@ -37,7 +37,7 @@ |
1509 | void refresh(uint8_t id); |
1510 | |
1511 | GameSettingsProvider* const s; |
1512 | - std::string shared_in_tribe[MAX_PLAYERS]; |
1513 | + std::string shared_in_tribe[kMaxPlayers]; |
1514 | }; |
1515 | |
1516 | #endif // end of include guard: WL_NETWORK_NETWORK_PLAYER_SETTINGS_BACKEND_H |
1517 | |
1518 | === modified file 'src/scripting/lua_bases.cc' |
1519 | --- src/scripting/lua_bases.cc 2016-08-04 15:49:05 +0000 |
1520 | +++ src/scripting/lua_bases.cc 2016-10-25 07:08:37 +0000 |
1521 | @@ -22,7 +22,6 @@ |
1522 | #include <boost/format.hpp> |
1523 | |
1524 | #include "economy/economy.h" |
1525 | -#include "logic/constants.h" |
1526 | #include "logic/map_objects/checkstep.h" |
1527 | #include "logic/map_objects/tribes/tribe_descr.h" |
1528 | #include "logic/map_objects/tribes/tribes.h" |
1529 | @@ -132,7 +131,7 @@ |
1530 | lua_newtable(L); |
1531 | |
1532 | uint32_t idx = 1; |
1533 | - for (PlayerNumber i = 1; i <= MAX_PLAYERS; i++) { |
1534 | + for (PlayerNumber i = 1; i <= kMaxPlayers; i++) { |
1535 | Player* rv = egbase.get_player(i); |
1536 | if (!rv) |
1537 | continue; |
1538 | @@ -695,7 +694,7 @@ |
1539 | ========================================================== |
1540 | */ |
1541 | Player& LuaPlayerBase::get(lua_State* L, Widelands::EditorGameBase& egbase) { |
1542 | - if (player_number_ > MAX_PLAYERS) |
1543 | + if (player_number_ > kMaxPlayers) |
1544 | report_error(L, "Illegal player number %i", player_number_); |
1545 | Player* rv = egbase.get_player(player_number_); |
1546 | if (!rv) |
1547 | |
1548 | === modified file 'src/scripting/lua_game.cc' |
1549 | --- src/scripting/lua_game.cc 2016-10-15 16:36:12 +0000 |
1550 | +++ src/scripting/lua_game.cc 2016-10-25 07:08:37 +0000 |
1551 | @@ -26,7 +26,6 @@ |
1552 | #include "economy/economy.h" |
1553 | #include "economy/flag.h" |
1554 | #include "logic/campaign_visibility.h" |
1555 | -#include "logic/constants.h" |
1556 | #include "logic/game_controller.h" |
1557 | #include "logic/map_objects/tribes/tribe_descr.h" |
1558 | #include "logic/message.h" |
1559 | @@ -1250,7 +1249,7 @@ |
1560 | ========================================================== |
1561 | */ |
1562 | Player& LuaMessage::get_plr(lua_State* L, Widelands::Game& game) { |
1563 | - if (player_number_ > MAX_PLAYERS) |
1564 | + if (player_number_ > kMaxPlayers) |
1565 | report_error(L, "Illegal player number %i", player_number_); |
1566 | Player* rv = game.get_player(player_number_); |
1567 | if (!rv) |
1568 | |
1569 | === modified file 'src/ui_fsmenu/CMakeLists.txt' |
1570 | --- src/ui_fsmenu/CMakeLists.txt 2016-03-10 12:57:08 +0000 |
1571 | +++ src/ui_fsmenu/CMakeLists.txt 2016-10-25 07:08:37 +0000 |
1572 | @@ -44,6 +44,7 @@ |
1573 | game_io |
1574 | graphic |
1575 | graphic_image_io |
1576 | + graphic_playercolor |
1577 | graphic_surface |
1578 | graphic_text |
1579 | graphic_text_layout |
1580 | |
1581 | === modified file 'src/ui_fsmenu/launch_mpg.cc' |
1582 | --- src/ui_fsmenu/launch_mpg.cc 2016-10-24 14:04:00 +0000 |
1583 | +++ src/ui_fsmenu/launch_mpg.cc 2016-10-25 07:08:37 +0000 |
1584 | @@ -26,9 +26,9 @@ |
1585 | #include "base/i18n.h" |
1586 | #include "base/warning.h" |
1587 | #include "graphic/graphic.h" |
1588 | +#include "graphic/playercolor.h" |
1589 | #include "graphic/text_constants.h" |
1590 | #include "io/filesystem/layered_filesystem.h" |
1591 | -#include "logic/constants.h" |
1592 | #include "logic/game.h" |
1593 | #include "logic/game_controller.h" |
1594 | #include "logic/game_settings.h" |
1595 | @@ -214,7 +214,7 @@ |
1596 | map_info_.set_text(_("The host has not yet selected a map or saved game.")); |
1597 | |
1598 | mpsg_ = new MultiPlayerSetupGroup( |
1599 | - this, get_w() / 50, get_h() / 8, get_w() * 57 / 80, get_h() / 2, settings, butw_, buth_); |
1600 | + this, get_w() / 50, get_h() / 8, get_w() * 57 / 80, get_h(), settings, butw_, buth_); |
1601 | |
1602 | // If we are the host, open the map or save selection menu at startup |
1603 | if (settings_->settings().usernum == 0 && settings_->settings().mapname.empty()) { |
1604 | @@ -481,7 +481,7 @@ |
1605 | } else { |
1606 | // Write client infos |
1607 | std::string client_info = |
1608 | - (settings.playernum >= 0) && (settings.playernum < MAX_PLAYERS) ? |
1609 | + (settings.playernum >= 0) && (settings.playernum < kMaxPlayers) ? |
1610 | (boost::format(_("You are Player %i.")) % (settings.playernum + 1)).str() : |
1611 | _("You are a spectator."); |
1612 | client_info_.set_text(client_info); |
1613 | @@ -538,9 +538,9 @@ |
1614 | Profile prof; |
1615 | prof.read("map/player_names", nullptr, *l_fs); |
1616 | std::string infotext = _("Saved players are:"); |
1617 | - std::string player_save_name[MAX_PLAYERS]; |
1618 | - std::string player_save_tribe[MAX_PLAYERS]; |
1619 | - std::string player_save_ai[MAX_PLAYERS]; |
1620 | + std::string player_save_name[kMaxPlayers]; |
1621 | + std::string player_save_tribe[kMaxPlayers]; |
1622 | + std::string player_save_ai[kMaxPlayers]; |
1623 | |
1624 | uint8_t i = 1; |
1625 | for (; i <= nr_players_; ++i) { |
1626 | |
1627 | === modified file 'src/ui_fsmenu/launch_spg.cc' |
1628 | --- src/ui_fsmenu/launch_spg.cc 2016-09-25 12:24:46 +0000 |
1629 | +++ src/ui_fsmenu/launch_spg.cc 2016-10-25 07:08:37 +0000 |
1630 | @@ -30,7 +30,6 @@ |
1631 | #include "graphic/text_constants.h" |
1632 | #include "helper.h" |
1633 | #include "io/filesystem/layered_filesystem.h" |
1634 | -#include "logic/constants.h" |
1635 | #include "logic/game.h" |
1636 | #include "logic/game_controller.h" |
1637 | #include "logic/game_settings.h" |
1638 | @@ -44,18 +43,6 @@ |
1639 | #include "ui_fsmenu/mapselect.h" |
1640 | #include "wui/playerdescrgroup.h" |
1641 | |
1642 | -namespace { |
1643 | -static char const* const player_pictures_small[] = { |
1644 | - "images/players/fsel_editor_set_player_01_pos.png", |
1645 | - "images/players/fsel_editor_set_player_02_pos.png", |
1646 | - "images/players/fsel_editor_set_player_03_pos.png", |
1647 | - "images/players/fsel_editor_set_player_04_pos.png", |
1648 | - "images/players/fsel_editor_set_player_05_pos.png", |
1649 | - "images/players/fsel_editor_set_player_06_pos.png", |
1650 | - "images/players/fsel_editor_set_player_07_pos.png", |
1651 | - "images/players/fsel_editor_set_player_08_pos.png"}; |
1652 | -} // namespace |
1653 | - |
1654 | FullscreenMenuLaunchSPG::FullscreenMenuLaunchSPG(GameSettingsProvider* const settings, |
1655 | GameController* const ctrl, |
1656 | bool /* autolaunch */) |
1657 | @@ -160,8 +147,10 @@ |
1658 | init_.set_fontsize(smaller_fontsize); |
1659 | |
1660 | uint32_t y = get_h() * 3 / 10 - buth_; |
1661 | - for (uint32_t i = 0; i < MAX_PLAYERS; ++i) { |
1662 | - const Image* player_image = g_gr->images().get(player_pictures_small[i]); |
1663 | + for (uint32_t i = 0; i < kMaxPlayers; ++i) { |
1664 | + const Image* player_image = |
1665 | + playercolor_image(i, g_gr->images().get("images/players/player_position_menu.png"), |
1666 | + g_gr->images().get("images/players/player_position_menu_pc.png")); |
1667 | assert(player_image); |
1668 | |
1669 | pos_[i] = |
1670 | @@ -334,11 +323,11 @@ |
1671 | pos_[i]->set_enabled(!is_scenario_ && (player.state == PlayerSettings::stateOpen || |
1672 | player.state == PlayerSettings::stateComputer)); |
1673 | } |
1674 | - for (uint32_t i = nr_players_; i < MAX_PLAYERS; ++i) |
1675 | + for (uint32_t i = nr_players_; i < kMaxPlayers; ++i) |
1676 | pos_[i]->set_visible(false); |
1677 | |
1678 | // update the player description groups |
1679 | - for (uint32_t i = 0; i < MAX_PLAYERS; ++i) |
1680 | + for (uint32_t i = 0; i < kMaxPlayers; ++i) |
1681 | players_[i]->refresh(); |
1682 | |
1683 | win_condition_update(); |
1684 | |
1685 | === modified file 'src/ui_fsmenu/launch_spg.h' |
1686 | --- src/ui_fsmenu/launch_spg.h 2016-08-04 15:49:05 +0000 |
1687 | +++ src/ui_fsmenu/launch_spg.h 2016-10-25 07:08:37 +0000 |
1688 | @@ -22,7 +22,7 @@ |
1689 | |
1690 | #include <string> |
1691 | |
1692 | -#include "logic/constants.h" |
1693 | +#include "graphic/playercolor.h" |
1694 | #include "ui_basic/button.h" |
1695 | #include "ui_basic/multilinetextarea.h" |
1696 | #include "ui_basic/textarea.h" |
1697 | @@ -75,16 +75,16 @@ |
1698 | uint32_t buth_; |
1699 | |
1700 | UI::Button select_map_, wincondition_, back_, ok_; |
1701 | - UI::Button* pos_[MAX_PLAYERS]; |
1702 | + UI::Button* pos_[kMaxPlayers]; |
1703 | UI::Textarea title_, mapname_; |
1704 | UI::Textarea name_, type_, team_, tribe_, init_, wincondition_type_; |
1705 | GameSettingsProvider* settings_; |
1706 | GameController* ctrl_; // optional |
1707 | - PlayerDescriptionGroup* players_[MAX_PLAYERS]; |
1708 | + PlayerDescriptionGroup* players_[kMaxPlayers]; |
1709 | std::string filename_; |
1710 | std::string filename_proof_; // local var. to check UI state |
1711 | - std::string player_save_name_[MAX_PLAYERS]; |
1712 | - std::string player_save_tribe_[MAX_PLAYERS]; |
1713 | + std::string player_save_name_[kMaxPlayers]; |
1714 | + std::string player_save_tribe_[kMaxPlayers]; |
1715 | int8_t nr_players_; |
1716 | bool is_scenario_; |
1717 | std::vector<std::string> win_condition_scripts_; |
1718 | |
1719 | === modified file 'src/wui/CMakeLists.txt' |
1720 | --- src/wui/CMakeLists.txt 2016-10-24 14:04:00 +0000 |
1721 | +++ src/wui/CMakeLists.txt 2016-10-25 07:08:37 +0000 |
1722 | @@ -71,6 +71,7 @@ |
1723 | base_i18n |
1724 | base_log |
1725 | graphic |
1726 | + graphic_playercolor |
1727 | graphic_text_layout |
1728 | io_filesystem |
1729 | logic |
1730 | @@ -218,12 +219,14 @@ |
1731 | graphic |
1732 | graphic_color |
1733 | graphic_minimap_renderer |
1734 | + graphic_playercolor |
1735 | graphic_surface |
1736 | graphic_text |
1737 | graphic_text_layout |
1738 | io_fileread |
1739 | io_filesystem |
1740 | logic |
1741 | + logic_constants |
1742 | logic_game_controller |
1743 | logic_game_settings |
1744 | logic_widelands_geometry |
1745 | |
1746 | === modified file 'src/wui/chat_msg_layout.cc' |
1747 | --- src/wui/chat_msg_layout.cc 2016-08-04 15:49:05 +0000 |
1748 | +++ src/wui/chat_msg_layout.cc 2016-10-25 07:08:37 +0000 |
1749 | @@ -24,15 +24,14 @@ |
1750 | #include "chat/chat.h" |
1751 | #include "graphic/color.h" |
1752 | #include "graphic/text_layout.h" |
1753 | -#include "logic/constants.h" |
1754 | #include "logic/player.h" |
1755 | |
1756 | namespace { |
1757 | |
1758 | // Returns the hexcolor for the 'player'. |
1759 | std::string color(const int16_t playern) { |
1760 | - if ((playern >= 0) && playern < MAX_PLAYERS) { |
1761 | - const RGBColor& clr = Widelands::Player::Colors[playern]; |
1762 | + if ((playern >= 0) && playern < kMaxPlayers) { |
1763 | + const RGBColor& clr = kPlayerColors[playern]; |
1764 | char buf[sizeof("ffffff")]; |
1765 | snprintf(buf, sizeof(buf), "%.2x%.2x%.2x", clr.r, clr.g, clr.b); |
1766 | return buf; |
1767 | |
1768 | === modified file 'src/wui/game_summary.cc' |
1769 | --- src/wui/game_summary.cc 2016-08-04 15:49:05 +0000 |
1770 | +++ src/wui/game_summary.cc 2016-10-25 07:08:37 +0000 |
1771 | @@ -24,6 +24,7 @@ |
1772 | |
1773 | #include "base/time_string.h" |
1774 | #include "graphic/graphic.h" |
1775 | +#include "graphic/playercolor.h" |
1776 | #include "logic/game.h" |
1777 | #include "logic/player.h" |
1778 | #include "logic/playersmanager.h" |
1779 | @@ -36,14 +37,6 @@ |
1780 | #include "wui/interactive_gamebase.h" |
1781 | #include "wui/interactive_player.h" |
1782 | |
1783 | -namespace { |
1784 | -static char const* const flag_pictures[] = { |
1785 | - "images/players/genstats_enable_plr_01.png", "images/players/genstats_enable_plr_02.png", |
1786 | - "images/players/genstats_enable_plr_03.png", "images/players/genstats_enable_plr_04.png", |
1787 | - "images/players/genstats_enable_plr_05.png", "images/players/genstats_enable_plr_06.png", |
1788 | - "images/players/genstats_enable_plr_07.png", "images/players/genstats_enable_plr_08.png"}; |
1789 | -} // namespace |
1790 | - |
1791 | #define PADDING 4 |
1792 | |
1793 | GameSummaryScreen::GameSummaryScreen(InteractiveGameBase* parent, UI::UniqueWindow::Registry* r) |
1794 | @@ -153,7 +146,9 @@ |
1795 | Widelands::Player* p = game_.get_player(pes.player); |
1796 | UI::Table<uintptr_t const>::EntryRecord& te = players_table_->add(i); |
1797 | // Player name & pic |
1798 | - const Image* player_image = g_gr->images().get(flag_pictures[pes.player - 1]); |
1799 | + const Image* player_image = |
1800 | + playercolor_image(pes.player - 1, g_gr->images().get("images/players/genstats_player.png"), |
1801 | + g_gr->images().get("images/players/genstats_player_pc.png")); |
1802 | assert(player_image); |
1803 | te.set_picture(0, player_image, p->get_name()); |
1804 | // Team |
1805 | |
1806 | === modified file 'src/wui/general_statistics_menu.cc' |
1807 | --- src/wui/general_statistics_menu.cc 2016-10-24 14:07:28 +0000 |
1808 | +++ src/wui/general_statistics_menu.cc 2016-10-25 07:08:37 +0000 |
1809 | @@ -41,14 +41,6 @@ |
1810 | #include "ui_basic/textarea.h" |
1811 | #include "wui/interactive_player.h" |
1812 | |
1813 | -namespace { |
1814 | -static char const* const flag_pictures[] = { |
1815 | - "images/players/genstats_enable_plr_01.png", "images/players/genstats_enable_plr_02.png", |
1816 | - "images/players/genstats_enable_plr_03.png", "images/players/genstats_enable_plr_04.png", |
1817 | - "images/players/genstats_enable_plr_05.png", "images/players/genstats_enable_plr_06.png", |
1818 | - "images/players/genstats_enable_plr_07.png", "images/players/genstats_enable_plr_08.png"}; |
1819 | -} // namespace |
1820 | - |
1821 | using namespace Widelands; |
1822 | |
1823 | #define PLOT_HEIGHT 130 |
1824 | @@ -85,7 +77,7 @@ |
1825 | } |
1826 | |
1827 | for (Game::GeneralStatsVector::size_type i = 0; i < general_statistics_size; ++i) { |
1828 | - const RGBColor& color = Player::Colors[i]; |
1829 | + const RGBColor& color = kPlayerColors[i]; |
1830 | plot_.register_plot_data(i * ndatasets_ + 0, &genstats[i].land_size, color); |
1831 | plot_.register_plot_data(i * ndatasets_ + 1, &genstats[i].nr_workers, color); |
1832 | plot_.register_plot_data(i * ndatasets_ + 2, &genstats[i].nr_buildings, color); |
1833 | @@ -116,7 +108,9 @@ |
1834 | iterate_players_existing_novar(p, nr_players, game)++ plr_in_game; |
1835 | |
1836 | iterate_players_existing_const(p, nr_players, game, player) { |
1837 | - const Image* player_image = g_gr->images().get(flag_pictures[p - 1]); |
1838 | + const Image* player_image = |
1839 | + playercolor_image(p - 1, g_gr->images().get("images/players/genstats_player.png"), |
1840 | + g_gr->images().get("images/players/genstats_player_pc.png")); |
1841 | assert(player_image); |
1842 | UI::Button& cb = *new UI::Button(hbox1, "playerbutton", 0, 0, 25, 25, |
1843 | g_gr->images().get("images/ui_basic/but4.png"), player_image, |
1844 | |
1845 | === modified file 'src/wui/general_statistics_menu.h' |
1846 | --- src/wui/general_statistics_menu.h 2016-08-04 15:49:05 +0000 |
1847 | +++ src/wui/general_statistics_menu.h 2016-10-25 07:08:37 +0000 |
1848 | @@ -20,7 +20,7 @@ |
1849 | #ifndef WL_WUI_GENERAL_STATISTICS_MENU_H |
1850 | #define WL_WUI_GENERAL_STATISTICS_MENU_H |
1851 | |
1852 | -#include "logic/constants.h" |
1853 | +#include "graphic/playercolor.h" |
1854 | #include "ui_basic/box.h" |
1855 | #include "ui_basic/button.h" |
1856 | #include "ui_basic/radiobutton.h" |
1857 | @@ -39,7 +39,7 @@ |
1858 | Registry() |
1859 | : UI::UniqueWindow::Registry(), |
1860 | selected_information(0), |
1861 | - selected_players(true, MAX_PLAYERS), |
1862 | + selected_players(true, kMaxPlayers), |
1863 | time(WuiPlotArea::TIME_GAME) { |
1864 | } |
1865 | |
1866 | @@ -57,7 +57,7 @@ |
1867 | WuiPlotArea plot_; |
1868 | UI::Radiogroup radiogroup_; |
1869 | int32_t selected_information_; |
1870 | - UI::Button* cbs_[MAX_PLAYERS]; |
1871 | + UI::Button* cbs_[kMaxPlayers]; |
1872 | uint32_t ndatasets_; |
1873 | |
1874 | void clicked_help(); |
1875 | |
1876 | === modified file 'src/wui/interactive_base.cc' |
1877 | --- src/wui/interactive_base.cc 2016-10-24 12:35:30 +0000 |
1878 | +++ src/wui/interactive_base.cc 2016-10-25 07:08:37 +0000 |
1879 | @@ -196,12 +196,12 @@ |
1880 | /* |
1881 | * Set/Unset sel picture |
1882 | */ |
1883 | -void InteractiveBase::set_sel_picture(const char* const file) { |
1884 | - sel_.pic = g_gr->images().get(file); |
1885 | +void InteractiveBase::set_sel_picture(const Image* image) { |
1886 | + sel_.pic = image; |
1887 | set_sel_pos(get_sel_pos()); // redraw |
1888 | } |
1889 | void InteractiveBase::unset_sel_picture() { |
1890 | - set_sel_picture("images/ui_basic/fsel.png"); |
1891 | + set_sel_picture(g_gr->images().get("images/ui_basic/fsel.png")); |
1892 | } |
1893 | |
1894 | bool InteractiveBase::buildhelp() const { |
1895 | |
1896 | === modified file 'src/wui/interactive_base.h' |
1897 | --- src/wui/interactive_base.h 2016-10-22 18:19:22 +0000 |
1898 | +++ src/wui/interactive_base.h 2016-10-25 07:08:37 +0000 |
1899 | @@ -183,7 +183,7 @@ |
1900 | bool handle_key(bool down, SDL_Keysym) override; |
1901 | |
1902 | void unset_sel_picture(); |
1903 | - void set_sel_picture(const char* const); |
1904 | + void set_sel_picture(const Image* image); |
1905 | void adjust_toolbar_position() { |
1906 | toolbar_.set_pos(Vector2i((get_inner_w() - toolbar_.get_w()) >> 1, get_inner_h() - 34)); |
1907 | } |
1908 | |
1909 | === modified file 'src/wui/interactive_player.cc' |
1910 | --- src/wui/interactive_player.cc 2016-10-24 14:04:00 +0000 |
1911 | +++ src/wui/interactive_player.cc 2016-10-25 07:08:37 +0000 |
1912 | @@ -31,7 +31,6 @@ |
1913 | #include "economy/flag.h" |
1914 | #include "game_io/game_loader.h" |
1915 | #include "logic/cmd_queue.h" |
1916 | -#include "logic/constants.h" |
1917 | #include "logic/map_objects/immovable.h" |
1918 | #include "logic/map_objects/tribes/building.h" |
1919 | #include "logic/map_objects/tribes/constructionsite.h" |
1920 | @@ -364,7 +363,7 @@ |
1921 | } |
1922 | |
1923 | int const n = atoi(args[1].c_str()); |
1924 | - if (n < 1 || n > MAX_PLAYERS || !game().get_player(n)) { |
1925 | + if (n < 1 || n > kMaxPlayers || !game().get_player(n)) { |
1926 | DebugConsole::write(str(boost::format("Player #%1% does not exist.") % n)); |
1927 | return; |
1928 | } |
1929 | |
1930 | === modified file 'src/wui/multiplayersetupgroup.cc' |
1931 | --- src/wui/multiplayersetupgroup.cc 2016-10-10 14:05:13 +0000 |
1932 | +++ src/wui/multiplayersetupgroup.cc 2016-10-25 07:08:37 +0000 |
1933 | @@ -28,8 +28,8 @@ |
1934 | #include "base/log.h" |
1935 | #include "base/wexception.h" |
1936 | #include "graphic/graphic.h" |
1937 | +#include "graphic/playercolor.h" |
1938 | #include "graphic/text_constants.h" |
1939 | -#include "logic/constants.h" |
1940 | #include "logic/game.h" |
1941 | #include "logic/game_settings.h" |
1942 | #include "logic/map_objects/tribes/tribe_descr.h" |
1943 | @@ -40,23 +40,6 @@ |
1944 | #include "ui_basic/scrollbar.h" |
1945 | #include "ui_basic/textarea.h" |
1946 | |
1947 | -namespace { |
1948 | -static char const* const flag_pictures[] = { |
1949 | - "images/players/genstats_enable_plr_01.png", "images/players/genstats_enable_plr_02.png", |
1950 | - "images/players/genstats_enable_plr_03.png", "images/players/genstats_enable_plr_04.png", |
1951 | - "images/players/genstats_enable_plr_05.png", "images/players/genstats_enable_plr_06.png", |
1952 | - "images/players/genstats_enable_plr_07.png", "images/players/genstats_enable_plr_08.png"}; |
1953 | -static char const* const player_pictures_small[] = { |
1954 | - "images/players/fsel_editor_set_player_01_pos.png", |
1955 | - "images/players/fsel_editor_set_player_02_pos.png", |
1956 | - "images/players/fsel_editor_set_player_03_pos.png", |
1957 | - "images/players/fsel_editor_set_player_04_pos.png", |
1958 | - "images/players/fsel_editor_set_player_05_pos.png", |
1959 | - "images/players/fsel_editor_set_player_06_pos.png", |
1960 | - "images/players/fsel_editor_set_player_07_pos.png", |
1961 | - "images/players/fsel_editor_set_player_08_pos.png"}; |
1962 | -} // namespace |
1963 | - |
1964 | struct MultiPlayerClientGroup : public UI::Box { |
1965 | MultiPlayerClientGroup(UI::Panel* const parent, |
1966 | uint8_t id, |
1967 | @@ -117,25 +100,27 @@ |
1968 | } else { |
1969 | name->set_text(us.name); |
1970 | if (save_ != us.position) { |
1971 | - std::string pic; |
1972 | + const Image* position_image; |
1973 | std::string temp_tooltip; |
1974 | if (us.position < UserSettings::highest_playernum()) { |
1975 | - pic = flag_pictures[us.position]; |
1976 | + position_image = playercolor_image( |
1977 | + us.position, g_gr->images().get("images/players/genstats_player.png"), |
1978 | + g_gr->images().get("images/players/genstats_player_pc.png")); |
1979 | temp_tooltip = |
1980 | (boost::format(_("Player %u")) % static_cast<unsigned int>(us.position + 1)) |
1981 | .str(); |
1982 | } else { |
1983 | - pic = "images/wui/fieldaction/menu_tab_watch.png"; |
1984 | + position_image = g_gr->images().get("images/wui/fieldaction/menu_tab_watch.png"); |
1985 | temp_tooltip = _("Spectator"); |
1986 | } |
1987 | |
1988 | // Either Button if changeable OR text if not |
1989 | if (id_ == s->settings().usernum) { |
1990 | - type->set_pic(g_gr->images().get(pic)); |
1991 | + type->set_pic(position_image); |
1992 | type->set_tooltip(temp_tooltip); |
1993 | type->set_visible(true); |
1994 | } else { |
1995 | - type_icon->set_icon(g_gr->images().get(pic)); |
1996 | + type_icon->set_icon(position_image); |
1997 | type_icon->set_tooltip(temp_tooltip); |
1998 | type_icon->set_visible(true); |
1999 | } |
2000 | @@ -174,7 +159,9 @@ |
2001 | tribepics_(tp), |
2002 | tribenames_(tn) { |
2003 | set_size(w, h); |
2004 | - const Image* player_image = g_gr->images().get(player_pictures_small[id]); |
2005 | + const Image* player_image = |
2006 | + playercolor_image(id, g_gr->images().get("images/players/player_position_menu.png"), |
2007 | + g_gr->images().get("images/players/player_position_menu_pc.png")); |
2008 | assert(player_image); |
2009 | player = new UI::Icon(this, 0, 0, h, h, player_image); |
2010 | add(player, UI::Align::kHCenter); |
2011 | @@ -266,7 +253,9 @@ |
2012 | type->set_tooltip(_("Shared in")); |
2013 | type->set_pic(g_gr->images().get("images/ui_fsmenu/shared_in.png")); |
2014 | const Image* player_image = |
2015 | - g_gr->images().get(player_pictures_small[player_setting.shared_in - 1]); |
2016 | + playercolor_image(player_setting.shared_in - 1, |
2017 | + g_gr->images().get("images/players/player_position_menu.png"), |
2018 | + g_gr->images().get("images/players/player_position_menu_pc.png")); |
2019 | assert(player_image); |
2020 | tribe->set_pic(player_image); |
2021 | tribe->set_tooltip( |
2022 | @@ -420,7 +409,7 @@ |
2023 | labels.back()->set_fontsize(small_font); |
2024 | |
2025 | playerbox.set_size(w * 9 / 15, h - buth); |
2026 | - multi_player_player_groups.resize(MAX_PLAYERS); |
2027 | + multi_player_player_groups.resize(kMaxPlayers); |
2028 | for (uint8_t i = 0; i < multi_player_player_groups.size(); ++i) { |
2029 | multi_player_player_groups.at(i) = new MultiPlayerPlayerGroup( |
2030 | &playerbox, i, 0, 0, playerbox.get_w(), buth, s, npsb.get(), tribepics_, tribenames_); |
2031 | @@ -452,7 +441,7 @@ |
2032 | } |
2033 | |
2034 | // Update player groups |
2035 | - for (uint32_t i = 0; i < MAX_PLAYERS; ++i) { |
2036 | + for (uint32_t i = 0; i < kMaxPlayers; ++i) { |
2037 | multi_player_player_groups.at(i)->refresh(); |
2038 | } |
2039 | } |
2040 | |
2041 | === modified file 'src/wui/suggested_teams_box.cc' |
2042 | --- src/wui/suggested_teams_box.cc 2016-08-04 15:49:05 +0000 |
2043 | +++ src/wui/suggested_teams_box.cc 2016-10-25 07:08:37 +0000 |
2044 | @@ -23,18 +23,7 @@ |
2045 | #include <string> |
2046 | |
2047 | #include "graphic/graphic.h" |
2048 | - |
2049 | -namespace { |
2050 | -static char const* const player_pictures_small[] = { |
2051 | - "images/players/fsel_editor_set_player_01_pos.png", |
2052 | - "images/players/fsel_editor_set_player_02_pos.png", |
2053 | - "images/players/fsel_editor_set_player_03_pos.png", |
2054 | - "images/players/fsel_editor_set_player_04_pos.png", |
2055 | - "images/players/fsel_editor_set_player_05_pos.png", |
2056 | - "images/players/fsel_editor_set_player_06_pos.png", |
2057 | - "images/players/fsel_editor_set_player_07_pos.png", |
2058 | - "images/players/fsel_editor_set_player_08_pos.png"}; |
2059 | -} // namespace |
2060 | +#include "graphic/playercolor.h" |
2061 | |
2062 | namespace UI { |
2063 | |
2064 | @@ -52,10 +41,11 @@ |
2065 | orientation, |
2066 | max_x, |
2067 | max_y, |
2068 | - g_gr->images().get(player_pictures_small[0])->height()), |
2069 | + g_gr->images().get("images/players/player_position_menu.png")->height()), |
2070 | padding_(padding), |
2071 | indent_(indent), |
2072 | - label_height_(g_gr->images().get(player_pictures_small[0])->height() + padding) { |
2073 | + label_height_(g_gr->images().get("images/players/player_position_menu.png")->height() + |
2074 | + padding) { |
2075 | player_icons_.clear(); |
2076 | suggested_teams_.clear(); |
2077 | set_size(max_x, max_y); |
2078 | @@ -128,8 +118,11 @@ |
2079 | is_first = false; |
2080 | |
2081 | for (Widelands::PlayerNumber player : team) { |
2082 | - assert(player < MAX_PLAYERS); |
2083 | - const Image* player_image = g_gr->images().get(player_pictures_small[player]); |
2084 | + assert(player < kMaxPlayers); |
2085 | + const Image* player_image = playercolor_image( |
2086 | + player, g_gr->images().get("images/players/player_position_menu.png"), |
2087 | + g_gr->images().get("images/players/player_position_menu_pc.png")); |
2088 | + |
2089 | assert(player_image); |
2090 | player_icon = new UI::Icon( |
2091 | lineup_box_, 0, 0, player_image->width(), player_image->height(), player_image); |
Looks good, I just noticed one small issue with localization, I will send you a screenshot.
I have not looked at code (yet)