Merge lp:~widelands-dev/widelands/font_size-lua into lp:widelands
- font_size-lua
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 9126 | ||||
Proposed branch: | lp:~widelands-dev/widelands/font_size-lua | ||||
Merge into: | lp:widelands | ||||
Diff against target: |
7424 lines (+2687/-1172) 134 files modified
data/templates/default/init.lua (+600/-17) src/CMakeLists.txt (+0/-1) src/editor/tools/info_tool.cc (+20/-19) src/editor/ui_menus/main_menu_load_or_save_map.cc (+1/-1) src/editor/ui_menus/main_menu_map_options.cc (+4/-3) src/editor/ui_menus/main_menu_random_map.cc (+7/-10) src/editor/ui_menus/main_menu_save_map.cc (+1/-1) src/editor/ui_menus/main_menu_save_map_make_directory.cc (+1/-1) src/editor/ui_menus/player_menu.cc (+13/-8) src/editor/ui_menus/tool_change_resources_options_menu.cc (+1/-1) src/graphic/CMakeLists.txt (+5/-19) src/graphic/align.cc (+48/-1) src/graphic/align.h (+8/-0) src/graphic/font_handler.cc (+1/-1) src/graphic/graphic.cc (+0/-1) src/graphic/panel_styles.cc (+0/-1) src/graphic/rendertarget.cc (+1/-1) src/graphic/style_manager.cc (+245/-49) src/graphic/style_manager.h (+42/-7) src/graphic/styles/CMakeLists.txt (+18/-0) src/graphic/styles/building_statistics_style.h (+99/-0) src/graphic/styles/button_style.h (+65/-0) src/graphic/styles/font_style.cc (+130/-0) src/graphic/styles/font_style.h (+97/-0) src/graphic/styles/panel_styles.h (+29/-23) src/graphic/styles/progress_bar_style.h (+69/-0) src/graphic/styles/statistics_plot_style.h (+68/-0) src/graphic/styles/table_style.h (+47/-0) src/graphic/styles/text_panel_style.h (+61/-0) src/graphic/styles/ware_info_style.h (+80/-0) src/graphic/text/CMakeLists.txt (+0/-1) src/graphic/text/font_set.cc (+1/-0) src/graphic/text/font_set.h (+2/-2) src/graphic/text/rendered_text.cc (+0/-1) src/graphic/text/rt_render.cc (+20/-6) src/graphic/text/rt_render.h (+2/-2) src/graphic/text_constants.cc (+0/-1) src/graphic/text_constants.h (+0/-50) src/graphic/text_layout.cc (+127/-192) src/graphic/text_layout.h (+37/-68) src/graphic/wordwrap.cc (+25/-1) src/graphic/wordwrap.h (+4/-4) src/io/filesystem/filesystem.cc (+2/-2) src/logic/map_objects/CMakeLists.txt (+0/-1) src/logic/map_objects/immovable.cc (+1/-4) src/logic/map_objects/map_object.cc (+10/-4) src/logic/map_objects/tribes/building.cc (+5/-5) src/logic/map_objects/tribes/constructionsite.cc (+1/-4) src/logic/map_objects/tribes/dismantlesite.cc (+1/-4) src/logic/map_objects/tribes/militarysite.cc (+3/-5) src/logic/map_objects/tribes/productionsite.cc (+27/-35) src/logic/map_objects/tribes/ship.cc (+3/-8) src/logic/map_objects/tribes/worker.cc (+8/-7) src/ui_basic/CMakeLists.txt (+0/-1) src/ui_basic/button.cc (+12/-8) src/ui_basic/button.h (+3/-3) src/ui_basic/checkbox.cc (+1/-1) src/ui_basic/dropdown.cc (+18/-10) src/ui_basic/dropdown.h (+2/-1) src/ui_basic/editbox.cc (+62/-49) src/ui_basic/editbox.h (+6/-5) src/ui_basic/fullscreen_window.cc (+3/-7) src/ui_basic/fullscreen_window.h (+2/-3) src/ui_basic/listselect.cc (+5/-5) src/ui_basic/listselect.h (+3/-1) src/ui_basic/messagebox.cc (+6/-3) src/ui_basic/multilineeditbox.cc (+10/-10) src/ui_basic/multilinetextarea.cc (+21/-11) src/ui_basic/multilinetextarea.h (+9/-6) src/ui_basic/panel.cc (+5/-6) src/ui_basic/panel.h (+1/-1) src/ui_basic/progressbar.cc (+6/-8) src/ui_basic/progressbar.h (+2/-0) src/ui_basic/progresswindow.cc (+6/-9) src/ui_basic/progresswindow.h (+1/-0) src/ui_basic/slider.cc (+9/-8) src/ui_basic/slider.h (+6/-0) src/ui_basic/spinbox.cc (+0/-1) src/ui_basic/table.cc (+16/-9) src/ui_basic/table.h (+21/-10) src/ui_basic/tabpanel.cc (+1/-1) src/ui_basic/textarea.cc (+42/-50) src/ui_basic/textarea.h (+26/-22) src/ui_basic/window.cc (+1/-1) src/ui_fsmenu/CMakeLists.txt (+1/-5) src/ui_fsmenu/about.cc (+1/-2) src/ui_fsmenu/campaign_select.cc (+3/-6) src/ui_fsmenu/campaigndetails.cc (+0/-1) src/ui_fsmenu/internet_lobby.cc (+26/-23) src/ui_fsmenu/internet_lobby.h (+0/-1) src/ui_fsmenu/intro.cc (+5/-3) src/ui_fsmenu/launch_game.cc (+3/-3) src/ui_fsmenu/launch_mpg.cc (+19/-18) src/ui_fsmenu/launch_mpg.h (+0/-2) src/ui_fsmenu/launch_spg.cc (+19/-9) src/ui_fsmenu/loadgame.cc (+5/-2) src/ui_fsmenu/main.cc (+5/-1) src/ui_fsmenu/mapselect.cc (+2/-2) src/ui_fsmenu/multiplayer.cc (+4/-3) src/ui_fsmenu/netsetup_lan.cc (+10/-14) src/ui_fsmenu/options.cc (+3/-5) src/ui_fsmenu/scenario_select.cc (+5/-6) src/ui_fsmenu/scenariodetails.cc (+0/-1) src/ui_fsmenu/singleplayer.cc (+2/-3) src/wlapplication.cc (+0/-1) src/wui/CMakeLists.txt (+4/-4) src/wui/attack_box.cc (+15/-15) src/wui/attack_box.h (+2/-4) src/wui/building_statistics_menu.cc (+42/-57) src/wui/building_statistics_menu.h (+4/-1) src/wui/buildingwindow.cc (+4/-3) src/wui/chat_msg_layout.cc (+28/-46) src/wui/chat_overlay.cc (+6/-2) src/wui/encyclopedia_window.cc (+1/-0) src/wui/fieldaction.cc (+2/-5) src/wui/game_chat_panel.cc (+3/-3) src/wui/game_main_menu_save_game.cc (+1/-1) src/wui/game_message_menu.cc (+1/-0) src/wui/game_summary.cc (+1/-4) src/wui/gamedetails.cc (+3/-3) src/wui/helpwindow.cc (+1/-0) src/wui/inputqueuedisplay.cc (+25/-15) src/wui/interactive_base.cc (+4/-5) src/wui/interactive_gamebase.cc (+4/-5) src/wui/load_or_save_game.cc (+13/-12) src/wui/login_box.cc (+7/-7) src/wui/mapdetails.cc (+4/-3) src/wui/multiplayersetupgroup.cc (+0/-1) src/wui/multiplayersetupgroup.h (+0/-1) src/wui/playerdescrgroup.cc (+0/-1) src/wui/plot_area.cc (+29/-26) src/wui/soldierlist.cc (+9/-6) src/wui/sound_options.h (+1/-0) src/wui/waresdisplay.cc (+14/-9) |
||||
To merge this branch: | bzr merge lp:~widelands-dev/widelands/font_size-lua | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Toni Förster | Approve | ||
Review via email: mp+366938@code.launchpad.net |
Commit message
Except for scenario and win condition messages, define all font styles via Lua. Reduce the number of construtors in TextArea.
Description of the change
The long-term goal is to allow user-defined styles.
bunnybot (widelandsofficial) wrote : | # |
kaputtnik (franku) wrote : | # |
I get a crash when trying to open the buildings statistics menu:
Texture (21925, 7772) too big! Maximum size is 2048.
Fatal exception: Texture (21925, 7772) too big! Maximum size is 2048.
FATAL ERROR - game crashed. Attempting emergency save.
The crash does not appear in current trunk, so i guess it is in this branch.
Backtrace:
FATAL ERROR - game crashed. Attempting emergency save.
Game: Writing Preload Data ...
Thread 1 "widelands" received signal SIGSEGV, Segmentation fault.
Widelands:
at /home/kaputtnik
114 s.set_int(
(gdb) bt
#0 Widelands:
at /home/kaputtnik
#1 0x00005555565af007 in Widelands:
at /home/kaputtnik
#2 0x0000555556148385 in SaveHandler:
__closure=
at /home/kaputtnik
#3 0x0000555556148757 in std::_Function_
__functor=..., __args#0=...) at /usr/include/
#4 0x0000555556474f11 in std::function<void (FileSystem&
__args#0=...) at /usr/include/
#5 0x0000555556472a2d in GenericSaveHand
at /home/kaputtnik
#6 0x0000555556472f14 in GenericSaveHand
at /home/kaputtnik
#7 0x00005555561484be in SaveHandler:
complete_
at /home/kaputtnik
#8 0x0000555555f7434e in WLApplication:
at /home/kaputtnik
#9 0x0000555555f73774 in WLApplication:
at /home/kaputtnik
#10 0x0000555555f722fe in WLApplication:
at /home/kaputtnik
#11 0x0000555555f71c2b in WLApplication:
at /home/kaputtnik
#12 0x0000555555f6dfa7 in WLApplication::run (this=0x555556d
at /home/kaputtnik
kaputtnik (franku) wrote : | # |
GunChleoc (gunchleoc) wrote : | # |
Thanks, I can reproduce this.
Toni Förster (stonerl) wrote : | # |
I get 2 compile warnings:
src/graphic/
void replace_
src/wui/
constexpr int kTabHeight = 35 + 5 * (kBuildGridCell
GunChleoc (gunchleoc) wrote : | # |
Found the bug and fixed the compiler warnings :)
Toni Förster (stonerl) wrote : | # |
Some problems in the lobby and multiplayer chat:
- The text in the input box is not centred
(q,g, j and so on are cut off)
- Private messages double the prefix
- The @ in private message shouldn't be underlined
- There should either be no space before the @
in private messages or an additional behind the @
(as it is b20)
- If we have the space it should not be underlined
- The Username and the message look a little of
(The message seems to be 2-4 pixels to high)
See this picture:
Toni Förster (stonerl) wrote : | # |
=== modified file 'src/wui/
--- src/wui/
+++ src/wui/
@@ -41,12 +41,12 @@
0,
0,
w,
- h - 25,
+ h - 30,
"",
- editbox(this, 0, h - 20, w, style),
+ editbox(this, 0, h - 25, w, style),
chat_
chat_
bunnybot (widelandsofficial) wrote : | # |
Continuous integration builds have changed state:
Travis build 4953. State: failed. Details: https:/
Appveyor build 4734. State: success. Details: https:/
GunChleoc (gunchleoc) wrote : | # |
- The text in the input box is not centred
(q,g, j and so on are cut off)
Thanks for the fix. The whole alignment code in the editbox should be overhauled sometime.
- Private messages double the prefix
Fixed
- The @ in private message shouldn't be underlined
Fixed
- There should either be no space before the @
in private messages or an additional behind the @
(as it is b20)
I did that on purpose. Mentions on Twitter and lots of modern messageboards etc. are always "@username", never "@ username".
No space before the @ would make it too hard to read-
- If we have the space it should not be underlined
Fixed
- The Username and the message look a little of
(The message seems to be 2-4 pixels to high)
That's https:/
Toni Förster (stonerl) wrote : | # |
On more question. We have 2 different fonts now. The one used in editboxes is completely different from the other font. Is this intentionally?
Toni Förster (stonerl) wrote : | # |
And one more. This is the handling of direct messages. I know this is branch is about fonts but maybe we can address this here.
Do we need:
sender @recepiant: text
For direct messages? The name is already coloured green and the text italic. This differentiates the message more than enough from normal messages IMHO.
For the sender:
@recepiant: text
For the recipient:
sender: text
This should be sufficient, IMHO.
GunChleoc (gunchleoc) wrote : | # |
Good idea. I'd also like each player name to have the respective player's color, but this will need changing of the chat message protocol, because we only have 1 of the 2 player colors available there. So, not in this branch.
> On more question. We have 2 different fonts now. The one used in editboxes is completely different from the other font. Is this intentionally?
It's the same font. The only difference is that it's not bold. I think it looks better if we use bold fonts only for headings etc.
Toni Förster (stonerl) wrote : | # |
In trunk admins are written in green in the client list. Did you remove this on purpose? If not, I'm going to post the patch the next comment,
Toni Förster (stonerl) wrote : | # |
=== modified file 'src/ui_
--- src/ui_
+++ src/ui_
@@ -296,6 +296,8 @@
case kClientSuperuser:
pic = g_gr->images(
er.
+ er.set_
+ er.set_picture(0, pic);
break;
case kClientIRC:
// No icon for IRC users
GunChleoc (gunchleoc) wrote : | # |
That one fell victim to a merge conflict. I have added the style now :)
GunChleoc (gunchleoc) wrote : | # |
Thanks a lot for the review!
@bunnybot merge
bunnybot (widelandsofficial) wrote : | # |
Continuous integration builds have changed state:
Travis build 5055. State: passed. Details: https:/
Appveyor build 4835. State: success. Details: https:/
Preview Diff
1 | === modified file 'data/templates/default/init.lua' | |||
2 | --- data/templates/default/init.lua 2017-06-14 06:40:42 +0000 | |||
3 | +++ data/templates/default/init.lua 2019-05-26 02:00:17 +0000 | |||
4 | @@ -1,7 +1,15 @@ | |||
5 | 1 | -- This script defines a GUI style for Widelands. At the moment, we only | 1 | -- This script defines a GUI style for Widelands. At the moment, we only |
6 | 2 | -- support the default template. | 2 | -- support the default template. |
9 | 3 | -- So far, only background textures and colors can be defined, and they all have | 3 | |
10 | 4 | -- the format { image = filename, color = {r, g, b } }. | 4 | -- Background textures and colors have the format { image = filename, color = {r, g, b } }. |
11 | 5 | |||
12 | 6 | -- Required parameters for font styles are: | ||
13 | 7 | -- * face: string | ||
14 | 8 | -- * color: table with r, g, b values as int | ||
15 | 9 | -- * size: positive int | ||
16 | 10 | -- Optional bools are: bold, italic, underline, shadow | ||
17 | 11 | |||
18 | 12 | -- Some elements carry custom parameters like e.g. "margin" that should be expanded upon in the future. | ||
19 | 5 | 13 | ||
20 | 6 | dirname = path.dirname(__file__) | 14 | dirname = path.dirname(__file__) |
21 | 7 | 15 | ||
22 | @@ -17,43 +25,222 @@ | |||
23 | 17 | local wui_green = {3, 15, 0} | 25 | local wui_green = {3, 15, 0} |
24 | 18 | local wui_brown = {32, 19, 8} | 26 | local wui_brown = {32, 19, 8} |
25 | 19 | 27 | ||
26 | 28 | local fs_font_color = {255, 255, 0} | ||
27 | 29 | local fs_font_face = "sans" | ||
28 | 30 | local fs_font_size = 14 | ||
29 | 31 | |||
30 | 32 | local wui_font_color = {255, 255, 0} | ||
31 | 33 | local wui_font_face = "sans" | ||
32 | 34 | local wui_font_size = 14 | ||
33 | 35 | |||
34 | 36 | local default_ui_font = { | ||
35 | 37 | color = fs_font_color, | ||
36 | 38 | face = fs_font_face, | ||
37 | 39 | size = fs_font_size, | ||
38 | 40 | bold = true, | ||
39 | 41 | shadow = true | ||
40 | 42 | } | ||
41 | 43 | |||
42 | 44 | local default_button_fonts = { | ||
43 | 45 | enabled = default_ui_font, | ||
44 | 46 | disabled = { | ||
45 | 47 | color = {127, 127, 127}, | ||
46 | 48 | face = fs_font_face, | ||
47 | 49 | size = fs_font_size, | ||
48 | 50 | bold = true, | ||
49 | 51 | shadow = true | ||
50 | 52 | }, | ||
51 | 53 | } | ||
52 | 54 | |||
53 | 55 | local productivity_colors = { | ||
54 | 56 | low = {187, 0, 0}, | ||
55 | 57 | medium = {255, 225, 30}, | ||
56 | 58 | high = {0, 187, 0}, | ||
57 | 59 | } | ||
58 | 60 | |||
59 | 20 | -- These are the style definitions to be returned. | 61 | -- These are the style definitions to be returned. |
60 | 21 | -- Note: you have to keep all the keys intact, or Widelands will not be happy. | 62 | -- Note: you have to keep all the keys intact, or Widelands will not be happy. |
61 | 22 | return { | 63 | return { |
63 | 23 | -- Button backgrounds | 64 | -- Automatic resizing of fonts to make them fit onto buttons etc. |
64 | 65 | -- won't go below this size | ||
65 | 66 | minimum_font_size = 10, | ||
66 | 67 | minimap_icon_frame = fs_font_color, | ||
67 | 68 | |||
68 | 69 | -- Buttons | ||
69 | 24 | buttons = { | 70 | buttons = { |
70 | 25 | -- Buttons used in Fullscreen menus | 71 | -- Buttons used in Fullscreen menus |
71 | 26 | fsmenu = { | 72 | fsmenu = { |
72 | 27 | -- Main menu ("Single Player", "Watch Replay", ...) | 73 | -- Main menu ("Single Player", "Watch Replay", ...) |
74 | 28 | menu = { image = fs_button, color = fs_blue }, | 74 | menu = { |
75 | 75 | enabled = { | ||
76 | 76 | font = default_button_fonts["enabled"], | ||
77 | 77 | background = { | ||
78 | 78 | image = fs_button, | ||
79 | 79 | color = fs_blue, | ||
80 | 80 | } | ||
81 | 81 | }, | ||
82 | 82 | disabled = { | ||
83 | 83 | font = default_button_fonts["disabled"], | ||
84 | 84 | background = { | ||
85 | 85 | image = fs_button, | ||
86 | 86 | color = fs_blue, | ||
87 | 87 | } | ||
88 | 88 | } | ||
89 | 89 | }, | ||
90 | 29 | -- Primary user selection ("OK", ...) | 90 | -- Primary user selection ("OK", ...) |
92 | 30 | primary = { image = fs_button, color = fs_green }, | 91 | primary = { |
93 | 92 | enabled = { | ||
94 | 93 | font = default_button_fonts["enabled"], | ||
95 | 94 | background = { | ||
96 | 95 | image = fs_button, | ||
97 | 96 | color = fs_green, | ||
98 | 97 | } | ||
99 | 98 | }, | ||
100 | 99 | disabled = { | ||
101 | 100 | font = default_button_fonts["disabled"], | ||
102 | 101 | background = { | ||
103 | 102 | image = fs_button, | ||
104 | 103 | color = fs_green, | ||
105 | 104 | } | ||
106 | 105 | } | ||
107 | 106 | }, | ||
108 | 31 | -- Secondary user selection ("Cancel", "Delete", selection buttons, ...) | 107 | -- Secondary user selection ("Cancel", "Delete", selection buttons, ...) |
110 | 32 | secondary = { image = fs_button, color = fs_brown }, | 108 | secondary = { |
111 | 109 | enabled = { | ||
112 | 110 | font = default_button_fonts["enabled"], | ||
113 | 111 | background = { | ||
114 | 112 | image = fs_button, | ||
115 | 113 | color = fs_brown, | ||
116 | 114 | } | ||
117 | 115 | }, | ||
118 | 116 | disabled = { | ||
119 | 117 | font = default_button_fonts["disabled"], | ||
120 | 118 | background = { | ||
121 | 119 | image = fs_button, | ||
122 | 120 | color = fs_brown, | ||
123 | 121 | } | ||
124 | 122 | } | ||
125 | 123 | }, | ||
126 | 33 | }, | 124 | }, |
127 | 34 | -- Buttons used in-game and in the editor | 125 | -- Buttons used in-game and in the editor |
128 | 35 | wui = { | 126 | wui = { |
129 | 36 | -- Main menu ("Exit Game"), Building Windows, selection buttons, ... | 127 | -- Main menu ("Exit Game"), Building Windows, selection buttons, ... |
131 | 37 | menu = { image = wui_button, color = wui_light }, | 128 | menu = { |
132 | 129 | enabled = { | ||
133 | 130 | font = default_button_fonts["enabled"], | ||
134 | 131 | background = { | ||
135 | 132 | image = wui_button, | ||
136 | 133 | color = wui_light, | ||
137 | 134 | } | ||
138 | 135 | }, | ||
139 | 136 | disabled = { | ||
140 | 137 | font = default_button_fonts["disabled"], | ||
141 | 138 | background = { | ||
142 | 139 | image = wui_button, | ||
143 | 140 | color = wui_light, | ||
144 | 141 | } | ||
145 | 142 | } | ||
146 | 143 | }, | ||
147 | 38 | -- Primary user selection ("OK", attack, ...) | 144 | -- Primary user selection ("OK", attack, ...) |
149 | 39 | primary = { image = wui_button, color = wui_green }, | 145 | primary = { |
150 | 146 | enabled = { | ||
151 | 147 | font = default_button_fonts["enabled"], | ||
152 | 148 | background = { | ||
153 | 149 | image = wui_button, | ||
154 | 150 | color = wui_green, | ||
155 | 151 | } | ||
156 | 152 | }, | ||
157 | 153 | disabled = { | ||
158 | 154 | font = default_button_fonts["disabled"], | ||
159 | 155 | background = { | ||
160 | 156 | image = wui_button, | ||
161 | 157 | color = wui_green, | ||
162 | 158 | } | ||
163 | 159 | } | ||
164 | 160 | }, | ||
165 | 40 | -- Secondary user selection ("Cancel", "Delete", ...) | 161 | -- Secondary user selection ("Cancel", "Delete", ...) |
167 | 41 | secondary = { image = wui_button, color = wui_brown }, | 162 | secondary = { |
168 | 163 | enabled = { | ||
169 | 164 | font = default_button_fonts["enabled"], | ||
170 | 165 | background = { | ||
171 | 166 | image = wui_button, | ||
172 | 167 | color = wui_brown, | ||
173 | 168 | } | ||
174 | 169 | }, | ||
175 | 170 | disabled = { | ||
176 | 171 | font = default_button_fonts["disabled"], | ||
177 | 172 | background = { | ||
178 | 173 | image = wui_button, | ||
179 | 174 | color = wui_brown, | ||
180 | 175 | } | ||
181 | 176 | } | ||
182 | 177 | }, | ||
183 | 42 | -- Building buttons on fieldaction and building statistics need to be | 178 | -- Building buttons on fieldaction and building statistics need to be |
184 | 43 | -- transparent in order to match the background of the tab panel. | 179 | -- transparent in order to match the background of the tab panel. |
186 | 44 | building_stats = { image = "", color = {0, 0, 0} }, | 180 | building_stats = { |
187 | 181 | enabled = { | ||
188 | 182 | font = default_button_fonts["enabled"], | ||
189 | 183 | background = { | ||
190 | 184 | image = "", | ||
191 | 185 | color = {0, 0, 0}, | ||
192 | 186 | } | ||
193 | 187 | }, | ||
194 | 188 | disabled = { | ||
195 | 189 | font = default_button_fonts["disabled"], | ||
196 | 190 | background = { | ||
197 | 191 | image = "", | ||
198 | 192 | color = {0, 0, 0}, | ||
199 | 193 | } | ||
200 | 194 | } | ||
201 | 195 | }, | ||
202 | 45 | } | 196 | } |
203 | 46 | }, | 197 | }, |
204 | 47 | -- Slider cursors (Sound control, attack, statistics, ...) | 198 | -- Slider cursors (Sound control, attack, statistics, ...) |
205 | 48 | sliders = { | 199 | sliders = { |
206 | 49 | fsmenu = { | 200 | fsmenu = { |
208 | 50 | menu = { image = fs_button, color = fs_blue }, | 201 | menu = { |
209 | 202 | background = { | ||
210 | 203 | image = fs_button, | ||
211 | 204 | color = fs_blue, | ||
212 | 205 | }, | ||
213 | 206 | font = { | ||
214 | 207 | color = fs_font_color, | ||
215 | 208 | face = "condensed", | ||
216 | 209 | size = 11, | ||
217 | 210 | bold = true, | ||
218 | 211 | shadow = true | ||
219 | 212 | } | ||
220 | 213 | } | ||
221 | 51 | }, | 214 | }, |
222 | 52 | wui = { | 215 | wui = { |
223 | 53 | -- Sound Options, Statistics | 216 | -- Sound Options, Statistics |
225 | 54 | light = { image = wui_button, color = wui_brown }, | 217 | light = { |
226 | 218 | background = { | ||
227 | 219 | image = wui_button, | ||
228 | 220 | color = wui_brown, | ||
229 | 221 | }, | ||
230 | 222 | font = { | ||
231 | 223 | color = fs_font_color, | ||
232 | 224 | face = "condensed", | ||
233 | 225 | size = 11, | ||
234 | 226 | bold = true, | ||
235 | 227 | shadow = true | ||
236 | 228 | } | ||
237 | 229 | }, | ||
238 | 55 | -- Fieldaction (attack) | 230 | -- Fieldaction (attack) |
240 | 56 | dark = { image = wui_button, color = wui_green }, | 231 | dark = { |
241 | 232 | background = { | ||
242 | 233 | image = wui_button, | ||
243 | 234 | color = wui_green, | ||
244 | 235 | }, | ||
245 | 236 | font = { | ||
246 | 237 | color = fs_font_color, | ||
247 | 238 | face = "condensed", | ||
248 | 239 | size = 11, | ||
249 | 240 | bold = true, | ||
250 | 241 | shadow = true | ||
251 | 242 | } | ||
252 | 243 | }, | ||
253 | 57 | } | 244 | } |
254 | 58 | }, | 245 | }, |
255 | 59 | -- Background for tab panels | 246 | -- Background for tab panels |
256 | @@ -74,11 +261,31 @@ | |||
257 | 74 | -- Used both for one-line and multiline edit boxes | 261 | -- Used both for one-line and multiline edit boxes |
258 | 75 | editboxes = { | 262 | editboxes = { |
259 | 76 | fsmenu = { | 263 | fsmenu = { |
261 | 77 | menu = { image = fs_button, color = fs_green }, | 264 | background = { |
262 | 265 | image = fs_button, | ||
263 | 266 | color = fs_green, | ||
264 | 267 | margin = 4 | ||
265 | 268 | }, | ||
266 | 269 | font = { | ||
267 | 270 | color = fs_font_color, | ||
268 | 271 | face = fs_font_face, | ||
269 | 272 | size = fs_font_size, | ||
270 | 273 | shadow = true | ||
271 | 274 | }, | ||
272 | 78 | }, | 275 | }, |
273 | 79 | wui = { | 276 | wui = { |
276 | 80 | menu = { image = wui_button, color = wui_brown }, | 277 | background = { |
277 | 81 | } | 278 | image = wui_button, |
278 | 279 | color = wui_brown, | ||
279 | 280 | margin = 2, | ||
280 | 281 | }, | ||
281 | 282 | font = { | ||
282 | 283 | color = wui_font_color, | ||
283 | 284 | face = wui_font_face, | ||
284 | 285 | size = wui_font_size, | ||
285 | 286 | shadow = true | ||
286 | 287 | }, | ||
287 | 288 | }, | ||
288 | 82 | }, | 289 | }, |
289 | 83 | -- Background for dropdown menus | 290 | -- Background for dropdown menus |
290 | 84 | dropdowns = { | 291 | dropdowns = { |
291 | @@ -97,5 +304,381 @@ | |||
292 | 97 | wui = { | 304 | wui = { |
293 | 98 | menu = { image = wui_button, color = wui_brown }, | 305 | menu = { image = wui_button, color = wui_brown }, |
294 | 99 | } | 306 | } |
296 | 100 | } | 307 | }, |
297 | 308 | |||
298 | 309 | -- In-game statistics plots | ||
299 | 310 | statistics_plot = { | ||
300 | 311 | fonts = { | ||
301 | 312 | x_tick = { | ||
302 | 313 | color = { 255, 0, 0 }, | ||
303 | 314 | face = "condensed", | ||
304 | 315 | size = 13, | ||
305 | 316 | }, | ||
306 | 317 | y_min_value = { | ||
307 | 318 | color = { 125, 0, 0 }, | ||
308 | 319 | face = "condensed", | ||
309 | 320 | size = 13, | ||
310 | 321 | }, | ||
311 | 322 | y_max_value = { | ||
312 | 323 | color = { 60, 125, 0 }, | ||
313 | 324 | face = "condensed", | ||
314 | 325 | size = 13, | ||
315 | 326 | }, | ||
316 | 327 | }, | ||
317 | 328 | colors = { | ||
318 | 329 | axis_line = { 0, 0, 0 }, | ||
319 | 330 | zero_line = { 255, 255, 255 }, | ||
320 | 331 | } | ||
321 | 332 | }, | ||
322 | 333 | |||
323 | 334 | -- Map census and statistics, and building statistics window | ||
324 | 335 | building_statistics = { | ||
325 | 336 | census_font = { | ||
326 | 337 | color = wui_font_color, -- Default color | ||
327 | 338 | face = "condensed", | ||
328 | 339 | size = wui_font_size, | ||
329 | 340 | bold = true, | ||
330 | 341 | shadow = true | ||
331 | 342 | }, | ||
332 | 343 | statistics_font = { | ||
333 | 344 | color = wui_font_color, -- Default color | ||
334 | 345 | face = "condensed", | ||
335 | 346 | size = wui_font_size, | ||
336 | 347 | bold = true, | ||
337 | 348 | shadow = true | ||
338 | 349 | }, | ||
339 | 350 | -- Building statistics window | ||
340 | 351 | statistics_window = { | ||
341 | 352 | fonts = { | ||
342 | 353 | button_font = { | ||
343 | 354 | color = wui_font_color, -- Default color | ||
344 | 355 | face = "condensed", | ||
345 | 356 | size = 12, -- Do not make this bigger - the UI element size is still hard-coded. | ||
346 | 357 | bold = true, | ||
347 | 358 | shadow = true | ||
348 | 359 | }, | ||
349 | 360 | details_font = { | ||
350 | 361 | color = wui_font_color, -- Default color | ||
351 | 362 | face = "sans", | ||
352 | 363 | size = 12, -- Do not make this bigger - the UI element size is still hard-coded. | ||
353 | 364 | bold = true, | ||
354 | 365 | shadow = true | ||
355 | 366 | }, | ||
356 | 367 | }, | ||
357 | 368 | editbox_margin = 0 | ||
358 | 369 | }, | ||
359 | 370 | colors = { | ||
360 | 371 | construction = { 163, 144, 19 }, | ||
361 | 372 | neutral = { 255, 250, 170 }, | ||
362 | 373 | low = productivity_colors["low"], | ||
363 | 374 | medium = productivity_colors["medium"], | ||
364 | 375 | high = productivity_colors["high"], | ||
365 | 376 | } | ||
366 | 377 | }, | ||
367 | 378 | |||
368 | 379 | progressbar = { | ||
369 | 380 | fsmenu = { | ||
370 | 381 | font = { | ||
371 | 382 | color = { 128, 128, 255 }, | ||
372 | 383 | face = fs_font_face, | ||
373 | 384 | size = fs_font_size, | ||
374 | 385 | bold = true, | ||
375 | 386 | shadow = true | ||
376 | 387 | }, | ||
377 | 388 | background_colors = { | ||
378 | 389 | low = { 64, 64, 0 }, -- Unused | ||
379 | 390 | medium = { 64, 64, 0 }, | ||
380 | 391 | high = { 64, 64, 0 }, -- Unused | ||
381 | 392 | } | ||
382 | 393 | }, | ||
383 | 394 | wui = { | ||
384 | 395 | font = { | ||
385 | 396 | color = {255, 250, 170}, | ||
386 | 397 | face = wui_font_face, | ||
387 | 398 | size = wui_font_size, | ||
388 | 399 | bold = true, | ||
389 | 400 | shadow = true | ||
390 | 401 | }, | ||
391 | 402 | background_colors = { | ||
392 | 403 | low = productivity_colors["low"], | ||
393 | 404 | medium = productivity_colors["medium"], | ||
394 | 405 | high = productivity_colors["high"], | ||
395 | 406 | } | ||
396 | 407 | } | ||
397 | 408 | }, | ||
398 | 409 | |||
399 | 410 | tables = { | ||
400 | 411 | fsmenu = { | ||
401 | 412 | enabled = { | ||
402 | 413 | color = fs_font_color, | ||
403 | 414 | face = fs_font_face, | ||
404 | 415 | size = fs_font_size, | ||
405 | 416 | bold = true, | ||
406 | 417 | shadow = true | ||
407 | 418 | }, | ||
408 | 419 | disabled = { | ||
409 | 420 | color = {127, 127, 127}, | ||
410 | 421 | face = fs_font_face, | ||
411 | 422 | size = fs_font_size, | ||
412 | 423 | bold = true, | ||
413 | 424 | shadow = true | ||
414 | 425 | } | ||
415 | 426 | }, | ||
416 | 427 | wui = { | ||
417 | 428 | enabled = { | ||
418 | 429 | color = fs_font_color, | ||
419 | 430 | face = fs_font_face, | ||
420 | 431 | size = fs_font_size, | ||
421 | 432 | bold = true, | ||
422 | 433 | shadow = true | ||
423 | 434 | }, | ||
424 | 435 | disabled = { | ||
425 | 436 | color = {127, 127, 127}, | ||
426 | 437 | face = fs_font_face, | ||
427 | 438 | size = fs_font_size, | ||
428 | 439 | bold = true, | ||
429 | 440 | shadow = true | ||
430 | 441 | } | ||
431 | 442 | }, | ||
432 | 443 | }, | ||
433 | 444 | |||
434 | 445 | wareinfo = { | ||
435 | 446 | -- TODO(GunChleoc): This design is ugly. | ||
436 | 447 | -- Group stuff more logically once everything has been styled. | ||
437 | 448 | normal = { | ||
438 | 449 | fonts = { | ||
439 | 450 | header = { | ||
440 | 451 | color = wui_font_color, | ||
441 | 452 | face = "sans", | ||
442 | 453 | size = 11, | ||
443 | 454 | }, | ||
444 | 455 | info = { | ||
445 | 456 | color = wui_font_color, | ||
446 | 457 | face = "condensed", | ||
447 | 458 | size = 10, | ||
448 | 459 | }, | ||
449 | 460 | }, | ||
450 | 461 | colors = { | ||
451 | 462 | icon_frame = { 69, 69, 69 }, | ||
452 | 463 | icon_background = { 69, 69, 69 }, | ||
453 | 464 | info_background = { 0, 0, 0 }, | ||
454 | 465 | }, | ||
455 | 466 | icon_background_image = "images/wui/ware_list_bg.png", | ||
456 | 467 | }, | ||
457 | 468 | highlight = { | ||
458 | 469 | fonts = { | ||
459 | 470 | header = { | ||
460 | 471 | color = wui_font_color, | ||
461 | 472 | face = "sans", | ||
462 | 473 | size = 11, | ||
463 | 474 | }, | ||
464 | 475 | info = { | ||
465 | 476 | color = wui_font_color, | ||
466 | 477 | face = "condensed", | ||
467 | 478 | size = 10, | ||
468 | 479 | }, | ||
469 | 480 | }, | ||
470 | 481 | colors = { | ||
471 | 482 | icon_frame = {255, 255, 0}, | ||
472 | 483 | icon_background = {69, 69, 69}, | ||
473 | 484 | info_background = {0, 0, 0}, | ||
474 | 485 | }, | ||
475 | 486 | icon_background_image = "images/wui/ware_list_bg_selected.png", | ||
476 | 487 | } | ||
477 | 488 | }, | ||
478 | 489 | |||
479 | 490 | -- Font styles. Required parameters are: | ||
480 | 491 | -- * face: string | ||
481 | 492 | -- * color: table with r, g, b values as int | ||
482 | 493 | -- * size: positive int | ||
483 | 494 | -- Optional bools are: bold, italic, underline, shadow | ||
484 | 495 | fonts = { | ||
485 | 496 | -- Basic chat message text color | ||
486 | 497 | chat_message = { | ||
487 | 498 | color = wui_font_color, | ||
488 | 499 | face = "serif", | ||
489 | 500 | size = fs_font_size, | ||
490 | 501 | shadow = true, | ||
491 | 502 | }, | ||
492 | 503 | -- Basic chat message text color | ||
493 | 504 | chat_timestamp = { | ||
494 | 505 | color = { 51, 255, 51 }, | ||
495 | 506 | face = "serif", | ||
496 | 507 | size = 9, | ||
497 | 508 | shadow = true, | ||
498 | 509 | }, | ||
499 | 510 | -- Chat for private messages | ||
500 | 511 | chat_whisper = { | ||
501 | 512 | color = { 238, 238, 238 }, | ||
502 | 513 | face = "serif", | ||
503 | 514 | size = fs_font_size, | ||
504 | 515 | italic = true, | ||
505 | 516 | shadow = true, | ||
506 | 517 | }, | ||
507 | 518 | -- Chat playername highlight | ||
508 | 519 | chat_playername = { | ||
509 | 520 | color = { 255, 255, 255 }, | ||
510 | 521 | face = "serif", | ||
511 | 522 | size = fs_font_size, | ||
512 | 523 | bold = true, | ||
513 | 524 | shadow = true, | ||
514 | 525 | }, | ||
515 | 526 | -- Chat log messages color. Also doubles as spectator playercolor for chat messages. | ||
516 | 527 | chat_server = { | ||
517 | 528 | color = { 221, 221, 221 }, | ||
518 | 529 | face = "serif", | ||
519 | 530 | size = fs_font_size, | ||
520 | 531 | bold = true, | ||
521 | 532 | shadow = true, | ||
522 | 533 | }, | ||
523 | 534 | -- Intro screen | ||
524 | 535 | fsmenu_intro = { | ||
525 | 536 | color = { 192, 192, 128 }, | ||
526 | 537 | face = fs_font_face, | ||
527 | 538 | size = 16, | ||
528 | 539 | bold = true, | ||
529 | 540 | shadow = true | ||
530 | 541 | }, | ||
531 | 542 | -- Displayed in the loading screens | ||
532 | 543 | fsmenu_gametip = { | ||
533 | 544 | color = { 33, 33, 27 }, | ||
534 | 545 | face = "serif", | ||
535 | 546 | size = 16, | ||
536 | 547 | }, | ||
537 | 548 | -- Game and Map info panels | ||
538 | 549 | fsmenu_info_panel_heading = { | ||
539 | 550 | color = { 255, 255, 0 }, | ||
540 | 551 | face = fs_font_face, | ||
541 | 552 | size = fs_font_size, | ||
542 | 553 | bold = true, | ||
543 | 554 | shadow = true | ||
544 | 555 | }, | ||
545 | 556 | fsmenu_info_panel_paragraph = { | ||
546 | 557 | color = { 209, 209, 209 }, | ||
547 | 558 | face = fs_font_face, | ||
548 | 559 | size = fs_font_size, | ||
549 | 560 | shadow = true | ||
550 | 561 | }, | ||
551 | 562 | -- Internet lobby and launch game | ||
552 | 563 | fsmenu_game_setup_headings = { | ||
553 | 564 | color = { 0, 255, 0 }, | ||
554 | 565 | face = fs_font_face, | ||
555 | 566 | size = fs_font_size, | ||
556 | 567 | bold = true, | ||
557 | 568 | shadow = true | ||
558 | 569 | }, | ||
559 | 570 | fsmenu_game_setup_mapname = { | ||
560 | 571 | color = { 255, 255, 127 }, | ||
561 | 572 | face = fs_font_face, | ||
562 | 573 | size = fs_font_size, | ||
563 | 574 | bold = true, | ||
564 | 575 | shadow = true | ||
565 | 576 | }, | ||
566 | 577 | -- List admin in the internet lobby | ||
567 | 578 | fsmenu_game_setup_superuser = { | ||
568 | 579 | color = { 0, 255, 0 }, | ||
569 | 580 | face = fs_font_face, | ||
570 | 581 | size = fs_font_size, | ||
571 | 582 | bold = true, | ||
572 | 583 | shadow = true | ||
573 | 584 | }, | ||
574 | 585 | -- List IRC clients in the internet lobby | ||
575 | 586 | fsmenu_game_setup_irc_client = { | ||
576 | 587 | color = { 221, 221, 221 }, | ||
577 | 588 | face = fs_font_face, | ||
578 | 589 | size = fs_font_size, | ||
579 | 590 | bold = true, | ||
580 | 591 | shadow = true | ||
581 | 592 | }, | ||
582 | 593 | -- Page titles. Also used in game summary TODO(GunChleoc): Refactor game summary | ||
583 | 594 | fsmenu_title = { | ||
584 | 595 | color = fs_font_color, | ||
585 | 596 | face = fs_font_face, | ||
586 | 597 | size = 22, | ||
587 | 598 | bold = true, | ||
588 | 599 | shadow = true | ||
589 | 600 | }, | ||
590 | 601 | -- Make font a bit smaller so the link will fit at 800x600 resolution. | ||
591 | 602 | fsmenu_translation_info = { | ||
592 | 603 | color = fs_font_color, | ||
593 | 604 | face = fs_font_face, | ||
594 | 605 | size = fs_font_size - 2, | ||
595 | 606 | bold = true, | ||
596 | 607 | shadow = true | ||
597 | 608 | }, | ||
598 | 609 | |||
599 | 610 | -- Textarea default style, also used for sliders, checkboxes, both in fsmenu and wui ... | ||
600 | 611 | label = default_ui_font, | ||
601 | 612 | tooltip = { | ||
602 | 613 | color = fs_font_color, | ||
603 | 614 | face = fs_font_face, | ||
604 | 615 | size = 14, | ||
605 | 616 | bold = false, | ||
606 | 617 | }, | ||
607 | 618 | tooltip_header = { | ||
608 | 619 | color = fs_font_color, | ||
609 | 620 | face = fs_font_face, | ||
610 | 621 | size = 16, | ||
611 | 622 | bold = true, | ||
612 | 623 | }, | ||
613 | 624 | warning = { | ||
614 | 625 | color = {255, 22, 22}, | ||
615 | 626 | face = fs_font_face, | ||
616 | 627 | size = fs_font_size, | ||
617 | 628 | bold = true, | ||
618 | 629 | shadow = true | ||
619 | 630 | }, | ||
620 | 631 | disabled = { | ||
621 | 632 | color = {127, 127, 127}, | ||
622 | 633 | face = fs_font_face, | ||
623 | 634 | size = fs_font_size, | ||
624 | 635 | bold = true, | ||
625 | 636 | shadow = true | ||
626 | 637 | }, | ||
627 | 638 | |||
628 | 639 | wui_attack_box_slider_label = { | ||
629 | 640 | color = wui_font_color, | ||
630 | 641 | face = wui_font_face, | ||
631 | 642 | size = 10, | ||
632 | 643 | bold = true, | ||
633 | 644 | shadow = true | ||
634 | 645 | }, | ||
635 | 646 | wui_info_panel_heading = { | ||
636 | 647 | color = { 209, 209, 209 }, | ||
637 | 648 | face = wui_font_face, | ||
638 | 649 | size = wui_font_size, | ||
639 | 650 | bold = true, | ||
640 | 651 | }, | ||
641 | 652 | wui_info_panel_paragraph = { | ||
642 | 653 | color = { 255, 255, 0 }, | ||
643 | 654 | face = wui_font_face, | ||
644 | 655 | size = wui_font_size, | ||
645 | 656 | }, | ||
646 | 657 | -- Messages | ||
647 | 658 | wui_message_heading = { | ||
648 | 659 | color = { 209, 209, 209 }, | ||
649 | 660 | face = wui_font_face, | ||
650 | 661 | size = 18, | ||
651 | 662 | bold = true, | ||
652 | 663 | }, | ||
653 | 664 | wui_message_paragraph = { | ||
654 | 665 | color = { 255, 255, 0 }, | ||
655 | 666 | face = wui_font_face, | ||
656 | 667 | size = 12, | ||
657 | 668 | }, | ||
658 | 669 | wui_window_title = { | ||
659 | 670 | color = fs_font_color, | ||
660 | 671 | face = wui_font_face, | ||
661 | 672 | size = 13, | ||
662 | 673 | bold=true, | ||
663 | 674 | shadow=true, | ||
664 | 675 | }, | ||
665 | 676 | wui_game_speed_and_coordinates = { | ||
666 | 677 | color = wui_font_color, | ||
667 | 678 | face = "condensed", | ||
668 | 679 | size = wui_font_size, | ||
669 | 680 | bold = true, | ||
670 | 681 | shadow = true | ||
671 | 682 | }, | ||
672 | 683 | }, | ||
673 | 101 | } | 684 | } |
674 | 102 | 685 | ||
675 | === modified file 'src/CMakeLists.txt' | |||
676 | --- src/CMakeLists.txt 2019-05-05 18:53:14 +0000 | |||
677 | +++ src/CMakeLists.txt 2019-05-26 02:00:17 +0000 | |||
678 | @@ -107,7 +107,6 @@ | |||
679 | 107 | graphic | 107 | graphic |
680 | 108 | graphic_fonthandler | 108 | graphic_fonthandler |
681 | 109 | graphic_text | 109 | graphic_text |
682 | 110 | graphic_text_constants | ||
683 | 111 | helper | 110 | helper |
684 | 112 | io_filesystem | 111 | io_filesystem |
685 | 113 | logic | 112 | logic |
686 | 114 | 113 | ||
687 | === modified file 'src/editor/tools/info_tool.cc' | |||
688 | --- src/editor/tools/info_tool.cc 2019-04-09 16:43:49 +0000 | |||
689 | +++ src/editor/tools/info_tool.cc 2019-05-26 02:00:17 +0000 | |||
690 | @@ -39,7 +39,8 @@ | |||
691 | 39 | EditorActionArgs* /* args */, | 39 | EditorActionArgs* /* args */, |
692 | 40 | Widelands::Map* map) { | 40 | Widelands::Map* map) { |
693 | 41 | 41 | ||
695 | 42 | static constexpr int kListFontsize = UI_FONT_SIZE_MESSAGE; | 42 | constexpr UI::FontStyle font_style = UI::FontStyle::kWuiInfoPanelParagraph; |
696 | 43 | |||
697 | 43 | parent.stop_painting(); | 44 | parent.stop_painting(); |
698 | 44 | 45 | ||
699 | 45 | UI::Window* const w = | 46 | UI::Window* const w = |
700 | @@ -53,7 +54,7 @@ | |||
701 | 53 | std::string buf = as_heading(_("Node"), UI::PanelStyle::kWui, true); | 54 | std::string buf = as_heading(_("Node"), UI::PanelStyle::kWui, true); |
702 | 54 | buf += as_listitem( | 55 | buf += as_listitem( |
703 | 55 | (boost::format(_("Coordinates: (%1$i, %2$i)")) % center.node.x % center.node.y).str(), | 56 | (boost::format(_("Coordinates: (%1$i, %2$i)")) % center.node.x % center.node.y).str(), |
705 | 56 | kListFontsize); | 57 | font_style); |
706 | 57 | 58 | ||
707 | 58 | std::vector<std::string> caps_strings; | 59 | std::vector<std::string> caps_strings; |
708 | 59 | Widelands::NodeCaps const caps = f.nodecaps(); | 60 | Widelands::NodeCaps const caps = f.nodecaps(); |
709 | @@ -100,15 +101,15 @@ | |||
710 | 100 | buf += as_listitem((boost::format(_("Caps: %s")) % | 101 | buf += as_listitem((boost::format(_("Caps: %s")) % |
711 | 101 | i18n::localize_list(caps_strings, i18n::ConcatenateWith::COMMA)) | 102 | i18n::localize_list(caps_strings, i18n::ConcatenateWith::COMMA)) |
712 | 102 | .str(), | 103 | .str(), |
714 | 103 | kListFontsize); | 104 | font_style); |
715 | 104 | 105 | ||
716 | 105 | if (f.get_owned_by() > 0) { | 106 | if (f.get_owned_by() > 0) { |
717 | 106 | buf += as_listitem( | 107 | buf += as_listitem( |
718 | 107 | (boost::format(_("Owned by: Player %u")) % static_cast<unsigned int>(f.get_owned_by())) | 108 | (boost::format(_("Owned by: Player %u")) % static_cast<unsigned int>(f.get_owned_by())) |
719 | 108 | .str(), | 109 | .str(), |
721 | 109 | kListFontsize); | 110 | font_style); |
722 | 110 | } else { | 111 | } else { |
724 | 111 | buf += as_listitem(_("Owned by: —"), kListFontsize); | 112 | buf += as_listitem(_("Owned by: —"), font_style); |
725 | 112 | } | 113 | } |
726 | 113 | 114 | ||
727 | 114 | // *** Terrain info | 115 | // *** Terrain info |
728 | @@ -119,7 +120,7 @@ | |||
729 | 119 | center.triangle.t == Widelands::TriangleIndex::D ? tf.terrain_d() : tf.terrain_r()); | 120 | center.triangle.t == Widelands::TriangleIndex::D ? tf.terrain_d() : tf.terrain_r()); |
730 | 120 | 121 | ||
731 | 121 | buf += as_listitem( | 122 | buf += as_listitem( |
733 | 122 | (boost::format(pgettext("terrain_name", "Name: %s")) % ter.descname()).str(), kListFontsize); | 123 | (boost::format(pgettext("terrain_name", "Name: %s")) % ter.descname()).str(), font_style); |
734 | 123 | 124 | ||
735 | 124 | std::vector<std::string> terrain_is_strings; | 125 | std::vector<std::string> terrain_is_strings; |
736 | 125 | for (const Widelands::TerrainDescription::Type& terrain_type : ter.get_types()) { | 126 | for (const Widelands::TerrainDescription::Type& terrain_type : ter.get_types()) { |
737 | @@ -132,10 +133,10 @@ | |||
738 | 132 | (boost::format(_("Is: %s")) % | 133 | (boost::format(_("Is: %s")) % |
739 | 133 | i18n::localize_list(terrain_is_strings, i18n::ConcatenateWith::AMPERSAND)) | 134 | i18n::localize_list(terrain_is_strings, i18n::ConcatenateWith::AMPERSAND)) |
740 | 134 | .str(), | 135 | .str(), |
742 | 135 | kListFontsize); | 136 | font_style); |
743 | 136 | buf += as_listitem( | 137 | buf += as_listitem( |
744 | 137 | (boost::format(_("Editor Category: %s")) % ter.editor_category()->descname()).str(), | 138 | (boost::format(_("Editor Category: %s")) % ter.editor_category()->descname()).str(), |
746 | 138 | kListFontsize); | 139 | font_style); |
747 | 139 | 140 | ||
748 | 140 | // *** Map Object info | 141 | // *** Map Object info |
749 | 141 | const Widelands::BaseImmovable* immovable = f.get_immovable(); | 142 | const Widelands::BaseImmovable* immovable = f.get_immovable(); |
750 | @@ -146,7 +147,7 @@ | |||
751 | 146 | if (immovable) { | 147 | if (immovable) { |
752 | 147 | buf += | 148 | buf += |
753 | 148 | as_listitem((boost::format(_("Immovable: %s")) % immovable->descr().descname()).str(), | 149 | as_listitem((boost::format(_("Immovable: %s")) % immovable->descr().descname()).str(), |
755 | 149 | kListFontsize); | 150 | font_style); |
756 | 150 | } | 151 | } |
757 | 151 | 152 | ||
758 | 152 | if (bob) { | 153 | if (bob) { |
759 | @@ -179,19 +180,19 @@ | |||
760 | 179 | buf += as_listitem((boost::format(_("Animals: %s")) % | 180 | buf += as_listitem((boost::format(_("Animals: %s")) % |
761 | 180 | i18n::localize_list(critternames, i18n::ConcatenateWith::COMMA)) | 181 | i18n::localize_list(critternames, i18n::ConcatenateWith::COMMA)) |
762 | 181 | .str(), | 182 | .str(), |
764 | 182 | kListFontsize); | 183 | font_style); |
765 | 183 | } | 184 | } |
766 | 184 | if (!workernames.empty()) { | 185 | if (!workernames.empty()) { |
767 | 185 | buf += as_listitem((boost::format(_("Workers: %s")) % | 186 | buf += as_listitem((boost::format(_("Workers: %s")) % |
768 | 186 | i18n::localize_list(workernames, i18n::ConcatenateWith::COMMA)) | 187 | i18n::localize_list(workernames, i18n::ConcatenateWith::COMMA)) |
769 | 187 | .str(), | 188 | .str(), |
771 | 188 | kListFontsize); | 189 | font_style); |
772 | 189 | } | 190 | } |
773 | 190 | if (!shipnames.empty()) { | 191 | if (!shipnames.empty()) { |
774 | 191 | buf += as_listitem((boost::format(_("Ships: %s")) % | 192 | buf += as_listitem((boost::format(_("Ships: %s")) % |
775 | 192 | i18n::localize_list(shipnames, i18n::ConcatenateWith::COMMA)) | 193 | i18n::localize_list(shipnames, i18n::ConcatenateWith::COMMA)) |
776 | 193 | .str(), | 194 | .str(), |
778 | 194 | kListFontsize); | 195 | font_style); |
779 | 195 | } | 196 | } |
780 | 196 | } | 197 | } |
781 | 197 | } | 198 | } |
782 | @@ -204,28 +205,28 @@ | |||
783 | 204 | (boost::format(pgettext("resources", "%1%x %2%")) % static_cast<unsigned int>(ramount) % | 205 | (boost::format(pgettext("resources", "%1%x %2%")) % static_cast<unsigned int>(ramount) % |
784 | 205 | world.get_resource(f.get_resources())->descname()) | 206 | world.get_resource(f.get_resources())->descname()) |
785 | 206 | .str(), | 207 | .str(), |
787 | 207 | kListFontsize); | 208 | font_style); |
788 | 208 | } | 209 | } |
789 | 209 | 210 | ||
790 | 210 | // *** Map info | 211 | // *** Map info |
791 | 211 | buf += as_heading(_("Map"), UI::PanelStyle::kWui); | 212 | buf += as_heading(_("Map"), UI::PanelStyle::kWui); |
792 | 212 | buf += as_listitem( | 213 | buf += as_listitem( |
794 | 213 | (boost::format(pgettext("map_name", "Name: %s")) % map->get_name()).str(), kListFontsize); | 214 | (boost::format(pgettext("map_name", "Name: %s")) % map->get_name()).str(), font_style); |
795 | 214 | buf += as_listitem( | 215 | buf += as_listitem( |
796 | 215 | (boost::format(_("Size: %1% x %2%")) % map->get_width() % map->get_height()).str(), | 216 | (boost::format(_("Size: %1% x %2%")) % map->get_width() % map->get_height()).str(), |
798 | 216 | kListFontsize); | 217 | font_style); |
799 | 217 | 218 | ||
800 | 218 | if (map->get_nrplayers() > 0) { | 219 | if (map->get_nrplayers() > 0) { |
801 | 219 | buf += as_listitem( | 220 | buf += as_listitem( |
802 | 220 | (boost::format(_("Players: %u")) % static_cast<unsigned int>(map->get_nrplayers())).str(), | 221 | (boost::format(_("Players: %u")) % static_cast<unsigned int>(map->get_nrplayers())).str(), |
804 | 221 | kListFontsize); | 222 | font_style); |
805 | 222 | } else { | 223 | } else { |
807 | 223 | buf += as_listitem(_("Players: –"), kListFontsize); | 224 | buf += as_listitem(_("Players: –"), font_style); |
808 | 224 | } | 225 | } |
809 | 225 | 226 | ||
811 | 226 | buf += as_listitem((boost::format(_("Author: %s")) % map->get_author()).str(), kListFontsize); | 227 | buf += as_listitem((boost::format(_("Author: %s")) % map->get_author()).str(), font_style); |
812 | 227 | buf += as_listitem( | 228 | buf += as_listitem( |
814 | 228 | (boost::format(_("Description: %s")) % map->get_description()).str(), kListFontsize); | 229 | (boost::format(_("Description: %s")) % map->get_description()).str(), font_style); |
815 | 229 | 230 | ||
816 | 230 | multiline_textarea->set_text(as_richtext(buf)); | 231 | multiline_textarea->set_text(as_richtext(buf)); |
817 | 231 | 232 | ||
818 | 232 | 233 | ||
819 | === modified file 'src/editor/ui_menus/main_menu_load_or_save_map.cc' | |||
820 | --- src/editor/ui_menus/main_menu_load_or_save_map.cc 2019-04-18 16:50:35 +0000 | |||
821 | +++ src/editor/ui_menus/main_menu_load_or_save_map.cc 2019-05-26 02:00:17 +0000 | |||
822 | @@ -55,7 +55,7 @@ | |||
823 | 55 | get_inner_w() - right_column_x_ - padding_, | 55 | get_inner_w() - right_column_x_ - padding_, |
824 | 56 | tableh_, | 56 | tableh_, |
825 | 57 | UI::PanelStyle::kWui), | 57 | UI::PanelStyle::kWui), |
827 | 58 | directory_info_(this, padding_, get_inner_h() - 2 * buth_ - 4 * padding_), | 58 | directory_info_(this, padding_, get_inner_h() - 2 * buth_ - 4 * padding_, 0, 0), |
828 | 59 | ok_(this, | 59 | ok_(this, |
829 | 60 | "ok", | 60 | "ok", |
830 | 61 | UI::g_fh->fontset()->is_rtl() ? get_inner_w() / 2 - butw_ - padding_ : | 61 | UI::g_fh->fontset()->is_rtl() ? get_inner_w() / 2 - butw_ - padding_ : |
831 | 62 | 62 | ||
832 | === modified file 'src/editor/ui_menus/main_menu_map_options.cc' | |||
833 | --- src/editor/ui_menus/main_menu_map_options.cc 2019-02-23 11:00:49 +0000 | |||
834 | +++ src/editor/ui_menus/main_menu_map_options.cc 2019-05-26 02:00:17 +0000 | |||
835 | @@ -28,6 +28,7 @@ | |||
836 | 28 | #include "editor/editorinteractive.h" | 28 | #include "editor/editorinteractive.h" |
837 | 29 | #include "graphic/font_handler.h" | 29 | #include "graphic/font_handler.h" |
838 | 30 | #include "graphic/graphic.h" | 30 | #include "graphic/graphic.h" |
839 | 31 | #include "graphic/text_layout.h" | ||
840 | 31 | #include "logic/map.h" | 32 | #include "logic/map.h" |
841 | 32 | #include "ui_basic/editbox.h" | 33 | #include "ui_basic/editbox.h" |
842 | 33 | #include "ui_basic/multilineeditbox.h" | 34 | #include "ui_basic/multilineeditbox.h" |
843 | @@ -45,7 +46,7 @@ | |||
844 | 45 | : UI::Window(&parent, "map_options", 0, 0, 350, parent.get_inner_h() - 80, _("Map Options")), | 46 | : UI::Window(&parent, "map_options", 0, 0, 350, parent.get_inner_h() - 80, _("Map Options")), |
845 | 46 | padding_(4), | 47 | padding_(4), |
846 | 47 | indent_(10), | 48 | indent_(10), |
848 | 48 | labelh_(text_height() + 4), | 49 | labelh_(text_height(UI::FontStyle::kLabel) + 4), |
849 | 49 | checkbox_space_(25), | 50 | checkbox_space_(25), |
850 | 50 | butw_((get_inner_w() - 3 * padding_) / 2), | 51 | butw_((get_inner_w() - 3 * padding_) / 2), |
851 | 51 | max_w_(get_inner_w() - 2 * padding_), | 52 | max_w_(get_inner_w() - 2 * padding_), |
852 | @@ -72,8 +73,8 @@ | |||
853 | 72 | tags_box_(&tabs_, padding_, padding_, UI::Box::Vertical, max_w_, get_inner_h(), 0), | 73 | tags_box_(&tabs_, padding_, padding_, UI::Box::Vertical, max_w_, get_inner_h(), 0), |
854 | 73 | teams_box_(&tabs_, padding_, padding_, UI::Box::Vertical, max_w_, get_inner_h(), 0), | 74 | teams_box_(&tabs_, padding_, padding_, UI::Box::Vertical, max_w_, get_inner_h(), 0), |
855 | 74 | 75 | ||
858 | 75 | name_(&main_box_, 0, 0, max_w_, 0, 2, UI::PanelStyle::kWui), | 76 | name_(&main_box_, 0, 0, max_w_, UI::PanelStyle::kWui), |
859 | 76 | author_(&main_box_, 0, 0, max_w_, 0, 2, UI::PanelStyle::kWui), | 77 | author_(&main_box_, 0, 0, max_w_, UI::PanelStyle::kWui), |
860 | 77 | size_(&main_box_, 0, 0, max_w_ - indent_, labelh_, ""), | 78 | size_(&main_box_, 0, 0, max_w_ - indent_, labelh_, ""), |
861 | 78 | 79 | ||
862 | 79 | teams_list_( | 80 | teams_list_( |
863 | 80 | 81 | ||
864 | === modified file 'src/editor/ui_menus/main_menu_random_map.cc' | |||
865 | --- src/editor/ui_menus/main_menu_random_map.cc 2019-04-24 07:09:29 +0000 | |||
866 | +++ src/editor/ui_menus/main_menu_random_map.cc 2019-05-26 02:00:17 +0000 | |||
867 | @@ -32,6 +32,7 @@ | |||
868 | 32 | #include "editor/editorinteractive.h" | 32 | #include "editor/editorinteractive.h" |
869 | 33 | #include "editor/map_generator.h" | 33 | #include "editor/map_generator.h" |
870 | 34 | #include "graphic/font_handler.h" | 34 | #include "graphic/font_handler.h" |
871 | 35 | #include "graphic/text_layout.h" | ||
872 | 35 | #include "logic/editor_game_base.h" | 36 | #include "logic/editor_game_base.h" |
873 | 36 | #include "logic/map.h" | 37 | #include "logic/map.h" |
874 | 37 | #include "logic/map_objects/world/world.h" | 38 | #include "logic/map_objects/world/world.h" |
875 | @@ -51,7 +52,7 @@ | |||
876 | 51 | // UI elements | 52 | // UI elements |
877 | 52 | margin_(4), | 53 | margin_(4), |
878 | 53 | box_width_(get_inner_w() - 2 * margin_), | 54 | box_width_(get_inner_w() - 2 * margin_), |
880 | 54 | label_height_(text_height() + 2), | 55 | label_height_(text_height(UI::FontStyle::kLabel) + 2), |
881 | 55 | box_(this, margin_, margin_, UI::Box::Vertical, 0, 0, margin_), | 56 | box_(this, margin_, margin_, UI::Box::Vertical, 0, 0, margin_), |
882 | 56 | // Size | 57 | // Size |
883 | 57 | width_(&box_, | 58 | width_(&box_, |
884 | @@ -108,8 +109,8 @@ | |||
885 | 108 | resource_amount_(2), | 109 | resource_amount_(2), |
886 | 109 | world_box_(&box_, 0, 0, UI::Box::Horizontal, 0, 0, margin_), | 110 | world_box_(&box_, 0, 0, UI::Box::Horizontal, 0, 0, margin_), |
887 | 110 | resources_box_(&box_, 0, 0, UI::Box::Horizontal, 0, 0, margin_), | 111 | resources_box_(&box_, 0, 0, UI::Box::Horizontal, 0, 0, margin_), |
890 | 111 | world_label_(&world_box_, 0, 0, _("Climate:")), | 112 | world_label_(&world_box_, 0, 0, 0, 0, _("Climate:")), |
891 | 112 | resources_label_(&resources_box_, 0, 0, _("Resources:")), | 113 | resources_label_(&resources_box_, 0, 0, 0, 0, _("Resources:")), |
892 | 113 | world_(&world_box_, | 114 | world_(&world_box_, |
893 | 114 | "world", | 115 | "world", |
894 | 115 | 0, | 116 | 0, |
895 | @@ -171,7 +172,7 @@ | |||
896 | 171 | UI::SpinBox::Type::kSmall, | 172 | UI::SpinBox::Type::kSmall, |
897 | 172 | 5), | 173 | 5), |
898 | 173 | mountains_box_(&box_, 0, 0, UI::Box::Horizontal, 0, 0, margin_), | 174 | mountains_box_(&box_, 0, 0, UI::Box::Horizontal, 0, 0, margin_), |
900 | 174 | mountains_label_(&mountains_box_, 0, 0, _("Mountains:")), | 175 | mountains_label_(&mountains_box_, 0, 0, 0, 0, _("Mountains:")), |
901 | 175 | mountains_(&mountains_box_, | 176 | mountains_(&mountains_box_, |
902 | 176 | 0, | 177 | 0, |
903 | 177 | 0, | 178 | 0, |
904 | @@ -182,22 +183,18 @@ | |||
905 | 182 | island_mode_(&box_, Vector2i::zero(), _("Island mode")), | 183 | island_mode_(&box_, Vector2i::zero(), _("Island mode")), |
906 | 183 | // Geeky stuff | 184 | // Geeky stuff |
907 | 184 | map_number_box_(&box_, 0, 0, UI::Box::Horizontal, 0, 0, margin_), | 185 | map_number_box_(&box_, 0, 0, UI::Box::Horizontal, 0, 0, margin_), |
909 | 185 | map_number_label_(&map_number_box_, 0, 0, _("Random number:")), | 186 | map_number_label_(&map_number_box_, 0, 0, 0, 0, _("Random number:")), |
910 | 186 | map_number_edit_(&map_number_box_, | 187 | map_number_edit_(&map_number_box_, |
911 | 187 | 0, | 188 | 0, |
912 | 188 | 0, | 189 | 0, |
913 | 189 | box_width_ - 2 * margin_ - map_number_label_.get_w(), | 190 | box_width_ - 2 * margin_ - map_number_label_.get_w(), |
914 | 190 | 0, | ||
915 | 191 | 2, | ||
916 | 192 | UI::PanelStyle::kWui), | 191 | UI::PanelStyle::kWui), |
917 | 193 | map_id_box_(&box_, 0, 0, UI::Box::Horizontal, 0, 0, margin_), | 192 | map_id_box_(&box_, 0, 0, UI::Box::Horizontal, 0, 0, margin_), |
919 | 194 | map_id_label_(&map_id_box_, 0, 0, _("Map ID:")), | 193 | map_id_label_(&map_id_box_, 0, 0, 0, 0, _("Map ID:")), |
920 | 195 | map_id_edit_(&map_id_box_, | 194 | map_id_edit_(&map_id_box_, |
921 | 196 | 0, | 195 | 0, |
922 | 197 | 0, | 196 | 0, |
923 | 198 | box_width_ - 2 * margin_ - map_id_label_.get_w(), | 197 | box_width_ - 2 * margin_ - map_id_label_.get_w(), |
924 | 199 | 0, | ||
925 | 200 | 2, | ||
926 | 201 | UI::PanelStyle::kWui), | 198 | UI::PanelStyle::kWui), |
927 | 202 | // Buttons | 199 | // Buttons |
928 | 203 | button_box_(&box_, 0, 0, UI::Box::Horizontal, 0, 0, margin_), | 200 | button_box_(&box_, 0, 0, UI::Box::Horizontal, 0, 0, margin_), |
929 | 204 | 201 | ||
930 | === modified file 'src/editor/ui_menus/main_menu_save_map.cc' | |||
931 | --- src/editor/ui_menus/main_menu_save_map.cc 2019-03-18 21:10:56 +0000 | |||
932 | +++ src/editor/ui_menus/main_menu_save_map.cc 2019-05-26 02:00:17 +0000 | |||
933 | @@ -83,7 +83,7 @@ | |||
934 | 83 | 83 | ||
935 | 84 | editbox_ = new UI::EditBox( | 84 | editbox_ = new UI::EditBox( |
936 | 85 | this, editbox_label_.get_x() + editbox_label_.get_w() + padding_, editbox_label_.get_y(), | 85 | this, editbox_label_.get_x() + editbox_label_.get_w() + padding_, editbox_label_.get_y(), |
938 | 86 | tablew_ - editbox_label_.get_w() - padding_ + 1, buth_, 2, UI::PanelStyle::kWui); | 86 | tablew_ - editbox_label_.get_w() - padding_ + 1, UI::PanelStyle::kWui); |
939 | 87 | editbox_->set_text(parent.egbase().map().get_name()); | 87 | editbox_->set_text(parent.egbase().map().get_name()); |
940 | 88 | 88 | ||
941 | 89 | editbox_->changed.connect(boost::bind(&MainMenuSaveMap::edit_box_changed, this)); | 89 | editbox_->changed.connect(boost::bind(&MainMenuSaveMap::edit_box_changed, this)); |
942 | 90 | 90 | ||
943 | === modified file 'src/editor/ui_menus/main_menu_save_map_make_directory.cc' | |||
944 | --- src/editor/ui_menus/main_menu_save_map_make_directory.cc 2019-02-23 11:00:49 +0000 | |||
945 | +++ src/editor/ui_menus/main_menu_save_map_make_directory.cc 2019-05-26 02:00:17 +0000 | |||
946 | @@ -41,7 +41,7 @@ | |||
947 | 41 | get_inner_h() - 3 * padding_ - buth_, | 41 | get_inner_h() - 3 * padding_ - buth_, |
948 | 42 | padding_ / 2), | 42 | padding_ / 2), |
949 | 43 | label_(&vbox_, 0, 0, get_inner_w() - 2 * padding_, buth_, _("Enter Directory Name:")), | 43 | label_(&vbox_, 0, 0, get_inner_w() - 2 * padding_, buth_, _("Enter Directory Name:")), |
951 | 44 | edit_(&vbox_, 0, 0, get_inner_w() - 2 * padding_, 0, 4, UI::PanelStyle::kWui), | 44 | edit_(&vbox_, 0, 0, get_inner_w() - 2 * padding_, UI::PanelStyle::kWui), |
952 | 45 | ok_button_(this, | 45 | ok_button_(this, |
953 | 46 | "ok", | 46 | "ok", |
954 | 47 | UI::g_fh->fontset()->is_rtl() ? padding_ : get_inner_w() - butw_ - padding_, | 47 | UI::g_fh->fontset()->is_rtl() ? padding_ : get_inner_w() - butw_ - padding_, |
955 | 48 | 48 | ||
956 | === modified file 'src/editor/ui_menus/player_menu.cc' | |||
957 | --- src/editor/ui_menus/player_menu.cc 2019-02-27 19:00:36 +0000 | |||
958 | +++ src/editor/ui_menus/player_menu.cc 2019-05-26 02:00:17 +0000 | |||
959 | @@ -160,13 +160,11 @@ | |||
960 | 160 | UI::Box* row = new UI::Box(&box_, 0, 0, UI::Box::Horizontal); | 160 | UI::Box* row = new UI::Box(&box_, 0, 0, UI::Box::Horizontal); |
961 | 161 | 161 | ||
962 | 162 | // Name | 162 | // Name |
964 | 163 | UI::EditBox* plr_name = new UI::EditBox(row, 0, 0, 0, 0, kMargin, UI::PanelStyle::kWui); | 163 | UI::EditBox* plr_name = new UI::EditBox(row, 0, 0, 0, UI::PanelStyle::kWui); |
965 | 164 | if (map_has_player) { | 164 | if (map_has_player) { |
966 | 165 | plr_name->set_text(map.get_scenario_player_name(p)); | 165 | plr_name->set_text(map.get_scenario_player_name(p)); |
967 | 166 | } | 166 | } |
968 | 167 | plr_name->changed.connect(boost::bind(&EditorPlayerMenu::name_changed, this, p - 1)); | 167 | plr_name->changed.connect(boost::bind(&EditorPlayerMenu::name_changed, this, p - 1)); |
969 | 168 | row->add(plr_name, UI::Box::Resizing::kFillSpace); | ||
970 | 169 | row->add_space(kMargin); | ||
971 | 170 | 168 | ||
972 | 171 | // Tribe | 169 | // Tribe |
973 | 172 | UI::Dropdown<std::string>* plr_tribe = | 170 | UI::Dropdown<std::string>* plr_tribe = |
974 | @@ -189,8 +187,6 @@ | |||
975 | 189 | ""); | 187 | ""); |
976 | 190 | plr_tribe->selected.connect( | 188 | plr_tribe->selected.connect( |
977 | 191 | boost::bind(&EditorPlayerMenu::player_tribe_clicked, boost::ref(*this), p - 1)); | 189 | boost::bind(&EditorPlayerMenu::player_tribe_clicked, boost::ref(*this), p - 1)); |
978 | 192 | row->add(plr_tribe); | ||
979 | 193 | row->add_space(kMargin); | ||
980 | 194 | 190 | ||
981 | 195 | // Starting position | 191 | // Starting position |
982 | 196 | const Image* player_image = | 192 | const Image* player_image = |
983 | @@ -204,8 +200,17 @@ | |||
984 | 204 | player_image, _("Set this player’s starting position")); | 200 | player_image, _("Set this player’s starting position")); |
985 | 205 | plr_position->sigclicked.connect( | 201 | plr_position->sigclicked.connect( |
986 | 206 | boost::bind(&EditorPlayerMenu::set_starting_pos_clicked, boost::ref(*this), p)); | 202 | boost::bind(&EditorPlayerMenu::set_starting_pos_clicked, boost::ref(*this), p)); |
987 | 203 | |||
988 | 204 | // Add the elements to the row | ||
989 | 205 | row->add(plr_name, UI::Box::Resizing::kFillSpace); | ||
990 | 206 | row->add_space(kMargin); | ||
991 | 207 | |||
992 | 208 | row->add(plr_tribe); | ||
993 | 209 | row->add_space(kMargin); | ||
994 | 210 | |||
995 | 207 | row->add(plr_position); | 211 | row->add(plr_position); |
996 | 208 | 212 | ||
997 | 213 | // Add the row itself | ||
998 | 209 | box_.add(row, UI::Box::Resizing::kFullSize); | 214 | box_.add(row, UI::Box::Resizing::kFullSize); |
999 | 210 | box_.add_space(kMargin); | 215 | box_.add_space(kMargin); |
1000 | 211 | row->set_visible(map_has_player); | 216 | row->set_visible(map_has_player); |
1001 | @@ -227,7 +232,7 @@ | |||
1002 | 227 | assert(!rows_.empty()); | 232 | assert(!rows_.empty()); |
1003 | 228 | const Widelands::PlayerNumber nr_players = eia().egbase().map().get_nrplayers(); | 233 | const Widelands::PlayerNumber nr_players = eia().egbase().map().get_nrplayers(); |
1004 | 229 | box_.set_size(310, no_of_players_.get_h() + kMargin + | 234 | box_.set_size(310, no_of_players_.get_h() + kMargin + |
1006 | 230 | nr_players * (rows_.front()->tribe->get_h() + kMargin)); | 235 | nr_players * (rows_.front()->name->get_h() + kMargin)); |
1007 | 231 | set_inner_size(box_.get_w() + 2 * kMargin, box_.get_h() + 2 * kMargin); | 236 | set_inner_size(box_.get_w() + 2 * kMargin, box_.get_h() + 2 * kMargin); |
1008 | 232 | } | 237 | } |
1009 | 233 | 238 | ||
1010 | @@ -319,10 +324,10 @@ | |||
1011 | 319 | // Signal player position states via button states | 324 | // Signal player position states via button states |
1012 | 320 | iterate_player_numbers(pn, map->get_nrplayers()) { | 325 | iterate_player_numbers(pn, map->get_nrplayers()) { |
1013 | 321 | if (pn == row) { | 326 | if (pn == row) { |
1015 | 322 | rows_.at(pn - 1)->position->set_background_style(UI::ButtonStyle::kWuiPrimary); | 327 | rows_.at(pn - 1)->position->set_style(UI::ButtonStyle::kWuiPrimary); |
1016 | 323 | rows_.at(pn - 1)->position->set_perm_pressed(true); | 328 | rows_.at(pn - 1)->position->set_perm_pressed(true); |
1017 | 324 | } else { | 329 | } else { |
1019 | 325 | rows_.at(pn - 1)->position->set_background_style(UI::ButtonStyle::kWuiSecondary); | 330 | rows_.at(pn - 1)->position->set_style(UI::ButtonStyle::kWuiSecondary); |
1020 | 326 | rows_.at(pn - 1)->position->set_perm_pressed(map->get_starting_pos(pn) != | 331 | rows_.at(pn - 1)->position->set_perm_pressed(map->get_starting_pos(pn) != |
1021 | 327 | Widelands::Coords::null()); | 332 | Widelands::Coords::null()); |
1022 | 328 | } | 333 | } |
1023 | 329 | 334 | ||
1024 | === modified file 'src/editor/ui_menus/tool_change_resources_options_menu.cc' | |||
1025 | --- src/editor/ui_menus/tool_change_resources_options_menu.cc 2019-02-27 19:00:36 +0000 | |||
1026 | +++ src/editor/ui_menus/tool_change_resources_options_menu.cc 2019-05-26 02:00:17 +0000 | |||
1027 | @@ -73,7 +73,7 @@ | |||
1028 | 73 | UI::SpinBox::Units::kNone, | 73 | UI::SpinBox::Units::kNone, |
1029 | 74 | UI::SpinBox::Type::kSmall), | 74 | UI::SpinBox::Type::kSmall), |
1030 | 75 | resources_box_(&box_, 0, 0, UI::Box::Horizontal, 0, 0, 1), | 75 | resources_box_(&box_, 0, 0, UI::Box::Horizontal, 0, 0, 1), |
1032 | 76 | cur_selection_(&box_, 0, 0, "", UI::Align::kCenter) { | 76 | cur_selection_(&box_, 0, 0, 0, 0, "", UI::Align::kCenter) { |
1033 | 77 | // Configure spin boxes | 77 | // Configure spin boxes |
1034 | 78 | change_by_.set_tooltip( | 78 | change_by_.set_tooltip( |
1035 | 79 | /** TRANSLATORS: Editor change rseources access keys. **/ | 79 | /** TRANSLATORS: Editor change rseources access keys. **/ |
1036 | 80 | 80 | ||
1037 | === modified file 'src/graphic/CMakeLists.txt' | |||
1038 | --- src/graphic/CMakeLists.txt 2019-05-11 10:22:57 +0000 | |||
1039 | +++ src/graphic/CMakeLists.txt 2019-05-26 02:00:17 +0000 | |||
1040 | @@ -1,3 +1,4 @@ | |||
1041 | 1 | add_subdirectory(styles) | ||
1042 | 1 | add_subdirectory(text) | 2 | add_subdirectory(text) |
1043 | 2 | 3 | ||
1044 | 3 | # TODO(sirver): Separate this directory into a base directory and one | 4 | # TODO(sirver): Separate this directory into a base directory and one |
1045 | @@ -5,20 +6,12 @@ | |||
1046 | 5 | 6 | ||
1047 | 6 | # Align and color | 7 | # Align and color |
1048 | 7 | 8 | ||
1049 | 8 | |||
1050 | 9 | wl_library(graphic_styles | ||
1051 | 10 | SRCS | ||
1052 | 11 | panel_styles.cc | ||
1053 | 12 | panel_styles.h | ||
1054 | 13 | DEPENDS | ||
1055 | 14 | graphic_color | ||
1056 | 15 | graphic_surface | ||
1057 | 16 | ) | ||
1058 | 17 | |||
1059 | 18 | wl_library(graphic_align | 9 | wl_library(graphic_align |
1060 | 19 | SRCS | 10 | SRCS |
1061 | 20 | align.h | 11 | align.h |
1062 | 21 | align.cc | 12 | align.cc |
1063 | 13 | DEPENDS | ||
1064 | 14 | base_geometry | ||
1065 | 22 | ) | 15 | ) |
1066 | 23 | 16 | ||
1067 | 24 | wl_library(graphic_color | 17 | wl_library(graphic_color |
1068 | @@ -269,12 +262,6 @@ | |||
1069 | 269 | graphic_text | 262 | graphic_text |
1070 | 270 | ) | 263 | ) |
1071 | 271 | 264 | ||
1072 | 272 | wl_library(graphic_text_constants | ||
1073 | 273 | SRCS | ||
1074 | 274 | text_constants.h | ||
1075 | 275 | text_constants.cc | ||
1076 | 276 | ) | ||
1077 | 277 | |||
1078 | 278 | wl_library(graphic_text_layout | 265 | wl_library(graphic_text_layout |
1079 | 279 | SRCS | 266 | SRCS |
1080 | 280 | text_layout.cc | 267 | text_layout.cc |
1081 | @@ -284,8 +271,8 @@ | |||
1082 | 284 | graphic_align | 271 | graphic_align |
1083 | 285 | graphic_color | 272 | graphic_color |
1084 | 286 | graphic_surface | 273 | graphic_surface |
1085 | 274 | graphic_styles | ||
1086 | 287 | graphic_text | 275 | graphic_text |
1087 | 288 | graphic_text_constants | ||
1088 | 289 | graphic_fonthandler | 276 | graphic_fonthandler |
1089 | 290 | graphic_styles | 277 | graphic_styles |
1090 | 291 | ) | 278 | ) |
1091 | @@ -304,7 +291,6 @@ | |||
1092 | 304 | graphic_color | 291 | graphic_color |
1093 | 305 | graphic_fonthandler | 292 | graphic_fonthandler |
1094 | 306 | graphic_text | 293 | graphic_text |
1095 | 307 | graphic_text_constants | ||
1096 | 308 | graphic_text_layout | 294 | graphic_text_layout |
1097 | 309 | ) | 295 | ) |
1098 | 310 | 296 | ||
1099 | @@ -343,7 +329,6 @@ | |||
1100 | 343 | graphic_render_queue | 329 | graphic_render_queue |
1101 | 344 | graphic_styles | 330 | graphic_styles |
1102 | 345 | graphic_surface | 331 | graphic_surface |
1103 | 346 | graphic_text_layout | ||
1104 | 347 | io_filesystem | 332 | io_filesystem |
1105 | 348 | io_stream | 333 | io_stream |
1106 | 349 | logic_constants | 334 | logic_constants |
1107 | @@ -355,3 +340,4 @@ | |||
1108 | 355 | scripting_lua_table | 340 | scripting_lua_table |
1109 | 356 | sound | 341 | sound |
1110 | 357 | ) | 342 | ) |
1111 | 343 | |||
1112 | 358 | 344 | ||
1113 | === modified file 'src/graphic/align.cc' | |||
1114 | --- src/graphic/align.cc 2019-02-23 11:00:49 +0000 | |||
1115 | +++ src/graphic/align.cc 2019-05-26 02:00:17 +0000 | |||
1116 | @@ -19,4 +19,51 @@ | |||
1117 | 19 | 19 | ||
1118 | 20 | #include "graphic/align.h" | 20 | #include "graphic/align.h" |
1119 | 21 | 21 | ||
1121 | 22 | // Dummy | 22 | namespace UI { |
1122 | 23 | |||
1123 | 24 | /** | ||
1124 | 25 | * Align pt horizontally to match align based on width w. | ||
1125 | 26 | * | ||
1126 | 27 | * When correcting for align, we never move from pixel boundaries to | ||
1127 | 28 | * sub-pixels, because this might lead from pixel-perfect rendering to | ||
1128 | 29 | * subsampled rendering - this can lead to blurry texts. That is why we | ||
1129 | 30 | * never do float divisions in this function. | ||
1130 | 31 | */ | ||
1131 | 32 | void correct_for_align(Align align, uint32_t w, Vector2i* pt) { | ||
1132 | 33 | if (align == Align::kCenter) { | ||
1133 | 34 | pt->x -= w / 2; | ||
1134 | 35 | } else if (align == Align::kRight) { | ||
1135 | 36 | pt->x -= w; | ||
1136 | 37 | } | ||
1137 | 38 | } | ||
1138 | 39 | |||
1139 | 40 | /** | ||
1140 | 41 | * Adjust the y coordinate in 'point 'pt' to vertically center an element with height 'h'. | ||
1141 | 42 | */ | ||
1142 | 43 | void center_vertically(uint32_t h, Vector2i* pt) { | ||
1143 | 44 | pt->y -= h / 2; | ||
1144 | 45 | } | ||
1145 | 46 | |||
1146 | 47 | |||
1147 | 48 | /** | ||
1148 | 49 | * This mirrors the horizontal alignment for RTL languages. | ||
1149 | 50 | * | ||
1150 | 51 | * Do not store this value as it is based on the global font setting. | ||
1151 | 52 | */ | ||
1152 | 53 | Align mirror_alignment(Align alignment, bool is_rtl) { | ||
1153 | 54 | if (is_rtl) { | ||
1154 | 55 | switch (alignment) { | ||
1155 | 56 | case Align::kLeft: | ||
1156 | 57 | alignment = Align::kRight; | ||
1157 | 58 | break; | ||
1158 | 59 | case Align::kRight: | ||
1159 | 60 | alignment = Align::kLeft; | ||
1160 | 61 | break; | ||
1161 | 62 | case Align::kCenter: | ||
1162 | 63 | break; | ||
1163 | 64 | } | ||
1164 | 65 | } | ||
1165 | 66 | return alignment; | ||
1166 | 67 | } | ||
1167 | 68 | |||
1168 | 69 | } // namespace UI | ||
1169 | 23 | 70 | ||
1170 | === modified file 'src/graphic/align.h' | |||
1171 | --- src/graphic/align.h 2019-02-23 11:00:49 +0000 | |||
1172 | +++ src/graphic/align.h 2019-05-26 02:00:17 +0000 | |||
1173 | @@ -20,6 +20,10 @@ | |||
1174 | 20 | #ifndef WL_GRAPHIC_ALIGN_H | 20 | #ifndef WL_GRAPHIC_ALIGN_H |
1175 | 21 | #define WL_GRAPHIC_ALIGN_H | 21 | #define WL_GRAPHIC_ALIGN_H |
1176 | 22 | 22 | ||
1177 | 23 | #include <string> | ||
1178 | 24 | |||
1179 | 25 | #include "base/vector.h" | ||
1180 | 26 | |||
1181 | 23 | namespace UI { | 27 | namespace UI { |
1182 | 24 | 28 | ||
1183 | 25 | // TODO(GunChleoc): Step 1: Clean up superfluous usages of kLeft/kTop, especially with dalls to | 29 | // TODO(GunChleoc): Step 1: Clean up superfluous usages of kLeft/kTop, especially with dalls to |
1184 | @@ -33,5 +37,9 @@ | |||
1185 | 33 | kTop = kLeft, | 37 | kTop = kLeft, |
1186 | 34 | kBottom = kRight, | 38 | kBottom = kRight, |
1187 | 35 | }; | 39 | }; |
1188 | 40 | |||
1189 | 41 | void center_vertically(uint32_t h, Vector2i* pt); | ||
1190 | 42 | void correct_for_align(Align, uint32_t w, Vector2i* pt); | ||
1191 | 43 | Align mirror_alignment(Align alignment, bool is_rtl); | ||
1192 | 36 | } // namespace UI | 44 | } // namespace UI |
1193 | 37 | #endif // end of include guard: WL_GRAPHIC_ALIGN_H | 45 | #endif // end of include guard: WL_GRAPHIC_ALIGN_H |
1194 | 38 | 46 | ||
1195 | === modified file 'src/graphic/font_handler.cc' | |||
1196 | --- src/graphic/font_handler.cc 2019-02-23 11:00:49 +0000 | |||
1197 | +++ src/graphic/font_handler.cc 2019-05-26 02:00:17 +0000 | |||
1198 | @@ -87,7 +87,7 @@ | |||
1199 | 87 | const std::string hash = boost::lexical_cast<std::string>(w) + text; | 87 | const std::string hash = boost::lexical_cast<std::string>(w) + text; |
1200 | 88 | std::shared_ptr<const RenderedText> rendered_text = render_cache_->get(hash); | 88 | std::shared_ptr<const RenderedText> rendered_text = render_cache_->get(hash); |
1201 | 89 | if (rendered_text == nullptr) { | 89 | if (rendered_text == nullptr) { |
1203 | 90 | rendered_text = render_cache_->insert(hash, rt_renderer_->render(text, w)); | 90 | rendered_text = render_cache_->insert(hash, rt_renderer_->render(text, w, fontset()->is_rtl())); |
1204 | 91 | } | 91 | } |
1205 | 92 | return rendered_text; | 92 | return rendered_text; |
1206 | 93 | } | 93 | } |
1207 | 94 | 94 | ||
1208 | === modified file 'src/graphic/graphic.cc' | |||
1209 | --- src/graphic/graphic.cc 2019-02-28 08:02:18 +0000 | |||
1210 | +++ src/graphic/graphic.cc 2019-05-26 02:00:17 +0000 | |||
1211 | @@ -35,7 +35,6 @@ | |||
1212 | 35 | #include "graphic/render_queue.h" | 35 | #include "graphic/render_queue.h" |
1213 | 36 | #include "graphic/rendertarget.h" | 36 | #include "graphic/rendertarget.h" |
1214 | 37 | #include "graphic/screen.h" | 37 | #include "graphic/screen.h" |
1215 | 38 | #include "graphic/text_layout.h" | ||
1216 | 39 | #include "graphic/texture.h" | 38 | #include "graphic/texture.h" |
1217 | 40 | #include "io/filesystem/layered_filesystem.h" | 39 | #include "io/filesystem/layered_filesystem.h" |
1218 | 41 | #include "io/streamwrite.h" | 40 | #include "io/streamwrite.h" |
1219 | 42 | 41 | ||
1220 | === removed file 'src/graphic/panel_styles.cc' | |||
1221 | --- src/graphic/panel_styles.cc 2017-06-12 11:07:47 +0000 | |||
1222 | +++ src/graphic/panel_styles.cc 1970-01-01 00:00:00 +0000 | |||
1223 | @@ -1,1 +0,0 @@ | |||
1224 | 1 | // Dummy to make CMake happy | ||
1225 | 2 | 0 | ||
1226 | === modified file 'src/graphic/rendertarget.cc' | |||
1227 | --- src/graphic/rendertarget.cc 2019-04-24 06:32:02 +0000 | |||
1228 | +++ src/graphic/rendertarget.cc 2019-05-26 02:00:17 +0000 | |||
1229 | @@ -20,10 +20,10 @@ | |||
1230 | 20 | #include "graphic/rendertarget.h" | 20 | #include "graphic/rendertarget.h" |
1231 | 21 | 21 | ||
1232 | 22 | #include "base/macros.h" | 22 | #include "base/macros.h" |
1233 | 23 | #include "graphic/align.h" | ||
1234 | 23 | #include "graphic/animation.h" | 24 | #include "graphic/animation.h" |
1235 | 24 | #include "graphic/graphic.h" | 25 | #include "graphic/graphic.h" |
1236 | 25 | #include "graphic/surface.h" | 26 | #include "graphic/surface.h" |
1237 | 26 | #include "graphic/text_layout.h" | ||
1238 | 27 | 27 | ||
1239 | 28 | /** | 28 | /** |
1240 | 29 | * Build a render target for the given surface. | 29 | * Build a render target for the given surface. |
1241 | 30 | 30 | ||
1242 | === modified file 'src/graphic/style_manager.cc' | |||
1243 | --- src/graphic/style_manager.cc 2019-02-23 11:00:49 +0000 | |||
1244 | +++ src/graphic/style_manager.cc 2019-05-26 02:00:17 +0000 | |||
1245 | @@ -21,21 +21,55 @@ | |||
1246 | 21 | 21 | ||
1247 | 22 | #include <memory> | 22 | #include <memory> |
1248 | 23 | 23 | ||
1249 | 24 | #include <boost/format.hpp> | ||
1250 | 25 | |||
1251 | 24 | #include "base/scoped_timer.h" | 26 | #include "base/scoped_timer.h" |
1252 | 25 | #include "base/wexception.h" | 27 | #include "base/wexception.h" |
1253 | 26 | #include "graphic/graphic.h" | 28 | #include "graphic/graphic.h" |
1254 | 27 | #include "scripting/lua_interface.h" | 29 | #include "scripting/lua_interface.h" |
1255 | 28 | 30 | ||
1256 | 29 | namespace { | 31 | namespace { |
1259 | 30 | // Read image filename and RGB color from LuaTable | 32 | // Read RGB color from LuaTable |
1260 | 31 | UI::PanelStyleInfo* read_style(const LuaTable& table) { | 33 | RGBColor read_rgb_color(const LuaTable& table) { |
1261 | 34 | std::vector<int> rgbcolor = table.array_entries<int>(); | ||
1262 | 35 | if (rgbcolor.size() != 3) { | ||
1263 | 36 | throw wexception("Expected 3 entries for RGB color, but got %" PRIuS ".", rgbcolor.size()); | ||
1264 | 37 | } | ||
1265 | 38 | return RGBColor(rgbcolor[0], rgbcolor[1], rgbcolor[2]); | ||
1266 | 39 | } | ||
1267 | 40 | |||
1268 | 41 | // Read font style from LuaTable | ||
1269 | 42 | UI::FontStyleInfo* read_font_style(const LuaTable& parent_table, const std::string& table_key) { | ||
1270 | 43 | std::unique_ptr<LuaTable> style_table = parent_table.get_table(table_key); | ||
1271 | 44 | const int size = style_table->get_int("size"); | ||
1272 | 45 | if (size < 1) { | ||
1273 | 46 | throw wexception("Font size %d too small for %s, must be at least 1!", size, table_key.c_str()); | ||
1274 | 47 | } | ||
1275 | 48 | return new UI::FontStyleInfo( | ||
1276 | 49 | style_table->get_string("face"), | ||
1277 | 50 | read_rgb_color(*style_table->get_table("color")), | ||
1278 | 51 | size, | ||
1279 | 52 | style_table->has_key<std::string>("bold") ? style_table->get_bool("bold") : false, | ||
1280 | 53 | style_table->has_key<std::string>("italic") ? style_table->get_bool("italic") : false, | ||
1281 | 54 | style_table->has_key<std::string>("underline") ? style_table->get_bool("underline") : false, | ||
1282 | 55 | style_table->has_key<std::string>("shadow") ? style_table->get_bool("shadow") : false); | ||
1283 | 56 | } | ||
1284 | 57 | |||
1285 | 58 | // Read image filename and RGBA color from LuaTable | ||
1286 | 59 | UI::PanelStyleInfo* read_panel_style(const LuaTable& table) { | ||
1287 | 32 | const std::string image = table.get_string("image"); | 60 | const std::string image = table.get_string("image"); |
1288 | 33 | std::vector<int> rgbcolor = table.get_table("color")->array_entries<int>(); | 61 | std::vector<int> rgbcolor = table.get_table("color")->array_entries<int>(); |
1289 | 34 | if (rgbcolor.size() != 3) { | 62 | if (rgbcolor.size() != 3) { |
1290 | 35 | throw wexception("Expected 3 entries for RGB color, but got %" PRIuS ".", rgbcolor.size()); | 63 | throw wexception("Expected 3 entries for RGB color, but got %" PRIuS ".", rgbcolor.size()); |
1291 | 36 | } | 64 | } |
1292 | 37 | return new UI::PanelStyleInfo(image.empty() ? nullptr : g_gr->images().get(image), | 65 | return new UI::PanelStyleInfo(image.empty() ? nullptr : g_gr->images().get(image), |
1294 | 38 | RGBAColor(rgbcolor[0], rgbcolor[1], rgbcolor[2], 0)); | 66 | RGBAColor(rgbcolor[0], rgbcolor[1], rgbcolor[2], 0), |
1295 | 67 | table.has_key<std::string>("margin") ? table.get_int("margin") : 0); | ||
1296 | 68 | } | ||
1297 | 69 | |||
1298 | 70 | // Read text panel style from LuaTable | ||
1299 | 71 | UI::TextPanelStyleInfo* read_text_panel_style(const LuaTable& table) { | ||
1300 | 72 | return new UI::TextPanelStyleInfo(read_font_style(table, "font"), read_panel_style(*table.get_table("background"))); | ||
1301 | 39 | } | 73 | } |
1302 | 40 | 74 | ||
1303 | 41 | // Stupid completeness check - enum classes weren't meant for iterating, so we just compare the size | 75 | // Stupid completeness check - enum classes weren't meant for iterating, so we just compare the size |
1304 | @@ -59,45 +93,34 @@ | |||
1305 | 59 | dropdownstyles_.clear(); | 93 | dropdownstyles_.clear(); |
1306 | 60 | scrollbarstyles_.clear(); | 94 | scrollbarstyles_.clear(); |
1307 | 61 | 95 | ||
1308 | 62 | log("Style Manager: Loading %sinit.lua ... ", kTemplateDir.c_str()); | ||
1309 | 63 | |||
1310 | 64 | LuaInterface lua; | 96 | LuaInterface lua; |
1311 | 65 | std::unique_ptr<LuaTable> table(lua.run_script(kTemplateDir + "init.lua")); | 97 | std::unique_ptr<LuaTable> table(lua.run_script(kTemplateDir + "init.lua")); |
1312 | 66 | 98 | ||
1313 | 67 | log("took %ums\n", timer.ms_since_last_query()); | ||
1314 | 68 | log("Style Manager: Reading button styles ... "); | ||
1315 | 69 | |||
1316 | 70 | // Buttons | 99 | // Buttons |
1317 | 71 | std::unique_ptr<LuaTable> element_table = table->get_table("buttons"); | 100 | std::unique_ptr<LuaTable> element_table = table->get_table("buttons"); |
1318 | 72 | std::unique_ptr<LuaTable> style_table = element_table->get_table("fsmenu"); | 101 | std::unique_ptr<LuaTable> style_table = element_table->get_table("fsmenu"); |
1322 | 73 | add_button_style(UI::ButtonStyle::kFsMenuMenu, *style_table->get_table("menu").get()); | 102 | add_button_style(UI::ButtonStyle::kFsMenuMenu, *style_table->get_table("menu")); |
1323 | 74 | add_button_style(UI::ButtonStyle::kFsMenuPrimary, *style_table->get_table("primary").get()); | 103 | add_button_style(UI::ButtonStyle::kFsMenuPrimary, *style_table->get_table("primary")); |
1324 | 75 | add_button_style(UI::ButtonStyle::kFsMenuSecondary, *style_table->get_table("secondary").get()); | 104 | add_button_style(UI::ButtonStyle::kFsMenuSecondary, *style_table->get_table("secondary")); |
1325 | 76 | style_table = element_table->get_table("wui"); | 105 | style_table = element_table->get_table("wui"); |
1329 | 77 | add_button_style(UI::ButtonStyle::kWuiMenu, *style_table->get_table("menu").get()); | 106 | add_button_style(UI::ButtonStyle::kWuiMenu, *style_table->get_table("menu")); |
1330 | 78 | add_button_style(UI::ButtonStyle::kWuiPrimary, *style_table->get_table("primary").get()); | 107 | add_button_style(UI::ButtonStyle::kWuiPrimary, *style_table->get_table("primary")); |
1331 | 79 | add_button_style(UI::ButtonStyle::kWuiSecondary, *style_table->get_table("secondary").get()); | 108 | add_button_style(UI::ButtonStyle::kWuiSecondary, *style_table->get_table("secondary")); |
1332 | 80 | add_button_style( | 109 | add_button_style( |
1334 | 81 | UI::ButtonStyle::kWuiBuildingStats, *style_table->get_table("building_stats").get()); | 110 | UI::ButtonStyle::kWuiBuildingStats, *style_table->get_table("building_stats")); |
1335 | 82 | check_completeness( | 111 | check_completeness( |
1336 | 83 | "buttons", buttonstyles_.size(), static_cast<size_t>(UI::ButtonStyle::kWuiBuildingStats)); | 112 | "buttons", buttonstyles_.size(), static_cast<size_t>(UI::ButtonStyle::kWuiBuildingStats)); |
1337 | 84 | 113 | ||
1338 | 85 | log("took %ums\n", timer.ms_since_last_query()); | ||
1339 | 86 | log("Style Manager: Reading slider styles ... "); | ||
1340 | 87 | |||
1341 | 88 | // Sliders | 114 | // Sliders |
1342 | 89 | element_table = table->get_table("sliders"); | 115 | element_table = table->get_table("sliders"); |
1343 | 90 | style_table = element_table->get_table("fsmenu"); | 116 | style_table = element_table->get_table("fsmenu"); |
1345 | 91 | add_slider_style(UI::SliderStyle::kFsMenu, *style_table->get_table("menu").get()); | 117 | add_slider_style(UI::SliderStyle::kFsMenu, *style_table->get_table("menu")); |
1346 | 92 | style_table = element_table->get_table("wui"); | 118 | style_table = element_table->get_table("wui"); |
1349 | 93 | add_slider_style(UI::SliderStyle::kWuiLight, *style_table->get_table("light").get()); | 119 | add_slider_style(UI::SliderStyle::kWuiLight, *style_table->get_table("light")); |
1350 | 94 | add_slider_style(UI::SliderStyle::kWuiDark, *style_table->get_table("dark").get()); | 120 | add_slider_style(UI::SliderStyle::kWuiDark, *style_table->get_table("dark")); |
1351 | 95 | check_completeness( | 121 | check_completeness( |
1352 | 96 | "sliders", sliderstyles_.size(), static_cast<size_t>(UI::SliderStyle::kWuiDark)); | 122 | "sliders", sliderstyles_.size(), static_cast<size_t>(UI::SliderStyle::kWuiDark)); |
1353 | 97 | 123 | ||
1354 | 98 | log("took %ums\n", timer.ms_since_last_query()); | ||
1355 | 99 | log("Style Manager: Reading tabpanel styles ... "); | ||
1356 | 100 | |||
1357 | 101 | // Tabpanels | 124 | // Tabpanels |
1358 | 102 | element_table = table->get_table("tabpanels"); | 125 | element_table = table->get_table("tabpanels"); |
1359 | 103 | style_table = element_table->get_table("fsmenu"); | 126 | style_table = element_table->get_table("fsmenu"); |
1360 | @@ -108,21 +131,13 @@ | |||
1361 | 108 | check_completeness( | 131 | check_completeness( |
1362 | 109 | "tabpanels", tabpanelstyles_.size(), static_cast<size_t>(UI::TabPanelStyle::kWuiDark)); | 132 | "tabpanels", tabpanelstyles_.size(), static_cast<size_t>(UI::TabPanelStyle::kWuiDark)); |
1363 | 110 | 133 | ||
1364 | 111 | log("took %ums\n", timer.ms_since_last_query()); | ||
1365 | 112 | log("Style Manager: Reading editbox styles ... "); | ||
1366 | 113 | |||
1367 | 114 | // Editboxes | 134 | // Editboxes |
1368 | 115 | element_table = table->get_table("editboxes"); | 135 | element_table = table->get_table("editboxes"); |
1373 | 116 | style_table = element_table->get_table("fsmenu"); | 136 | add_editbox_style(UI::PanelStyle::kFsMenu, *element_table->get_table("fsmenu")); |
1374 | 117 | add_style(UI::PanelStyle::kFsMenu, *style_table->get_table("menu").get(), &editboxstyles_); | 137 | add_editbox_style(UI::PanelStyle::kWui, *element_table->get_table("wui")); |
1371 | 118 | style_table = element_table->get_table("wui"); | ||
1372 | 119 | add_style(UI::PanelStyle::kWui, *style_table->get_table("menu").get(), &editboxstyles_); | ||
1375 | 120 | check_completeness( | 138 | check_completeness( |
1376 | 121 | "editboxes", editboxstyles_.size(), static_cast<size_t>(UI::PanelStyle::kWui)); | 139 | "editboxes", editboxstyles_.size(), static_cast<size_t>(UI::PanelStyle::kWui)); |
1377 | 122 | 140 | ||
1378 | 123 | log("took %ums\n", timer.ms_since_last_query()); | ||
1379 | 124 | log("Style Manager: Reading dropdown styles ... "); | ||
1380 | 125 | |||
1381 | 126 | // Dropdowns | 141 | // Dropdowns |
1382 | 127 | element_table = table->get_table("dropdowns"); | 142 | element_table = table->get_table("dropdowns"); |
1383 | 128 | style_table = element_table->get_table("fsmenu"); | 143 | style_table = element_table->get_table("fsmenu"); |
1384 | @@ -132,9 +147,6 @@ | |||
1385 | 132 | check_completeness( | 147 | check_completeness( |
1386 | 133 | "dropdowns", dropdownstyles_.size(), static_cast<size_t>(UI::PanelStyle::kWui)); | 148 | "dropdowns", dropdownstyles_.size(), static_cast<size_t>(UI::PanelStyle::kWui)); |
1387 | 134 | 149 | ||
1388 | 135 | log("took %ums\n", timer.ms_since_last_query()); | ||
1389 | 136 | log("Style Manager: Reading scrollbar styles ... "); | ||
1390 | 137 | |||
1391 | 138 | // Scrollbars | 150 | // Scrollbars |
1392 | 139 | element_table = table->get_table("scrollbars"); | 151 | element_table = table->get_table("scrollbars"); |
1393 | 140 | style_table = element_table->get_table("fsmenu"); | 152 | style_table = element_table->get_table("fsmenu"); |
1394 | @@ -144,18 +156,81 @@ | |||
1395 | 144 | check_completeness( | 156 | check_completeness( |
1396 | 145 | "scrollbars", scrollbarstyles_.size(), static_cast<size_t>(UI::PanelStyle::kWui)); | 157 | "scrollbars", scrollbarstyles_.size(), static_cast<size_t>(UI::PanelStyle::kWui)); |
1397 | 146 | 158 | ||
1399 | 147 | log("took %ums\n", timer.ms_since_last_query()); | 159 | // Building statistics etc. for map objects |
1400 | 160 | set_building_statistics_style(*table->get_table("building_statistics")); | ||
1401 | 161 | |||
1402 | 162 | // Progress bars | ||
1403 | 163 | element_table = table->get_table("progressbar"); | ||
1404 | 164 | add_progressbar_style(UI::PanelStyle::kFsMenu, *element_table->get_table("fsmenu")); | ||
1405 | 165 | add_progressbar_style(UI::PanelStyle::kWui, *element_table->get_table("wui")); | ||
1406 | 166 | check_completeness( | ||
1407 | 167 | "progressbars", progressbar_styles_.size(), static_cast<size_t>(UI::PanelStyle::kWui)); | ||
1408 | 168 | |||
1409 | 169 | // Table and listselect | ||
1410 | 170 | element_table = table->get_table("tables"); | ||
1411 | 171 | add_table_style(UI::PanelStyle::kFsMenu, *element_table->get_table("fsmenu")); | ||
1412 | 172 | add_table_style(UI::PanelStyle::kWui, *element_table->get_table("wui")); | ||
1413 | 173 | check_completeness( | ||
1414 | 174 | "tables", table_styles_.size(), static_cast<size_t>(UI::PanelStyle::kWui)); | ||
1415 | 175 | |||
1416 | 176 | // Statistics plot | ||
1417 | 177 | set_statistics_plot_style(*table->get_table("statistics_plot")); | ||
1418 | 178 | |||
1419 | 179 | // Ware info in warehouses, construction actions etc. | ||
1420 | 180 | element_table = table->get_table("wareinfo"); | ||
1421 | 181 | add_ware_info_style(UI::WareInfoStyle::kNormal, *element_table->get_table("normal")); | ||
1422 | 182 | add_ware_info_style(UI::WareInfoStyle::kHighlight, *element_table->get_table("highlight")); | ||
1423 | 183 | check_completeness( | ||
1424 | 184 | "wareinfos", ware_info_styles_.size(), static_cast<size_t>(UI::WareInfoStyle::kHighlight)); | ||
1425 | 185 | |||
1426 | 186 | // Special elements | ||
1427 | 187 | minimum_font_size_ = table->get_int("minimum_font_size"); | ||
1428 | 188 | if (minimum_font_size_ < 1) { | ||
1429 | 189 | throw wexception("Font size too small for minimum_font_size, must be at least 1!"); | ||
1430 | 190 | } | ||
1431 | 191 | minimap_icon_frame_ = read_rgb_color(*table->get_table("minimap_icon_frame")); | ||
1432 | 192 | |||
1433 | 193 | // Fonts | ||
1434 | 194 | element_table = table->get_table("fonts"); | ||
1435 | 195 | add_font_style(UI::FontStyle::kChatMessage, *element_table, "chat_message"); | ||
1436 | 196 | add_font_style(UI::FontStyle::kChatPlayername, *element_table, "chat_playername"); | ||
1437 | 197 | add_font_style(UI::FontStyle::kChatServer, *element_table, "chat_server"); | ||
1438 | 198 | add_font_style(UI::FontStyle::kChatTimestamp, *element_table, "chat_timestamp"); | ||
1439 | 199 | add_font_style(UI::FontStyle::kChatWhisper, *element_table, "chat_whisper"); | ||
1440 | 200 | add_font_style(UI::FontStyle::kFsGameSetupHeadings, *element_table, "fsmenu_game_setup_headings"); | ||
1441 | 201 | add_font_style(UI::FontStyle::kFsGameSetupSuperuser, *element_table, "fsmenu_game_setup_superuser"); | ||
1442 | 202 | add_font_style(UI::FontStyle::kFsGameSetupIrcClient, *element_table, "fsmenu_game_setup_irc_client"); | ||
1443 | 203 | add_font_style(UI::FontStyle::kFsGameSetupMapname, *element_table, "fsmenu_game_setup_mapname"); | ||
1444 | 204 | add_font_style(UI::FontStyle::kFsMenuGameTip, *element_table, "fsmenu_gametip"); | ||
1445 | 205 | add_font_style(UI::FontStyle::kFsMenuInfoPanelHeading, *element_table, "fsmenu_info_panel_heading"); | ||
1446 | 206 | add_font_style(UI::FontStyle::kFsMenuInfoPanelParagraph, *element_table, "fsmenu_info_panel_paragraph"); | ||
1447 | 207 | add_font_style(UI::FontStyle::kFsMenuIntro, *element_table, "fsmenu_intro"); | ||
1448 | 208 | add_font_style(UI::FontStyle::kFsMenuTitle, *element_table, "fsmenu_title"); | ||
1449 | 209 | add_font_style(UI::FontStyle::kFsMenuTranslationInfo, *element_table, "fsmenu_translation_info"); | ||
1450 | 210 | add_font_style(UI::FontStyle::kDisabled, *element_table, "disabled"); | ||
1451 | 211 | add_font_style(UI::FontStyle::kLabel, *element_table, "label"); | ||
1452 | 212 | add_font_style(UI::FontStyle::kTooltipHeader, *element_table, "tooltip_header"); | ||
1453 | 213 | add_font_style(UI::FontStyle::kTooltip, *element_table, "tooltip"); | ||
1454 | 214 | add_font_style(UI::FontStyle::kWarning, *element_table, "warning"); | ||
1455 | 215 | add_font_style(UI::FontStyle::kWuiAttackBoxSliderLabel, *element_table, "wui_attack_box_slider_label"); | ||
1456 | 216 | add_font_style(UI::FontStyle::kWuiGameSpeedAndCoordinates, *element_table, "wui_game_speed_and_coordinates"); | ||
1457 | 217 | add_font_style(UI::FontStyle::kWuiInfoPanelHeading, *element_table, "wui_info_panel_heading"); | ||
1458 | 218 | add_font_style(UI::FontStyle::kWuiInfoPanelParagraph, *element_table, "wui_info_panel_paragraph"); | ||
1459 | 219 | add_font_style(UI::FontStyle::kWuiMessageHeading, *element_table, "wui_message_heading"); | ||
1460 | 220 | add_font_style(UI::FontStyle::kWuiMessageParagraph, *element_table, "wui_message_paragraph"); | ||
1461 | 221 | add_font_style(UI::FontStyle::kWuiWindowTitle, *element_table, "wui_window_title"); | ||
1462 | 222 | check_completeness("fonts", fontstyles_.size(), static_cast<size_t>(UI::FontStyle::kWuiWindowTitle)); | ||
1463 | 148 | } | 223 | } |
1464 | 149 | 224 | ||
1465 | 150 | // Return functions for the styles | 225 | // Return functions for the styles |
1467 | 151 | const UI::PanelStyleInfo* StyleManager::button_style(UI::ButtonStyle style) const { | 226 | const UI::ButtonStyleInfo& StyleManager::button_style(UI::ButtonStyle style) const { |
1468 | 152 | assert(buttonstyles_.count(style) == 1); | 227 | assert(buttonstyles_.count(style) == 1); |
1470 | 153 | return buttonstyles_.at(style).get(); | 228 | return *buttonstyles_.at(style); |
1471 | 154 | } | 229 | } |
1472 | 155 | 230 | ||
1474 | 156 | const UI::PanelStyleInfo* StyleManager::slider_style(UI::SliderStyle style) const { | 231 | const UI::TextPanelStyleInfo& StyleManager::slider_style(UI::SliderStyle style) const { |
1475 | 157 | assert(sliderstyles_.count(style) == 1); | 232 | assert(sliderstyles_.count(style) == 1); |
1477 | 158 | return sliderstyles_.at(style).get(); | 233 | return *sliderstyles_.at(style); |
1478 | 159 | } | 234 | } |
1479 | 160 | 235 | ||
1480 | 161 | const UI::PanelStyleInfo* StyleManager::tabpanel_style(UI::TabPanelStyle style) const { | 236 | const UI::PanelStyleInfo* StyleManager::tabpanel_style(UI::TabPanelStyle style) const { |
1481 | @@ -163,9 +238,9 @@ | |||
1482 | 163 | return tabpanelstyles_.at(style).get(); | 238 | return tabpanelstyles_.at(style).get(); |
1483 | 164 | } | 239 | } |
1484 | 165 | 240 | ||
1486 | 166 | const UI::PanelStyleInfo* StyleManager::editbox_style(UI::PanelStyle style) const { | 241 | const UI::TextPanelStyleInfo& StyleManager::editbox_style(UI::PanelStyle style) const { |
1487 | 167 | assert(editboxstyles_.count(style) == 1); | 242 | assert(editboxstyles_.count(style) == 1); |
1489 | 168 | return editboxstyles_.at(style).get(); | 243 | return *editboxstyles_.at(style); |
1490 | 169 | } | 244 | } |
1491 | 170 | 245 | ||
1492 | 171 | const UI::PanelStyleInfo* StyleManager::dropdown_style(UI::PanelStyle style) const { | 246 | const UI::PanelStyleInfo* StyleManager::dropdown_style(UI::PanelStyle style) const { |
1493 | @@ -178,22 +253,143 @@ | |||
1494 | 178 | return scrollbarstyles_.at(style).get(); | 253 | return scrollbarstyles_.at(style).get(); |
1495 | 179 | } | 254 | } |
1496 | 180 | 255 | ||
1497 | 256 | const UI::BuildingStatisticsStyleInfo& StyleManager::building_statistics_style() const { | ||
1498 | 257 | return *building_statistics_style_; | ||
1499 | 258 | } | ||
1500 | 259 | |||
1501 | 260 | const UI::ProgressbarStyleInfo& StyleManager::progressbar_style(UI::PanelStyle style) const { | ||
1502 | 261 | assert(progressbar_styles_.count(style) == 1); | ||
1503 | 262 | return *progressbar_styles_.at(style); | ||
1504 | 263 | } | ||
1505 | 264 | |||
1506 | 265 | const UI::StatisticsPlotStyleInfo& StyleManager::statistics_plot_style() const { | ||
1507 | 266 | return *statistics_plot_style_; | ||
1508 | 267 | } | ||
1509 | 268 | |||
1510 | 269 | const UI::TableStyleInfo& StyleManager::table_style(UI::PanelStyle style) const { | ||
1511 | 270 | assert(table_styles_.count(style) == 1); | ||
1512 | 271 | return *table_styles_.at(style); | ||
1513 | 272 | } | ||
1514 | 273 | |||
1515 | 274 | const UI::WareInfoStyleInfo& StyleManager::ware_info_style(UI::WareInfoStyle style) const { | ||
1516 | 275 | assert(ware_info_styles_.count(style) == 1); | ||
1517 | 276 | return *ware_info_styles_.at(style); | ||
1518 | 277 | } | ||
1519 | 278 | |||
1520 | 279 | const UI::FontStyleInfo& StyleManager::font_style(UI::FontStyle style) const { | ||
1521 | 280 | assert(fontstyles_.count(style) == 1); | ||
1522 | 281 | return *fontstyles_.at(style); | ||
1523 | 282 | } | ||
1524 | 283 | |||
1525 | 284 | int StyleManager::minimum_font_size() const { | ||
1526 | 285 | return minimum_font_size_; | ||
1527 | 286 | } | ||
1528 | 287 | |||
1529 | 288 | const RGBColor& StyleManager::minimap_icon_frame() const { | ||
1530 | 289 | return minimap_icon_frame_; | ||
1531 | 290 | } | ||
1532 | 291 | |||
1533 | 292 | std::string StyleManager::color_tag(const std::string& text, const RGBColor& color) { | ||
1534 | 293 | static boost::format f("<font color=%s>%s</font>"); | ||
1535 | 294 | f % color.hex_value(); | ||
1536 | 295 | f % text; | ||
1537 | 296 | return f.str(); | ||
1538 | 297 | } | ||
1539 | 298 | |||
1540 | 181 | // Fill the maps | 299 | // Fill the maps |
1541 | 182 | void StyleManager::add_button_style(UI::ButtonStyle style, const LuaTable& table) { | 300 | void StyleManager::add_button_style(UI::ButtonStyle style, const LuaTable& table) { |
1542 | 183 | buttonstyles_.insert( | 301 | buttonstyles_.insert( |
1544 | 184 | std::make_pair(style, std::unique_ptr<UI::PanelStyleInfo>(read_style(table)))); | 302 | std::make_pair( |
1545 | 303 | style, | ||
1546 | 304 | std::unique_ptr<const UI::ButtonStyleInfo>( | ||
1547 | 305 | new UI::ButtonStyleInfo( | ||
1548 | 306 | read_text_panel_style(*table.get_table("enabled")), | ||
1549 | 307 | read_text_panel_style(*table.get_table("disabled")))))); | ||
1550 | 185 | } | 308 | } |
1551 | 186 | 309 | ||
1552 | 187 | void StyleManager::add_slider_style(UI::SliderStyle style, const LuaTable& table) { | 310 | void StyleManager::add_slider_style(UI::SliderStyle style, const LuaTable& table) { |
1553 | 188 | sliderstyles_.insert( | 311 | sliderstyles_.insert( |
1556 | 189 | std::make_pair(style, std::unique_ptr<UI::PanelStyleInfo>(read_style(table)))); | 312 | std::make_pair(style, std::unique_ptr<UI::TextPanelStyleInfo>(read_text_panel_style(table)))); |
1557 | 190 | } | 313 | } |
1558 | 314 | |||
1559 | 315 | void StyleManager::add_editbox_style(UI::PanelStyle style, const LuaTable& table) { | ||
1560 | 316 | editboxstyles_.insert( | ||
1561 | 317 | std::make_pair(style, std::unique_ptr<UI::TextPanelStyleInfo>(read_text_panel_style(table)))); | ||
1562 | 318 | } | ||
1563 | 319 | |||
1564 | 191 | 320 | ||
1565 | 192 | void StyleManager::add_tabpanel_style(UI::TabPanelStyle style, const LuaTable& table) { | 321 | void StyleManager::add_tabpanel_style(UI::TabPanelStyle style, const LuaTable& table) { |
1566 | 193 | tabpanelstyles_.insert( | 322 | tabpanelstyles_.insert( |
1568 | 194 | std::make_pair(style, std::unique_ptr<UI::PanelStyleInfo>(read_style(table)))); | 323 | std::make_pair(style, std::unique_ptr<UI::PanelStyleInfo>(read_panel_style(table)))); |
1569 | 324 | } | ||
1570 | 325 | |||
1571 | 326 | void StyleManager::add_progressbar_style(UI::PanelStyle style, const LuaTable& table) { | ||
1572 | 327 | std::unique_ptr<LuaTable> color_table = table.get_table("background_colors"); | ||
1573 | 328 | progressbar_styles_.insert(std::make_pair( | ||
1574 | 329 | style, | ||
1575 | 330 | std::unique_ptr<const UI::ProgressbarStyleInfo>( | ||
1576 | 331 | new UI::ProgressbarStyleInfo( | ||
1577 | 332 | read_font_style(table, "font"), | ||
1578 | 333 | read_rgb_color(*color_table->get_table("low")), | ||
1579 | 334 | read_rgb_color(*color_table->get_table("medium")), | ||
1580 | 335 | read_rgb_color(*color_table->get_table("high")))))); | ||
1581 | 336 | } | ||
1582 | 337 | |||
1583 | 338 | void StyleManager::add_table_style(UI::PanelStyle style, const LuaTable& table) { | ||
1584 | 339 | table_styles_.insert(std::make_pair(style, | ||
1585 | 340 | std::unique_ptr<const UI::TableStyleInfo>( | ||
1586 | 341 | new UI::TableStyleInfo( | ||
1587 | 342 | read_font_style(table, "enabled"), | ||
1588 | 343 | read_font_style(table, "disabled"))))); | ||
1589 | 344 | } | ||
1590 | 345 | |||
1591 | 346 | void StyleManager::set_statistics_plot_style(const LuaTable& table) { | ||
1592 | 347 | std::unique_ptr<LuaTable> fonts_table = table.get_table("fonts"); | ||
1593 | 348 | std::unique_ptr<LuaTable> colors_table = table.get_table("colors"); | ||
1594 | 349 | statistics_plot_style_.reset(new UI::StatisticsPlotStyleInfo( | ||
1595 | 350 | read_font_style(*fonts_table, "x_tick"), | ||
1596 | 351 | read_font_style(*fonts_table, "y_min_value"), | ||
1597 | 352 | read_font_style(*fonts_table, "y_max_value"), | ||
1598 | 353 | read_rgb_color(*colors_table->get_table("axis_line")), | ||
1599 | 354 | read_rgb_color(*colors_table->get_table("zero_line")))); | ||
1600 | 355 | } | ||
1601 | 356 | |||
1602 | 357 | void StyleManager::set_building_statistics_style(const LuaTable& table) { | ||
1603 | 358 | std::unique_ptr<LuaTable> window_table = table.get_table("statistics_window"); | ||
1604 | 359 | std::unique_ptr<LuaTable> colors_table = table.get_table("colors"); | ||
1605 | 360 | std::unique_ptr<LuaTable> fonts_table = window_table->get_table("fonts"); | ||
1606 | 361 | building_statistics_style_.reset(new UI::BuildingStatisticsStyleInfo( | ||
1607 | 362 | read_font_style(*fonts_table, "button_font"), | ||
1608 | 363 | read_font_style(*fonts_table, "details_font"), | ||
1609 | 364 | window_table->get_int("editbox_margin"), | ||
1610 | 365 | read_font_style(table, "census_font"), | ||
1611 | 366 | read_font_style(table, "statistics_font"), | ||
1612 | 367 | read_rgb_color(*colors_table->get_table("construction")), | ||
1613 | 368 | read_rgb_color(*colors_table->get_table("neutral")), | ||
1614 | 369 | read_rgb_color(*colors_table->get_table("low")), | ||
1615 | 370 | read_rgb_color(*colors_table->get_table("medium")), | ||
1616 | 371 | read_rgb_color(*colors_table->get_table("high")))); | ||
1617 | 372 | } | ||
1618 | 373 | |||
1619 | 374 | void StyleManager::add_ware_info_style(UI::WareInfoStyle style, const LuaTable& table) { | ||
1620 | 375 | std::unique_ptr<LuaTable> fonts_table = table.get_table("fonts"); | ||
1621 | 376 | std::unique_ptr<LuaTable> colors_table = table.get_table("colors"); | ||
1622 | 377 | ware_info_styles_.insert( | ||
1623 | 378 | std::make_pair(style, | ||
1624 | 379 | std::unique_ptr<const UI::WareInfoStyleInfo>( | ||
1625 | 380 | new UI::WareInfoStyleInfo( | ||
1626 | 381 | read_font_style(*fonts_table, "header"), | ||
1627 | 382 | read_font_style(*fonts_table, "info"), | ||
1628 | 383 | g_gr->images().get(table.get_string("icon_background_image")), | ||
1629 | 384 | read_rgb_color(*colors_table->get_table("icon_frame")), | ||
1630 | 385 | read_rgb_color(*colors_table->get_table("icon_background")), | ||
1631 | 386 | read_rgb_color(*colors_table->get_table("info_background")))))); | ||
1632 | 195 | } | 387 | } |
1633 | 196 | 388 | ||
1634 | 197 | void StyleManager::add_style(UI::PanelStyle style, const LuaTable& table, PanelStyleMap* map) { | 389 | void StyleManager::add_style(UI::PanelStyle style, const LuaTable& table, PanelStyleMap* map) { |
1636 | 198 | map->insert(std::make_pair(style, std::unique_ptr<UI::PanelStyleInfo>(read_style(table)))); | 390 | map->insert(std::make_pair(style, std::unique_ptr<UI::PanelStyleInfo>(read_panel_style(table)))); |
1637 | 391 | } | ||
1638 | 392 | |||
1639 | 393 | void StyleManager::add_font_style(UI::FontStyle font_key, const LuaTable& table, const std::string& table_key) { | ||
1640 | 394 | fontstyles_.emplace(std::make_pair(font_key, std::unique_ptr<UI::FontStyleInfo>(read_font_style(table, table_key)))); | ||
1641 | 199 | } | 395 | } |
1642 | 200 | 396 | ||
1643 | === modified file 'src/graphic/style_manager.h' | |||
1644 | --- src/graphic/style_manager.h 2019-02-23 11:00:49 +0000 | |||
1645 | +++ src/graphic/style_manager.h 2019-05-26 02:00:17 +0000 | |||
1646 | @@ -23,7 +23,15 @@ | |||
1647 | 23 | #include <map> | 23 | #include <map> |
1648 | 24 | #include <memory> | 24 | #include <memory> |
1649 | 25 | 25 | ||
1651 | 26 | #include "graphic/panel_styles.h" | 26 | #include "graphic/styles/building_statistics_style.h" |
1652 | 27 | #include "graphic/styles/button_style.h" | ||
1653 | 28 | #include "graphic/styles/font_style.h" | ||
1654 | 29 | #include "graphic/styles/panel_styles.h" | ||
1655 | 30 | #include "graphic/styles/progress_bar_style.h" | ||
1656 | 31 | #include "graphic/styles/statistics_plot_style.h" | ||
1657 | 32 | #include "graphic/styles/table_style.h" | ||
1658 | 33 | #include "graphic/styles/text_panel_style.h" | ||
1659 | 34 | #include "graphic/styles/ware_info_style.h" | ||
1660 | 27 | #include "scripting/lua_table.h" | 35 | #include "scripting/lua_table.h" |
1661 | 28 | 36 | ||
1662 | 29 | static const std::string kTemplateDir = "templates/default/"; | 37 | static const std::string kTemplateDir = "templates/default/"; |
1663 | @@ -36,27 +44,54 @@ | |||
1664 | 36 | // Late initialization, because Graphics needs to load the image files first. | 44 | // Late initialization, because Graphics needs to load the image files first. |
1665 | 37 | void init(); | 45 | void init(); |
1666 | 38 | 46 | ||
1669 | 39 | const UI::PanelStyleInfo* button_style(UI::ButtonStyle) const; | 47 | const UI::BuildingStatisticsStyleInfo& building_statistics_style() const; |
1670 | 40 | const UI::PanelStyleInfo* slider_style(UI::SliderStyle) const; | 48 | const UI::ButtonStyleInfo& button_style(UI::ButtonStyle) const; |
1671 | 49 | const UI::TextPanelStyleInfo& slider_style(UI::SliderStyle) const; | ||
1672 | 41 | const UI::PanelStyleInfo* tabpanel_style(UI::TabPanelStyle) const; | 50 | const UI::PanelStyleInfo* tabpanel_style(UI::TabPanelStyle) const; |
1674 | 42 | const UI::PanelStyleInfo* editbox_style(UI::PanelStyle) const; | 51 | const UI::TextPanelStyleInfo& editbox_style(UI::PanelStyle) const; |
1675 | 43 | const UI::PanelStyleInfo* dropdown_style(UI::PanelStyle) const; | 52 | const UI::PanelStyleInfo* dropdown_style(UI::PanelStyle) const; |
1676 | 44 | const UI::PanelStyleInfo* scrollbar_style(UI::PanelStyle) const; | 53 | const UI::PanelStyleInfo* scrollbar_style(UI::PanelStyle) const; |
1677 | 54 | const UI::ProgressbarStyleInfo& progressbar_style(UI::PanelStyle) const; | ||
1678 | 55 | const UI::StatisticsPlotStyleInfo& statistics_plot_style() const; | ||
1679 | 56 | const UI::TableStyleInfo& table_style(UI::PanelStyle) const; | ||
1680 | 57 | const UI::WareInfoStyleInfo& ware_info_style(UI::WareInfoStyle) const; | ||
1681 | 58 | const UI::FontStyleInfo& font_style(UI::FontStyle style) const; | ||
1682 | 59 | |||
1683 | 60 | // Special elements | ||
1684 | 61 | int minimum_font_size() const; | ||
1685 | 62 | const RGBColor& minimap_icon_frame() const; | ||
1686 | 63 | static std::string color_tag(const std::string& text, const RGBColor& color); | ||
1687 | 45 | 64 | ||
1688 | 46 | private: | 65 | private: |
1689 | 47 | using PanelStyleMap = std::map<UI::PanelStyle, std::unique_ptr<const UI::PanelStyleInfo>>; | 66 | using PanelStyleMap = std::map<UI::PanelStyle, std::unique_ptr<const UI::PanelStyleInfo>>; |
1690 | 48 | void add_button_style(UI::ButtonStyle style, const LuaTable& table); | 67 | void add_button_style(UI::ButtonStyle style, const LuaTable& table); |
1691 | 49 | void add_slider_style(UI::SliderStyle style, const LuaTable& table); | 68 | void add_slider_style(UI::SliderStyle style, const LuaTable& table); |
1692 | 69 | void add_editbox_style(UI::PanelStyle style, const LuaTable& table); | ||
1693 | 50 | void add_tabpanel_style(UI::TabPanelStyle style, const LuaTable& table); | 70 | void add_tabpanel_style(UI::TabPanelStyle style, const LuaTable& table); |
1694 | 71 | void add_progressbar_style(UI::PanelStyle style, const LuaTable& table); | ||
1695 | 72 | void add_table_style(UI::PanelStyle style, const LuaTable& table); | ||
1696 | 73 | void set_statistics_plot_style(const LuaTable& table); | ||
1697 | 74 | void set_building_statistics_style(const LuaTable& table); | ||
1698 | 75 | void add_ware_info_style(UI::WareInfoStyle style, const LuaTable& table); | ||
1699 | 51 | void add_style(UI::PanelStyle style, const LuaTable& table, PanelStyleMap* map); | 76 | void add_style(UI::PanelStyle style, const LuaTable& table, PanelStyleMap* map); |
1700 | 77 | void add_font_style(UI::FontStyle font, const LuaTable& table, const std::string& key); | ||
1701 | 52 | 78 | ||
1704 | 53 | std::map<UI::ButtonStyle, std::unique_ptr<const UI::PanelStyleInfo>> buttonstyles_; | 79 | std::map<UI::ButtonStyle, std::unique_ptr<const UI::ButtonStyleInfo>> buttonstyles_; |
1705 | 54 | std::map<UI::SliderStyle, std::unique_ptr<const UI::PanelStyleInfo>> sliderstyles_; | 80 | std::map<UI::PanelStyle, std::unique_ptr<const UI::TextPanelStyleInfo>> editboxstyles_; |
1706 | 81 | std::map<UI::SliderStyle, std::unique_ptr<const UI::TextPanelStyleInfo>> sliderstyles_; | ||
1707 | 55 | std::map<UI::TabPanelStyle, std::unique_ptr<const UI::PanelStyleInfo>> tabpanelstyles_; | 82 | std::map<UI::TabPanelStyle, std::unique_ptr<const UI::PanelStyleInfo>> tabpanelstyles_; |
1708 | 56 | PanelStyleMap editboxstyles_; | ||
1709 | 57 | PanelStyleMap dropdownstyles_; | 83 | PanelStyleMap dropdownstyles_; |
1710 | 58 | PanelStyleMap scrollbarstyles_; | 84 | PanelStyleMap scrollbarstyles_; |
1711 | 59 | 85 | ||
1712 | 86 | int minimum_font_size_; | ||
1713 | 87 | RGBColor minimap_icon_frame_; | ||
1714 | 88 | std::map<UI::FontStyle, std::unique_ptr<const UI::FontStyleInfo>> fontstyles_; | ||
1715 | 89 | std::unique_ptr<const UI::BuildingStatisticsStyleInfo> building_statistics_style_; | ||
1716 | 90 | std::map<UI::PanelStyle, std::unique_ptr<const UI::ProgressbarStyleInfo>> progressbar_styles_; | ||
1717 | 91 | std::unique_ptr<const UI::StatisticsPlotStyleInfo> statistics_plot_style_; | ||
1718 | 92 | std::map<UI::PanelStyle, std::unique_ptr<const UI::TableStyleInfo>> table_styles_; | ||
1719 | 93 | std::map<UI::WareInfoStyle, std::unique_ptr<const UI::WareInfoStyleInfo>> ware_info_styles_; | ||
1720 | 94 | |||
1721 | 60 | DISALLOW_COPY_AND_ASSIGN(StyleManager); | 95 | DISALLOW_COPY_AND_ASSIGN(StyleManager); |
1722 | 61 | }; | 96 | }; |
1723 | 62 | 97 | ||
1724 | 63 | 98 | ||
1725 | === added directory 'src/graphic/styles' | |||
1726 | === added file 'src/graphic/styles/CMakeLists.txt' | |||
1727 | --- src/graphic/styles/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
1728 | +++ src/graphic/styles/CMakeLists.txt 2019-05-26 02:00:17 +0000 | |||
1729 | @@ -0,0 +1,18 @@ | |||
1730 | 1 | wl_library(graphic_styles | ||
1731 | 2 | SRCS | ||
1732 | 3 | building_statistics_style.h | ||
1733 | 4 | button_style.h | ||
1734 | 5 | font_style.cc | ||
1735 | 6 | font_style.h | ||
1736 | 7 | panel_styles.h | ||
1737 | 8 | progress_bar_style.h | ||
1738 | 9 | text_panel_style.h | ||
1739 | 10 | statistics_plot_style.h | ||
1740 | 11 | table_style.h | ||
1741 | 12 | ware_info_style.h | ||
1742 | 13 | DEPENDS | ||
1743 | 14 | base_exceptions | ||
1744 | 15 | base_log | ||
1745 | 16 | graphic_color | ||
1746 | 17 | graphic_surface | ||
1747 | 18 | ) | ||
1748 | 0 | 19 | ||
1749 | === added file 'src/graphic/styles/building_statistics_style.h' | |||
1750 | --- src/graphic/styles/building_statistics_style.h 1970-01-01 00:00:00 +0000 | |||
1751 | +++ src/graphic/styles/building_statistics_style.h 2019-05-26 02:00:17 +0000 | |||
1752 | @@ -0,0 +1,99 @@ | |||
1753 | 1 | /* | ||
1754 | 2 | * Copyright (C) 2018 by the Widelands Development Team | ||
1755 | 3 | * | ||
1756 | 4 | * This program is free software; you can redistribute it and/or | ||
1757 | 5 | * modify it under the terms of the GNU General Public License | ||
1758 | 6 | * as published by the Free Software Foundation; either version 2 | ||
1759 | 7 | * of the License, or (at your option) any later version. | ||
1760 | 8 | * | ||
1761 | 9 | * This program is distributed in the hope that it will be useful, | ||
1762 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1763 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1764 | 12 | * GNU General Public License for more details. | ||
1765 | 13 | * | ||
1766 | 14 | * You should have received a copy of the GNU General Public License | ||
1767 | 15 | * along with this program; if not, write to the Free Software | ||
1768 | 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
1769 | 17 | * | ||
1770 | 18 | */ | ||
1771 | 19 | |||
1772 | 20 | #ifndef WL_GRAPHIC_STYLES_BUILDING_STATISTICS_STYLE_H | ||
1773 | 21 | #define WL_GRAPHIC_STYLES_BUILDING_STATISTICS_STYLE_H | ||
1774 | 22 | |||
1775 | 23 | #include <memory> | ||
1776 | 24 | |||
1777 | 25 | #include "graphic/color.h" | ||
1778 | 26 | #include "graphic/styles/font_style.h" | ||
1779 | 27 | |||
1780 | 28 | namespace UI { | ||
1781 | 29 | |||
1782 | 30 | struct BuildingStatisticsStyleInfo { | ||
1783 | 31 | explicit BuildingStatisticsStyleInfo(UI::FontStyleInfo* init_building_statistics_button_font, | ||
1784 | 32 | UI::FontStyleInfo* init_building_statistics_details_font, | ||
1785 | 33 | int init_editbox_margin, | ||
1786 | 34 | UI::FontStyleInfo* init_census, | ||
1787 | 35 | UI::FontStyleInfo* init_statistics, | ||
1788 | 36 | const RGBColor& init_construction_color, | ||
1789 | 37 | const RGBColor& init_neutral_color, | ||
1790 | 38 | const RGBColor& init_low_color, | ||
1791 | 39 | const RGBColor& init_medium_color, | ||
1792 | 40 | const RGBColor& init_high_color) : | ||
1793 | 41 | building_statistics_button_font_(init_building_statistics_button_font), | ||
1794 | 42 | building_statistics_details_font_(init_building_statistics_details_font), | ||
1795 | 43 | editbox_margin_(init_editbox_margin), | ||
1796 | 44 | census_font_(init_census), | ||
1797 | 45 | statistics_font_(init_statistics), | ||
1798 | 46 | construction_color_(init_construction_color), | ||
1799 | 47 | neutral_color_(init_neutral_color), | ||
1800 | 48 | low_color_(init_low_color), | ||
1801 | 49 | medium_color_(init_medium_color), | ||
1802 | 50 | high_color_(init_high_color) {} | ||
1803 | 51 | |||
1804 | 52 | const UI::FontStyleInfo& building_statistics_button_font() const { | ||
1805 | 53 | return *building_statistics_button_font_.get(); | ||
1806 | 54 | } | ||
1807 | 55 | const UI::FontStyleInfo& building_statistics_details_font() const { | ||
1808 | 56 | return *building_statistics_details_font_.get(); | ||
1809 | 57 | } | ||
1810 | 58 | int editbox_margin() const { | ||
1811 | 59 | return editbox_margin_; | ||
1812 | 60 | } | ||
1813 | 61 | |||
1814 | 62 | const UI::FontStyleInfo& census_font() const { | ||
1815 | 63 | return *census_font_.get(); | ||
1816 | 64 | } | ||
1817 | 65 | const UI::FontStyleInfo& statistics_font() const { | ||
1818 | 66 | return *statistics_font_.get(); | ||
1819 | 67 | } | ||
1820 | 68 | const RGBColor& construction_color() const { | ||
1821 | 69 | return construction_color_; | ||
1822 | 70 | } | ||
1823 | 71 | const RGBColor& neutral_color() const { | ||
1824 | 72 | return neutral_color_; | ||
1825 | 73 | } | ||
1826 | 74 | const RGBColor& low_color() const { | ||
1827 | 75 | return low_color_; | ||
1828 | 76 | } | ||
1829 | 77 | const RGBColor& medium_color() const { | ||
1830 | 78 | return medium_color_; | ||
1831 | 79 | } | ||
1832 | 80 | const RGBColor& high_color() const { | ||
1833 | 81 | return high_color_; | ||
1834 | 82 | } | ||
1835 | 83 | |||
1836 | 84 | private: | ||
1837 | 85 | std::unique_ptr<const UI::FontStyleInfo> building_statistics_button_font_; | ||
1838 | 86 | std::unique_ptr<const UI::FontStyleInfo> building_statistics_details_font_; | ||
1839 | 87 | int editbox_margin_; | ||
1840 | 88 | std::unique_ptr<const UI::FontStyleInfo> census_font_; | ||
1841 | 89 | std::unique_ptr<const UI::FontStyleInfo> statistics_font_; | ||
1842 | 90 | const RGBColor construction_color_; | ||
1843 | 91 | const RGBColor neutral_color_; | ||
1844 | 92 | const RGBColor low_color_; | ||
1845 | 93 | const RGBColor medium_color_; | ||
1846 | 94 | const RGBColor high_color_; | ||
1847 | 95 | }; | ||
1848 | 96 | |||
1849 | 97 | } // namespace UI | ||
1850 | 98 | |||
1851 | 99 | #endif // end of include guard: WL_GRAPHIC_STYLES_BUILDING_STATISTICS_STYLE_H | ||
1852 | 0 | 100 | ||
1853 | === added file 'src/graphic/styles/button_style.h' | |||
1854 | --- src/graphic/styles/button_style.h 1970-01-01 00:00:00 +0000 | |||
1855 | +++ src/graphic/styles/button_style.h 2019-05-26 02:00:17 +0000 | |||
1856 | @@ -0,0 +1,65 @@ | |||
1857 | 1 | /* | ||
1858 | 2 | * Copyright (C) 2018 by the Widelands Development Team | ||
1859 | 3 | * | ||
1860 | 4 | * This program is free software; you can redistribute it and/or | ||
1861 | 5 | * modify it under the terms of the GNU General Public License | ||
1862 | 6 | * as published by the Free Software Foundation; either version 2 | ||
1863 | 7 | * of the License, or (at your option) any later version. | ||
1864 | 8 | * | ||
1865 | 9 | * This program is distributed in the hope that it will be useful, | ||
1866 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1867 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1868 | 12 | * GNU General Public License for more details. | ||
1869 | 13 | * | ||
1870 | 14 | * You should have received a copy of the GNU General Public License | ||
1871 | 15 | * along with this program; if not, write to the Free Software | ||
1872 | 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
1873 | 17 | * | ||
1874 | 18 | */ | ||
1875 | 19 | |||
1876 | 20 | #ifndef WL_GRAPHIC_STYLES_BUTTON_STYLE_H | ||
1877 | 21 | #define WL_GRAPHIC_STYLES_BUTTON_STYLE_H | ||
1878 | 22 | |||
1879 | 23 | #include <memory> | ||
1880 | 24 | |||
1881 | 25 | #include "graphic/styles/font_style.h" | ||
1882 | 26 | #include "graphic/styles/panel_styles.h" | ||
1883 | 27 | #include "graphic/styles/text_panel_style.h" | ||
1884 | 28 | |||
1885 | 29 | namespace UI { | ||
1886 | 30 | |||
1887 | 31 | enum class ButtonStyle { | ||
1888 | 32 | kFsMenuMenu, | ||
1889 | 33 | kFsMenuPrimary, | ||
1890 | 34 | kFsMenuSecondary, | ||
1891 | 35 | kWuiMenu, | ||
1892 | 36 | kWuiPrimary, | ||
1893 | 37 | kWuiSecondary, | ||
1894 | 38 | kWuiBuildingStats | ||
1895 | 39 | }; | ||
1896 | 40 | |||
1897 | 41 | struct ButtonStyleInfo { | ||
1898 | 42 | ButtonStyleInfo(const UI::TextPanelStyleInfo* init_enabled, const UI::TextPanelStyleInfo* init_disabled) : | ||
1899 | 43 | enabled_(init_enabled), | ||
1900 | 44 | disabled_(init_disabled) { | ||
1901 | 45 | } | ||
1902 | 46 | ButtonStyleInfo(const ButtonStyleInfo& other) : | ||
1903 | 47 | enabled_(new UI::TextPanelStyleInfo(other.enabled())), | ||
1904 | 48 | disabled_(new UI::TextPanelStyleInfo(other.disabled())) { | ||
1905 | 49 | } | ||
1906 | 50 | |||
1907 | 51 | const UI::TextPanelStyleInfo& enabled() const { | ||
1908 | 52 | return *enabled_.get(); | ||
1909 | 53 | } | ||
1910 | 54 | const UI::TextPanelStyleInfo& disabled() const { | ||
1911 | 55 | return *disabled_.get(); | ||
1912 | 56 | } | ||
1913 | 57 | |||
1914 | 58 | private: | ||
1915 | 59 | std::unique_ptr<const UI::TextPanelStyleInfo> enabled_; | ||
1916 | 60 | std::unique_ptr<const UI::TextPanelStyleInfo> disabled_; | ||
1917 | 61 | }; | ||
1918 | 62 | |||
1919 | 63 | } // namespace UI | ||
1920 | 64 | |||
1921 | 65 | #endif // end of include guard: WL_GRAPHIC_STYLES_BUTTON_STYLE_H | ||
1922 | 0 | 66 | ||
1923 | === added file 'src/graphic/styles/font_style.cc' | |||
1924 | --- src/graphic/styles/font_style.cc 1970-01-01 00:00:00 +0000 | |||
1925 | +++ src/graphic/styles/font_style.cc 2019-05-26 02:00:17 +0000 | |||
1926 | @@ -0,0 +1,130 @@ | |||
1927 | 1 | /* | ||
1928 | 2 | * Copyright (C) 2018 by the Widelands Development Team | ||
1929 | 3 | * | ||
1930 | 4 | * This program is free software; you can redistribute it and/or | ||
1931 | 5 | * modify it under the terms of the GNU General Public License | ||
1932 | 6 | * as published by the Free Software Foundation; either version 2 | ||
1933 | 7 | * of the License, or (at your option) any later version. | ||
1934 | 8 | * | ||
1935 | 9 | * This program is distributed in the hope that it will be useful, | ||
1936 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1937 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1938 | 12 | * GNU General Public License for more details. | ||
1939 | 13 | * | ||
1940 | 14 | * You should have received a copy of the GNU General Public License | ||
1941 | 15 | * along with this program; if not, write to the Free Software | ||
1942 | 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
1943 | 17 | * | ||
1944 | 18 | */ | ||
1945 | 19 | |||
1946 | 20 | #include "graphic/styles/font_style.h" | ||
1947 | 21 | |||
1948 | 22 | #include <boost/format.hpp> | ||
1949 | 23 | |||
1950 | 24 | #include "base/log.h" | ||
1951 | 25 | #include "base/wexception.h" | ||
1952 | 26 | |||
1953 | 27 | namespace UI { | ||
1954 | 28 | |||
1955 | 29 | FontStyleInfo::FontStyleInfo(const std::string& init_face, const RGBColor& init_color, int init_size, | ||
1956 | 30 | bool init_bold, bool init_italic, bool init_underline, bool init_shadow) : | ||
1957 | 31 | face_(string_to_face(init_face)), | ||
1958 | 32 | color_(init_color), | ||
1959 | 33 | size_(init_size), | ||
1960 | 34 | bold_(init_bold), | ||
1961 | 35 | italic_(init_italic), | ||
1962 | 36 | underline_(init_underline), | ||
1963 | 37 | shadow_(init_shadow) { | ||
1964 | 38 | } | ||
1965 | 39 | |||
1966 | 40 | FontStyleInfo::FontStyleInfo(const FontStyleInfo& other) : | ||
1967 | 41 | face_(other.face()), | ||
1968 | 42 | color_(other.color()), | ||
1969 | 43 | size_(other.size()), | ||
1970 | 44 | bold_(other.bold()), | ||
1971 | 45 | italic_(other.italic()), | ||
1972 | 46 | underline_(other.underline()), | ||
1973 | 47 | shadow_(other.shadow()) | ||
1974 | 48 | {} | ||
1975 | 49 | |||
1976 | 50 | const std::string FontStyleInfo::face_to_string() const { | ||
1977 | 51 | switch (face_) { | ||
1978 | 52 | case Face::kSans: | ||
1979 | 53 | return "sans"; | ||
1980 | 54 | case Face::kSerif: | ||
1981 | 55 | return "serif"; | ||
1982 | 56 | case Face::kCondensed: | ||
1983 | 57 | return "condensed"; | ||
1984 | 58 | } | ||
1985 | 59 | return "sans"; | ||
1986 | 60 | } | ||
1987 | 61 | |||
1988 | 62 | FontStyleInfo::Face FontStyleInfo::string_to_face(const std::string& init_face) { | ||
1989 | 63 | FontStyleInfo::Face result; | ||
1990 | 64 | if (init_face == "sans") { | ||
1991 | 65 | result = Face::kSans; | ||
1992 | 66 | } else if (init_face == "serif") { | ||
1993 | 67 | result = Face::kSerif; | ||
1994 | 68 | } else if (init_face == "condensed") { | ||
1995 | 69 | result = Face::kCondensed; | ||
1996 | 70 | } else { | ||
1997 | 71 | throw wexception("Unknown font face '%s', expected 'sans', 'serif' or 'condensed'", init_face.c_str()); | ||
1998 | 72 | } | ||
1999 | 73 | return result; | ||
2000 | 74 | } | ||
2001 | 75 | |||
2002 | 76 | std::string FontStyleInfo::as_font_tag(const std::string& text) const { | ||
2003 | 77 | static boost::format f("<font face=%s size=%d color=%s%s>%s</font>"); | ||
2004 | 78 | std::string optionals = ""; | ||
2005 | 79 | if (bold_) { | ||
2006 | 80 | optionals += " bold=1"; | ||
2007 | 81 | } | ||
2008 | 82 | if (italic_) { | ||
2009 | 83 | optionals += " italic=1"; | ||
2010 | 84 | } | ||
2011 | 85 | if (shadow_) { | ||
2012 | 86 | optionals += " shadow=1"; | ||
2013 | 87 | } | ||
2014 | 88 | if (underline_) { | ||
2015 | 89 | optionals += " underline=1"; | ||
2016 | 90 | } | ||
2017 | 91 | f % face_to_string(); | ||
2018 | 92 | f % size_; | ||
2019 | 93 | f % color_.hex_value(); | ||
2020 | 94 | f % optionals; | ||
2021 | 95 | f % text; | ||
2022 | 96 | return f.str(); | ||
2023 | 97 | } | ||
2024 | 98 | |||
2025 | 99 | FontStyleInfo::Face FontStyleInfo::face() const { | ||
2026 | 100 | return face_; | ||
2027 | 101 | } | ||
2028 | 102 | void FontStyleInfo::make_condensed() { | ||
2029 | 103 | face_ = Face::kCondensed; | ||
2030 | 104 | } | ||
2031 | 105 | const RGBColor& FontStyleInfo::color() const { | ||
2032 | 106 | return color_; | ||
2033 | 107 | } | ||
2034 | 108 | void FontStyleInfo::set_color(const RGBColor& new_color) { | ||
2035 | 109 | color_ = new_color; | ||
2036 | 110 | } | ||
2037 | 111 | int FontStyleInfo::size() const { | ||
2038 | 112 | return size_; | ||
2039 | 113 | } | ||
2040 | 114 | void FontStyleInfo::set_size(int new_size) { | ||
2041 | 115 | size_ = new_size; | ||
2042 | 116 | } | ||
2043 | 117 | bool FontStyleInfo::bold() const { | ||
2044 | 118 | return bold_; | ||
2045 | 119 | } | ||
2046 | 120 | bool FontStyleInfo::italic() const { | ||
2047 | 121 | return italic_; | ||
2048 | 122 | } | ||
2049 | 123 | bool FontStyleInfo::underline() const { | ||
2050 | 124 | return underline_; | ||
2051 | 125 | } | ||
2052 | 126 | bool FontStyleInfo::shadow() const { | ||
2053 | 127 | return shadow_; | ||
2054 | 128 | } | ||
2055 | 129 | |||
2056 | 130 | } // namespace UI | ||
2057 | 0 | 131 | ||
2058 | === added file 'src/graphic/styles/font_style.h' | |||
2059 | --- src/graphic/styles/font_style.h 1970-01-01 00:00:00 +0000 | |||
2060 | +++ src/graphic/styles/font_style.h 2019-05-26 02:00:17 +0000 | |||
2061 | @@ -0,0 +1,97 @@ | |||
2062 | 1 | /* | ||
2063 | 2 | * Copyright (C) 2018 by the Widelands Development Team | ||
2064 | 3 | * | ||
2065 | 4 | * This program is free software; you can redistribute it and/or | ||
2066 | 5 | * modify it under the terms of the GNU General Public License | ||
2067 | 6 | * as published by the Free Software Foundation; either version 2 | ||
2068 | 7 | * of the License, or (at your option) any later version. | ||
2069 | 8 | * | ||
2070 | 9 | * This program is distributed in the hope that it will be useful, | ||
2071 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2072 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2073 | 12 | * GNU General Public License for more details. | ||
2074 | 13 | * | ||
2075 | 14 | * You should have received a copy of the GNU General Public License | ||
2076 | 15 | * along with this program; if not, write to the Free Software | ||
2077 | 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
2078 | 17 | * | ||
2079 | 18 | */ | ||
2080 | 19 | |||
2081 | 20 | #ifndef WL_GRAPHIC_STYLES_FONT_STYLE_H | ||
2082 | 21 | #define WL_GRAPHIC_STYLES_FONT_STYLE_H | ||
2083 | 22 | |||
2084 | 23 | #include <string> | ||
2085 | 24 | |||
2086 | 25 | #include "graphic/color.h" | ||
2087 | 26 | |||
2088 | 27 | namespace UI { | ||
2089 | 28 | enum class FontStyle { | ||
2090 | 29 | kChatMessage, | ||
2091 | 30 | kChatPlayername, | ||
2092 | 31 | kChatServer, | ||
2093 | 32 | kChatTimestamp, | ||
2094 | 33 | kChatWhisper, | ||
2095 | 34 | kFsGameSetupHeadings, | ||
2096 | 35 | kFsGameSetupIrcClient, | ||
2097 | 36 | kFsGameSetupSuperuser, | ||
2098 | 37 | kFsGameSetupMapname, | ||
2099 | 38 | kFsMenuGameTip, | ||
2100 | 39 | kFsMenuInfoPanelHeading, | ||
2101 | 40 | kFsMenuInfoPanelParagraph, | ||
2102 | 41 | kFsMenuIntro, | ||
2103 | 42 | kFsMenuTitle, | ||
2104 | 43 | kFsMenuTranslationInfo, | ||
2105 | 44 | kDisabled, | ||
2106 | 45 | kLabel, | ||
2107 | 46 | kTooltipHeader, | ||
2108 | 47 | kTooltip, | ||
2109 | 48 | kWarning, | ||
2110 | 49 | kWuiAttackBoxSliderLabel, | ||
2111 | 50 | kWuiGameSpeedAndCoordinates, | ||
2112 | 51 | kWuiInfoPanelHeading, | ||
2113 | 52 | kWuiInfoPanelParagraph, | ||
2114 | 53 | kWuiMessageHeading, | ||
2115 | 54 | kWuiMessageParagraph, | ||
2116 | 55 | kWuiWindowTitle | ||
2117 | 56 | }; | ||
2118 | 57 | |||
2119 | 58 | struct FontStyleInfo { | ||
2120 | 59 | enum class Face { kSans, kSerif, kCondensed }; | ||
2121 | 60 | |||
2122 | 61 | explicit FontStyleInfo(const std::string& init_face, const RGBColor& init_color, int init_size, | ||
2123 | 62 | bool init_bold, bool init_italic, bool init_underline, bool init_shadow); | ||
2124 | 63 | explicit FontStyleInfo(const FontStyleInfo& other); | ||
2125 | 64 | FontStyleInfo& operator=(const FontStyleInfo& other) = default; | ||
2126 | 65 | |||
2127 | 66 | std::string as_font_tag(const std::string& text) const; | ||
2128 | 67 | |||
2129 | 68 | Face face() const; | ||
2130 | 69 | void make_condensed(); | ||
2131 | 70 | |||
2132 | 71 | const RGBColor& color() const; | ||
2133 | 72 | void set_color(const RGBColor& new_color); | ||
2134 | 73 | |||
2135 | 74 | int size() const; | ||
2136 | 75 | void set_size(int new_size); | ||
2137 | 76 | |||
2138 | 77 | bool bold() const; | ||
2139 | 78 | bool italic() const; | ||
2140 | 79 | bool underline() const; | ||
2141 | 80 | bool shadow() const; | ||
2142 | 81 | |||
2143 | 82 | private: | ||
2144 | 83 | static Face string_to_face(const std::string& face_); | ||
2145 | 84 | const std::string face_to_string() const; | ||
2146 | 85 | |||
2147 | 86 | Face face_; | ||
2148 | 87 | RGBColor color_; | ||
2149 | 88 | int size_; | ||
2150 | 89 | const bool bold_; | ||
2151 | 90 | const bool italic_; | ||
2152 | 91 | const bool underline_; | ||
2153 | 92 | const bool shadow_; | ||
2154 | 93 | }; | ||
2155 | 94 | |||
2156 | 95 | } // namespace UI | ||
2157 | 96 | |||
2158 | 97 | #endif // end of include guard: WL_GRAPHIC_STYLES_FONT_STYLE_H | ||
2159 | 0 | 98 | ||
2160 | === renamed file 'src/graphic/panel_styles.h' => 'src/graphic/styles/panel_styles.h' | |||
2161 | --- src/graphic/panel_styles.h 2019-02-23 11:00:49 +0000 | |||
2162 | +++ src/graphic/styles/panel_styles.h 2019-05-26 02:00:17 +0000 | |||
2163 | @@ -17,41 +17,47 @@ | |||
2164 | 17 | * | 17 | * |
2165 | 18 | */ | 18 | */ |
2166 | 19 | 19 | ||
2169 | 20 | #ifndef WL_GRAPHIC_PANEL_STYLES_H | 20 | #ifndef WL_GRAPHIC_STYLES_PANEL_STYLES_H |
2170 | 21 | #define WL_GRAPHIC_PANEL_STYLES_H | 21 | #define WL_GRAPHIC_STYLES_PANEL_STYLES_H |
2171 | 22 | |||
2172 | 23 | #include <map> | ||
2173 | 24 | #include <memory> | ||
2174 | 22 | 25 | ||
2175 | 23 | #include "graphic/color.h" | 26 | #include "graphic/color.h" |
2176 | 27 | #include "graphic/styles/font_style.h" | ||
2177 | 24 | #include "graphic/image.h" | 28 | #include "graphic/image.h" |
2178 | 25 | 29 | ||
2179 | 26 | namespace UI { | 30 | namespace UI { |
2180 | 27 | 31 | ||
2181 | 28 | // Buttons | ||
2182 | 29 | enum class ButtonStyle { | ||
2183 | 30 | kFsMenuMenu, | ||
2184 | 31 | kFsMenuPrimary, | ||
2185 | 32 | kFsMenuSecondary, | ||
2186 | 33 | kWuiMenu, | ||
2187 | 34 | kWuiPrimary, | ||
2188 | 35 | kWuiSecondary, | ||
2189 | 36 | kWuiBuildingStats | ||
2190 | 37 | }; | ||
2191 | 38 | enum class SliderStyle { kFsMenu, kWuiLight, kWuiDark }; | ||
2192 | 39 | |||
2193 | 40 | // Backgrounds | 32 | // Backgrounds |
2194 | 41 | enum class PanelStyle { kFsMenu, kWui }; | 33 | enum class PanelStyle { kFsMenu, kWui }; |
2195 | 42 | enum class TabPanelStyle { kFsMenu, kWuiLight, kWuiDark }; | 34 | enum class TabPanelStyle { kFsMenu, kWuiLight, kWuiDark }; |
2196 | 43 | 35 | ||
2197 | 44 | struct PanelStyleInfo { | 36 | struct PanelStyleInfo { |
2206 | 45 | PanelStyleInfo(const Image* init_image, const RGBAColor& init_color) | 37 | PanelStyleInfo(const Image* init_image, const RGBAColor& init_color, int init_margin) |
2207 | 46 | : image(init_image), color(init_color) { | 38 | : margin_(init_margin), image_(init_image), color_(init_color) { |
2208 | 47 | } | 39 | } |
2209 | 48 | PanelStyleInfo() : PanelStyleInfo(nullptr, RGBAColor(0, 0, 0, 0)) { | 40 | PanelStyleInfo(const PanelStyleInfo& other) |
2210 | 49 | } | 41 | : image_(other.image()), color_(other.color()) { |
2211 | 50 | 42 | } | |
2212 | 51 | const Image* image; | 43 | |
2213 | 52 | const RGBAColor color; | 44 | const RGBAColor& color() const { |
2214 | 45 | return color_; | ||
2215 | 46 | } | ||
2216 | 47 | const Image* image() const { | ||
2217 | 48 | return image_; | ||
2218 | 49 | } | ||
2219 | 50 | |||
2220 | 51 | int margin() const { | ||
2221 | 52 | return margin_; | ||
2222 | 53 | } | ||
2223 | 54 | |||
2224 | 55 | private: | ||
2225 | 56 | int margin_; | ||
2226 | 57 | const Image* image_; | ||
2227 | 58 | RGBAColor color_; | ||
2228 | 53 | }; | 59 | }; |
2229 | 54 | 60 | ||
2230 | 55 | } // namespace UI | 61 | } // namespace UI |
2231 | 56 | 62 | ||
2233 | 57 | #endif // end of include guard: WL_GRAPHIC_PANEL_STYLES_H | 63 | #endif // end of include guard: WL_GRAPHIC_STYLES_PANEL_STYLES_H |
2234 | 58 | 64 | ||
2235 | === added file 'src/graphic/styles/progress_bar_style.h' | |||
2236 | --- src/graphic/styles/progress_bar_style.h 1970-01-01 00:00:00 +0000 | |||
2237 | +++ src/graphic/styles/progress_bar_style.h 2019-05-26 02:00:17 +0000 | |||
2238 | @@ -0,0 +1,69 @@ | |||
2239 | 1 | /* | ||
2240 | 2 | * Copyright (C) 2018 by the Widelands Development Team | ||
2241 | 3 | * | ||
2242 | 4 | * This program is free software; you can redistribute it and/or | ||
2243 | 5 | * modify it under the terms of the GNU General Public License | ||
2244 | 6 | * as published by the Free Software Foundation; either version 2 | ||
2245 | 7 | * of the License, or (at your option) any later version. | ||
2246 | 8 | * | ||
2247 | 9 | * This program is distributed in the hope that it will be useful, | ||
2248 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2249 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2250 | 12 | * GNU General Public License for more details. | ||
2251 | 13 | * | ||
2252 | 14 | * You should have received a copy of the GNU General Public License | ||
2253 | 15 | * along with this program; if not, write to the Free Software | ||
2254 | 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
2255 | 17 | * | ||
2256 | 18 | */ | ||
2257 | 19 | |||
2258 | 20 | #ifndef WL_GRAPHIC_STYLES_PROGRESS_BAR_STYLE_H | ||
2259 | 21 | #define WL_GRAPHIC_STYLES_PROGRESS_BAR_STYLE_H | ||
2260 | 22 | |||
2261 | 23 | #include <memory> | ||
2262 | 24 | |||
2263 | 25 | #include "graphic/color.h" | ||
2264 | 26 | #include "graphic/styles/font_style.h" | ||
2265 | 27 | |||
2266 | 28 | namespace UI { | ||
2267 | 29 | |||
2268 | 30 | struct ProgressbarStyleInfo { | ||
2269 | 31 | explicit ProgressbarStyleInfo(UI::FontStyleInfo* init_font, | ||
2270 | 32 | const RGBColor& init_low_color, | ||
2271 | 33 | const RGBColor& init_medium_color, | ||
2272 | 34 | const RGBColor& init_high_color) : | ||
2273 | 35 | font_(init_font), | ||
2274 | 36 | low_color_(init_low_color), | ||
2275 | 37 | medium_color_(init_medium_color), | ||
2276 | 38 | high_color_(init_high_color) {} | ||
2277 | 39 | explicit ProgressbarStyleInfo(const ProgressbarStyleInfo& other): | ||
2278 | 40 | font_(new UI::FontStyleInfo(other.font())), | ||
2279 | 41 | low_color_(other.low_color()), | ||
2280 | 42 | medium_color_(other.medium_color()), | ||
2281 | 43 | high_color_(other.high_color()) | ||
2282 | 44 | { | ||
2283 | 45 | } | ||
2284 | 46 | |||
2285 | 47 | const UI::FontStyleInfo& font() const { | ||
2286 | 48 | return *font_.get(); | ||
2287 | 49 | } | ||
2288 | 50 | const RGBColor& low_color() const { | ||
2289 | 51 | return low_color_; | ||
2290 | 52 | } | ||
2291 | 53 | const RGBColor& medium_color() const { | ||
2292 | 54 | return medium_color_; | ||
2293 | 55 | } | ||
2294 | 56 | const RGBColor& high_color() const { | ||
2295 | 57 | return high_color_; | ||
2296 | 58 | } | ||
2297 | 59 | |||
2298 | 60 | private: | ||
2299 | 61 | std::unique_ptr<const UI::FontStyleInfo> font_; | ||
2300 | 62 | const RGBColor low_color_; | ||
2301 | 63 | const RGBColor medium_color_; | ||
2302 | 64 | const RGBColor high_color_; | ||
2303 | 65 | }; | ||
2304 | 66 | |||
2305 | 67 | } // namespace UI | ||
2306 | 68 | |||
2307 | 69 | #endif // end of include guard: WL_GRAPHIC_STYLES_PROGRESS_BAR_STYLE_H | ||
2308 | 0 | 70 | ||
2309 | === added file 'src/graphic/styles/statistics_plot_style.h' | |||
2310 | --- src/graphic/styles/statistics_plot_style.h 1970-01-01 00:00:00 +0000 | |||
2311 | +++ src/graphic/styles/statistics_plot_style.h 2019-05-26 02:00:17 +0000 | |||
2312 | @@ -0,0 +1,68 @@ | |||
2313 | 1 | /* | ||
2314 | 2 | * Copyright (C) 2018 by the Widelands Development Team | ||
2315 | 3 | * | ||
2316 | 4 | * This program is free software; you can redistribute it and/or | ||
2317 | 5 | * modify it under the terms of the GNU General Public License | ||
2318 | 6 | * as published by the Free Software Foundation; either version 2 | ||
2319 | 7 | * of the License, or (at your option) any later version. | ||
2320 | 8 | * | ||
2321 | 9 | * This program is distributed in the hope that it will be useful, | ||
2322 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2323 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2324 | 12 | * GNU General Public License for more details. | ||
2325 | 13 | * | ||
2326 | 14 | * You should have received a copy of the GNU General Public License | ||
2327 | 15 | * along with this program; if not, write to the Free Software | ||
2328 | 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
2329 | 17 | * | ||
2330 | 18 | */ | ||
2331 | 19 | |||
2332 | 20 | #ifndef WL_GRAPHIC_STYLES_STATISTICS_PLOT_STYLE_H | ||
2333 | 21 | #define WL_GRAPHIC_STYLES_STATISTICS_PLOT_STYLE_H | ||
2334 | 22 | |||
2335 | 23 | #include <memory> | ||
2336 | 24 | |||
2337 | 25 | #include "graphic/color.h" | ||
2338 | 26 | #include "graphic/styles/font_style.h" | ||
2339 | 27 | |||
2340 | 28 | namespace UI { | ||
2341 | 29 | |||
2342 | 30 | struct StatisticsPlotStyleInfo { | ||
2343 | 31 | explicit StatisticsPlotStyleInfo(UI::FontStyleInfo* init_x_tick_font, | ||
2344 | 32 | UI::FontStyleInfo* init_y_min_value_font, | ||
2345 | 33 | UI::FontStyleInfo* init_y_max_value_font, | ||
2346 | 34 | const RGBColor& init_axis_line_color, | ||
2347 | 35 | const RGBColor& init_zero_line_color) : | ||
2348 | 36 | x_tick_font_(init_x_tick_font), | ||
2349 | 37 | y_min_value_font_(init_y_min_value_font), | ||
2350 | 38 | y_max_value_font_(init_y_max_value_font), | ||
2351 | 39 | axis_line_color_(init_axis_line_color), | ||
2352 | 40 | zero_line_color_(init_zero_line_color) {} | ||
2353 | 41 | |||
2354 | 42 | const UI::FontStyleInfo& x_tick_font() const { | ||
2355 | 43 | return *x_tick_font_.get(); | ||
2356 | 44 | } | ||
2357 | 45 | const UI::FontStyleInfo& y_min_value_font() const { | ||
2358 | 46 | return *y_min_value_font_.get(); | ||
2359 | 47 | } | ||
2360 | 48 | const UI::FontStyleInfo& y_max_value_font() const { | ||
2361 | 49 | return *y_max_value_font_.get(); | ||
2362 | 50 | } | ||
2363 | 51 | const RGBColor& axis_line_color() const { | ||
2364 | 52 | return axis_line_color_; | ||
2365 | 53 | } | ||
2366 | 54 | const RGBColor& zero_line_color() const { | ||
2367 | 55 | return zero_line_color_; | ||
2368 | 56 | } | ||
2369 | 57 | |||
2370 | 58 | private: | ||
2371 | 59 | std::unique_ptr<const UI::FontStyleInfo> x_tick_font_; | ||
2372 | 60 | std::unique_ptr<const UI::FontStyleInfo> y_min_value_font_; | ||
2373 | 61 | std::unique_ptr<const UI::FontStyleInfo> y_max_value_font_; | ||
2374 | 62 | const RGBColor axis_line_color_; | ||
2375 | 63 | const RGBColor zero_line_color_; | ||
2376 | 64 | }; | ||
2377 | 65 | |||
2378 | 66 | } // namespace UI | ||
2379 | 67 | |||
2380 | 68 | #endif // end of include guard: WL_GRAPHIC_STYLES_STATISTICS_PLOT_STYLE_H | ||
2381 | 0 | 69 | ||
2382 | === added file 'src/graphic/styles/table_style.h' | |||
2383 | --- src/graphic/styles/table_style.h 1970-01-01 00:00:00 +0000 | |||
2384 | +++ src/graphic/styles/table_style.h 2019-05-26 02:00:17 +0000 | |||
2385 | @@ -0,0 +1,47 @@ | |||
2386 | 1 | /* | ||
2387 | 2 | * Copyright (C) 2018 by the Widelands Development Team | ||
2388 | 3 | * | ||
2389 | 4 | * This program is free software; you can redistribute it and/or | ||
2390 | 5 | * modify it under the terms of the GNU General Public License | ||
2391 | 6 | * as published by the Free Software Foundation; either version 2 | ||
2392 | 7 | * of the License, or (at your option) any later version. | ||
2393 | 8 | * | ||
2394 | 9 | * This program is distributed in the hope that it will be useful, | ||
2395 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2396 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2397 | 12 | * GNU General Public License for more details. | ||
2398 | 13 | * | ||
2399 | 14 | * You should have received a copy of the GNU General Public License | ||
2400 | 15 | * along with this program; if not, write to the Free Software | ||
2401 | 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
2402 | 17 | * | ||
2403 | 18 | */ | ||
2404 | 19 | |||
2405 | 20 | #ifndef WL_GRAPHIC_STYLES_TABLE_STYLE_H | ||
2406 | 21 | #define WL_GRAPHIC_STYLES_TABLE_STYLE_H | ||
2407 | 22 | |||
2408 | 23 | #include <memory> | ||
2409 | 24 | |||
2410 | 25 | #include "graphic/styles/font_style.h" | ||
2411 | 26 | |||
2412 | 27 | namespace UI { | ||
2413 | 28 | |||
2414 | 29 | struct TableStyleInfo { | ||
2415 | 30 | explicit TableStyleInfo(UI::FontStyleInfo* init_enabled, UI::FontStyleInfo* init_disabled) : | ||
2416 | 31 | enabled_(init_enabled), disabled_(init_disabled) {} | ||
2417 | 32 | |||
2418 | 33 | const UI::FontStyleInfo& enabled() const { | ||
2419 | 34 | return *enabled_.get(); | ||
2420 | 35 | } | ||
2421 | 36 | const UI::FontStyleInfo& disabled() const { | ||
2422 | 37 | return *disabled_.get(); | ||
2423 | 38 | } | ||
2424 | 39 | |||
2425 | 40 | private: | ||
2426 | 41 | std::unique_ptr<const UI::FontStyleInfo> enabled_; | ||
2427 | 42 | std::unique_ptr<const UI::FontStyleInfo> disabled_; | ||
2428 | 43 | }; | ||
2429 | 44 | |||
2430 | 45 | } // namespace UI | ||
2431 | 46 | |||
2432 | 47 | #endif // end of include guard: WL_GRAPHIC_STYLES_TABLE_STYLE_H | ||
2433 | 0 | 48 | ||
2434 | === added file 'src/graphic/styles/text_panel_style.h' | |||
2435 | --- src/graphic/styles/text_panel_style.h 1970-01-01 00:00:00 +0000 | |||
2436 | +++ src/graphic/styles/text_panel_style.h 2019-05-26 02:00:17 +0000 | |||
2437 | @@ -0,0 +1,61 @@ | |||
2438 | 1 | /* | ||
2439 | 2 | * Copyright (C) 2018 by the Widelands Development Team | ||
2440 | 3 | * | ||
2441 | 4 | * This program is free software; you can redistribute it and/or | ||
2442 | 5 | * modify it under the terms of the GNU General Public License | ||
2443 | 6 | * as published by the Free Software Foundation; either version 2 | ||
2444 | 7 | * of the License, or (at your option) any later version. | ||
2445 | 8 | * | ||
2446 | 9 | * This program is distributed in the hope that it will be useful, | ||
2447 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2448 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2449 | 12 | * GNU General Public License for more details. | ||
2450 | 13 | * | ||
2451 | 14 | * You should have received a copy of the GNU General Public License | ||
2452 | 15 | * along with this program; if not, write to the Free Software | ||
2453 | 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
2454 | 17 | * | ||
2455 | 18 | */ | ||
2456 | 19 | |||
2457 | 20 | #ifndef WL_GRAPHIC_STYLES_TEXT_PANEL_STYLE_H | ||
2458 | 21 | #define WL_GRAPHIC_STYLES_TEXT_PANEL_STYLE_H | ||
2459 | 22 | |||
2460 | 23 | #include <memory> | ||
2461 | 24 | |||
2462 | 25 | #include "graphic/styles/font_style.h" | ||
2463 | 26 | #include "graphic/styles/panel_styles.h" | ||
2464 | 27 | |||
2465 | 28 | namespace UI { | ||
2466 | 29 | |||
2467 | 30 | enum class SliderStyle { kFsMenu, kWuiLight, kWuiDark }; | ||
2468 | 31 | |||
2469 | 32 | struct TextPanelStyleInfo { | ||
2470 | 33 | explicit TextPanelStyleInfo(const UI::FontStyleInfo* init_font, const UI::PanelStyleInfo* init_background) : | ||
2471 | 34 | background_(init_background), | ||
2472 | 35 | font_(init_font) { | ||
2473 | 36 | } | ||
2474 | 37 | explicit TextPanelStyleInfo(const TextPanelStyleInfo& other) : | ||
2475 | 38 | background_(new UI::PanelStyleInfo(other.background())), | ||
2476 | 39 | font_(new UI::FontStyleInfo(other.font())) { | ||
2477 | 40 | } | ||
2478 | 41 | TextPanelStyleInfo& operator=(const TextPanelStyleInfo& other) = default; | ||
2479 | 42 | |||
2480 | 43 | const UI::FontStyleInfo& font() const { | ||
2481 | 44 | return *font_.get(); | ||
2482 | 45 | } | ||
2483 | 46 | void set_font(const UI::FontStyleInfo& new_font) { | ||
2484 | 47 | font_.reset(new UI::FontStyleInfo(new_font)); | ||
2485 | 48 | } | ||
2486 | 49 | |||
2487 | 50 | const UI::PanelStyleInfo& background() const { | ||
2488 | 51 | return *background_.get(); | ||
2489 | 52 | } | ||
2490 | 53 | |||
2491 | 54 | private: | ||
2492 | 55 | std::unique_ptr<const UI::PanelStyleInfo> background_; | ||
2493 | 56 | std::unique_ptr<const UI::FontStyleInfo> font_; | ||
2494 | 57 | }; | ||
2495 | 58 | |||
2496 | 59 | } // namespace UI | ||
2497 | 60 | |||
2498 | 61 | #endif // end of include guard: WL_GRAPHIC_STYLES_TEXT_PANEL_STYLE_H | ||
2499 | 0 | 62 | ||
2500 | === added file 'src/graphic/styles/ware_info_style.h' | |||
2501 | --- src/graphic/styles/ware_info_style.h 1970-01-01 00:00:00 +0000 | |||
2502 | +++ src/graphic/styles/ware_info_style.h 2019-05-26 02:00:17 +0000 | |||
2503 | @@ -0,0 +1,80 @@ | |||
2504 | 1 | /* | ||
2505 | 2 | * Copyright (C) 2018 by the Widelands Development Team | ||
2506 | 3 | * | ||
2507 | 4 | * This program is free software; you can redistribute it and/or | ||
2508 | 5 | * modify it under the terms of the GNU General Public License | ||
2509 | 6 | * as published by the Free Software Foundation; either version 2 | ||
2510 | 7 | * of the License, or (at your option) any later version. | ||
2511 | 8 | * | ||
2512 | 9 | * This program is distributed in the hope that it will be useful, | ||
2513 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2514 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2515 | 12 | * GNU General Public License for more details. | ||
2516 | 13 | * | ||
2517 | 14 | * You should have received a copy of the GNU General Public License | ||
2518 | 15 | * along with this program; if not, write to the Free Software | ||
2519 | 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
2520 | 17 | * | ||
2521 | 18 | */ | ||
2522 | 19 | |||
2523 | 20 | #ifndef WL_GRAPHIC_STYLES_WARE_INFO_STYLE_H | ||
2524 | 21 | #define WL_GRAPHIC_STYLES_WARE_INFO_STYLE_H | ||
2525 | 22 | |||
2526 | 23 | #include <memory> | ||
2527 | 24 | |||
2528 | 25 | #include "graphic/color.h" | ||
2529 | 26 | #include "graphic/styles/font_style.h" | ||
2530 | 27 | #include "graphic/image.h" | ||
2531 | 28 | |||
2532 | 29 | namespace UI { | ||
2533 | 30 | |||
2534 | 31 | enum class WareInfoStyle { | ||
2535 | 32 | kNormal, | ||
2536 | 33 | kHighlight | ||
2537 | 34 | }; | ||
2538 | 35 | |||
2539 | 36 | struct WareInfoStyleInfo { | ||
2540 | 37 | explicit WareInfoStyleInfo(UI::FontStyleInfo* init_header_font, | ||
2541 | 38 | UI::FontStyleInfo* init_info_font, | ||
2542 | 39 | const Image* init_icon_background_image, | ||
2543 | 40 | const RGBColor& init_icon_frame, | ||
2544 | 41 | const RGBColor& init_icon_background, | ||
2545 | 42 | const RGBColor& init_info_background) : | ||
2546 | 43 | header_font_(init_header_font), | ||
2547 | 44 | info_font_(init_info_font), | ||
2548 | 45 | icon_background_image_(init_icon_background_image), | ||
2549 | 46 | icon_frame_(init_icon_frame), | ||
2550 | 47 | icon_background_(init_icon_background), | ||
2551 | 48 | info_background_(init_info_background) {} | ||
2552 | 49 | |||
2553 | 50 | const UI::FontStyleInfo& header_font() const { | ||
2554 | 51 | return *header_font_.get(); | ||
2555 | 52 | } | ||
2556 | 53 | const UI::FontStyleInfo& info_font() const { | ||
2557 | 54 | return *info_font_.get(); | ||
2558 | 55 | } | ||
2559 | 56 | const Image* icon_background_image() const { | ||
2560 | 57 | return icon_background_image_; | ||
2561 | 58 | } | ||
2562 | 59 | const RGBColor& icon_frame() const { | ||
2563 | 60 | return icon_frame_; | ||
2564 | 61 | } | ||
2565 | 62 | const RGBColor& icon_background() const { | ||
2566 | 63 | return icon_background_; | ||
2567 | 64 | } | ||
2568 | 65 | const RGBColor& info_background() const { | ||
2569 | 66 | return info_background_; | ||
2570 | 67 | } | ||
2571 | 68 | |||
2572 | 69 | private: | ||
2573 | 70 | std::unique_ptr<const UI::FontStyleInfo> header_font_; | ||
2574 | 71 | std::unique_ptr<const UI::FontStyleInfo> info_font_; | ||
2575 | 72 | const Image* icon_background_image_; | ||
2576 | 73 | const RGBColor icon_frame_; | ||
2577 | 74 | const RGBColor icon_background_; | ||
2578 | 75 | const RGBColor info_background_; | ||
2579 | 76 | }; | ||
2580 | 77 | |||
2581 | 78 | } // namespace UI | ||
2582 | 79 | |||
2583 | 80 | #endif // end of include guard: WL_GRAPHIC_STYLES_WARE_INFO_STYLE_H | ||
2584 | 0 | 81 | ||
2585 | === modified file 'src/graphic/text/CMakeLists.txt' | |||
2586 | --- src/graphic/text/CMakeLists.txt 2018-03-02 06:01:51 +0000 | |||
2587 | +++ src/graphic/text/CMakeLists.txt 2019-05-26 02:00:17 +0000 | |||
2588 | @@ -41,7 +41,6 @@ | |||
2589 | 41 | graphic_playercolor | 41 | graphic_playercolor |
2590 | 42 | graphic_sdl_utils | 42 | graphic_sdl_utils |
2591 | 43 | graphic_surface | 43 | graphic_surface |
2592 | 44 | graphic_text_layout | ||
2593 | 45 | io_fileread | 44 | io_fileread |
2594 | 46 | io_filesystem | 45 | io_filesystem |
2595 | 47 | scripting_lua_interface | 46 | scripting_lua_interface |
2596 | 48 | 47 | ||
2597 | === modified file 'src/graphic/text/font_set.cc' | |||
2598 | --- src/graphic/text/font_set.cc 2019-02-23 11:00:49 +0000 | |||
2599 | +++ src/graphic/text/font_set.cc 2019-05-26 02:00:17 +0000 | |||
2600 | @@ -27,6 +27,7 @@ | |||
2601 | 27 | 27 | ||
2602 | 28 | #include "base/i18n.h" | 28 | #include "base/i18n.h" |
2603 | 29 | #include "base/log.h" | 29 | #include "base/log.h" |
2604 | 30 | #include "graphic/text/bidi.h" | ||
2605 | 30 | #include "io/filesystem/layered_filesystem.h" | 31 | #include "io/filesystem/layered_filesystem.h" |
2606 | 31 | #include "scripting/lua_interface.h" | 32 | #include "scripting/lua_interface.h" |
2607 | 32 | #include "scripting/lua_table.h" | 33 | #include "scripting/lua_table.h" |
2608 | 33 | 34 | ||
2609 | === modified file 'src/graphic/text/font_set.h' | |||
2610 | --- src/graphic/text/font_set.h 2019-02-23 11:00:49 +0000 | |||
2611 | +++ src/graphic/text/font_set.h 2019-05-26 02:00:17 +0000 | |||
2612 | @@ -25,6 +25,7 @@ | |||
2613 | 25 | #include <string> | 25 | #include <string> |
2614 | 26 | 26 | ||
2615 | 27 | #include "base/macros.h" | 27 | #include "base/macros.h" |
2616 | 28 | #include "graphic/align.h" | ||
2617 | 28 | #include "scripting/lua_table.h" | 29 | #include "scripting/lua_table.h" |
2618 | 29 | 30 | ||
2619 | 30 | namespace UI { | 31 | namespace UI { |
2620 | @@ -32,8 +33,6 @@ | |||
2621 | 32 | // Contains font information for a locale | 33 | // Contains font information for a locale |
2622 | 33 | struct FontSet { | 34 | struct FontSet { |
2623 | 34 | 35 | ||
2624 | 35 | enum class Face { kSans, kSerif, kCondensed }; | ||
2625 | 36 | |||
2626 | 37 | static constexpr const char* kFallbackFont = "DejaVu/DejaVuSans.ttf"; | 36 | static constexpr const char* kFallbackFont = "DejaVu/DejaVuSans.ttf"; |
2627 | 38 | 37 | ||
2628 | 39 | /// Create a fontset from i18n/fonts.lua | 38 | /// Create a fontset from i18n/fonts.lua |
2629 | @@ -62,6 +61,7 @@ | |||
2630 | 62 | // Returns true iff the fontset's script is written from right to left. | 61 | // Returns true iff the fontset's script is written from right to left. |
2631 | 63 | bool is_rtl() const; | 62 | bool is_rtl() const; |
2632 | 64 | 63 | ||
2633 | 64 | |||
2634 | 65 | private: | 65 | private: |
2635 | 66 | /// Parses font information for the given fontset name from Lua. | 66 | /// Parses font information for the given fontset name from Lua. |
2636 | 67 | /// The fontset definitions are in i18n/fonts.lua | 67 | /// The fontset definitions are in i18n/fonts.lua |
2637 | 68 | 68 | ||
2638 | === modified file 'src/graphic/text/rendered_text.cc' | |||
2639 | --- src/graphic/text/rendered_text.cc 2019-02-23 11:00:49 +0000 | |||
2640 | +++ src/graphic/text/rendered_text.cc 2019-05-26 02:00:17 +0000 | |||
2641 | @@ -22,7 +22,6 @@ | |||
2642 | 22 | #include <memory> | 22 | #include <memory> |
2643 | 23 | 23 | ||
2644 | 24 | #include "graphic/graphic.h" | 24 | #include "graphic/graphic.h" |
2645 | 25 | #include "graphic/text_layout.h" | ||
2646 | 26 | 25 | ||
2647 | 27 | namespace UI { | 26 | namespace UI { |
2648 | 28 | // RenderedRect | 27 | // RenderedRect |
2649 | 29 | 28 | ||
2650 | === modified file 'src/graphic/text/rt_render.cc' | |||
2651 | --- src/graphic/text/rt_render.cc 2019-05-04 09:59:51 +0000 | |||
2652 | +++ src/graphic/text/rt_render.cc 2019-05-26 02:00:17 +0000 | |||
2653 | @@ -48,11 +48,23 @@ | |||
2654 | 48 | #include "graphic/text/rt_parse.h" | 48 | #include "graphic/text/rt_parse.h" |
2655 | 49 | #include "graphic/text/sdl_ttf_font.h" | 49 | #include "graphic/text/sdl_ttf_font.h" |
2656 | 50 | #include "graphic/text/textstream.h" | 50 | #include "graphic/text/textstream.h" |
2657 | 51 | #include "graphic/text_layout.h" | ||
2658 | 52 | #include "graphic/texture.h" | 51 | #include "graphic/texture.h" |
2659 | 53 | #include "io/filesystem/filesystem_exceptions.h" | 52 | #include "io/filesystem/filesystem_exceptions.h" |
2660 | 54 | #include "io/filesystem/layered_filesystem.h" | 53 | #include "io/filesystem/layered_filesystem.h" |
2661 | 55 | 54 | ||
2662 | 55 | namespace { | ||
2663 | 56 | /** | ||
2664 | 57 | * This function replaces some HTML entities in strings, e.g. . | ||
2665 | 58 | * It is used by the renderer after the tags have been parsed. | ||
2666 | 59 | */ | ||
2667 | 60 | void replace_entities(std::string* text) { | ||
2668 | 61 | boost::replace_all(*text, ">", ">"); | ||
2669 | 62 | boost::replace_all(*text, "<", "<"); | ||
2670 | 63 | boost::replace_all(*text, " ", " "); | ||
2671 | 64 | boost::replace_all(*text, "&", "&"); // Must be performed last | ||
2672 | 65 | } | ||
2673 | 66 | } // namespace | ||
2674 | 67 | |||
2675 | 56 | namespace RT { | 68 | namespace RT { |
2676 | 57 | 69 | ||
2677 | 58 | static const uint16_t INFINITE_WIDTH = 65535; // 2^16-1 | 70 | static const uint16_t INFINITE_WIDTH = 65535; // 2^16-1 |
2678 | @@ -93,6 +105,7 @@ | |||
2679 | 93 | uint8_t spacing; | 105 | uint8_t spacing; |
2680 | 94 | UI::Align halign; | 106 | UI::Align halign; |
2681 | 95 | UI::Align valign; | 107 | UI::Align valign; |
2682 | 108 | const bool is_rtl; | ||
2683 | 96 | std::string reference; | 109 | std::string reference; |
2684 | 97 | }; | 110 | }; |
2685 | 98 | 111 | ||
2686 | @@ -975,7 +988,7 @@ | |||
2687 | 975 | : RenderNode(ns), | 988 | : RenderNode(ns), |
2688 | 976 | image_(image), | 989 | image_(image), |
2689 | 977 | filename_(""), | 990 | filename_(""), |
2691 | 978 | scale_(1.0f), | 991 | scale_(1.0), |
2692 | 979 | color_(RGBColor(0, 0, 0)), | 992 | color_(RGBColor(0, 0, 0)), |
2693 | 980 | use_playercolor_(false) { | 993 | use_playercolor_(false) { |
2694 | 981 | check_size(); | 994 | check_size(); |
2695 | @@ -1234,7 +1247,7 @@ | |||
2696 | 1234 | nodestyle_.halign = UI::Align::kLeft; | 1247 | nodestyle_.halign = UI::Align::kLeft; |
2697 | 1235 | } | 1248 | } |
2698 | 1236 | } | 1249 | } |
2700 | 1237 | nodestyle_.halign = mirror_alignment(nodestyle_.halign); | 1250 | nodestyle_.halign = mirror_alignment(nodestyle_.halign, nodestyle_.is_rtl); |
2701 | 1238 | if (a.has("valign")) { | 1251 | if (a.has("valign")) { |
2702 | 1239 | const std::string align = a["valign"].get_string(); | 1252 | const std::string align = a["valign"].get_string(); |
2703 | 1240 | if (align == "bottom") { | 1253 | if (align == "bottom") { |
2704 | @@ -1715,7 +1728,7 @@ | |||
2705 | 1715 | } | 1728 | } |
2706 | 1716 | 1729 | ||
2707 | 1717 | std::shared_ptr<RenderNode> | 1730 | std::shared_ptr<RenderNode> |
2709 | 1718 | Renderer::layout(const std::string& text, uint16_t width, const TagSet& allowed_tags) { | 1731 | Renderer::layout(const std::string& text, uint16_t width, bool is_rtl, const TagSet& allowed_tags) { |
2710 | 1719 | std::unique_ptr<Tag> rt(parser_->parse(text, allowed_tags)); | 1732 | std::unique_ptr<Tag> rt(parser_->parse(text, allowed_tags)); |
2711 | 1720 | 1733 | ||
2712 | 1721 | if (!width) { | 1734 | if (!width) { |
2713 | @@ -1735,6 +1748,7 @@ | |||
2714 | 1735 | 0, | 1748 | 0, |
2715 | 1736 | UI::Align::kLeft, | 1749 | UI::Align::kLeft, |
2716 | 1737 | UI::Align::kTop, | 1750 | UI::Align::kTop, |
2717 | 1751 | is_rtl, | ||
2718 | 1738 | ""}; | 1752 | ""}; |
2719 | 1739 | 1753 | ||
2720 | 1740 | RTTagHandler rtrn( | 1754 | RTTagHandler rtrn( |
2721 | @@ -1749,8 +1763,8 @@ | |||
2722 | 1749 | } | 1763 | } |
2723 | 1750 | 1764 | ||
2724 | 1751 | std::shared_ptr<const UI::RenderedText> | 1765 | std::shared_ptr<const UI::RenderedText> |
2727 | 1752 | Renderer::render(const std::string& text, uint16_t width, const TagSet& allowed_tags) { | 1766 | Renderer::render(const std::string& text, uint16_t width, bool is_rtl, const TagSet& allowed_tags) { |
2728 | 1753 | std::shared_ptr<RenderNode> node(layout(text, width, allowed_tags)); | 1767 | std::shared_ptr<RenderNode> node(layout(text, width, is_rtl, allowed_tags)); |
2729 | 1754 | return std::shared_ptr<const UI::RenderedText>(node->render(texture_cache_)); | 1768 | return std::shared_ptr<const UI::RenderedText>(node->render(texture_cache_)); |
2730 | 1755 | } | 1769 | } |
2731 | 1756 | } // namespace RT | 1770 | } // namespace RT |
2732 | 1757 | 1771 | ||
2733 | === modified file 'src/graphic/text/rt_render.h' | |||
2734 | --- src/graphic/text/rt_render.h 2019-02-23 11:00:49 +0000 | |||
2735 | +++ src/graphic/text/rt_render.h 2019-05-26 02:00:17 +0000 | |||
2736 | @@ -70,11 +70,11 @@ | |||
2737 | 70 | // Render the given string in the given width. Restricts the allowed tags to | 70 | // Render the given string in the given width. Restricts the allowed tags to |
2738 | 71 | // the ones in TagSet. | 71 | // the ones in TagSet. |
2739 | 72 | std::shared_ptr<const UI::RenderedText> | 72 | std::shared_ptr<const UI::RenderedText> |
2741 | 73 | render(const std::string&, uint16_t width, const TagSet& tagset = TagSet()); | 73 | render(const std::string&, uint16_t width, bool is_rtl, const TagSet& tagset = TagSet()); |
2742 | 74 | 74 | ||
2743 | 75 | private: | 75 | private: |
2744 | 76 | std::shared_ptr<RenderNode> | 76 | std::shared_ptr<RenderNode> |
2746 | 77 | layout(const std::string& text, uint16_t width, const TagSet& allowed_tags); | 77 | layout(const std::string& text, uint16_t width, bool is_rtl, const TagSet& allowed_tags); |
2747 | 78 | 78 | ||
2748 | 79 | std::unique_ptr<FontCache> font_cache_; | 79 | std::unique_ptr<FontCache> font_cache_; |
2749 | 80 | std::unique_ptr<Parser> parser_; | 80 | std::unique_ptr<Parser> parser_; |
2750 | 81 | 81 | ||
2751 | === removed file 'src/graphic/text_constants.cc' | |||
2752 | --- src/graphic/text_constants.cc 2017-03-04 12:37:17 +0000 | |||
2753 | +++ src/graphic/text_constants.cc 1970-01-01 00:00:00 +0000 | |||
2754 | @@ -1,1 +0,0 @@ | |||
2755 | 1 | // Dummy to make CMake happy | ||
2756 | 2 | 0 | ||
2757 | === removed file 'src/graphic/text_constants.h' | |||
2758 | --- src/graphic/text_constants.h 2019-02-23 11:00:49 +0000 | |||
2759 | +++ src/graphic/text_constants.h 1970-01-01 00:00:00 +0000 | |||
2760 | @@ -1,50 +0,0 @@ | |||
2761 | 1 | /* | ||
2762 | 2 | * Copyright (C) 2006-2019 by the Widelands Development Team | ||
2763 | 3 | * | ||
2764 | 4 | * This program is free software; you can redistribute it and/or | ||
2765 | 5 | * modify it under the terms of the GNU General Public License | ||
2766 | 6 | * as published by the Free Software Foundation; either version 2 | ||
2767 | 7 | * of the License, or (at your option) any later version. | ||
2768 | 8 | * | ||
2769 | 9 | * This program is distributed in the hope that it will be useful, | ||
2770 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2771 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2772 | 12 | * GNU General Public License for more details. | ||
2773 | 13 | * | ||
2774 | 14 | * You should have received a copy of the GNU General Public License | ||
2775 | 15 | * along with this program; if not, write to the Free Software | ||
2776 | 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
2777 | 17 | * | ||
2778 | 18 | */ | ||
2779 | 19 | |||
2780 | 20 | #ifndef WL_GRAPHIC_TEXT_CONSTANTS_H | ||
2781 | 21 | #define WL_GRAPHIC_TEXT_CONSTANTS_H | ||
2782 | 22 | |||
2783 | 23 | // Basic constants for often used text attributes. | ||
2784 | 24 | |||
2785 | 25 | /// Font Sizes | ||
2786 | 26 | #define UI_FONT_SIZE_BIG 22 | ||
2787 | 27 | #define UI_FONT_SIZE_SMALL 14 | ||
2788 | 28 | #define UI_FONT_SIZE_MESSAGE 12 | ||
2789 | 29 | #define UI_FONT_SIZE_ULTRASMALL 10 | ||
2790 | 30 | constexpr int kMinimumFontSize = 6; | ||
2791 | 31 | constexpr int kLineMargin = 1; | ||
2792 | 32 | |||
2793 | 33 | /// Font colors | ||
2794 | 34 | |||
2795 | 35 | /// Global UI font color | ||
2796 | 36 | #define UI_FONT_CLR_FG RGBColor(255, 255, 0) | ||
2797 | 37 | #define UI_FONT_CLR_DISABLED RGBColor(127, 127, 127) | ||
2798 | 38 | #define UI_FONT_CLR_WARNING RGBColor(255, 22, 22) | ||
2799 | 39 | |||
2800 | 40 | /// Tooltip font color | ||
2801 | 41 | #define UI_FONT_TOOLTIP_CLR RGBColor(255, 255, 0) | ||
2802 | 42 | |||
2803 | 43 | /// Colors for good/ok/bad | ||
2804 | 44 | #define UI_FONT_CLR_BRIGHT RGBColor(255, 250, 170) | ||
2805 | 45 | #define UI_FONT_CLR_DARK RGBColor(163, 144, 19) | ||
2806 | 46 | #define UI_FONT_CLR_BAD RGBColor(187, 0, 0) | ||
2807 | 47 | #define UI_FONT_CLR_OK RGBColor(255, 225, 30) | ||
2808 | 48 | #define UI_FONT_CLR_GOOD RGBColor(0, 187, 0) | ||
2809 | 49 | |||
2810 | 50 | #endif // end of include guard: WL_GRAPHIC_TEXT_CONSTANTS_H | ||
2811 | 51 | 0 | ||
2812 | === modified file 'src/graphic/text_layout.cc' | |||
2813 | --- src/graphic/text_layout.cc 2019-04-18 16:50:35 +0000 | |||
2814 | +++ src/graphic/text_layout.cc 2019-05-26 02:00:17 +0000 | |||
2815 | @@ -19,18 +19,14 @@ | |||
2816 | 19 | 19 | ||
2817 | 20 | #include "graphic/text_layout.h" | 20 | #include "graphic/text_layout.h" |
2818 | 21 | 21 | ||
2819 | 22 | #include <map> | ||
2820 | 23 | |||
2821 | 24 | #include <SDL_ttf.h> | ||
2822 | 25 | #include <boost/algorithm/string.hpp> | 22 | #include <boost/algorithm/string.hpp> |
2823 | 26 | #include <boost/format.hpp> | 23 | #include <boost/format.hpp> |
2824 | 27 | 24 | ||
2825 | 28 | #include "graphic/font_handler.h" | 25 | #include "graphic/font_handler.h" |
2826 | 29 | #include "graphic/graphic.h" | 26 | #include "graphic/graphic.h" |
2827 | 30 | #include "graphic/image.h" | 27 | #include "graphic/image.h" |
2829 | 31 | #include "graphic/text/bidi.h" | 28 | #include "graphic/style_manager.h" |
2830 | 32 | #include "graphic/text/font_set.h" | 29 | #include "graphic/text/font_set.h" |
2831 | 33 | #include "graphic/text_constants.h" | ||
2832 | 34 | 30 | ||
2833 | 35 | namespace { | 31 | namespace { |
2834 | 36 | bool is_paragraph(const std::string& text) { | 32 | bool is_paragraph(const std::string& text) { |
2835 | @@ -40,70 +36,8 @@ | |||
2836 | 40 | bool is_div(const std::string& text) { | 36 | bool is_div(const std::string& text) { |
2837 | 41 | return boost::starts_with(text, "<div"); | 37 | return boost::starts_with(text, "<div"); |
2838 | 42 | } | 38 | } |
2903 | 43 | } // namespace | 39 | |
2904 | 44 | 40 | std::string as_richtext_paragraph(const std::string& text, UI::Align align) { | |
2841 | 45 | void replace_entities(std::string* text) { | ||
2842 | 46 | boost::replace_all(*text, ">", ">"); | ||
2843 | 47 | boost::replace_all(*text, "<", "<"); | ||
2844 | 48 | boost::replace_all(*text, " ", " "); | ||
2845 | 49 | boost::replace_all(*text, "&", "&"); // Must be performed last | ||
2846 | 50 | } | ||
2847 | 51 | |||
2848 | 52 | int text_width(const std::string& text, int ptsize) { | ||
2849 | 53 | return UI::g_fh | ||
2850 | 54 | ->render(as_editorfont( | ||
2851 | 55 | text.substr(0, g_gr->max_texture_size_for_font_rendering() / text_height() - 1), | ||
2852 | 56 | ptsize - UI::g_fh->fontset()->size_offset())) | ||
2853 | 57 | ->width(); | ||
2854 | 58 | } | ||
2855 | 59 | |||
2856 | 60 | int text_height(int ptsize, UI::FontSet::Face face) { | ||
2857 | 61 | return UI::g_fh | ||
2858 | 62 | ->render(as_aligned(UI::g_fh->fontset()->representative_character(), UI::Align::kLeft, | ||
2859 | 63 | ptsize - UI::g_fh->fontset()->size_offset(), RGBColor(0, 0, 0), face)) | ||
2860 | 64 | ->height(); | ||
2861 | 65 | } | ||
2862 | 66 | |||
2863 | 67 | std::string richtext_escape(const std::string& given_text) { | ||
2864 | 68 | std::string text = given_text; | ||
2865 | 69 | boost::replace_all(text, "&", "&"); // Must be performed first | ||
2866 | 70 | boost::replace_all(text, ">", ">"); | ||
2867 | 71 | boost::replace_all(text, "<", "<"); | ||
2868 | 72 | return text; | ||
2869 | 73 | } | ||
2870 | 74 | |||
2871 | 75 | std::string as_game_tip(const std::string& txt) { | ||
2872 | 76 | static boost::format f( | ||
2873 | 77 | "<rt><p align=center><font color=21211b face=serif size=16>%s</font></p></rt>"); | ||
2874 | 78 | f % txt; | ||
2875 | 79 | return f.str(); | ||
2876 | 80 | } | ||
2877 | 81 | |||
2878 | 82 | std::string | ||
2879 | 83 | as_uifont(const std::string& txt, int size, const RGBColor& clr, UI::FontSet::Face face) { | ||
2880 | 84 | return as_aligned(txt, UI::Align::kLeft, size, clr, face); | ||
2881 | 85 | } | ||
2882 | 86 | |||
2883 | 87 | std::string | ||
2884 | 88 | as_condensed(const std::string& text, UI::Align align, int ptsize, const RGBColor& clr) { | ||
2885 | 89 | return as_aligned(text, align, ptsize, clr, UI::FontSet::Face::kCondensed); | ||
2886 | 90 | } | ||
2887 | 91 | |||
2888 | 92 | std::string as_editorfont(const std::string& text, int ptsize, const RGBColor& clr) { | ||
2889 | 93 | // UI Text is always bold due to historic reasons | ||
2890 | 94 | static boost::format f( | ||
2891 | 95 | "<rt keep_spaces=1><p><font face=sans size=%i bold=1 shadow=1 color=%s>%s</font></p></rt>"); | ||
2892 | 96 | f % ptsize; | ||
2893 | 97 | f % clr.hex_value(); | ||
2894 | 98 | f % richtext_escape(text); | ||
2895 | 99 | return f.str(); | ||
2896 | 100 | } | ||
2897 | 101 | |||
2898 | 102 | std::string as_aligned(const std::string& txt, | ||
2899 | 103 | UI::Align align, | ||
2900 | 104 | int ptsize, | ||
2901 | 105 | const RGBColor& clr, | ||
2902 | 106 | UI::FontSet::Face face) { | ||
2905 | 107 | std::string alignment = "left"; | 41 | std::string alignment = "left"; |
2906 | 108 | switch (align) { | 42 | switch (align) { |
2907 | 109 | case UI::Align::kCenter: | 43 | case UI::Align::kCenter: |
2908 | @@ -117,38 +51,48 @@ | |||
2909 | 117 | break; | 51 | break; |
2910 | 118 | } | 52 | } |
2911 | 119 | 53 | ||
2929 | 120 | std::string font_face = "sans"; | 54 | static boost::format f("<rt><p align=%s>%s</p></rt>"); |
2913 | 121 | |||
2914 | 122 | switch (face) { | ||
2915 | 123 | case UI::FontSet::Face::kCondensed: | ||
2916 | 124 | font_face = "condensed"; | ||
2917 | 125 | break; | ||
2918 | 126 | case UI::FontSet::Face::kSerif: | ||
2919 | 127 | font_face = "serif"; | ||
2920 | 128 | break; | ||
2921 | 129 | case UI::FontSet::Face::kSans: | ||
2922 | 130 | font_face = "sans"; | ||
2923 | 131 | break; | ||
2924 | 132 | } | ||
2925 | 133 | |||
2926 | 134 | // UI Text is always bold due to historic reasons | ||
2927 | 135 | static boost::format f( | ||
2928 | 136 | "<rt><p align=%s><font face=%s size=%i bold=1 shadow=1 color=%s>%s</font></p></rt>"); | ||
2930 | 137 | f % alignment; | 55 | f % alignment; |
2935 | 138 | f % font_face; | 56 | f % text; |
2932 | 139 | f % ptsize; | ||
2933 | 140 | f % clr.hex_value(); | ||
2934 | 141 | f % txt; | ||
2936 | 142 | return f.str(); | 57 | return f.str(); |
2937 | 143 | } | 58 | } |
2938 | 59 | } // namespace | ||
2939 | 60 | |||
2940 | 61 | int text_width(const std::string& text, const UI::FontStyleInfo& style, float scale) { | ||
2941 | 62 | UI::FontStyleInfo info(style); | ||
2942 | 63 | info.set_size(info.size() * scale - UI::g_fh->fontset()->size_offset()); | ||
2943 | 64 | return UI::g_fh | ||
2944 | 65 | ->render(as_editor_richtext_paragraph(text, info))->width(); | ||
2945 | 66 | } | ||
2946 | 67 | |||
2947 | 68 | int text_height(const UI::FontStyleInfo& style, float scale) { | ||
2948 | 69 | UI::FontStyleInfo info(style); | ||
2949 | 70 | info.set_size(info.size() * scale - UI::g_fh->fontset()->size_offset()); | ||
2950 | 71 | return UI::g_fh | ||
2951 | 72 | ->render(as_richtext_paragraph(UI::g_fh->fontset()->representative_character(), info)) | ||
2952 | 73 | ->height(); | ||
2953 | 74 | } | ||
2954 | 75 | |||
2955 | 76 | int text_height(UI::FontStyle style, float scale) { | ||
2956 | 77 | return text_height(g_gr->styles().font_style(style), scale); | ||
2957 | 78 | } | ||
2958 | 79 | |||
2959 | 80 | std::string richtext_escape(const std::string& given_text) { | ||
2960 | 81 | std::string text = given_text; | ||
2961 | 82 | boost::replace_all(text, "&", "&"); // Must be performed first | ||
2962 | 83 | boost::replace_all(text, ">", ">"); | ||
2963 | 84 | boost::replace_all(text, "<", "<"); | ||
2964 | 85 | return text; | ||
2965 | 86 | } | ||
2966 | 144 | 87 | ||
2967 | 145 | /// Bullet list item | 88 | /// Bullet list item |
2969 | 146 | std::string as_listitem(const std::string& txt, int ptsize, const RGBColor& clr) { | 89 | std::string as_listitem(const std::string& txt, UI::FontStyle style) { |
2970 | 147 | static boost::format f("<div width=100%%><div><p><font size=%d " | 90 | static boost::format f("<div width=100%%><div><p><font size=%d " |
2971 | 148 | "color=%s>•</font></p></div><div><p><space gap=6></p></div><div " | 91 | "color=%s>•</font></p></div><div><p><space gap=6></p></div><div " |
2972 | 149 | "width=*><p><font size=%d color=%s>%s<vspace " | 92 | "width=*><p><font size=%d color=%s>%s<vspace " |
2973 | 150 | "gap=6></font></p></div></div>"); | 93 | "gap=6></font></p></div></div>"); |
2975 | 151 | f % ptsize % clr.hex_value() % ptsize % clr.hex_value() % txt; | 94 | const UI::FontStyleInfo& font_style = g_gr->styles().font_style(style); |
2976 | 95 | f % font_style.size() % font_style.color().hex_value() % font_style.size() % font_style.color().hex_value() % txt; | ||
2977 | 152 | return f.str(); | 96 | return f.str(); |
2978 | 153 | } | 97 | } |
2979 | 154 | 98 | ||
2980 | @@ -158,33 +102,83 @@ | |||
2981 | 158 | return f.str(); | 102 | return f.str(); |
2982 | 159 | } | 103 | } |
2983 | 160 | 104 | ||
2998 | 161 | std::string as_tooltip(const std::string& txt) { | 105 | std::string as_richtext_paragraph(const std::string& text, UI::FontStyle style, UI::Align align) { |
2999 | 162 | static boost::format f("<rt><p><font face=sans size=%i bold=1 color=%s>%s</font></p></rt>"); | 106 | return as_richtext_paragraph(text, g_gr->styles().font_style(style), align); |
3000 | 163 | 107 | } | |
3001 | 164 | f % UI_FONT_SIZE_SMALL; | 108 | |
3002 | 165 | f % UI_FONT_TOOLTIP_CLR.hex_value(); | 109 | std::string as_richtext_paragraph(const std::string& text, const UI::FontStyleInfo& style, UI::Align align) { |
3003 | 166 | f % txt; | 110 | return as_richtext_paragraph(style.as_font_tag(text), align); |
3004 | 167 | return f.str(); | 111 | } |
3005 | 168 | } | 112 | |
3006 | 169 | 113 | std::string as_editor_richtext_paragraph(const std::string& text, const UI::FontStyleInfo& style) { | |
3007 | 170 | std::string as_waresinfo(const std::string& txt) { | 114 | static boost::format f("<rt keep_spaces=1><p>%s</p></rt>"); |
3008 | 171 | static boost::format f("<rt><p><font face=condensed size=10 bold=0 color=%s>%s</font></p></rt>"); | 115 | f % style.as_font_tag(text); |
3009 | 172 | f % UI_FONT_TOOLTIP_CLR.hex_value(); | 116 | return f.str(); |
3010 | 173 | f % txt; | 117 | } |
3011 | 174 | return f.str(); | 118 | |
3012 | 119 | std::string as_game_tip(const std::string& txt) { | ||
3013 | 120 | static boost::format f("<rt><p align=center>%s</p></rt>"); | ||
3014 | 121 | f % g_gr->styles().font_style(UI::FontStyle::kFsMenuGameTip).as_font_tag(txt); | ||
3015 | 122 | return f.str(); | ||
3016 | 123 | } | ||
3017 | 124 | |||
3018 | 125 | std::string as_mapobject_message(const std::string& image, int width, const std::string& txt, const RGBColor* player_color) { | ||
3019 | 126 | assert(!image.empty()); | ||
3020 | 127 | assert(!txt.empty()); | ||
3021 | 128 | const std::string image_type = g_gr->images().has(image) ? "src" : "object"; | ||
3022 | 129 | static boost::format f_color("<div padding_r=10><p><img width=%d %s=%s color=%s></p></div>" | ||
3023 | 130 | "<div width=*><p>%s</p></div>"); | ||
3024 | 131 | static boost::format f_nocolor("<div padding_r=10><p><img width=%d %s=%s></p></div>" | ||
3025 | 132 | "<div width=*><p>%s</p></div>"); | ||
3026 | 133 | if (player_color != nullptr) { | ||
3027 | 134 | f_color % width; | ||
3028 | 135 | f_color % image_type; | ||
3029 | 136 | f_color % image; | ||
3030 | 137 | f_color % player_color->hex_value(); | ||
3031 | 138 | f_color % g_gr->styles().font_style(UI::FontStyle::kWuiMessageParagraph).as_font_tag(txt); | ||
3032 | 139 | return f_color.str(); | ||
3033 | 140 | } else { | ||
3034 | 141 | f_nocolor % width; | ||
3035 | 142 | f_nocolor % image_type; | ||
3036 | 143 | f_nocolor % image; | ||
3037 | 144 | f_nocolor % g_gr->styles().font_style(UI::FontStyle::kWuiMessageParagraph).as_font_tag(txt); | ||
3038 | 145 | return f_nocolor.str(); | ||
3039 | 146 | } | ||
3040 | 175 | } | 147 | } |
3041 | 176 | 148 | ||
3042 | 177 | std::string as_message(const std::string& heading, const std::string& body) { | 149 | std::string as_message(const std::string& heading, const std::string& body) { |
3043 | 178 | return ( | 150 | return ( |
3044 | 179 | (boost::format( | 151 | (boost::format( |
3047 | 180 | "<rt><p><font size=18 bold=1 color=D1D1D1>%s<br></font></p><vspace gap=6>%s</rt>") % | 152 | "<rt><p>%s<br></p><vspace gap=6>%s</rt>") % |
3048 | 181 | heading % | 153 | g_gr->styles().font_style(UI::FontStyle::kWuiMessageHeading).as_font_tag(heading) % |
3049 | 182 | (is_paragraph(body) || is_div(body) ? | 154 | (is_paragraph(body) || is_div(body) ? |
3050 | 183 | body : | 155 | body : |
3052 | 184 | (boost::format("<p><font size=%d>%s</font></p>") % UI_FONT_SIZE_MESSAGE % body).str())) | 156 | (boost::format("<p>%s</p>") % |
3053 | 157 | g_gr->styles().font_style(UI::FontStyle::kWuiMessageParagraph).as_font_tag(body)) | ||
3054 | 158 | .str())) | ||
3055 | 185 | .str()); | 159 | .str()); |
3056 | 186 | } | 160 | } |
3057 | 187 | 161 | ||
3058 | 162 | std::shared_ptr<const UI::RenderedText> autofit_text(const std::string& text, | ||
3059 | 163 | const UI::FontStyleInfo& font_info, | ||
3060 | 164 | int width) { | ||
3061 | 165 | std::shared_ptr<const UI::RenderedText> rendered_text = | ||
3062 | 166 | UI::g_fh->render(as_richtext_paragraph(text, font_info)); | ||
3063 | 167 | |||
3064 | 168 | // Autoshrink if it doesn't fit | ||
3065 | 169 | if (width > 0 && rendered_text->width() > width) { | ||
3066 | 170 | const int minimum_size = g_gr->styles().minimum_font_size(); | ||
3067 | 171 | // We take a copy, because we are changing values during the autofit. | ||
3068 | 172 | UI::FontStyleInfo temp_font_info(font_info); | ||
3069 | 173 | temp_font_info.make_condensed(); | ||
3070 | 174 | while (rendered_text->width() > width && temp_font_info.size() >= minimum_size) { | ||
3071 | 175 | rendered_text = UI::g_fh->render(as_richtext_paragraph(text, temp_font_info)); | ||
3072 | 176 | temp_font_info.set_size(temp_font_info.size() - 1); | ||
3073 | 177 | } | ||
3074 | 178 | } | ||
3075 | 179 | return rendered_text; | ||
3076 | 180 | } | ||
3077 | 181 | |||
3078 | 188 | std::string as_heading_with_content(const std::string& header, | 182 | std::string as_heading_with_content(const std::string& header, |
3079 | 189 | const std::string& content, | 183 | const std::string& content, |
3080 | 190 | UI::PanelStyle style, | 184 | UI::PanelStyle style, |
3081 | @@ -192,18 +186,16 @@ | |||
3082 | 192 | bool noescape) { | 186 | bool noescape) { |
3083 | 193 | switch (style) { | 187 | switch (style) { |
3084 | 194 | case UI::PanelStyle::kFsMenu: | 188 | case UI::PanelStyle::kFsMenu: |
3090 | 195 | return (boost::format( | 189 | return (boost::format("<p>%s%s %s</p>") % |
3091 | 196 | "<p><font size=%i bold=1 shadow=1>%s%s <font color=D1D1D1>%s</font></font></p>") % | 190 | (is_first ? "" : "<vspace gap=9>") % |
3092 | 197 | UI_FONT_SIZE_SMALL % (is_first ? "" : "<vspace gap=9>") % | 191 | g_gr->styles().font_style(UI::FontStyle::kFsMenuInfoPanelHeading).as_font_tag(noescape ? header : richtext_escape(header)) % |
3093 | 198 | (noescape ? header : richtext_escape(header)) % | 192 | g_gr->styles().font_style(UI::FontStyle::kFsMenuInfoPanelParagraph).as_font_tag(noescape ? content : richtext_escape(content))) |
3089 | 199 | (noescape ? content : richtext_escape(content))) | ||
3094 | 200 | .str(); | 193 | .str(); |
3095 | 201 | case UI::PanelStyle::kWui: | 194 | case UI::PanelStyle::kWui: |
3101 | 202 | return (boost::format( | 195 | return (boost::format("<p>%s%s %s</p>") % |
3102 | 203 | "<p><font size=%i>%s<font bold=1 color=D1D1D1>%s</font> %s</font></p>") % | 196 | (is_first ? "" : "<vspace gap=6>") % |
3103 | 204 | UI_FONT_SIZE_SMALL % (is_first ? "" : "<vspace gap=6>") % | 197 | g_gr->styles().font_style(UI::FontStyle::kWuiInfoPanelHeading).as_font_tag(noescape ? header : richtext_escape(header)) % |
3104 | 205 | (noescape ? header : richtext_escape(header)) % | 198 | g_gr->styles().font_style(UI::FontStyle::kWuiInfoPanelParagraph).as_font_tag(noescape ? content : richtext_escape(content))) |
3100 | 206 | (noescape ? content : richtext_escape(content))) | ||
3105 | 207 | .str(); | 199 | .str(); |
3106 | 208 | } | 200 | } |
3107 | 209 | NEVER_HERE(); | 201 | NEVER_HERE(); |
3108 | @@ -212,12 +204,16 @@ | |||
3109 | 212 | std::string as_heading(const std::string& txt, UI::PanelStyle style, bool is_first) { | 204 | std::string as_heading(const std::string& txt, UI::PanelStyle style, bool is_first) { |
3110 | 213 | switch (style) { | 205 | switch (style) { |
3111 | 214 | case UI::PanelStyle::kFsMenu: | 206 | case UI::PanelStyle::kFsMenu: |
3114 | 215 | return (boost::format("<p><font size=%i bold=1 shadow=1>%s%s</font></p>") % | 207 | return (boost::format("<p>%s%s</p>") % (is_first ? "" : "<vspace gap=9>") % |
3115 | 216 | UI_FONT_SIZE_SMALL % (is_first ? "" : "<vspace gap=9>") % richtext_escape(txt)) | 208 | g_gr->styles() |
3116 | 209 | .font_style(UI::FontStyle::kFsMenuInfoPanelHeading) | ||
3117 | 210 | .as_font_tag(richtext_escape(txt))) | ||
3118 | 217 | .str(); | 211 | .str(); |
3119 | 218 | case UI::PanelStyle::kWui: | 212 | case UI::PanelStyle::kWui: |
3122 | 219 | return (boost::format("<p><font size=%i bold=1 color=D1D1D1>%s%s</font></p>") % | 213 | return (boost::format("<p>%s%s</p>") % (is_first ? "" : "<vspace gap=6>") % |
3123 | 220 | UI_FONT_SIZE_SMALL % (is_first ? "" : "<vspace gap=6>") % richtext_escape(txt)) | 214 | g_gr->styles() |
3124 | 215 | .font_style(UI::FontStyle::kWuiInfoPanelHeading) | ||
3125 | 216 | .as_font_tag(richtext_escape(txt))) | ||
3126 | 221 | .str(); | 217 | .str(); |
3127 | 222 | } | 218 | } |
3128 | 223 | NEVER_HERE(); | 219 | NEVER_HERE(); |
3129 | @@ -226,78 +222,17 @@ | |||
3130 | 226 | std::string as_content(const std::string& txt, UI::PanelStyle style) { | 222 | std::string as_content(const std::string& txt, UI::PanelStyle style) { |
3131 | 227 | switch (style) { | 223 | switch (style) { |
3132 | 228 | case UI::PanelStyle::kFsMenu: | 224 | case UI::PanelStyle::kFsMenu: |
3135 | 229 | return (boost::format("<p><font size=%i color=D1D1D1 shadow=1><vspace gap=2>%s</font></p>") % | 225 | return (boost::format("<p><vspace gap=2>%s</p>") % |
3136 | 230 | UI_FONT_SIZE_SMALL % richtext_escape(txt)) | 226 | g_gr->styles() |
3137 | 227 | .font_style(UI::FontStyle::kFsMenuInfoPanelParagraph) | ||
3138 | 228 | .as_font_tag(richtext_escape(txt))) | ||
3139 | 231 | .str(); | 229 | .str(); |
3140 | 232 | case UI::PanelStyle::kWui: | 230 | case UI::PanelStyle::kWui: |
3143 | 233 | return (boost::format("<p><font size=%i><vspace gap=2>%s</font></p>") % | 231 | return (boost::format("<p><vspace gap=2>%s</p>") % |
3144 | 234 | (UI_FONT_SIZE_SMALL - 2) % richtext_escape(txt)) | 232 | g_gr->styles() |
3145 | 233 | .font_style(UI::FontStyle::kWuiInfoPanelParagraph) | ||
3146 | 234 | .as_font_tag(richtext_escape(txt))) | ||
3147 | 235 | .str(); | 235 | .str(); |
3148 | 236 | } | 236 | } |
3149 | 237 | NEVER_HERE(); | 237 | NEVER_HERE(); |
3150 | 238 | } | 238 | } |
3151 | 239 | |||
3152 | 240 | std::shared_ptr<const UI::RenderedText> | ||
3153 | 241 | autofit_ui_text(const std::string& text, int width, RGBColor color, int fontsize) { | ||
3154 | 242 | std::shared_ptr<const UI::RenderedText> result = | ||
3155 | 243 | UI::g_fh->render(as_uifont(richtext_escape(text), fontsize, color)); | ||
3156 | 244 | if (width > 0) { // Autofit | ||
3157 | 245 | for (; result->width() > width && fontsize >= kMinimumFontSize; --fontsize) { | ||
3158 | 246 | result = UI::g_fh->render( | ||
3159 | 247 | as_condensed(richtext_escape(text), UI::Align::kLeft, fontsize, color)); | ||
3160 | 248 | } | ||
3161 | 249 | } | ||
3162 | 250 | return result; | ||
3163 | 251 | } | ||
3164 | 252 | |||
3165 | 253 | namespace UI { | ||
3166 | 254 | |||
3167 | 255 | /** | ||
3168 | 256 | * This mirrors the horizontal alignment for RTL languages. | ||
3169 | 257 | * | ||
3170 | 258 | * Do not store this value as it is based on the global font setting. | ||
3171 | 259 | * | ||
3172 | 260 | * If 'checkme' is not empty, mirror the alignment if the first 20 characters contain an RTL | ||
3173 | 261 | * character. Otherwise, mirror if the current fontset is RTL. | ||
3174 | 262 | */ | ||
3175 | 263 | Align mirror_alignment(Align alignment, const std::string& checkme) { | ||
3176 | 264 | bool do_swap_alignment = checkme.empty() ? UI::g_fh->fontset()->is_rtl() : | ||
3177 | 265 | i18n::has_rtl_character(checkme.c_str(), 20); | ||
3178 | 266 | if (do_swap_alignment) { | ||
3179 | 267 | switch (alignment) { | ||
3180 | 268 | case Align::kLeft: | ||
3181 | 269 | alignment = Align::kRight; | ||
3182 | 270 | break; | ||
3183 | 271 | case Align::kRight: | ||
3184 | 272 | alignment = Align::kLeft; | ||
3185 | 273 | break; | ||
3186 | 274 | case Align::kCenter: | ||
3187 | 275 | break; | ||
3188 | 276 | } | ||
3189 | 277 | } | ||
3190 | 278 | return alignment; | ||
3191 | 279 | } | ||
3192 | 280 | |||
3193 | 281 | /** | ||
3194 | 282 | * Align pt horizontally to match align based on width w. | ||
3195 | 283 | * | ||
3196 | 284 | * When correcting for align, we never move from pixel boundaries to | ||
3197 | 285 | * sub-pixels, because this might lead from pixel-perfect rendering to | ||
3198 | 286 | * subsampled rendering - this can lead to blurry texts. That is why we | ||
3199 | 287 | * never do float divisions in this function. | ||
3200 | 288 | */ | ||
3201 | 289 | void correct_for_align(Align align, uint32_t w, Vector2i* pt) { | ||
3202 | 290 | |||
3203 | 291 | if (align == Align::kCenter) | ||
3204 | 292 | pt->x -= w / 2; | ||
3205 | 293 | else if (align == Align::kRight) | ||
3206 | 294 | pt->x -= w; | ||
3207 | 295 | } | ||
3208 | 296 | |||
3209 | 297 | /** | ||
3210 | 298 | * Adjust the y coordinate in 'point 'pt' to vertically center an element with height 'h'. | ||
3211 | 299 | */ | ||
3212 | 300 | void center_vertically(uint32_t h, Vector2i* pt) { | ||
3213 | 301 | pt->y -= h / 2; | ||
3214 | 302 | } | ||
3215 | 303 | } // namespace UI | ||
3216 | 304 | 239 | ||
3217 | === modified file 'src/graphic/text_layout.h' | |||
3218 | --- src/graphic/text_layout.h 2019-04-18 16:50:35 +0000 | |||
3219 | +++ src/graphic/text_layout.h 2019-05-26 02:00:17 +0000 | |||
3220 | @@ -23,30 +23,26 @@ | |||
3221 | 23 | #include <string> | 23 | #include <string> |
3222 | 24 | 24 | ||
3223 | 25 | #include "graphic/align.h" | 25 | #include "graphic/align.h" |
3224 | 26 | #include "graphic/styles/font_style.h" | ||
3225 | 27 | #include "graphic/styles/panel_styles.h" | ||
3226 | 28 | #include "graphic/text/rendered_text.h" | ||
3227 | 26 | #include "graphic/color.h" | 29 | #include "graphic/color.h" |
3228 | 27 | #include "graphic/font_handler.h" | 30 | #include "graphic/font_handler.h" |
3229 | 28 | #include "graphic/image.h" | 31 | #include "graphic/image.h" |
3230 | 29 | #include "graphic/panel_styles.h" | ||
3231 | 30 | #include "graphic/text/font_set.h" | 32 | #include "graphic/text/font_set.h" |
3251 | 31 | #include "graphic/text_constants.h" | 33 | |
3252 | 32 | 34 | /** | |
3253 | 33 | /** | 35 | * Returns the exact width of the text rendered as editorfont for the given font size. |
3254 | 34 | * This function replaces some HTML entities in strings, e.g. %nbsp;. | 36 | * This function is inefficient; only call when we need the exact width. |
3255 | 35 | * It is used by the renderers after the tags have been parsed. | 37 | */ |
3256 | 36 | */ | 38 | int text_width(const std::string& text, const UI::FontStyleInfo& style, float scale = 1.0f); |
3257 | 37 | void replace_entities(std::string* text); | 39 | |
3258 | 38 | 40 | /** | |
3259 | 39 | /** | 41 | * Returns the exact height of the text rendered for the given font size and face. |
3260 | 40 | * Returns the exact width of the text rendered as editorfont for the given font size. | 42 | * This function is inefficient; only call when we need the exact height. |
3261 | 41 | * This function is inefficient; only call when we need the exact width. | 43 | */ |
3262 | 42 | */ | 44 | int text_height(const UI::FontStyleInfo& style, float scale = 1.0f); |
3263 | 43 | int text_width(const std::string& text, int ptsize = UI_FONT_SIZE_SMALL); | 45 | int text_height(UI::FontStyle style, float scale = 1.0f); |
3245 | 44 | |||
3246 | 45 | /** | ||
3247 | 46 | * Returns the exact height of the text rendered for the given font size and face. | ||
3248 | 47 | * This function is inefficient; only call when we need the exact height. | ||
3249 | 48 | */ | ||
3250 | 49 | int text_height(int ptsize = UI_FONT_SIZE_SMALL, UI::FontSet::Face face = UI::FontSet::Face::kSans); | ||
3264 | 50 | 46 | ||
3265 | 51 | /** | 47 | /** |
3266 | 52 | * Checks it the given string is RichText or not. Does not do validity checking. | 48 | * Checks it the given string is RichText or not. Does not do validity checking. |
3267 | @@ -60,42 +56,35 @@ | |||
3268 | 60 | */ | 56 | */ |
3269 | 61 | std::string richtext_escape(const std::string& given_text); | 57 | std::string richtext_escape(const std::string& given_text); |
3270 | 62 | 58 | ||
3271 | 59 | std::string as_richtext(const std::string&); | ||
3272 | 60 | |||
3273 | 63 | /** | 61 | /** |
3274 | 64 | * Convenience functions to convert simple text into a valid block | 62 | * Convenience functions to convert simple text into a valid block |
3275 | 65 | * of rich text which can be rendered. | 63 | * of rich text which can be rendered. |
3276 | 66 | */ | 64 | */ |
3305 | 67 | std::string as_uifont(const std::string&, | 65 | std::string as_richtext_paragraph(const std::string& text, UI::FontStyle style, UI::Align align = UI::Align::kLeft); |
3306 | 68 | int ptsize = UI_FONT_SIZE_SMALL, | 66 | std::string as_richtext_paragraph(const std::string& text, const UI::FontStyleInfo& style, UI::Align align = UI::Align::kLeft); |
3307 | 69 | const RGBColor& clr = UI_FONT_CLR_FG, | 67 | std::string as_editor_richtext_paragraph(const std::string& text, const UI::FontStyleInfo& style); |
3308 | 70 | UI::FontSet::Face face = UI::FontSet::Face::kSans); | 68 | |
3309 | 71 | 69 | std::string as_listitem(const std::string&, UI::FontStyle style); | |
3310 | 72 | // Same as as_aligned, but with the condensed font preselected. | 70 | |
3283 | 73 | std::string as_condensed(const std::string& text, | ||
3284 | 74 | UI::Align align = UI::Align::kLeft, | ||
3285 | 75 | int ptsize = UI_FONT_SIZE_SMALL, | ||
3286 | 76 | const RGBColor& clr = UI_FONT_CLR_FG); | ||
3287 | 77 | |||
3288 | 78 | std::string as_editorfont(const std::string& text, | ||
3289 | 79 | int ptsize = UI_FONT_SIZE_SMALL, | ||
3290 | 80 | const RGBColor& clr = UI_FONT_CLR_FG); | ||
3291 | 81 | |||
3292 | 82 | std::string as_aligned(const std::string& txt, | ||
3293 | 83 | UI::Align align, | ||
3294 | 84 | int ptsize = UI_FONT_SIZE_SMALL, | ||
3295 | 85 | const RGBColor& clr = UI_FONT_CLR_FG, | ||
3296 | 86 | UI::FontSet::Face face = UI::FontSet::Face::kSans); | ||
3297 | 87 | |||
3298 | 88 | std::string as_listitem(const std::string&, | ||
3299 | 89 | int ptsize = UI_FONT_SIZE_SMALL, | ||
3300 | 90 | const RGBColor& clr = UI_FONT_CLR_FG); | ||
3301 | 91 | |||
3302 | 92 | std::string as_richtext(const std::string&); | ||
3303 | 93 | std::string as_tooltip(const std::string&); | ||
3304 | 94 | std::string as_waresinfo(const std::string&); | ||
3311 | 95 | std::string as_game_tip(const std::string&); | 71 | std::string as_game_tip(const std::string&); |
3312 | 72 | /// Format message to player. 'image' is either an image filename or a map object name. | ||
3313 | 73 | std::string as_mapobject_message(const std::string& image, int width, const std::string& txt, const RGBColor* player_color = nullptr); | ||
3314 | 96 | std::string as_message(const std::string& heading, const std::string& body); | 74 | std::string as_message(const std::string& heading, const std::string& body); |
3315 | 97 | 75 | ||
3316 | 98 | /** | 76 | /** |
3317 | 77 | |||
3318 | 78 | * Render 'text' with the given font style. If 'width' > 0 and the rendered image is too | ||
3319 | 79 | * wide, it will first use the condensed font face and then make the text | ||
3320 | 80 | * smaller until it fits 'width'. The resulting font size will not go below | ||
3321 | 81 | * 'StyleManager::minimum_font_size()'. | ||
3322 | 82 | */ | ||
3323 | 83 | std::shared_ptr<const UI::RenderedText> autofit_text(const std::string& text, | ||
3324 | 84 | const UI::FontStyleInfo& font_info, | ||
3325 | 85 | int width); | ||
3326 | 86 | |||
3327 | 87 | /** | ||
3328 | 99 | * 'is_first' omits the vertical gap before the line. | 88 | * 'is_first' omits the vertical gap before the line. |
3329 | 100 | * 'noescape' is needed for error message formatting and does not call richtext_escape. */ | 89 | * 'noescape' is needed for error message formatting and does not call richtext_escape. */ |
3330 | 101 | std::string as_heading_with_content(const std::string& header, | 90 | std::string as_heading_with_content(const std::string& header, |
3331 | @@ -112,24 +101,4 @@ | |||
3332 | 112 | /// Paragraph in menu info texts | 101 | /// Paragraph in menu info texts |
3333 | 113 | std::string as_content(const std::string& txt, UI::PanelStyle style); | 102 | std::string as_content(const std::string& txt, UI::PanelStyle style); |
3334 | 114 | 103 | ||
3335 | 115 | /** | ||
3336 | 116 | * Render 'text' as ui_font. If 'width' > 0 and the rendered image is too | ||
3337 | 117 | * wide, it will first use the condensed font face and then make the text | ||
3338 | 118 | * smaller until it fits 'width'. The resulting font size will not go below | ||
3339 | 119 | * 'kMinimumFontSize'. | ||
3340 | 120 | */ | ||
3341 | 121 | std::shared_ptr<const UI::RenderedText> autofit_ui_text(const std::string& text, | ||
3342 | 122 | int width = 0, | ||
3343 | 123 | RGBColor color = UI_FONT_CLR_FG, | ||
3344 | 124 | int fontsize = UI_FONT_SIZE_SMALL); | ||
3345 | 125 | |||
3346 | 126 | namespace UI { | ||
3347 | 127 | |||
3348 | 128 | Align mirror_alignment(Align alignment, const std::string& checkme = ""); | ||
3349 | 129 | |||
3350 | 130 | void center_vertically(uint32_t h, Vector2i* pt); | ||
3351 | 131 | void correct_for_align(Align, uint32_t w, Vector2i* pt); | ||
3352 | 132 | |||
3353 | 133 | } // namespace UI | ||
3354 | 134 | |||
3355 | 135 | #endif // end of include guard: WL_GRAPHIC_TEXT_LAYOUT_H | 104 | #endif // end of include guard: WL_GRAPHIC_TEXT_LAYOUT_H |
3356 | 136 | 105 | ||
3357 | === modified file 'src/graphic/wordwrap.cc' | |||
3358 | --- src/graphic/wordwrap.cc 2019-02-23 11:00:49 +0000 | |||
3359 | +++ src/graphic/wordwrap.cc 2019-05-26 02:00:17 +0000 | |||
3360 | @@ -36,6 +36,30 @@ | |||
3361 | 36 | #include "graphic/text/font_io.h" | 36 | #include "graphic/text/font_io.h" |
3362 | 37 | #include "graphic/text_layout.h" | 37 | #include "graphic/text_layout.h" |
3363 | 38 | 38 | ||
3364 | 39 | namespace { | ||
3365 | 40 | std::string as_editorfont(const std::string& text, int ptsize, const RGBColor& clr) { | ||
3366 | 41 | // UI Text is always bold due to historic reasons | ||
3367 | 42 | static boost::format f( | ||
3368 | 43 | "<rt keep_spaces=1><p><font face=sans size=%i bold=1 shadow=1 color=%s>%s</font></p></rt>"); | ||
3369 | 44 | f % ptsize; | ||
3370 | 45 | f % clr.hex_value(); | ||
3371 | 46 | f % richtext_escape(text); | ||
3372 | 47 | return f.str(); | ||
3373 | 48 | } | ||
3374 | 49 | |||
3375 | 50 | int text_width(const std::string& text, int ptsize) { | ||
3376 | 51 | RGBColor color(0, 0, 0); | ||
3377 | 52 | return UI::g_fh->render(as_editorfont(text, ptsize - UI::g_fh->fontset()->size_offset(), color)) | ||
3378 | 53 | ->width(); | ||
3379 | 54 | } | ||
3380 | 55 | |||
3381 | 56 | int text_height(int ptsize) { | ||
3382 | 57 | RGBColor font_color(0, 0, 0); | ||
3383 | 58 | const UI::FontStyleInfo font_info("sans", font_color, ptsize, false, false, false, false); | ||
3384 | 59 | return UI::g_fh->render(as_richtext_paragraph(UI::g_fh->fontset()->representative_character(), font_info))->height(); | ||
3385 | 60 | } | ||
3386 | 61 | } // namespace | ||
3387 | 62 | |||
3388 | 39 | namespace UI { | 63 | namespace UI { |
3389 | 40 | 64 | ||
3390 | 41 | WordWrap::WordWrap(int fontsize, const RGBColor& color, uint32_t gwrapwidth) | 65 | WordWrap::WordWrap(int fontsize, const RGBColor& color, uint32_t gwrapwidth) |
3391 | @@ -299,7 +323,7 @@ | |||
3392 | 299 | 323 | ||
3393 | 300 | ++where.y; | 324 | ++where.y; |
3394 | 301 | 325 | ||
3396 | 302 | Align alignment = mirror_alignment(align); | 326 | Align alignment = mirror_alignment(align, g_fh->fontset()->is_rtl()); |
3397 | 303 | 327 | ||
3398 | 304 | const int fontheight = text_height(fontsize_); | 328 | const int fontheight = text_height(fontsize_); |
3399 | 305 | for (uint32_t line = 0; line < lines_.size(); ++line, where.y += fontheight) { | 329 | for (uint32_t line = 0; line < lines_.size(); ++line, where.y += fontheight) { |
3400 | 306 | 330 | ||
3401 | === modified file 'src/graphic/wordwrap.h' | |||
3402 | --- src/graphic/wordwrap.h 2019-02-23 11:00:49 +0000 | |||
3403 | +++ src/graphic/wordwrap.h 2019-05-26 02:00:17 +0000 | |||
3404 | @@ -27,8 +27,8 @@ | |||
3405 | 27 | #include "base/vector.h" | 27 | #include "base/vector.h" |
3406 | 28 | #include "graphic/align.h" | 28 | #include "graphic/align.h" |
3407 | 29 | #include "graphic/color.h" | 29 | #include "graphic/color.h" |
3408 | 30 | #include "graphic/graphic.h" | ||
3409 | 30 | #include "graphic/text/sdl_ttf_font.h" | 31 | #include "graphic/text/sdl_ttf_font.h" |
3410 | 31 | #include "graphic/text_constants.h" | ||
3411 | 32 | 32 | ||
3412 | 33 | class RenderTarget; | 33 | class RenderTarget; |
3413 | 34 | 34 | ||
3414 | @@ -38,9 +38,9 @@ | |||
3415 | 38 | * Helper struct that provides word wrapping and related functionality. | 38 | * Helper struct that provides word wrapping and related functionality. |
3416 | 39 | */ | 39 | */ |
3417 | 40 | struct WordWrap { | 40 | struct WordWrap { |
3421 | 41 | WordWrap(int fontsize = UI_FONT_SIZE_SMALL, | 41 | static constexpr int kLineMargin = 1; |
3422 | 42 | const RGBColor& color = UI_FONT_CLR_FG, | 42 | |
3423 | 43 | uint32_t wrapwidth = std::numeric_limits<uint32_t>::max()); | 43 | explicit WordWrap(int fontsize, const RGBColor& color, uint32_t wrapwidth); |
3424 | 44 | 44 | ||
3425 | 45 | void set_wrapwidth(uint32_t wrapwidth); | 45 | void set_wrapwidth(uint32_t wrapwidth); |
3426 | 46 | 46 | ||
3427 | 47 | 47 | ||
3428 | === modified file 'src/io/filesystem/filesystem.cc' | |||
3429 | --- src/io/filesystem/filesystem.cc 2019-02-23 11:00:49 +0000 | |||
3430 | +++ src/io/filesystem/filesystem.cc 2019-05-26 02:00:17 +0000 | |||
3431 | @@ -205,7 +205,7 @@ | |||
3432 | 205 | (boost::format(pgettext("illegal_filename_characters", "%s at the start of the filename")) % | 205 | (boost::format(pgettext("illegal_filename_characters", "%s at the start of the filename")) % |
3433 | 206 | richtext_escape(i18n::localize_list(starting_characters, i18n::ConcatenateWith::OR))) | 206 | richtext_escape(i18n::localize_list(starting_characters, i18n::ConcatenateWith::OR))) |
3434 | 207 | .str(), | 207 | .str(), |
3436 | 208 | UI_FONT_SIZE_MESSAGE)); | 208 | UI::FontStyle::kWuiMessageParagraph)); |
3437 | 209 | 209 | ||
3438 | 210 | const std::string illegal(as_listitem( | 210 | const std::string illegal(as_listitem( |
3439 | 211 | /** TRANSLATORS: Tooltip entry for characters in illegal filenames. | 211 | /** TRANSLATORS: Tooltip entry for characters in illegal filenames. |
3440 | @@ -213,7 +213,7 @@ | |||
3441 | 213 | (boost::format(pgettext("illegal_filename_characters", "%s anywhere in the filename")) % | 213 | (boost::format(pgettext("illegal_filename_characters", "%s anywhere in the filename")) % |
3442 | 214 | richtext_escape(i18n::localize_list(illegal_filename_characters, i18n::ConcatenateWith::OR))) | 214 | richtext_escape(i18n::localize_list(illegal_filename_characters, i18n::ConcatenateWith::OR))) |
3443 | 215 | .str(), | 215 | .str(), |
3445 | 216 | UI_FONT_SIZE_MESSAGE)); | 216 | UI::FontStyle::kWuiMessageParagraph)); |
3446 | 217 | 217 | ||
3447 | 218 | return (boost::format("%s%s%s") % | 218 | return (boost::format("%s%s%s") % |
3448 | 219 | /** TRANSLATORS: Tooltip header for characters in illegal filenames. | 219 | /** TRANSLATORS: Tooltip header for characters in illegal filenames. |
3449 | 220 | 220 | ||
3450 | === modified file 'src/logic/map_objects/CMakeLists.txt' | |||
3451 | --- src/logic/map_objects/CMakeLists.txt 2019-05-05 18:53:14 +0000 | |||
3452 | +++ src/logic/map_objects/CMakeLists.txt 2019-05-26 02:00:17 +0000 | |||
3453 | @@ -125,7 +125,6 @@ | |||
3454 | 125 | graphic_fonthandler | 125 | graphic_fonthandler |
3455 | 126 | graphic_image_io | 126 | graphic_image_io |
3456 | 127 | graphic_surface | 127 | graphic_surface |
3457 | 128 | graphic_text_constants | ||
3458 | 129 | graphic_text_layout | 128 | graphic_text_layout |
3459 | 130 | helper | 129 | helper |
3460 | 131 | io_fileread | 130 | io_fileread |
3461 | 132 | 131 | ||
3462 | === modified file 'src/logic/map_objects/immovable.cc' | |||
3463 | --- src/logic/map_objects/immovable.cc 2019-05-19 12:25:24 +0000 | |||
3464 | +++ src/logic/map_objects/immovable.cc 2019-05-26 02:00:17 +0000 | |||
3465 | @@ -32,7 +32,6 @@ | |||
3466 | 32 | #include "config.h" | 32 | #include "config.h" |
3467 | 33 | #include "graphic/graphic.h" | 33 | #include "graphic/graphic.h" |
3468 | 34 | #include "graphic/rendertarget.h" | 34 | #include "graphic/rendertarget.h" |
3469 | 35 | #include "graphic/text_constants.h" | ||
3470 | 36 | #include "helper.h" | 35 | #include "helper.h" |
3471 | 37 | #include "io/fileread.h" | 36 | #include "io/fileread.h" |
3472 | 38 | #include "io/filewrite.h" | 37 | #include "io/filewrite.h" |
3473 | @@ -526,9 +525,7 @@ | |||
3474 | 526 | 525 | ||
3475 | 527 | // Additionally, if statistics are enabled, draw a progression string | 526 | // Additionally, if statistics are enabled, draw a progression string |
3476 | 528 | do_draw_info(draw_text, descr().descname(), | 527 | do_draw_info(draw_text, descr().descname(), |
3480 | 529 | (boost::format("<font color=%s>%s</font>") % UI_FONT_CLR_DARK.hex_value() % | 528 | g_gr->styles().color_tag((boost::format(_("%i%% built")) % (100 * done / total)).str(), g_gr->styles().building_statistics_style().construction_color()), |
3478 | 530 | (boost::format(_("%i%% built")) % (100 * done / total)).str()) | ||
3479 | 531 | .str(), | ||
3481 | 532 | point_on_dst, scale, dst); | 529 | point_on_dst, scale, dst); |
3482 | 533 | } | 530 | } |
3483 | 534 | 531 | ||
3484 | 535 | 532 | ||
3485 | === modified file 'src/logic/map_objects/map_object.cc' | |||
3486 | --- src/logic/map_objects/map_object.cc 2019-05-18 20:43:25 +0000 | |||
3487 | +++ src/logic/map_objects/map_object.cc 2019-05-26 02:00:17 +0000 | |||
3488 | @@ -32,6 +32,7 @@ | |||
3489 | 32 | #include "graphic/font_handler.h" | 32 | #include "graphic/font_handler.h" |
3490 | 33 | #include "graphic/graphic.h" | 33 | #include "graphic/graphic.h" |
3491 | 34 | #include "graphic/rendertarget.h" | 34 | #include "graphic/rendertarget.h" |
3492 | 35 | #include "graphic/style_manager.h" | ||
3493 | 35 | #include "graphic/text_layout.h" | 36 | #include "graphic/text_layout.h" |
3494 | 36 | #include "io/fileread.h" | 37 | #include "io/fileread.h" |
3495 | 37 | #include "io/filewrite.h" | 38 | #include "io/filewrite.h" |
3496 | @@ -485,20 +486,25 @@ | |||
3497 | 485 | if (scale < 1.f) { | 486 | if (scale < 1.f) { |
3498 | 486 | return; | 487 | return; |
3499 | 487 | } | 488 | } |
3501 | 488 | const int font_size = scale * UI_FONT_SIZE_SMALL; | 489 | |
3502 | 490 | UI::FontStyleInfo census_font(g_gr->styles().building_statistics_style().census_font()); | ||
3503 | 491 | census_font.set_size(scale * census_font.size()); | ||
3504 | 489 | 492 | ||
3505 | 490 | // We always render this so we can have a stable position for the statistics string. | 493 | // We always render this so we can have a stable position for the statistics string. |
3506 | 491 | std::shared_ptr<const UI::RenderedText> rendered_census = | 494 | std::shared_ptr<const UI::RenderedText> rendered_census = |
3508 | 492 | UI::g_fh->render(as_condensed(census, UI::Align::kCenter, font_size), 120 * scale); | 495 | UI::g_fh->render(as_richtext_paragraph(census, census_font, UI::Align::kCenter), 120 * scale); |
3509 | 493 | Vector2i position = field_on_dst.cast<int>() - Vector2i(0, 48) * scale; | 496 | Vector2i position = field_on_dst.cast<int>() - Vector2i(0, 48) * scale; |
3510 | 494 | if ((draw_text & TextToDraw::kCensus) != TextToDraw::kNone) { | 497 | if ((draw_text & TextToDraw::kCensus) != TextToDraw::kNone) { |
3511 | 495 | rendered_census->draw(*dst, position, UI::Align::kCenter); | 498 | rendered_census->draw(*dst, position, UI::Align::kCenter); |
3512 | 496 | } | 499 | } |
3513 | 497 | 500 | ||
3514 | 498 | if ((draw_text & TextToDraw::kStatistics) != TextToDraw::kNone && !statictics.empty()) { | 501 | if ((draw_text & TextToDraw::kStatistics) != TextToDraw::kNone && !statictics.empty()) { |
3515 | 502 | UI::FontStyleInfo statistics_font(g_gr->styles().building_statistics_style().statistics_font()); | ||
3516 | 503 | statistics_font.set_size(scale * statistics_font.size()); | ||
3517 | 504 | |||
3518 | 499 | std::shared_ptr<const UI::RenderedText> rendered_statistics = | 505 | std::shared_ptr<const UI::RenderedText> rendered_statistics = |
3521 | 500 | UI::g_fh->render(as_condensed(statictics, UI::Align::kCenter, font_size)); | 506 | UI::g_fh->render(as_richtext_paragraph(statictics, statistics_font, UI::Align::kCenter)); |
3522 | 501 | position.y += rendered_census->height() + text_height(font_size) / 4; | 507 | position.y += rendered_census->height() + text_height(statistics_font) / 4; |
3523 | 502 | rendered_statistics->draw(*dst, position, UI::Align::kCenter); | 508 | rendered_statistics->draw(*dst, position, UI::Align::kCenter); |
3524 | 503 | } | 509 | } |
3525 | 504 | } | 510 | } |
3526 | 505 | 511 | ||
3527 | === modified file 'src/logic/map_objects/tribes/building.cc' | |||
3528 | --- src/logic/map_objects/tribes/building.cc 2019-05-11 13:48:12 +0000 | |||
3529 | +++ src/logic/map_objects/tribes/building.cc 2019-05-26 02:00:17 +0000 | |||
3530 | @@ -33,7 +33,7 @@ | |||
3531 | 33 | #include "economy/input_queue.h" | 33 | #include "economy/input_queue.h" |
3532 | 34 | #include "economy/request.h" | 34 | #include "economy/request.h" |
3533 | 35 | #include "graphic/rendertarget.h" | 35 | #include "graphic/rendertarget.h" |
3535 | 36 | #include "graphic/text_constants.h" | 36 | #include "graphic/text_layout.h" |
3536 | 37 | #include "io/filesystem/filesystem.h" | 37 | #include "io/filesystem/filesystem.h" |
3537 | 38 | #include "io/filesystem/layered_filesystem.h" | 38 | #include "io/filesystem/layered_filesystem.h" |
3538 | 39 | #include "logic/game.h" | 39 | #include "logic/game.h" |
3539 | @@ -774,10 +774,10 @@ | |||
3540 | 774 | uint32_t throttle_time, | 774 | uint32_t throttle_time, |
3541 | 775 | uint32_t throttle_radius) { | 775 | uint32_t throttle_radius) { |
3542 | 776 | const std::string rt_description = | 776 | const std::string rt_description = |
3547 | 777 | (boost::format("<div padding_r=10><p><img object=%s color=%s></p></div>" | 777 | as_mapobject_message(descr().name(), |
3548 | 778 | "<div width=*><p><font size=%d>%s</font></p></div>") % | 778 | descr().representative_image()->width(), |
3549 | 779 | descr().name() % owner().get_playercolor().hex_value() % UI_FONT_SIZE_MESSAGE % description) | 779 | description, |
3550 | 780 | .str(); | 780 | &owner().get_playercolor()); |
3551 | 781 | 781 | ||
3552 | 782 | std::unique_ptr<Message> msg(new Message(msgtype, game.get_gametime(), title, icon_filename, | 782 | std::unique_ptr<Message> msg(new Message(msgtype, game.get_gametime(), title, icon_filename, |
3553 | 783 | heading, rt_description, get_position(), | 783 | heading, rt_description, get_position(), |
3554 | 784 | 784 | ||
3555 | === modified file 'src/logic/map_objects/tribes/constructionsite.cc' | |||
3556 | --- src/logic/map_objects/tribes/constructionsite.cc 2019-05-18 20:43:25 +0000 | |||
3557 | +++ src/logic/map_objects/tribes/constructionsite.cc 2019-05-26 02:00:17 +0000 | |||
3558 | @@ -30,7 +30,6 @@ | |||
3559 | 30 | #include "graphic/animation.h" | 30 | #include "graphic/animation.h" |
3560 | 31 | #include "graphic/graphic.h" | 31 | #include "graphic/graphic.h" |
3561 | 32 | #include "graphic/rendertarget.h" | 32 | #include "graphic/rendertarget.h" |
3562 | 33 | #include "graphic/text_constants.h" | ||
3563 | 34 | #include "logic/editor_game_base.h" | 33 | #include "logic/editor_game_base.h" |
3564 | 35 | #include "logic/game.h" | 34 | #include "logic/game.h" |
3565 | 36 | #include "logic/map_objects/tribes/tribe_descr.h" | 35 | #include "logic/map_objects/tribes/tribe_descr.h" |
3566 | @@ -110,9 +109,7 @@ | |||
3567 | 110 | 109 | ||
3568 | 111 | void ConstructionSite::update_statistics_string(std::string* s) { | 110 | void ConstructionSite::update_statistics_string(std::string* s) { |
3569 | 112 | unsigned int percent = (get_built_per64k() * 100) >> 16; | 111 | unsigned int percent = (get_built_per64k() * 100) >> 16; |
3573 | 113 | *s = (boost::format("<font color=%s>%s</font>") % UI_FONT_CLR_DARK.hex_value() % | 112 | *s = g_gr->styles().color_tag((boost::format(_("%i%% built")) % percent).str(), g_gr->styles().building_statistics_style().construction_color()); |
3571 | 114 | (boost::format(_("%i%% built")) % percent)) | ||
3572 | 115 | .str(); | ||
3574 | 116 | } | 113 | } |
3575 | 117 | 114 | ||
3576 | 118 | /* | 115 | /* |
3577 | 119 | 116 | ||
3578 | === modified file 'src/logic/map_objects/tribes/dismantlesite.cc' | |||
3579 | --- src/logic/map_objects/tribes/dismantlesite.cc 2019-05-18 20:43:25 +0000 | |||
3580 | +++ src/logic/map_objects/tribes/dismantlesite.cc 2019-05-26 02:00:17 +0000 | |||
3581 | @@ -29,7 +29,6 @@ | |||
3582 | 29 | #include "economy/wares_queue.h" | 29 | #include "economy/wares_queue.h" |
3583 | 30 | #include "graphic/animation.h" | 30 | #include "graphic/animation.h" |
3584 | 31 | #include "graphic/rendertarget.h" | 31 | #include "graphic/rendertarget.h" |
3585 | 32 | #include "graphic/text_constants.h" | ||
3586 | 33 | #include "logic/editor_game_base.h" | 32 | #include "logic/editor_game_base.h" |
3587 | 34 | #include "logic/game.h" | 33 | #include "logic/game.h" |
3588 | 35 | #include "logic/map_objects/tribes/tribe_descr.h" | 34 | #include "logic/map_objects/tribes/tribe_descr.h" |
3589 | @@ -103,9 +102,7 @@ | |||
3590 | 103 | */ | 102 | */ |
3591 | 104 | void DismantleSite::update_statistics_string(std::string* s) { | 103 | void DismantleSite::update_statistics_string(std::string* s) { |
3592 | 105 | unsigned int percent = (get_built_per64k() * 100) >> 16; | 104 | unsigned int percent = (get_built_per64k() * 100) >> 16; |
3596 | 106 | *s = (boost::format("<font color=%s>%s</font>") % UI_FONT_CLR_DARK.hex_value() % | 105 | *s = g_gr->styles().color_tag((boost::format(_("%u%% dismantled")) % percent).str(), g_gr->styles().building_statistics_style().construction_color()); |
3594 | 107 | (boost::format(_("%u%% dismantled")) % percent)) | ||
3595 | 108 | .str(); | ||
3597 | 109 | } | 106 | } |
3598 | 110 | 107 | ||
3599 | 111 | /* | 108 | /* |
3600 | 112 | 109 | ||
3601 | === modified file 'src/logic/map_objects/tribes/militarysite.cc' | |||
3602 | --- src/logic/map_objects/tribes/militarysite.cc 2019-05-18 20:43:25 +0000 | |||
3603 | +++ src/logic/map_objects/tribes/militarysite.cc 2019-05-26 02:00:17 +0000 | |||
3604 | @@ -30,7 +30,6 @@ | |||
3605 | 30 | #include "base/macros.h" | 30 | #include "base/macros.h" |
3606 | 31 | #include "economy/flag.h" | 31 | #include "economy/flag.h" |
3607 | 32 | #include "economy/request.h" | 32 | #include "economy/request.h" |
3608 | 33 | #include "graphic/text_constants.h" | ||
3609 | 34 | #include "logic/editor_game_base.h" | 33 | #include "logic/editor_game_base.h" |
3610 | 35 | #include "logic/game.h" | 34 | #include "logic/game.h" |
3611 | 36 | #include "logic/map_objects/findbob.h" | 35 | #include "logic/map_objects/findbob.h" |
3612 | @@ -396,10 +395,9 @@ | |||
3613 | 396 | .str(); | 395 | .str(); |
3614 | 397 | } | 396 | } |
3615 | 398 | } | 397 | } |
3620 | 399 | *s = (boost::format("<font color=%s>%s</font>") % UI_FONT_CLR_OK.hex_value() % | 398 | *s = g_gr->styles().color_tag( |
3621 | 400 | // Line break to make Codecheck happy. | 399 | // Line break to make Codecheck happy. |
3622 | 401 | *s) | 400 | *s, g_gr->styles().building_statistics_style().medium_color()); |
3619 | 402 | .str(); | ||
3623 | 403 | } | 401 | } |
3624 | 404 | 402 | ||
3625 | 405 | bool MilitarySite::init(EditorGameBase& egbase) { | 403 | bool MilitarySite::init(EditorGameBase& egbase) { |
3626 | 406 | 404 | ||
3627 | === modified file 'src/logic/map_objects/tribes/productionsite.cc' | |||
3628 | --- src/logic/map_objects/tribes/productionsite.cc 2019-05-22 15:46:08 +0000 | |||
3629 | +++ src/logic/map_objects/tribes/productionsite.cc 2019-05-26 02:00:17 +0000 | |||
3630 | @@ -32,7 +32,6 @@ | |||
3631 | 32 | #include "economy/ware_instance.h" | 32 | #include "economy/ware_instance.h" |
3632 | 33 | #include "economy/wares_queue.h" | 33 | #include "economy/wares_queue.h" |
3633 | 34 | #include "economy/workers_queue.h" | 34 | #include "economy/workers_queue.h" |
3634 | 35 | #include "graphic/text_constants.h" | ||
3635 | 36 | #include "logic/editor_game_base.h" | 35 | #include "logic/editor_game_base.h" |
3636 | 37 | #include "logic/game.h" | 36 | #include "logic/game.h" |
3637 | 38 | #include "logic/game_data_error.h" | 37 | #include "logic/game_data_error.h" |
3638 | @@ -296,28 +295,23 @@ | |||
3639 | 296 | nr_workers += working_positions_[--i].worker ? 1 : 0; | 295 | nr_workers += working_positions_[--i].worker ? 1 : 0; |
3640 | 297 | 296 | ||
3641 | 298 | if (nr_workers == 0) { | 297 | if (nr_workers == 0) { |
3645 | 299 | *s = (boost::format("<font color=%s>%s</font>") % UI_FONT_CLR_BAD.hex_value() % | 298 | *s = g_gr->styles().color_tag(_("(not occupied)"), g_gr->styles().building_statistics_style().low_color()); |
3643 | 300 | _("(not occupied)")) | ||
3644 | 301 | .str(); | ||
3646 | 302 | return; | 299 | return; |
3647 | 303 | } | 300 | } |
3648 | 304 | 301 | ||
3649 | 305 | if (uint32_t const nr_requests = nr_working_positions - nr_workers) { | 302 | if (uint32_t const nr_requests = nr_working_positions - nr_workers) { |
3651 | 306 | *s = (boost::format("<font color=%s>%s</font>") % UI_FONT_CLR_BAD.hex_value() % | 303 | *s = g_gr->styles().color_tag( |
3652 | 307 | (nr_requests == 1 ? | 304 | (nr_requests == 1 ? |
3653 | 308 | /** TRANSLATORS: Productivity label on a building if there is 1 worker missing */ | 305 | /** TRANSLATORS: Productivity label on a building if there is 1 worker missing */ |
3654 | 309 | _("Worker missing") : | 306 | _("Worker missing") : |
3655 | 310 | /** TRANSLATORS: Productivity label on a building if there is more than 1 worker | 307 | /** TRANSLATORS: Productivity label on a building if there is more than 1 worker |
3656 | 311 | missing. If you need plural forms here, please let us know. */ | 308 | missing. If you need plural forms here, please let us know. */ |
3659 | 312 | _("Workers missing"))) | 309 | _("Workers missing")), g_gr->styles().building_statistics_style().low_color()); |
3658 | 313 | .str(); | ||
3660 | 314 | return; | 310 | return; |
3661 | 315 | } | 311 | } |
3662 | 316 | 312 | ||
3663 | 317 | if (is_stopped_) { | 313 | if (is_stopped_) { |
3667 | 318 | *s = (boost::format("<font color=%s>%s</font>") % UI_FONT_CLR_BRIGHT.hex_value() % | 314 | *s = g_gr->styles().color_tag(_("(stopped)"), g_gr->styles().building_statistics_style().neutral_color()); |
3665 | 319 | _("(stopped)")) | ||
3666 | 320 | .str(); | ||
3668 | 321 | return; | 315 | return; |
3669 | 322 | } | 316 | } |
3670 | 323 | *s = statistics_string_on_changed_statistics_; | 317 | *s = statistics_string_on_changed_statistics_; |
3671 | @@ -407,34 +401,32 @@ | |||
3672 | 407 | 401 | ||
3673 | 408 | const unsigned int lastPercOk = (lastOk * 100) / (STATISTICS_VECTOR_LENGTH / 2); | 402 | const unsigned int lastPercOk = (lastOk * 100) / (STATISTICS_VECTOR_LENGTH / 2); |
3674 | 409 | 403 | ||
3675 | 410 | std::string color; | ||
3676 | 411 | if (percOk < 33) | ||
3677 | 412 | color = UI_FONT_CLR_BAD.hex_value(); | ||
3678 | 413 | else if (percOk < 66) | ||
3679 | 414 | color = UI_FONT_CLR_OK.hex_value(); | ||
3680 | 415 | else | ||
3681 | 416 | color = UI_FONT_CLR_GOOD.hex_value(); | ||
3682 | 417 | const std::string perc_str = | 404 | const std::string perc_str = |
3701 | 418 | (boost::format("<font color=%s>%s</font>") % color % (boost::format(_("%i%%")) % percOk)) | 405 | g_gr->styles().color_tag((boost::format(_("%i%%")) % percOk).str(), |
3702 | 419 | .str(); | 406 | (percOk < 33) ? g_gr->styles().building_statistics_style().low_color() : |
3703 | 420 | 407 | (percOk < 66) ? | |
3704 | 421 | std::string trend; | 408 | g_gr->styles().building_statistics_style().medium_color() : |
3705 | 422 | if (lastPercOk > percOk) { | 409 | g_gr->styles().building_statistics_style().high_color()); |
3688 | 423 | trend_ = Trend::kRising; | ||
3689 | 424 | color = UI_FONT_CLR_GOOD.hex_value(); | ||
3690 | 425 | trend = "+"; | ||
3691 | 426 | } else if (lastPercOk < percOk) { | ||
3692 | 427 | trend_ = Trend::kFalling; | ||
3693 | 428 | color = UI_FONT_CLR_BAD.hex_value(); | ||
3694 | 429 | trend = "-"; | ||
3695 | 430 | } else { | ||
3696 | 431 | trend_ = Trend::kUnchanged; | ||
3697 | 432 | color = UI_FONT_CLR_BRIGHT.hex_value(); | ||
3698 | 433 | trend = "="; | ||
3699 | 434 | } | ||
3700 | 435 | const std::string trend_str = (boost::format("<font color=%s>%s</font>") % color % trend).str(); | ||
3706 | 436 | 410 | ||
3707 | 437 | if (0 < percOk && percOk < 100) { | 411 | if (0 < percOk && percOk < 100) { |
3708 | 412 | RGBColor color = g_gr->styles().building_statistics_style().high_color(); | ||
3709 | 413 | std::string trend; | ||
3710 | 414 | if (lastPercOk > percOk) { | ||
3711 | 415 | trend_ = Trend::kRising; | ||
3712 | 416 | color = g_gr->styles().building_statistics_style().high_color(); | ||
3713 | 417 | trend = "+"; | ||
3714 | 418 | } else if (lastPercOk < percOk) { | ||
3715 | 419 | trend_ = Trend::kFalling; | ||
3716 | 420 | color = g_gr->styles().building_statistics_style().low_color(); | ||
3717 | 421 | trend = "-"; | ||
3718 | 422 | } else { | ||
3719 | 423 | trend_ = Trend::kUnchanged; | ||
3720 | 424 | color = g_gr->styles().building_statistics_style().neutral_color(); | ||
3721 | 425 | trend = "="; | ||
3722 | 426 | } | ||
3723 | 427 | |||
3724 | 428 | const std::string trend_str = g_gr->styles().color_tag((boost::format(_("%i%%")) % trend).str(), color); | ||
3725 | 429 | |||
3726 | 438 | // TODO(GunChleoc): We might need to reverse the order here for RTL languages | 430 | // TODO(GunChleoc): We might need to reverse the order here for RTL languages |
3727 | 439 | statistics_string_on_changed_statistics_ = | 431 | statistics_string_on_changed_statistics_ = |
3728 | 440 | (boost::format("%s\u2009%s") % perc_str % trend_str).str(); | 432 | (boost::format("%s\u2009%s") % perc_str % trend_str).str(); |
3729 | 441 | 433 | ||
3730 | === modified file 'src/logic/map_objects/tribes/ship.cc' | |||
3731 | --- src/logic/map_objects/tribes/ship.cc 2019-05-11 13:48:12 +0000 | |||
3732 | +++ src/logic/map_objects/tribes/ship.cc 2019-05-26 02:00:17 +0000 | |||
3733 | @@ -31,7 +31,7 @@ | |||
3734 | 31 | #include "economy/portdock.h" | 31 | #include "economy/portdock.h" |
3735 | 32 | #include "economy/wares_queue.h" | 32 | #include "economy/wares_queue.h" |
3736 | 33 | #include "graphic/rendertarget.h" | 33 | #include "graphic/rendertarget.h" |
3738 | 34 | #include "graphic/text_constants.h" | 34 | #include "graphic/text_layout.h" |
3739 | 35 | #include "io/fileread.h" | 35 | #include "io/fileread.h" |
3740 | 36 | #include "io/filewrite.h" | 36 | #include "io/filewrite.h" |
3741 | 37 | #include "logic/game.h" | 37 | #include "logic/game.h" |
3742 | @@ -1061,9 +1061,7 @@ | |||
3743 | 1061 | case (ShipStates::kSinkAnimation): | 1061 | case (ShipStates::kSinkAnimation): |
3744 | 1062 | break; | 1062 | break; |
3745 | 1063 | } | 1063 | } |
3749 | 1064 | statistics_string = (boost::format("<font color=%s>%s</font>") % UI_FONT_CLR_OK.hex_value() % | 1064 | statistics_string = g_gr->styles().color_tag(statistics_string, g_gr->styles().building_statistics_style().medium_color()); |
3747 | 1065 | statistics_string) | ||
3748 | 1066 | .str(); | ||
3750 | 1067 | } | 1065 | } |
3751 | 1068 | 1066 | ||
3752 | 1069 | do_draw_info(draw_text, shipname_, statistics_string, calc_drawpos(egbase, point_on_dst, scale), | 1067 | do_draw_info(draw_text, shipname_, statistics_string, calc_drawpos(egbase, point_on_dst, scale), |
3753 | @@ -1128,10 +1126,7 @@ | |||
3754 | 1128 | const std::string& description, | 1126 | const std::string& description, |
3755 | 1129 | const std::string& picture) { | 1127 | const std::string& picture) { |
3756 | 1130 | const std::string rt_description = | 1128 | const std::string rt_description = |
3761 | 1131 | (boost::format("<div padding_r=10><p><img src=%s></p></div>" | 1129 | as_mapobject_message(picture, g_gr->images().get(picture)->width(), description); |
3758 | 1132 | "<div width=*><p><font size=%d>%s</font></p></div>") % | ||
3759 | 1133 | picture % UI_FONT_SIZE_MESSAGE % description) | ||
3760 | 1134 | .str(); | ||
3762 | 1135 | 1130 | ||
3763 | 1136 | get_owner()->add_message(game, std::unique_ptr<Message>(new Message( | 1131 | get_owner()->add_message(game, std::unique_ptr<Message>(new Message( |
3764 | 1137 | Message::Type::kSeafaring, game.get_gametime(), title, picture, | 1132 | Message::Type::kSeafaring, game.get_gametime(), title, picture, |
3765 | 1138 | 1133 | ||
3766 | === modified file 'src/logic/map_objects/tribes/worker.cc' | |||
3767 | --- src/logic/map_objects/tribes/worker.cc 2019-05-25 10:47:18 +0000 | |||
3768 | +++ src/logic/map_objects/tribes/worker.cc 2019-05-26 02:00:17 +0000 | |||
3769 | @@ -33,8 +33,9 @@ | |||
3770 | 33 | #include "economy/portdock.h" | 33 | #include "economy/portdock.h" |
3771 | 34 | #include "economy/road.h" | 34 | #include "economy/road.h" |
3772 | 35 | #include "economy/transfer.h" | 35 | #include "economy/transfer.h" |
3773 | 36 | #include "graphic/graphic.h" | ||
3774 | 36 | #include "graphic/rendertarget.h" | 37 | #include "graphic/rendertarget.h" |
3776 | 37 | #include "graphic/text_constants.h" | 38 | #include "graphic/text_layout.h" |
3777 | 38 | #include "helper.h" | 39 | #include "helper.h" |
3778 | 39 | #include "io/fileread.h" | 40 | #include "io/fileread.h" |
3779 | 40 | #include "io/filewrite.h" | 41 | #include "io/filewrite.h" |
3780 | @@ -972,12 +973,12 @@ | |||
3781 | 972 | MapObjectDescr::OwnerType::kTribe, get_owner()); | 973 | MapObjectDescr::OwnerType::kTribe, get_owner()); |
3782 | 973 | 974 | ||
3783 | 974 | // Geologist also sends a message notifying the player | 975 | // Geologist also sends a message notifying the player |
3784 | 976 | // TODO(GunChleoc): We keep formatting this even when timeout has not elapsed | ||
3785 | 975 | if (rdescr && rdescr->detectable() && position.field->get_resources_amount()) { | 977 | if (rdescr && rdescr->detectable() && position.field->get_resources_amount()) { |
3791 | 976 | const std::string message = | 978 | const std::string rt_description = |
3792 | 977 | (boost::format("<div padding_r=10><p><img object=%s></p></div>" | 979 | as_mapobject_message(ri.descr().name(), |
3793 | 978 | "<div width=*><p><font size=%d>%s</font></p></div>") % | 980 | g_gr->images().get(rdescr->representative_image())->width(), |
3794 | 979 | ri.descr().name() % UI_FONT_SIZE_MESSAGE % _("A geologist found resources.")) | 981 | _("A geologist found resources.")); |
3790 | 980 | .str(); | ||
3795 | 981 | 982 | ||
3796 | 982 | // We should add a message to the player's message queue - but only, | 983 | // We should add a message to the player's message queue - but only, |
3797 | 983 | // if there is not already a similar one in list. | 984 | // if there is not already a similar one in list. |
3798 | @@ -985,7 +986,7 @@ | |||
3799 | 985 | game, | 986 | game, |
3800 | 986 | std::unique_ptr<Message>(new Message(Message::Type::kGeologists, game.get_gametime(), | 987 | std::unique_ptr<Message>(new Message(Message::Type::kGeologists, game.get_gametime(), |
3801 | 987 | rdescr->descname(), rdescr->representative_image(), | 988 | rdescr->descname(), rdescr->representative_image(), |
3803 | 988 | ri.descr().descname(), message, position, serial_, | 989 | ri.descr().descname(), rt_description, position, serial_, |
3804 | 989 | rdescr->name())), | 990 | rdescr->name())), |
3805 | 990 | rdescr->timeout_ms(), rdescr->timeout_radius()); | 991 | rdescr->timeout_ms(), rdescr->timeout_radius()); |
3806 | 991 | } | 992 | } |
3807 | 992 | 993 | ||
3808 | === modified file 'src/ui_basic/CMakeLists.txt' | |||
3809 | --- src/ui_basic/CMakeLists.txt 2019-04-09 04:51:44 +0000 | |||
3810 | +++ src/ui_basic/CMakeLists.txt 2019-05-26 02:00:17 +0000 | |||
3811 | @@ -67,7 +67,6 @@ | |||
3812 | 67 | graphic_styles | 67 | graphic_styles |
3813 | 68 | graphic_surface | 68 | graphic_surface |
3814 | 69 | graphic_text | 69 | graphic_text |
3815 | 70 | graphic_text_constants | ||
3816 | 71 | graphic_text_layout | 70 | graphic_text_layout |
3817 | 72 | graphic_wordwrap | 71 | graphic_wordwrap |
3818 | 73 | io_filesystem | 72 | io_filesystem |
3819 | 74 | 73 | ||
3820 | === modified file 'src/ui_basic/button.cc' | |||
3821 | --- src/ui_basic/button.cc 2019-02-23 11:00:49 +0000 | |||
3822 | +++ src/ui_basic/button.cc 2019-05-26 02:00:17 +0000 | |||
3823 | @@ -24,7 +24,6 @@ | |||
3824 | 24 | #include "graphic/image.h" | 24 | #include "graphic/image.h" |
3825 | 25 | #include "graphic/rendertarget.h" | 25 | #include "graphic/rendertarget.h" |
3826 | 26 | #include "graphic/style_manager.h" | 26 | #include "graphic/style_manager.h" |
3827 | 27 | #include "graphic/text_constants.h" | ||
3828 | 28 | #include "graphic/text_layout.h" | 27 | #include "graphic/text_layout.h" |
3829 | 29 | #include "ui_basic/mouse_constants.h" | 28 | #include "ui_basic/mouse_constants.h" |
3830 | 30 | 29 | ||
3831 | @@ -58,7 +57,7 @@ | |||
3832 | 58 | time_nextact_(0), | 57 | time_nextact_(0), |
3833 | 59 | title_(title_text), | 58 | title_(title_text), |
3834 | 60 | title_image_(title_image), | 59 | title_image_(title_image), |
3836 | 61 | background_style_(g_gr->styles().button_style(init_style)) { | 60 | style_(&g_gr->styles().button_style(init_style)) { |
3837 | 62 | set_thinks(false); | 61 | set_thinks(false); |
3838 | 63 | // Don't allow focus | 62 | // Don't allow focus |
3839 | 64 | assert(!get_can_focus()); | 63 | assert(!get_can_focus()); |
3840 | @@ -89,7 +88,7 @@ | |||
3841 | 89 | UI::Button::ImageMode::kShrink) { | 88 | UI::Button::ImageMode::kShrink) { |
3842 | 90 | // Automatically resize for font height and give it a margin. | 89 | // Automatically resize for font height and give it a margin. |
3843 | 91 | if (h < 1) { | 90 | if (h < 1) { |
3845 | 92 | int new_height = text_height() + 4; | 91 | const int new_height = text_height(g_gr->styles().button_style(init_style).enabled().font()) + 4; |
3846 | 93 | set_desired_size(w, new_height); | 92 | set_desired_size(w, new_height); |
3847 | 94 | set_size(w, new_height); | 93 | set_size(w, new_height); |
3848 | 95 | } | 94 | } |
3849 | @@ -170,8 +169,10 @@ | |||
3850 | 170 | const bool is_monochrome = | 169 | const bool is_monochrome = |
3851 | 171 | !enabled_ && static_cast<int>(disable_style_ & ButtonDisableStyle::kMonochrome); | 170 | !enabled_ && static_cast<int>(disable_style_ & ButtonDisableStyle::kMonochrome); |
3852 | 172 | 171 | ||
3853 | 172 | const UI::TextPanelStyleInfo& style_to_use = is_monochrome ? style_->disabled() : style_->enabled(); | ||
3854 | 173 | |||
3855 | 173 | // Draw the background | 174 | // Draw the background |
3857 | 174 | draw_background(dst, *background_style_); | 175 | draw_background(dst, style_to_use.background()); |
3858 | 175 | 176 | ||
3859 | 176 | if (is_flat && highlighted_) | 177 | if (is_flat && highlighted_) |
3860 | 177 | dst.brighten_rect(Recti(0, 0, get_w(), get_h()), MOUSE_OVER_BRIGHT_FACTOR); | 178 | dst.brighten_rect(Recti(0, 0, get_w(), get_h()), MOUSE_OVER_BRIGHT_FACTOR); |
3861 | @@ -216,8 +217,11 @@ | |||
3862 | 216 | } else if (title_.length()) { | 217 | } else if (title_.length()) { |
3863 | 217 | // Otherwise draw title string centered | 218 | // Otherwise draw title string centered |
3864 | 218 | std::shared_ptr<const UI::RenderedText> rendered_text = | 219 | std::shared_ptr<const UI::RenderedText> rendered_text = |
3867 | 219 | autofit_ui_text(title_, get_inner_w() - 2 * kButtonImageMargin, | 220 | autofit_text( |
3868 | 220 | is_monochrome ? UI_FONT_CLR_DISABLED : UI_FONT_CLR_FG); | 221 | richtext_escape(title_), |
3869 | 222 | style_to_use.font(), | ||
3870 | 223 | get_inner_w() - 2 * kButtonImageMargin); | ||
3871 | 224 | |||
3872 | 221 | // Blit on pixel boundary (not float), so that the text is blitted pixel perfect. | 225 | // Blit on pixel boundary (not float), so that the text is blitted pixel perfect. |
3873 | 222 | rendered_text->draw(dst, Vector2i((get_w() - rendered_text->width()) / 2, | 226 | rendered_text->draw(dst, Vector2i((get_w() - rendered_text->width()) / 2, |
3874 | 223 | (get_h() - rendered_text->height()) / 2)); | 227 | (get_h() - rendered_text->height()) / 2)); |
3875 | @@ -363,8 +367,8 @@ | |||
3876 | 363 | UI::Button::VisualState::kRaised); | 367 | UI::Button::VisualState::kRaised); |
3877 | 364 | } | 368 | } |
3878 | 365 | 369 | ||
3881 | 366 | void Button::set_background_style(UI::ButtonStyle bstyle) { | 370 | void Button::set_style(UI::ButtonStyle bstyle) { |
3882 | 367 | background_style_ = g_gr->styles().button_style(bstyle); | 371 | style_ = &g_gr->styles().button_style(bstyle); |
3883 | 368 | } | 372 | } |
3884 | 369 | 373 | ||
3885 | 370 | void Button::toggle() { | 374 | void Button::toggle() { |
3886 | 371 | 375 | ||
3887 | === modified file 'src/ui_basic/button.h' | |||
3888 | --- src/ui_basic/button.h 2019-02-23 11:00:49 +0000 | |||
3889 | +++ src/ui_basic/button.h 2019-05-26 02:00:17 +0000 | |||
3890 | @@ -25,7 +25,7 @@ | |||
3891 | 25 | #include <boost/signals2.hpp> | 25 | #include <boost/signals2.hpp> |
3892 | 26 | 26 | ||
3893 | 27 | #include "graphic/color.h" | 27 | #include "graphic/color.h" |
3895 | 28 | #include "graphic/text_layout.h" | 28 | #include "graphic/styles/button_style.h" |
3896 | 29 | #include "ui_basic/panel.h" | 29 | #include "ui_basic/panel.h" |
3897 | 30 | 30 | ||
3898 | 31 | namespace UI { | 31 | namespace UI { |
3899 | @@ -146,7 +146,7 @@ | |||
3900 | 146 | void set_perm_pressed(bool pressed); | 146 | void set_perm_pressed(bool pressed); |
3901 | 147 | 147 | ||
3902 | 148 | /// Change the background style of the button. | 148 | /// Change the background style of the button. |
3904 | 149 | void set_background_style(UI::ButtonStyle bstyle); | 149 | void set_style(UI::ButtonStyle bstyle); |
3905 | 150 | 150 | ||
3906 | 151 | /// Convenience function. Toggles between raised and permpressed style | 151 | /// Convenience function. Toggles between raised and permpressed style |
3907 | 152 | void toggle(); | 152 | void toggle(); |
3908 | @@ -172,7 +172,7 @@ | |||
3909 | 172 | std::string title_; // title string used when title_image_ == nullptr | 172 | std::string title_; // title string used when title_image_ == nullptr |
3910 | 173 | const Image* title_image_; // custom icon on the button | 173 | const Image* title_image_; // custom icon on the button |
3911 | 174 | 174 | ||
3913 | 175 | const UI::PanelStyleInfo* background_style_; // Background color and texture. Not owned. | 175 | const UI::ButtonStyleInfo* style_; // Background color and texture. Not owned. |
3914 | 176 | }; | 176 | }; |
3915 | 177 | 177 | ||
3916 | 178 | } // namespace UI | 178 | } // namespace UI |
3917 | 179 | 179 | ||
3918 | === modified file 'src/ui_basic/checkbox.cc' | |||
3919 | --- src/ui_basic/checkbox.cc 2019-02-23 11:00:49 +0000 | |||
3920 | +++ src/ui_basic/checkbox.cc 2019-05-26 02:00:17 +0000 | |||
3921 | @@ -80,7 +80,7 @@ | |||
3922 | 80 | } | 80 | } |
3923 | 81 | rendered_text_ = label_text_.empty() ? | 81 | rendered_text_ = label_text_.empty() ? |
3924 | 82 | nullptr : | 82 | nullptr : |
3926 | 83 | UI::g_fh->render(as_uifont(label_text_), text_width(get_w(), pic_width)); | 83 | UI::g_fh->render(as_richtext_paragraph(label_text_, UI::FontStyle::kLabel), text_width(get_w(), pic_width)); |
3927 | 84 | if (rendered_text_.get()) { | 84 | if (rendered_text_.get()) { |
3928 | 85 | w = std::max(rendered_text_->width() + kPadding + pic_width, w); | 85 | w = std::max(rendered_text_->width() + kPadding + pic_width, w); |
3929 | 86 | h = std::max(rendered_text_->height(), h); | 86 | h = std::max(rendered_text_->height(), h); |
3930 | 87 | 87 | ||
3931 | === modified file 'src/ui_basic/dropdown.cc' | |||
3932 | --- src/ui_basic/dropdown.cc 2019-02-23 11:00:49 +0000 | |||
3933 | +++ src/ui_basic/dropdown.cc 2019-05-26 02:00:17 +0000 | |||
3934 | @@ -29,18 +29,25 @@ | |||
3935 | 29 | #include "graphic/font_handler.h" | 29 | #include "graphic/font_handler.h" |
3936 | 30 | #include "graphic/graphic.h" | 30 | #include "graphic/graphic.h" |
3937 | 31 | #include "graphic/rendertarget.h" | 31 | #include "graphic/rendertarget.h" |
3938 | 32 | #include "graphic/text_layout.h" | ||
3939 | 32 | #include "ui_basic/mouse_constants.h" | 33 | #include "ui_basic/mouse_constants.h" |
3940 | 33 | #include "ui_basic/tabpanel.h" | 34 | #include "ui_basic/tabpanel.h" |
3941 | 34 | #include "ui_basic/window.h" | 35 | #include "ui_basic/window.h" |
3942 | 35 | 36 | ||
3943 | 36 | namespace { | 37 | namespace { |
3947 | 37 | 38 | int base_height(int button_dimension, UI::PanelStyle style) { | |
3948 | 38 | int base_height(int button_dimension) { | 39 | int result = std::max( |
3946 | 39 | return std::max( | ||
3949 | 40 | button_dimension, | 40 | button_dimension, |
3953 | 41 | UI::g_fh->render(as_uifont(UI::g_fh->fontset()->representative_character()))->height() + 2); | 41 | text_height(g_gr->styles().table_style(style).enabled()) + 2); |
3954 | 42 | } | 42 | return result; |
3955 | 43 | 43 | } | |
3956 | 44 | |||
3957 | 45 | |||
3958 | 46 | /* | ||
3959 | 47 | int BaseDropdown::base_height(int button_dimension) const { | ||
3960 | 48 | return std::max(button_dimension, text_height(g_gr->styles().table_style(UI::PanelStyle::kWui).enabled()) + 2); | ||
3961 | 49 | } | ||
3962 | 50 | */ | ||
3963 | 44 | } // namespace | 51 | } // namespace |
3964 | 45 | 52 | ||
3965 | 46 | namespace UI { | 53 | namespace UI { |
3966 | @@ -61,13 +68,14 @@ | |||
3967 | 61 | y, | 68 | y, |
3968 | 62 | type == DropdownType::kPictorial ? button_dimension : w, | 69 | type == DropdownType::kPictorial ? button_dimension : w, |
3969 | 63 | // Height only to fit the button, so we can use this in Box layout. | 70 | // Height only to fit the button, so we can use this in Box layout. |
3971 | 64 | base_height(button_dimension)), | 71 | base_height(button_dimension, style)), |
3972 | 65 | id_(next_id_++), | 72 | id_(next_id_++), |
3973 | 66 | max_list_height_(h - 2 * get_h()), | 73 | max_list_height_(h - 2 * get_h()), |
3974 | 67 | list_width_(w), | 74 | list_width_(w), |
3975 | 68 | list_offset_x_(0), | 75 | list_offset_x_(0), |
3976 | 69 | list_offset_y_(0), | 76 | list_offset_y_(0), |
3977 | 70 | button_dimension_(button_dimension), | 77 | button_dimension_(button_dimension), |
3978 | 78 | base_height_(base_height(button_dimension, style)), | ||
3979 | 71 | mouse_tolerance_(50), | 79 | mouse_tolerance_(50), |
3980 | 72 | button_box_(this, 0, 0, UI::Box::Horizontal, w, h), | 80 | button_box_(this, 0, 0, UI::Box::Horizontal, w, h), |
3981 | 73 | push_button_(type == DropdownType::kTextual ? | 81 | push_button_(type == DropdownType::kTextual ? |
3982 | @@ -154,16 +162,16 @@ | |||
3983 | 154 | } | 162 | } |
3984 | 155 | 163 | ||
3985 | 156 | void BaseDropdown::set_height(int height) { | 164 | void BaseDropdown::set_height(int height) { |
3987 | 157 | max_list_height_ = height - base_height(button_dimension_); | 165 | max_list_height_ = height - base_height_; |
3988 | 158 | layout(); | 166 | layout(); |
3989 | 159 | } | 167 | } |
3990 | 160 | 168 | ||
3991 | 161 | void BaseDropdown::set_max_items(int items) { | 169 | void BaseDropdown::set_max_items(int items) { |
3993 | 162 | set_height(list_->get_lineheight() * items + base_height(button_dimension_)); | 170 | set_height(list_->get_lineheight() * items + base_height_); |
3994 | 163 | } | 171 | } |
3995 | 164 | 172 | ||
3996 | 165 | void BaseDropdown::layout() { | 173 | void BaseDropdown::layout() { |
3998 | 166 | const int base_h = base_height(button_dimension_); | 174 | const int base_h = base_height_; |
3999 | 167 | const int w = type_ == DropdownType::kPictorial ? button_dimension_ : get_w(); | 175 | const int w = type_ == DropdownType::kPictorial ? button_dimension_ : get_w(); |
4000 | 168 | button_box_.set_size(w, base_h); | 176 | button_box_.set_size(w, base_h); |
4001 | 169 | display_button_.set_desired_size( | 177 | display_button_.set_desired_size( |
4002 | 170 | 178 | ||
4003 | === modified file 'src/ui_basic/dropdown.h' | |||
4004 | --- src/ui_basic/dropdown.h 2019-02-23 11:00:49 +0000 | |||
4005 | +++ src/ui_basic/dropdown.h 2019-05-26 02:00:17 +0000 | |||
4006 | @@ -179,7 +179,8 @@ | |||
4007 | 179 | int list_width_; | 179 | int list_width_; |
4008 | 180 | int list_offset_x_; | 180 | int list_offset_x_; |
4009 | 181 | int list_offset_y_; | 181 | int list_offset_y_; |
4011 | 182 | int button_dimension_; | 182 | const int button_dimension_; |
4012 | 183 | const int base_height_; | ||
4013 | 183 | const int mouse_tolerance_; // Allow mouse outside the panel a bit before autocollapse | 184 | const int mouse_tolerance_; // Allow mouse outside the panel a bit before autocollapse |
4014 | 184 | UI::Box button_box_; | 185 | UI::Box button_box_; |
4015 | 185 | UI::Button* push_button_; // Only used in textual dropdowns | 186 | UI::Button* push_button_; // Only used in textual dropdowns |
4016 | 186 | 187 | ||
4017 | === modified file 'src/ui_basic/editbox.cc' | |||
4018 | --- src/ui_basic/editbox.cc 2019-05-25 08:25:55 +0000 | |||
4019 | +++ src/ui_basic/editbox.cc 2019-05-26 02:00:17 +0000 | |||
4020 | @@ -34,7 +34,6 @@ | |||
4021 | 34 | #include "graphic/text/bidi.h" | 34 | #include "graphic/text/bidi.h" |
4022 | 35 | #include "graphic/text/font_set.h" | 35 | #include "graphic/text/font_set.h" |
4023 | 36 | #include "graphic/text/rt_errors.h" | 36 | #include "graphic/text/rt_errors.h" |
4024 | 37 | #include "graphic/text_constants.h" | ||
4025 | 38 | #include "graphic/text_layout.h" | 37 | #include "graphic/text_layout.h" |
4026 | 39 | #include "ui_basic/mouse_constants.h" | 38 | #include "ui_basic/mouse_constants.h" |
4027 | 40 | 39 | ||
4028 | @@ -43,23 +42,30 @@ | |||
4029 | 43 | namespace { | 42 | namespace { |
4030 | 44 | 43 | ||
4031 | 45 | constexpr int kMarginX = 4; | 44 | constexpr int kMarginX = 4; |
4032 | 45 | constexpr int kLineMargin = 1; | ||
4033 | 46 | 46 | ||
4034 | 47 | } // namespace | 47 | } // namespace |
4035 | 48 | 48 | ||
4036 | 49 | namespace UI { | 49 | namespace UI { |
4037 | 50 | 50 | ||
4038 | 51 | struct EditBoxImpl { | 51 | struct EditBoxImpl { |
4046 | 52 | /** | 52 | explicit EditBoxImpl(const UI::TextPanelStyleInfo& init_style) : |
4047 | 53 | * Font used for rendering text. | 53 | background_style(&init_style.background()), font_style(&init_style.font()), |
4048 | 54 | */ | 54 | margin(init_style.background().margin()), font_scale(1.0f) { |
4049 | 55 | /*@{*/ | 55 | } |
4043 | 56 | std::string fontname; | ||
4044 | 57 | uint32_t fontsize; | ||
4045 | 58 | /*@}*/ | ||
4050 | 59 | 56 | ||
4051 | 60 | /// Background color and texture | 57 | /// Background color and texture |
4052 | 61 | const UI::PanelStyleInfo* background_style; | 58 | const UI::PanelStyleInfo* background_style; |
4053 | 62 | 59 | ||
4054 | 60 | /// Font style | ||
4055 | 61 | const UI::FontStyleInfo* font_style; | ||
4056 | 62 | |||
4057 | 63 | /// Margin around the test | ||
4058 | 64 | int margin; | ||
4059 | 65 | |||
4060 | 66 | /// Scale for font size | ||
4061 | 67 | float font_scale; | ||
4062 | 68 | |||
4063 | 63 | /// Maximum number of characters in the input | 69 | /// Maximum number of characters in the input |
4064 | 64 | uint32_t maxLength; | 70 | uint32_t maxLength; |
4065 | 65 | 71 | ||
4066 | @@ -80,22 +86,17 @@ | |||
4067 | 80 | int32_t x, | 86 | int32_t x, |
4068 | 81 | int32_t y, | 87 | int32_t y, |
4069 | 82 | uint32_t w, | 88 | uint32_t w, |
4076 | 83 | uint32_t h, | 89 | UI::PanelStyle style) |
4077 | 84 | int margin_y, | 90 | : Panel(parent, x, y, w, |
4078 | 85 | UI::PanelStyle style, | 91 | text_height(g_gr->styles().editbox_style(style).font()) |
4079 | 86 | int font_size) | 92 | + 2 * g_gr->styles().editbox_style(style).background().margin()), |
4080 | 87 | : Panel(parent, x, y, w, h > 0 ? h : text_height(font_size) + 2 * margin_y), | 93 | m_(new EditBoxImpl(g_gr->styles().editbox_style(style))), |
4075 | 88 | m_(new EditBoxImpl), | ||
4081 | 89 | history_active_(false), | 94 | history_active_(false), |
4082 | 90 | history_position_(-1), | 95 | history_position_(-1), |
4083 | 91 | password_(false), | 96 | password_(false), |
4084 | 92 | warning_(false) { | 97 | warning_(false) { |
4085 | 93 | set_thinks(false); | 98 | set_thinks(false); |
4086 | 94 | 99 | ||
4087 | 95 | m_->background_style = g_gr->styles().editbox_style(style); | ||
4088 | 96 | m_->fontname = UI::g_fh->fontset()->sans(); | ||
4089 | 97 | m_->fontsize = font_size; | ||
4090 | 98 | |||
4091 | 99 | // Set alignment to the UI language's principal writing direction | 100 | // Set alignment to the UI language's principal writing direction |
4092 | 100 | m_->align = UI::g_fh->fontset()->is_rtl() ? UI::Align::kRight : UI::Align::kLeft; | 101 | m_->align = UI::g_fh->fontset()->is_rtl() ? UI::Align::kRight : UI::Align::kLeft; |
4093 | 101 | m_->caret = 0; | 102 | m_->caret = 0; |
4094 | @@ -103,6 +104,7 @@ | |||
4095 | 103 | // yes, use *signed* max as maximum length; just a small safe-guard. | 104 | // yes, use *signed* max as maximum length; just a small safe-guard. |
4096 | 104 | set_max_length(std::numeric_limits<int32_t>::max()); | 105 | set_max_length(std::numeric_limits<int32_t>::max()); |
4097 | 105 | 106 | ||
4098 | 107 | set_thinks(false); | ||
4099 | 106 | set_handle_mouse(true); | 108 | set_handle_mouse(true); |
4100 | 107 | set_can_focus(true); | 109 | set_can_focus(true); |
4101 | 108 | set_handle_textinput(); | 110 | set_handle_textinput(); |
4102 | @@ -148,9 +150,9 @@ | |||
4103 | 148 | * If the current string is longer than the new maximum length, | 150 | * If the current string is longer than the new maximum length, |
4104 | 149 | * its end is cut off to fit into the maximum length. | 151 | * its end is cut off to fit into the maximum length. |
4105 | 150 | */ | 152 | */ |
4107 | 151 | void EditBox::set_max_length(uint32_t const n) { | 153 | void EditBox::set_max_length(int const n) { |
4108 | 152 | m_->maxLength = | 154 | m_->maxLength = |
4110 | 153 | std::min(g_gr->max_texture_size_for_font_rendering() / text_height(), static_cast<int>(n)); | 155 | std::min(g_gr->max_texture_size_for_font_rendering() / text_height(*m_->font_style), n); |
4111 | 154 | 156 | ||
4112 | 155 | if (m_->text.size() > m_->maxLength) { | 157 | if (m_->text.size() > m_->maxLength) { |
4113 | 156 | m_->text.erase(m_->text.begin() + m_->maxLength, m_->text.end()); | 158 | m_->text.erase(m_->text.begin() + m_->maxLength, m_->text.end()); |
4114 | @@ -161,6 +163,22 @@ | |||
4115 | 161 | } | 163 | } |
4116 | 162 | } | 164 | } |
4117 | 163 | 165 | ||
4118 | 166 | void EditBox::set_font_scale(float scale) { | ||
4119 | 167 | m_->font_scale = scale; | ||
4120 | 168 | } | ||
4121 | 169 | |||
4122 | 170 | void EditBox::set_font_style(const UI::FontStyleInfo& style) { | ||
4123 | 171 | m_->font_style = &style; | ||
4124 | 172 | const int new_height = text_height(style) + 2 * m_->margin; | ||
4125 | 173 | set_size(get_w(), new_height); | ||
4126 | 174 | set_desired_size(get_w(), new_height); | ||
4127 | 175 | } | ||
4128 | 176 | |||
4129 | 177 | void EditBox::set_font_style_and_margin(const UI::FontStyleInfo& style, int margin) { | ||
4130 | 178 | m_->margin = margin; | ||
4131 | 179 | set_font_style(style); | ||
4132 | 180 | } | ||
4133 | 181 | |||
4134 | 164 | /** | 182 | /** |
4135 | 165 | * The mouse was clicked on this editbox | 183 | * The mouse was clicked on this editbox |
4136 | 166 | */ | 184 | */ |
4137 | @@ -389,12 +407,13 @@ | |||
4138 | 389 | } | 407 | } |
4139 | 390 | 408 | ||
4140 | 391 | const int max_width = get_w() - 2 * kMarginX; | 409 | const int max_width = get_w() - 2 * kMarginX; |
4142 | 392 | 410 | FontStyleInfo scaled_style(*m_->font_style); | |
4143 | 411 | scaled_style.set_size(scaled_style.size() * m_->font_scale); | ||
4144 | 393 | std::shared_ptr<const UI::RenderedText> rendered_text = | 412 | std::shared_ptr<const UI::RenderedText> rendered_text = |
4146 | 394 | UI::g_fh->render(as_editorfont(m_->text, m_->fontsize)); | 413 | UI::g_fh->render(as_editor_richtext_paragraph(password_ ? text_to_asterisk() : m_->text, scaled_style)); |
4147 | 395 | 414 | ||
4148 | 396 | const int linewidth = rendered_text->width(); | 415 | const int linewidth = rendered_text->width(); |
4150 | 397 | const int lineheight = m_->text.empty() ? text_height(m_->fontsize) : rendered_text->height(); | 416 | const int lineheight = m_->text.empty() ? text_height(scaled_style) : rendered_text->height(); |
4151 | 398 | 417 | ||
4152 | 399 | Vector2i point(kMarginX, get_h() / 2); | 418 | Vector2i point(kMarginX, get_h() / 2); |
4153 | 400 | if (m_->align == UI::Align::kRight) { | 419 | if (m_->align == UI::Align::kRight) { |
4154 | @@ -403,33 +422,27 @@ | |||
4155 | 403 | UI::center_vertically(lineheight, &point); | 422 | UI::center_vertically(lineheight, &point); |
4156 | 404 | 423 | ||
4157 | 405 | // Crop to max_width while blitting | 424 | // Crop to max_width while blitting |
4166 | 406 | if (!password_) { | 425 | if (max_width < linewidth) { |
4167 | 407 | if (max_width < linewidth) { | 426 | // Fix positioning for BiDi languages. |
4168 | 408 | // Fix positioning for BiDi languages. | 427 | if (UI::g_fh->fontset()->is_rtl()) { |
4169 | 409 | if (UI::g_fh->fontset()->is_rtl()) { | 428 | point.x = 0.f; |
4170 | 410 | point.x = 0.f; | 429 | } |
4171 | 411 | } | 430 | // We want this always on, e.g. for mixed language savegame filenames |
4172 | 412 | // We want this always on, e.g. for mixed language savegame filenames | 431 | if (i18n::has_rtl_character(m_->text.c_str(), 100)) { // Restrict check for efficiency |
4173 | 413 | if (i18n::has_rtl_character(m_->text.c_str(), 100)) { // Restrict check for efficiency | 432 | // TODO(GunChleoc): Arabic: Fix scrolloffset |
4174 | 433 | rendered_text->draw(dst, point, Recti(linewidth - max_width, 0, linewidth, lineheight)); | ||
4175 | 434 | } else { | ||
4176 | 435 | if (m_->align == UI::Align::kRight) { | ||
4177 | 414 | // TODO(GunChleoc): Arabic: Fix scrolloffset | 436 | // TODO(GunChleoc): Arabic: Fix scrolloffset |
4179 | 415 | rendered_text->draw(dst, point, Recti(linewidth - max_width, 0, linewidth, lineheight)); | 437 | rendered_text->draw( |
4180 | 438 | dst, point, | ||
4181 | 439 | Recti(point.x + m_->scrolloffset + kMarginX, 0, max_width, lineheight)); | ||
4182 | 416 | } else { | 440 | } else { |
4191 | 417 | if (m_->align == UI::Align::kRight) { | 441 | rendered_text->draw(dst, point, Recti(-m_->scrolloffset, 0, max_width, lineheight)); |
4184 | 418 | // TODO(GunChleoc): Arabic: Fix scrolloffset | ||
4185 | 419 | rendered_text->draw( | ||
4186 | 420 | dst, point, | ||
4187 | 421 | Recti(point.x + m_->scrolloffset + kMarginX, 0, max_width, lineheight)); | ||
4188 | 422 | } else { | ||
4189 | 423 | rendered_text->draw(dst, point, Recti(-m_->scrolloffset, 0, max_width, lineheight)); | ||
4190 | 424 | } | ||
4192 | 425 | } | 442 | } |
4193 | 426 | } else { | ||
4194 | 427 | rendered_text->draw(dst, point, Recti(0, 0, max_width, lineheight)); | ||
4195 | 428 | } | 443 | } |
4196 | 429 | } else { | 444 | } else { |
4200 | 430 | std::shared_ptr<const UI::RenderedText> password_text = | 445 | rendered_text->draw(dst, point, Recti(0, 0, max_width, lineheight)); |
4198 | 431 | UI::g_fh->render(as_editorfont(text_to_asterisk(), m_->fontsize)); | ||
4199 | 432 | password_text->draw(dst, point, Recti(0, 0, max_width, lineheight)); | ||
4201 | 433 | } | 446 | } |
4202 | 434 | 447 | ||
4203 | 435 | if (has_focus()) { | 448 | if (has_focus()) { |
4204 | @@ -443,9 +456,9 @@ | |||
4205 | 443 | } | 456 | } |
4206 | 444 | 457 | ||
4207 | 445 | // TODO(GunChleoc): Arabic: Fix cursor position for BIDI text. | 458 | // TODO(GunChleoc): Arabic: Fix cursor position for BIDI text. |
4209 | 446 | int caret_x = text_width(line_to_caret, m_->fontsize); | 459 | int caret_x = text_width(line_to_caret, *m_->font_style, m_->font_scale); |
4210 | 447 | 460 | ||
4212 | 448 | const uint16_t fontheight = text_height(m_->fontsize); | 461 | const uint16_t fontheight = text_height(*m_->font_style, m_->font_scale); |
4213 | 449 | 462 | ||
4214 | 450 | const Image* caret_image = g_gr->images().get("images/ui_basic/caret.png"); | 463 | const Image* caret_image = g_gr->images().get("images/ui_basic/caret.png"); |
4215 | 451 | Vector2i caretpt = Vector2i::zero(); | 464 | Vector2i caretpt = Vector2i::zero(); |
4216 | @@ -461,8 +474,8 @@ | |||
4217 | 461 | void EditBox::check_caret() { | 474 | void EditBox::check_caret() { |
4218 | 462 | std::string leftstr(m_->text, 0, m_->caret); | 475 | std::string leftstr(m_->text, 0, m_->caret); |
4219 | 463 | std::string rightstr(m_->text, m_->caret, std::string::npos); | 476 | std::string rightstr(m_->text, m_->caret, std::string::npos); |
4222 | 464 | int32_t leftw = text_width(leftstr, m_->fontsize); | 477 | int32_t leftw = text_width(leftstr, *m_->font_style, m_->font_scale); |
4223 | 465 | int32_t rightw = text_width(rightstr, m_->fontsize); | 478 | int32_t rightw = text_width(rightstr, *m_->font_style, m_->font_scale); |
4224 | 466 | 479 | ||
4225 | 467 | int32_t caretpos = 0; | 480 | int32_t caretpos = 0; |
4226 | 468 | 481 | ||
4227 | 469 | 482 | ||
4228 | === modified file 'src/ui_basic/editbox.h' | |||
4229 | --- src/ui_basic/editbox.h 2019-05-15 09:58:33 +0000 | |||
4230 | +++ src/ui_basic/editbox.h 2019-05-26 02:00:17 +0000 | |||
4231 | @@ -26,6 +26,7 @@ | |||
4232 | 26 | #include <boost/signals2.hpp> | 26 | #include <boost/signals2.hpp> |
4233 | 27 | 27 | ||
4234 | 28 | #include "graphic/align.h" | 28 | #include "graphic/align.h" |
4235 | 29 | #include "graphic/style_manager.h" | ||
4236 | 29 | #include "ui_basic/button.h" | 30 | #include "ui_basic/button.h" |
4237 | 30 | 31 | ||
4238 | 31 | #define CHAT_HISTORY_SIZE 5 | 32 | #define CHAT_HISTORY_SIZE 5 |
4239 | @@ -48,10 +49,7 @@ | |||
4240 | 48 | int32_t x, | 49 | int32_t x, |
4241 | 49 | int32_t y, | 50 | int32_t y, |
4242 | 50 | uint32_t w, | 51 | uint32_t w, |
4247 | 51 | uint32_t h, | 52 | UI::PanelStyle style); |
4244 | 52 | int margin_y, | ||
4245 | 53 | UI::PanelStyle style, | ||
4246 | 54 | int font_size = UI_FONT_SIZE_SMALL); | ||
4248 | 55 | ~EditBox() override; | 53 | ~EditBox() override; |
4249 | 56 | 54 | ||
4250 | 57 | boost::signals2::signal<void()> changed; | 55 | boost::signals2::signal<void()> changed; |
4251 | @@ -60,7 +58,10 @@ | |||
4252 | 60 | 58 | ||
4253 | 61 | const std::string& text() const; | 59 | const std::string& text() const; |
4254 | 62 | void set_text(const std::string&); | 60 | void set_text(const std::string&); |
4256 | 63 | void set_max_length(uint32_t); | 61 | void set_max_length(int); |
4257 | 62 | void set_font_scale(float scale); | ||
4258 | 63 | void set_font_style(const UI::FontStyleInfo& style); | ||
4259 | 64 | void set_font_style_and_margin(const UI::FontStyleInfo& style, int margin); | ||
4260 | 64 | 65 | ||
4261 | 65 | void activate_history(bool activate) { | 66 | void activate_history(bool activate) { |
4262 | 66 | history_active_ = activate; | 67 | history_active_ = activate; |
4263 | 67 | 68 | ||
4264 | === modified file 'src/ui_basic/fullscreen_window.cc' | |||
4265 | --- src/ui_basic/fullscreen_window.cc 2019-02-23 11:00:49 +0000 | |||
4266 | +++ src/ui_basic/fullscreen_window.cc 2019-05-26 02:00:17 +0000 | |||
4267 | @@ -22,9 +22,9 @@ | |||
4268 | 22 | #include <cstdio> | 22 | #include <cstdio> |
4269 | 23 | #include <memory> | 23 | #include <memory> |
4270 | 24 | 24 | ||
4271 | 25 | #include "base/log.h" | ||
4272 | 25 | #include "graphic/rendertarget.h" | 26 | #include "graphic/rendertarget.h" |
4273 | 26 | #include "graphic/style_manager.h" | 27 | #include "graphic/style_manager.h" |
4274 | 27 | #include "graphic/text_constants.h" | ||
4275 | 28 | 28 | ||
4276 | 29 | /* | 29 | /* |
4277 | 30 | ============================================================================== | 30 | ============================================================================== |
4278 | @@ -177,12 +177,8 @@ | |||
4279 | 177 | } | 177 | } |
4280 | 178 | } | 178 | } |
4281 | 179 | 179 | ||
4288 | 180 | int FullscreenWindow::fs_small() { | 180 | float FullscreenWindow::scale_factor() const { |
4289 | 181 | return UI_FONT_SIZE_SMALL * get_h() / 600; | 181 | return std::max(1.0f, get_h() / 600.0f); |
4284 | 182 | } | ||
4285 | 183 | |||
4286 | 184 | int FullscreenWindow::fs_big() { | ||
4287 | 185 | return UI_FONT_SIZE_BIG * get_h() / 600; | ||
4290 | 186 | } | 182 | } |
4291 | 187 | 183 | ||
4292 | 188 | } // namespace UI | 184 | } // namespace UI |
4293 | 189 | 185 | ||
4294 | === modified file 'src/ui_basic/fullscreen_window.h' | |||
4295 | --- src/ui_basic/fullscreen_window.h 2019-02-23 11:00:49 +0000 | |||
4296 | +++ src/ui_basic/fullscreen_window.h 2019-05-26 02:00:17 +0000 | |||
4297 | @@ -71,9 +71,8 @@ | |||
4298 | 71 | FullscreenWindow(); | 71 | FullscreenWindow(); |
4299 | 72 | ~FullscreenWindow() override; | 72 | ~FullscreenWindow() override; |
4300 | 73 | 73 | ||
4304 | 74 | /// \return the size for texts fitting to current resolution | 74 | /// \return the font size scale factor for fitting texts to current resolution |
4305 | 75 | int fs_small(); | 75 | float scale_factor() const; |
4303 | 76 | int fs_big(); | ||
4306 | 77 | 76 | ||
4307 | 78 | protected: | 77 | protected: |
4308 | 79 | void draw(RenderTarget&) override; | 78 | void draw(RenderTarget&) override; |
4309 | 80 | 79 | ||
4310 | === modified file 'src/ui_basic/listselect.cc' | |||
4311 | --- src/ui_basic/listselect.cc 2019-02-23 11:00:49 +0000 | |||
4312 | +++ src/ui_basic/listselect.cc 2019-05-26 02:00:17 +0000 | |||
4313 | @@ -30,7 +30,6 @@ | |||
4314 | 30 | #include "graphic/rendertarget.h" | 30 | #include "graphic/rendertarget.h" |
4315 | 31 | #include "graphic/style_manager.h" | 31 | #include "graphic/style_manager.h" |
4316 | 32 | #include "graphic/text/bidi.h" | 32 | #include "graphic/text/bidi.h" |
4317 | 33 | #include "graphic/text_constants.h" | ||
4318 | 34 | #include "graphic/text_layout.h" | 33 | #include "graphic/text_layout.h" |
4319 | 35 | #include "ui_basic/mouse_constants.h" | 34 | #include "ui_basic/mouse_constants.h" |
4320 | 36 | 35 | ||
4321 | @@ -54,16 +53,17 @@ | |||
4322 | 54 | UI::PanelStyle style, | 53 | UI::PanelStyle style, |
4323 | 55 | const ListselectLayout selection_mode) | 54 | const ListselectLayout selection_mode) |
4324 | 56 | : Panel(parent, x, y, w, h), | 55 | : Panel(parent, x, y, w, h), |
4325 | 57 | lineheight_(text_height() + kMargin), | ||
4326 | 58 | scrollbar_(this, get_w() - Scrollbar::kSize, 0, Scrollbar::kSize, h, style), | 56 | scrollbar_(this, get_w() - Scrollbar::kSize, 0, Scrollbar::kSize, h, style), |
4327 | 59 | scrollpos_(0), | 57 | scrollpos_(0), |
4328 | 60 | selection_(no_selection_index()), | 58 | selection_(no_selection_index()), |
4329 | 61 | last_click_time_(-10000), | 59 | last_click_time_(-10000), |
4330 | 62 | last_selection_(no_selection_index()), | 60 | last_selection_(no_selection_index()), |
4331 | 63 | selection_mode_(selection_mode), | 61 | selection_mode_(selection_mode), |
4332 | 62 | font_style_(&g_gr->styles().table_style(style).enabled()), | ||
4333 | 64 | background_style_(selection_mode == ListselectLayout::kDropdown ? | 63 | background_style_(selection_mode == ListselectLayout::kDropdown ? |
4334 | 65 | g_gr->styles().dropdown_style(style) : | 64 | g_gr->styles().dropdown_style(style) : |
4336 | 66 | nullptr) { | 65 | nullptr), |
4337 | 66 | lineheight_(text_height(*font_style_) + kMargin) { | ||
4338 | 67 | set_thinks(false); | 67 | set_thinks(false); |
4339 | 68 | 68 | ||
4340 | 69 | scrollbar_.moved.connect(boost::bind(&BaseListselect::set_scrollpos, this, _1)); | 69 | scrollbar_.moved.connect(boost::bind(&BaseListselect::set_scrollpos, this, _1)); |
4341 | @@ -297,7 +297,7 @@ | |||
4342 | 297 | for (size_t i = 0; i < entry_records_.size(); ++i) { | 297 | for (size_t i = 0; i < entry_records_.size(); ++i) { |
4343 | 298 | const EntryRecord& er = *entry_records_[i]; | 298 | const EntryRecord& er = *entry_records_[i]; |
4344 | 299 | std::shared_ptr<const UI::RenderedText> rendered_text = UI::g_fh->render( | 299 | std::shared_ptr<const UI::RenderedText> rendered_text = UI::g_fh->render( |
4346 | 300 | as_uifont(richtext_escape(er.name), UI_FONT_SIZE_SMALL, UI_FONT_CLR_FG)); | 300 | as_richtext_paragraph(richtext_escape(er.name), *font_style_)); |
4347 | 301 | int picw = max_pic_width_ ? max_pic_width_ + 10 : 0; | 301 | int picw = max_pic_width_ ? max_pic_width_ + 10 : 0; |
4348 | 302 | int difference = rendered_text->width() + picw + 8 - get_eff_w(); | 302 | int difference = rendered_text->width() + picw + 8 - get_eff_w(); |
4349 | 303 | if (difference > 0) { | 303 | if (difference > 0) { |
4350 | @@ -342,7 +342,7 @@ | |||
4351 | 342 | 342 | ||
4352 | 343 | const EntryRecord& er = *entry_records_[idx]; | 343 | const EntryRecord& er = *entry_records_[idx]; |
4353 | 344 | std::shared_ptr<const UI::RenderedText> rendered_text = | 344 | std::shared_ptr<const UI::RenderedText> rendered_text = |
4355 | 345 | UI::g_fh->render(as_uifont(richtext_escape(er.name), UI_FONT_SIZE_SMALL, UI_FONT_CLR_FG)); | 345 | UI::g_fh->render(as_richtext_paragraph(richtext_escape(er.name), *font_style_)); |
4356 | 346 | 346 | ||
4357 | 347 | int lineheight = std::max(get_lineheight(), rendered_text->height()); | 347 | int lineheight = std::max(get_lineheight(), rendered_text->height()); |
4358 | 348 | 348 | ||
4359 | 349 | 349 | ||
4360 | === modified file 'src/ui_basic/listselect.h' | |||
4361 | --- src/ui_basic/listselect.h 2019-02-23 11:00:49 +0000 | |||
4362 | +++ src/ui_basic/listselect.h 2019-05-26 02:00:17 +0000 | |||
4363 | @@ -26,6 +26,7 @@ | |||
4364 | 26 | #include <boost/signals2.hpp> | 26 | #include <boost/signals2.hpp> |
4365 | 27 | 27 | ||
4366 | 28 | #include "graphic/color.h" | 28 | #include "graphic/color.h" |
4367 | 29 | #include "graphic/styles/font_style.h" | ||
4368 | 29 | #include "ui_basic/panel.h" | 30 | #include "ui_basic/panel.h" |
4369 | 30 | #include "ui_basic/scrollbar.h" | 31 | #include "ui_basic/scrollbar.h" |
4370 | 31 | 32 | ||
4371 | @@ -139,7 +140,6 @@ | |||
4372 | 139 | using EntryRecordDeque = std::deque<EntryRecord*>; | 140 | using EntryRecordDeque = std::deque<EntryRecord*>; |
4373 | 140 | 141 | ||
4374 | 141 | int max_pic_width_; | 142 | int max_pic_width_; |
4375 | 142 | int lineheight_; | ||
4376 | 143 | EntryRecordDeque entry_records_; | 143 | EntryRecordDeque entry_records_; |
4377 | 144 | Scrollbar scrollbar_; | 144 | Scrollbar scrollbar_; |
4378 | 145 | uint32_t scrollpos_; // in pixels | 145 | uint32_t scrollpos_; // in pixels |
4379 | @@ -148,7 +148,9 @@ | |||
4380 | 148 | uint32_t last_selection_; // for double clicks | 148 | uint32_t last_selection_; // for double clicks |
4381 | 149 | ListselectLayout selection_mode_; | 149 | ListselectLayout selection_mode_; |
4382 | 150 | const Image* check_pic_; | 150 | const Image* check_pic_; |
4383 | 151 | const FontStyleInfo* font_style_; | ||
4384 | 151 | const UI::PanelStyleInfo* background_style_; // Background color and texture. Not owned. | 152 | const UI::PanelStyleInfo* background_style_; // Background color and texture. Not owned. |
4385 | 153 | int lineheight_; | ||
4386 | 152 | std::string current_tooltip_; | 154 | std::string current_tooltip_; |
4387 | 153 | }; | 155 | }; |
4388 | 154 | 156 | ||
4389 | 155 | 157 | ||
4390 | === modified file 'src/ui_basic/messagebox.cc' | |||
4391 | --- src/ui_basic/messagebox.cc 2019-02-23 11:00:49 +0000 | |||
4392 | +++ src/ui_basic/messagebox.cc 2019-05-26 02:00:17 +0000 | |||
4393 | @@ -22,6 +22,7 @@ | |||
4394 | 22 | #include "base/i18n.h" | 22 | #include "base/i18n.h" |
4395 | 23 | #include "graphic/font_handler.h" | 23 | #include "graphic/font_handler.h" |
4396 | 24 | #include "graphic/graphic.h" | 24 | #include "graphic/graphic.h" |
4397 | 25 | #include "graphic/text_layout.h" | ||
4398 | 25 | #include "ui_basic/window.h" | 26 | #include "ui_basic/window.h" |
4399 | 26 | 27 | ||
4400 | 27 | namespace UI { | 28 | namespace UI { |
4401 | @@ -44,19 +45,21 @@ | |||
4402 | 44 | // Make sure that there is space for buttons + message, but not too tall | 45 | // Make sure that there is space for buttons + message, but not too tall |
4403 | 45 | const int maxheight = std::min(260, std::max(outerheight * 2 / 3, 200)); | 46 | const int maxheight = std::min(260, std::max(outerheight * 2 / 3, 200)); |
4404 | 46 | 47 | ||
4405 | 48 | const UI::FontStyle font_style = UI::FontStyle::kLabel; | ||
4406 | 49 | |||
4407 | 47 | const int margin = 5; | 50 | const int margin = 5; |
4408 | 48 | int width, height = 0; | 51 | int width, height = 0; |
4409 | 49 | { | 52 | { |
4410 | 50 | std::shared_ptr<const UI::RenderedText> temp_rendered_text = | 53 | std::shared_ptr<const UI::RenderedText> temp_rendered_text = |
4412 | 51 | g_fh->render(as_uifont(text), maxwidth); | 54 | g_fh->render(as_richtext_paragraph(text, font_style), maxwidth); |
4413 | 52 | width = temp_rendered_text->width(); | 55 | width = temp_rendered_text->width(); |
4414 | 53 | height = temp_rendered_text->height(); | 56 | height = temp_rendered_text->height(); |
4415 | 54 | } | 57 | } |
4416 | 55 | 58 | ||
4417 | 56 | // Stupid heuristic to avoid excessively long lines | 59 | // Stupid heuristic to avoid excessively long lines |
4419 | 57 | if (height < 2 * UI_FONT_SIZE_SMALL) { | 60 | if (height < 2 * text_height(font_style)) { |
4420 | 58 | std::shared_ptr<const UI::RenderedText> temp_rendered_text = | 61 | std::shared_ptr<const UI::RenderedText> temp_rendered_text = |
4422 | 59 | g_fh->render(as_uifont(text), maxwidth / 2); | 62 | g_fh->render(as_richtext_paragraph(text, font_style), maxwidth / 2); |
4423 | 60 | width = temp_rendered_text->width(); | 63 | width = temp_rendered_text->width(); |
4424 | 61 | height = temp_rendered_text->height(); | 64 | height = temp_rendered_text->height(); |
4425 | 62 | } | 65 | } |
4426 | 63 | 66 | ||
4427 | === modified file 'src/ui_basic/multilineeditbox.cc' | |||
4428 | --- src/ui_basic/multilineeditbox.cc 2019-02-23 11:00:49 +0000 | |||
4429 | +++ src/ui_basic/multilineeditbox.cc 2019-05-26 02:00:17 +0000 | |||
4430 | @@ -41,8 +41,8 @@ | |||
4431 | 41 | /// The text in the edit box | 41 | /// The text in the edit box |
4432 | 42 | std::string text; | 42 | std::string text; |
4433 | 43 | 43 | ||
4436 | 44 | /// Background color and texture | 44 | /// Background color and texture + font style |
4437 | 45 | const UI::PanelStyleInfo* background_style; | 45 | const UI::TextPanelStyleInfo& style; |
4438 | 46 | 46 | ||
4439 | 47 | /// Position of the cursor inside the text. | 47 | /// Position of the cursor inside the text. |
4440 | 48 | /// 0 indicates that the cursor is before the first character, | 48 | /// 0 indicates that the cursor is before the first character, |
4441 | @@ -60,7 +60,7 @@ | |||
4442 | 60 | WordWrap ww; | 60 | WordWrap ww; |
4443 | 61 | /*@}*/ | 61 | /*@}*/ |
4444 | 62 | 62 | ||
4446 | 63 | Data(MultilineEditbox&, const UI::PanelStyleInfo* style); | 63 | Data(MultilineEditbox&, const TextPanelStyleInfo& style); |
4447 | 64 | void refresh_ww(); | 64 | void refresh_ww(); |
4448 | 65 | 65 | ||
4449 | 66 | void update(); | 66 | void update(); |
4450 | @@ -81,7 +81,7 @@ | |||
4451 | 81 | 81 | ||
4452 | 82 | /** | 82 | /** |
4453 | 83 | * Initialize an editbox that supports multiline strings. | 83 | * Initialize an editbox that supports multiline strings. |
4455 | 84 | */ | 84 | */ |
4456 | 85 | MultilineEditbox::MultilineEditbox( | 85 | MultilineEditbox::MultilineEditbox( |
4457 | 86 | Panel* parent, int32_t x, int32_t y, uint32_t w, uint32_t h, UI::PanelStyle style) | 86 | Panel* parent, int32_t x, int32_t y, uint32_t w, uint32_t h, UI::PanelStyle style) |
4458 | 87 | : Panel(parent, x, y, w, h), d_(new Data(*this, g_gr->styles().editbox_style(style))) { | 87 | : Panel(parent, x, y, w, h), d_(new Data(*this, g_gr->styles().editbox_style(style))) { |
4459 | @@ -91,17 +91,18 @@ | |||
4460 | 91 | set_handle_textinput(); | 91 | set_handle_textinput(); |
4461 | 92 | } | 92 | } |
4462 | 93 | 93 | ||
4464 | 94 | MultilineEditbox::Data::Data(MultilineEditbox& o, const UI::PanelStyleInfo* style) | 94 | MultilineEditbox::Data::Data(MultilineEditbox& o, const UI::TextPanelStyleInfo& init_style) |
4465 | 95 | : scrollbar( | 95 | : scrollbar( |
4466 | 96 | &o, o.get_w() - Scrollbar::kSize, 0, Scrollbar::kSize, o.get_h(), UI::PanelStyle::kWui), | 96 | &o, o.get_w() - Scrollbar::kSize, 0, Scrollbar::kSize, o.get_h(), UI::PanelStyle::kWui), |
4468 | 97 | background_style(style), | 97 | style(init_style), |
4469 | 98 | cursor_pos(0), | 98 | cursor_pos(0), |
4471 | 99 | lineheight(text_height()), | 99 | lineheight(text_height(style.font())), |
4472 | 100 | maxbytes(std::min(g_gr->max_texture_size_for_font_rendering() * | 100 | maxbytes(std::min(g_gr->max_texture_size_for_font_rendering() * |
4473 | 101 | g_gr->max_texture_size_for_font_rendering() / | 101 | g_gr->max_texture_size_for_font_rendering() / |
4475 | 102 | (text_height() * text_height()), | 102 | (text_height(style.font()) * text_height(style.font())), |
4476 | 103 | std::numeric_limits<int32_t>::max())), | 103 | std::numeric_limits<int32_t>::max())), |
4477 | 104 | ww_valid(false), | 104 | ww_valid(false), |
4478 | 105 | ww(style.font().size(), style.font().color(), o.get_w()), | ||
4479 | 105 | owner(o) { | 106 | owner(o) { |
4480 | 106 | scrollbar.moved.connect(boost::bind(&MultilineEditbox::scrollpos_changed, &o, _1)); | 107 | scrollbar.moved.connect(boost::bind(&MultilineEditbox::scrollpos_changed, &o, _1)); |
4481 | 107 | 108 | ||
4482 | @@ -413,7 +414,7 @@ | |||
4483 | 413 | * Redraw the Editbox | 414 | * Redraw the Editbox |
4484 | 414 | */ | 415 | */ |
4485 | 415 | void MultilineEditbox::draw(RenderTarget& dst) { | 416 | void MultilineEditbox::draw(RenderTarget& dst) { |
4487 | 416 | draw_background(dst, *d_->background_style); | 417 | draw_background(dst, d_->style.background()); |
4488 | 417 | 418 | ||
4489 | 418 | // Draw border. | 419 | // Draw border. |
4490 | 419 | if (get_w() >= 4 && get_h() >= 4) { | 420 | if (get_w() >= 4 && get_h() >= 4) { |
4491 | @@ -437,7 +438,6 @@ | |||
4492 | 437 | d_->refresh_ww(); | 438 | d_->refresh_ww(); |
4493 | 438 | 439 | ||
4494 | 439 | d_->ww.set_draw_caret(has_focus()); | 440 | d_->ww.set_draw_caret(has_focus()); |
4495 | 440 | |||
4496 | 441 | d_->ww.draw(dst, Vector2i(0, -int32_t(d_->scrollbar.get_scrollpos())), UI::Align::kLeft, | 441 | d_->ww.draw(dst, Vector2i(0, -int32_t(d_->scrollbar.get_scrollpos())), UI::Align::kLeft, |
4497 | 442 | has_focus() ? d_->cursor_pos : std::numeric_limits<uint32_t>::max()); | 442 | has_focus() ? d_->cursor_pos : std::numeric_limits<uint32_t>::max()); |
4498 | 443 | } | 443 | } |
4499 | 444 | 444 | ||
4500 | === modified file 'src/ui_basic/multilinetextarea.cc' | |||
4501 | --- src/ui_basic/multilinetextarea.cc 2019-02-23 11:00:49 +0000 | |||
4502 | +++ src/ui_basic/multilinetextarea.cc 2019-05-26 02:00:17 +0000 | |||
4503 | @@ -23,9 +23,10 @@ | |||
4504 | 23 | #include <boost/bind.hpp> | 23 | #include <boost/bind.hpp> |
4505 | 24 | 24 | ||
4506 | 25 | #include "graphic/font_handler.h" | 25 | #include "graphic/font_handler.h" |
4507 | 26 | #include "graphic/graphic.h" | ||
4508 | 26 | #include "graphic/rendertarget.h" | 27 | #include "graphic/rendertarget.h" |
4509 | 28 | #include "graphic/text/bidi.h" | ||
4510 | 27 | #include "graphic/text/font_set.h" | 29 | #include "graphic/text/font_set.h" |
4511 | 28 | #include "graphic/text_constants.h" | ||
4512 | 29 | #include "graphic/text_layout.h" | 30 | #include "graphic/text_layout.h" |
4513 | 30 | 31 | ||
4514 | 31 | namespace UI { | 32 | namespace UI { |
4515 | @@ -44,19 +45,30 @@ | |||
4516 | 44 | MultilineTextarea::ScrollMode scroll_mode) | 45 | MultilineTextarea::ScrollMode scroll_mode) |
4517 | 45 | : Panel(parent, x, y, w, h), | 46 | : Panel(parent, x, y, w, h), |
4518 | 46 | text_(text), | 47 | text_(text), |
4520 | 47 | color_(UI_FONT_CLR_FG), | 48 | style_(&g_gr->styles().font_style(FontStyle::kLabel)), |
4521 | 49 | font_scale_(1.0f), | ||
4522 | 48 | align_(align), | 50 | align_(align), |
4523 | 49 | scrollbar_(this, get_w() - Scrollbar::kSize, 0, Scrollbar::kSize, h, style, false) { | 51 | scrollbar_(this, get_w() - Scrollbar::kSize, 0, Scrollbar::kSize, h, style, false) { |
4524 | 50 | set_thinks(false); | 52 | set_thinks(false); |
4525 | 51 | 53 | ||
4526 | 52 | scrollbar_.moved.connect(boost::bind(&MultilineTextarea::scrollpos_changed, this, _1)); | 54 | scrollbar_.moved.connect(boost::bind(&MultilineTextarea::scrollpos_changed, this, _1)); |
4527 | 53 | 55 | ||
4529 | 54 | scrollbar_.set_singlestepsize(text_height()); | 56 | scrollbar_.set_singlestepsize(text_height(*style_, font_scale_)); |
4530 | 55 | scrollbar_.set_steps(1); | 57 | scrollbar_.set_steps(1); |
4531 | 56 | set_scrollmode(scroll_mode); | 58 | set_scrollmode(scroll_mode); |
4532 | 57 | assert(scrollmode_ == MultilineTextarea::ScrollMode::kNoScrolling || Scrollbar::kSize <= w); | 59 | assert(scrollmode_ == MultilineTextarea::ScrollMode::kNoScrolling || Scrollbar::kSize <= w); |
4533 | 58 | } | 60 | } |
4534 | 59 | 61 | ||
4535 | 62 | void MultilineTextarea::set_style(const UI::FontStyleInfo& style) { | ||
4536 | 63 | style_ = &style; | ||
4537 | 64 | recompute(); | ||
4538 | 65 | } | ||
4539 | 66 | void MultilineTextarea::set_font_scale(float scale) { | ||
4540 | 67 | font_scale_ = scale; | ||
4541 | 68 | scrollbar_.set_singlestepsize(text_height(*style_, font_scale_)); | ||
4542 | 69 | recompute(); | ||
4543 | 70 | } | ||
4544 | 71 | |||
4545 | 60 | /** | 72 | /** |
4546 | 61 | * Replace the current text with a new one. | 73 | * Replace the current text with a new one. |
4547 | 62 | * Fix up scrolling state if necessary. | 74 | * Fix up scrolling state if necessary. |
4548 | @@ -66,11 +78,6 @@ | |||
4549 | 66 | recompute(); | 78 | recompute(); |
4550 | 67 | } | 79 | } |
4551 | 68 | 80 | ||
4552 | 69 | void MultilineTextarea::set_color(RGBColor fg) { | ||
4553 | 70 | color_ = fg; | ||
4554 | 71 | recompute(); | ||
4555 | 72 | } | ||
4556 | 73 | |||
4557 | 74 | /** | 81 | /** |
4558 | 75 | * Recompute the text rendering or rich-text layouting, | 82 | * Recompute the text rendering or rich-text layouting, |
4559 | 76 | * and adjust scrollbar settings accordingly. | 83 | * and adjust scrollbar settings accordingly. |
4560 | @@ -129,7 +136,7 @@ | |||
4561 | 129 | // Take care of the scrollbar | 136 | // Take care of the scrollbar |
4562 | 130 | scrollbar_.set_pos(Vector2i(get_w() - Scrollbar::kSize, 0)); | 137 | scrollbar_.set_pos(Vector2i(get_w() - Scrollbar::kSize, 0)); |
4563 | 131 | scrollbar_.set_size(Scrollbar::kSize, get_h()); | 138 | scrollbar_.set_size(Scrollbar::kSize, get_h()); |
4565 | 132 | scrollbar_.set_pagesize(get_h() - 2 * UI_FONT_SIZE_BIG); | 139 | scrollbar_.set_pagesize(get_h() - 2 * style_->size() * font_scale_); |
4566 | 133 | } | 140 | } |
4567 | 134 | 141 | ||
4568 | 135 | /** | 142 | /** |
4569 | @@ -140,7 +147,7 @@ | |||
4570 | 140 | return; | 147 | return; |
4571 | 141 | } | 148 | } |
4572 | 142 | int anchor = 0; | 149 | int anchor = 0; |
4574 | 143 | Align alignment = mirror_alignment(align_, text_); | 150 | Align alignment = mirror_alignment(align_, i18n::has_rtl_character(text_.c_str(), 20)); |
4575 | 144 | switch (alignment) { | 151 | switch (alignment) { |
4576 | 145 | // TODO(Arty): We might want to revisit this after the font renderer can handle long strings | 152 | // TODO(Arty): We might want to revisit this after the font renderer can handle long strings |
4577 | 146 | // without whitespaces differently. | 153 | // without whitespaces differently. |
4578 | @@ -192,7 +199,10 @@ | |||
4579 | 192 | // TODO(GunChleoc): Revisit this once the old font renderer is completely gone. | 199 | // TODO(GunChleoc): Revisit this once the old font renderer is completely gone. |
4580 | 193 | boost::replace_all(temp, "\n\n", "<br> <br>"); | 200 | boost::replace_all(temp, "\n\n", "<br> <br>"); |
4581 | 194 | boost::replace_all(temp, "\n", "<br>"); | 201 | boost::replace_all(temp, "\n", "<br>"); |
4583 | 195 | return as_aligned(temp, align_, UI_FONT_SIZE_SMALL, color_); | 202 | |
4584 | 203 | FontStyleInfo scaled_style(*style_); | ||
4585 | 204 | scaled_style.set_size(std::max(g_gr->styles().minimum_font_size(), static_cast<int>(std::ceil(scaled_style.size() * font_scale_)))); | ||
4586 | 205 | return as_richtext_paragraph(temp, scaled_style, align_); | ||
4587 | 196 | } | 206 | } |
4588 | 197 | 207 | ||
4589 | 198 | } // namespace UI | 208 | } // namespace UI |
4590 | 199 | 209 | ||
4591 | === modified file 'src/ui_basic/multilinetextarea.h' | |||
4592 | --- src/ui_basic/multilinetextarea.h 2019-02-23 11:00:49 +0000 | |||
4593 | +++ src/ui_basic/multilinetextarea.h 2019-05-26 02:00:17 +0000 | |||
4594 | @@ -23,13 +23,12 @@ | |||
4595 | 23 | #include <memory> | 23 | #include <memory> |
4596 | 24 | 24 | ||
4597 | 25 | #include "graphic/align.h" | 25 | #include "graphic/align.h" |
4599 | 26 | #include "graphic/color.h" | 26 | #include "graphic/styles/panel_styles.h" |
4600 | 27 | #include "graphic/text_layout.h" | 27 | #include "graphic/text_layout.h" |
4601 | 28 | #include "ui_basic/panel.h" | 28 | #include "ui_basic/panel.h" |
4602 | 29 | #include "ui_basic/scrollbar.h" | 29 | #include "ui_basic/scrollbar.h" |
4603 | 30 | 30 | ||
4604 | 31 | namespace UI { | 31 | namespace UI { |
4605 | 32 | struct Scrollbar; | ||
4606 | 33 | 32 | ||
4607 | 34 | /** | 33 | /** |
4608 | 35 | * This defines an area, where a text can easily be printed. | 34 | * This defines an area, where a text can easily be printed. |
4609 | @@ -65,7 +64,8 @@ | |||
4610 | 65 | return scrollbar_.is_enabled() ? get_w() - Scrollbar::kSize : get_w(); | 64 | return scrollbar_.is_enabled() ? get_w() - Scrollbar::kSize : get_w(); |
4611 | 66 | } | 65 | } |
4612 | 67 | 66 | ||
4614 | 68 | void set_color(RGBColor fg); | 67 | void set_style(const FontStyleInfo& style); |
4615 | 68 | void set_font_scale(float scale); | ||
4616 | 69 | 69 | ||
4617 | 70 | // Drawing and event handlers | 70 | // Drawing and event handlers |
4618 | 71 | void draw(RenderTarget&) override; | 71 | void draw(RenderTarget&) override; |
4619 | @@ -88,10 +88,13 @@ | |||
4620 | 88 | * turns '\\n' into '<br>' tags as needed, then creates the richtext style wrappers. | 88 | * turns '\\n' into '<br>' tags as needed, then creates the richtext style wrappers. |
4621 | 89 | */ | 89 | */ |
4622 | 90 | std::string make_richtext(); | 90 | std::string make_richtext(); |
4623 | 91 | |||
4624 | 92 | std::string text_; | 91 | std::string text_; |
4627 | 93 | std::shared_ptr<const UI::RenderedText> rendered_text_; | 92 | |
4628 | 94 | RGBColor color_; | 93 | std::shared_ptr<const UI::RenderedText> rendered_text_; |
4629 | 94 | |||
4630 | 95 | const FontStyleInfo* style_; | ||
4631 | 96 | float font_scale_; | ||
4632 | 97 | |||
4633 | 95 | const Align align_; | 98 | const Align align_; |
4634 | 96 | 99 | ||
4635 | 97 | Scrollbar scrollbar_; | 100 | Scrollbar scrollbar_; |
4636 | 98 | 101 | ||
4637 | === modified file 'src/ui_basic/panel.cc' | |||
4638 | --- src/ui_basic/panel.cc 2019-04-24 06:01:37 +0000 | |||
4639 | +++ src/ui_basic/panel.cc 2019-05-26 02:00:17 +0000 | |||
4640 | @@ -24,7 +24,6 @@ | |||
4641 | 24 | #include "graphic/graphic.h" | 24 | #include "graphic/graphic.h" |
4642 | 25 | #include "graphic/rendertarget.h" | 25 | #include "graphic/rendertarget.h" |
4643 | 26 | #include "graphic/text/font_set.h" | 26 | #include "graphic/text/font_set.h" |
4644 | 27 | #include "graphic/text_constants.h" | ||
4645 | 28 | #include "graphic/text_layout.h" | 27 | #include "graphic/text_layout.h" |
4646 | 29 | #include "profile/profile.h" | 28 | #include "profile/profile.h" |
4647 | 30 | #include "sound/sound_handler.h" | 29 | #include "sound/sound_handler.h" |
4648 | @@ -458,12 +457,12 @@ | |||
4649 | 458 | draw_background(dst, Recti(0, 0, get_w(), get_h()), info); | 457 | draw_background(dst, Recti(0, 0, get_w(), get_h()), info); |
4650 | 459 | } | 458 | } |
4651 | 460 | void Panel::draw_background(RenderTarget& dst, Recti rect, const UI::PanelStyleInfo& info) { | 459 | void Panel::draw_background(RenderTarget& dst, Recti rect, const UI::PanelStyleInfo& info) { |
4653 | 461 | if (info.image != nullptr) { | 460 | if (info.image() != nullptr) { |
4654 | 462 | dst.fill_rect(rect, RGBAColor(0, 0, 0, 255)); | 461 | dst.fill_rect(rect, RGBAColor(0, 0, 0, 255)); |
4656 | 463 | dst.tile(rect, info.image, Vector2i(get_x(), get_y())); | 462 | dst.tile(rect, info.image(), Vector2i(get_x(), get_y())); |
4657 | 464 | } | 463 | } |
4660 | 465 | if (info.color != RGBAColor(0, 0, 0, 0)) { | 464 | if (info.color() != RGBAColor(0, 0, 0, 0)) { |
4661 | 466 | dst.fill_rect(rect, info.color, BlendMode::UseAlpha); | 465 | dst.fill_rect(rect, info.color(), BlendMode::UseAlpha); |
4662 | 467 | } | 466 | } |
4663 | 468 | } | 467 | } |
4664 | 469 | 468 | ||
4665 | @@ -1082,7 +1081,7 @@ | |||
4666 | 1082 | RenderTarget& dst = *g_gr->get_render_target(); | 1081 | RenderTarget& dst = *g_gr->get_render_target(); |
4667 | 1083 | std::string text_to_render = text; | 1082 | std::string text_to_render = text; |
4668 | 1084 | if (!is_richtext(text_to_render)) { | 1083 | if (!is_richtext(text_to_render)) { |
4670 | 1085 | text_to_render = as_tooltip(text_to_render); | 1084 | text_to_render = as_richtext_paragraph(text_to_render, UI::FontStyle::kTooltip); |
4671 | 1086 | } | 1085 | } |
4672 | 1087 | 1086 | ||
4673 | 1088 | constexpr uint32_t kTipWidthMax = 360; | 1087 | constexpr uint32_t kTipWidthMax = 360; |
4674 | 1089 | 1088 | ||
4675 | === modified file 'src/ui_basic/panel.h' | |||
4676 | --- src/ui_basic/panel.h 2019-05-05 11:20:18 +0000 | |||
4677 | +++ src/ui_basic/panel.h 2019-05-26 02:00:17 +0000 | |||
4678 | @@ -33,7 +33,7 @@ | |||
4679 | 33 | #include "base/vector.h" | 33 | #include "base/vector.h" |
4680 | 34 | #include "graphic/align.h" | 34 | #include "graphic/align.h" |
4681 | 35 | #include "graphic/font_handler.h" | 35 | #include "graphic/font_handler.h" |
4683 | 36 | #include "graphic/panel_styles.h" | 36 | #include "graphic/styles/panel_styles.h" |
4684 | 37 | #include "sound/constants.h" | 37 | #include "sound/constants.h" |
4685 | 38 | 38 | ||
4686 | 39 | class RenderTarget; | 39 | class RenderTarget; |
4687 | 40 | 40 | ||
4688 | === modified file 'src/ui_basic/progressbar.cc' | |||
4689 | --- src/ui_basic/progressbar.cc 2019-02-23 11:00:49 +0000 | |||
4690 | +++ src/ui_basic/progressbar.cc 2019-05-26 02:00:17 +0000 | |||
4691 | @@ -24,6 +24,7 @@ | |||
4692 | 24 | #include <boost/format.hpp> | 24 | #include <boost/format.hpp> |
4693 | 25 | 25 | ||
4694 | 26 | #include "graphic/font_handler.h" | 26 | #include "graphic/font_handler.h" |
4695 | 27 | #include "graphic/graphic.h" | ||
4696 | 27 | #include "graphic/rendertarget.h" | 28 | #include "graphic/rendertarget.h" |
4697 | 28 | #include "graphic/text_layout.h" | 29 | #include "graphic/text_layout.h" |
4698 | 29 | 30 | ||
4699 | @@ -37,7 +38,7 @@ | |||
4700 | 37 | int32_t const w, | 38 | int32_t const w, |
4701 | 38 | int32_t const h, | 39 | int32_t const h, |
4702 | 39 | uint32_t const orientation) | 40 | uint32_t const orientation) |
4704 | 40 | : Panel(parent, x, y, w, h), orientation_(orientation), state_(0), total_(100) { | 41 | : Panel(parent, x, y, w, h), orientation_(orientation), state_(0), total_(100), style_(g_gr->styles().progressbar_style(UI::PanelStyle::kWui)) { |
4705 | 41 | } | 42 | } |
4706 | 42 | 43 | ||
4707 | 43 | /** | 44 | /** |
4708 | @@ -66,9 +67,9 @@ | |||
4709 | 66 | assert(0 <= fraction); | 67 | assert(0 <= fraction); |
4710 | 67 | assert(fraction <= 1); | 68 | assert(fraction <= 1); |
4711 | 68 | 69 | ||
4715 | 69 | const RGBColor color = fraction <= 0.33f ? | 70 | const RGBColor& color = fraction <= 0.33f ? style_.low_color() : fraction <= 0.67f ? |
4716 | 70 | RGBColor(255, 0, 0) : | 71 | style_.medium_color() : |
4717 | 71 | fraction <= 0.67f ? RGBColor(255, 255, 0) : RGBColor(0, 255, 0); | 72 | style_.high_color(); |
4718 | 72 | 73 | ||
4719 | 73 | // Draw the actual bar | 74 | // Draw the actual bar |
4720 | 74 | if (orientation_ == Horizontal) { | 75 | if (orientation_ == Horizontal) { |
4721 | @@ -85,11 +86,8 @@ | |||
4722 | 85 | } | 86 | } |
4723 | 86 | 87 | ||
4724 | 87 | // Print the state in percent without decimal points. | 88 | // Print the state in percent without decimal points. |
4725 | 88 | const std::string progress_text = (boost::format("<font color=%s>%u%%</font>") % | ||
4726 | 89 | UI_FONT_CLR_BRIGHT.hex_value() % floorf(fraction * 100.f)) | ||
4727 | 90 | .str(); | ||
4728 | 91 | std::shared_ptr<const UI::RenderedText> rendered_text = | 89 | std::shared_ptr<const UI::RenderedText> rendered_text = |
4730 | 92 | UI::g_fh->render(as_uifont(progress_text)); | 90 | UI::g_fh->render(as_richtext_paragraph((boost::format("%u%%") % floorf(fraction * 100.f)).str(), style_.font())); |
4731 | 93 | Vector2i pos(get_w() / 2, get_h() / 2); | 91 | Vector2i pos(get_w() / 2, get_h() / 2); |
4732 | 94 | UI::center_vertically(rendered_text->height(), &pos); | 92 | UI::center_vertically(rendered_text->height(), &pos); |
4733 | 95 | rendered_text->draw(dst, pos, UI::Align::kCenter); | 93 | rendered_text->draw(dst, pos, UI::Align::kCenter); |
4734 | 96 | 94 | ||
4735 | === modified file 'src/ui_basic/progressbar.h' | |||
4736 | --- src/ui_basic/progressbar.h 2019-02-23 11:00:49 +0000 | |||
4737 | +++ src/ui_basic/progressbar.h 2019-05-26 02:00:17 +0000 | |||
4738 | @@ -20,6 +20,7 @@ | |||
4739 | 20 | #ifndef WL_UI_BASIC_PROGRESSBAR_H | 20 | #ifndef WL_UI_BASIC_PROGRESSBAR_H |
4740 | 21 | #define WL_UI_BASIC_PROGRESSBAR_H | 21 | #define WL_UI_BASIC_PROGRESSBAR_H |
4741 | 22 | 22 | ||
4742 | 23 | #include "graphic/style_manager.h" | ||
4743 | 23 | #include "ui_basic/panel.h" | 24 | #include "ui_basic/panel.h" |
4744 | 24 | 25 | ||
4745 | 25 | namespace UI { | 26 | namespace UI { |
4746 | @@ -58,6 +59,7 @@ | |||
4747 | 58 | uint32_t orientation_; | 59 | uint32_t orientation_; |
4748 | 59 | uint32_t state_; ///< state_ is [0..total_] | 60 | uint32_t state_; ///< state_ is [0..total_] |
4749 | 60 | uint32_t total_; ///< maximum progress | 61 | uint32_t total_; ///< maximum progress |
4750 | 62 | const UI::ProgressbarStyleInfo& style_; | ||
4751 | 61 | }; | 63 | }; |
4752 | 62 | } // namespace UI | 64 | } // namespace UI |
4753 | 63 | 65 | ||
4754 | 64 | 66 | ||
4755 | === modified file 'src/ui_basic/progresswindow.cc' | |||
4756 | --- src/ui_basic/progresswindow.cc 2019-02-23 11:00:49 +0000 | |||
4757 | +++ src/ui_basic/progresswindow.cc 2019-05-26 02:00:17 +0000 | |||
4758 | @@ -28,14 +28,10 @@ | |||
4759 | 28 | #include "graphic/graphic.h" | 28 | #include "graphic/graphic.h" |
4760 | 29 | #include "graphic/rendertarget.h" | 29 | #include "graphic/rendertarget.h" |
4761 | 30 | #include "graphic/text/font_set.h" | 30 | #include "graphic/text/font_set.h" |
4762 | 31 | #include "graphic/text_constants.h" | ||
4763 | 32 | #include "graphic/text_layout.h" | 31 | #include "graphic/text_layout.h" |
4764 | 33 | #include "io/filesystem/layered_filesystem.h" | 32 | #include "io/filesystem/layered_filesystem.h" |
4765 | 34 | 33 | ||
4766 | 35 | namespace { | 34 | namespace { |
4767 | 36 | |||
4768 | 37 | #define PROGRESS_FONT_COLOR_FG RGBColor(128, 128, 255) | ||
4769 | 38 | #define PROGRESS_FONT_COLOR_BG RGBColor(64, 64, 0) | ||
4770 | 39 | #define PROGRESS_STATUS_RECT_PADDING 2 | 35 | #define PROGRESS_STATUS_RECT_PADDING 2 |
4771 | 40 | #define PROGRESS_STATUS_BORDER_X 2 | 36 | #define PROGRESS_STATUS_BORDER_X 2 |
4772 | 41 | #define PROGRESS_STATUS_BORDER_Y 2 | 37 | #define PROGRESS_STATUS_BORDER_Y 2 |
4773 | @@ -46,7 +42,7 @@ | |||
4774 | 46 | namespace UI { | 42 | namespace UI { |
4775 | 47 | 43 | ||
4776 | 48 | ProgressWindow::ProgressWindow(const std::string& background) | 44 | ProgressWindow::ProgressWindow(const std::string& background) |
4778 | 49 | : UI::FullscreenWindow(), label_center_(Vector2i::zero()) { | 45 | : UI::FullscreenWindow(), label_center_(Vector2i::zero()), style_(g_gr->styles().progressbar_style(UI::PanelStyle::kFsMenu)) { |
4779 | 50 | set_background(background); | 46 | set_background(background); |
4780 | 51 | step(_("Loading…")); | 47 | step(_("Loading…")); |
4781 | 52 | } | 48 | } |
4782 | @@ -63,7 +59,7 @@ | |||
4783 | 63 | label_center_.x = get_w() / 2; | 59 | label_center_.x = get_w() / 2; |
4784 | 64 | label_center_.y = get_h() * PROGRESS_LABEL_POSITION_Y / 100; | 60 | label_center_.y = get_h() * PROGRESS_LABEL_POSITION_Y / 100; |
4785 | 65 | 61 | ||
4787 | 66 | const uint32_t h = text_height(); | 62 | const uint32_t h = text_height(style_.font()); |
4788 | 67 | 63 | ||
4789 | 68 | label_rectangle_.x = get_w() / 4; | 64 | label_rectangle_.x = get_w() / 4; |
4790 | 69 | label_rectangle_.w = get_w() / 2; | 65 | label_rectangle_.w = get_w() / 2; |
4791 | @@ -76,7 +72,9 @@ | |||
4792 | 76 | border_rect.w += 2 * PROGRESS_STATUS_BORDER_X; | 72 | border_rect.w += 2 * PROGRESS_STATUS_BORDER_X; |
4793 | 77 | border_rect.h += 2 * PROGRESS_STATUS_BORDER_Y; | 73 | border_rect.h += 2 * PROGRESS_STATUS_BORDER_Y; |
4794 | 78 | 74 | ||
4796 | 79 | rt.draw_rect(border_rect, PROGRESS_FONT_COLOR_FG); | 75 | rt.draw_rect(border_rect, style_.font().color()); |
4797 | 76 | // TODO(GunChleoc): this should depend on actual progress. Add a total steps variable and reuse the Progressbar class. | ||
4798 | 77 | rt.fill_rect(label_rectangle_, style_.medium_color()); | ||
4799 | 80 | } | 78 | } |
4800 | 81 | 79 | ||
4801 | 82 | /// Set a picture to render in the background | 80 | /// Set a picture to render in the background |
4802 | @@ -97,9 +95,8 @@ | |||
4803 | 97 | // always repaint the background first | 95 | // always repaint the background first |
4804 | 98 | draw(rt); | 96 | draw(rt); |
4805 | 99 | 97 | ||
4806 | 100 | rt.fill_rect(label_rectangle_, PROGRESS_FONT_COLOR_BG); | ||
4807 | 101 | std::shared_ptr<const UI::RenderedText> rendered_text = | 98 | std::shared_ptr<const UI::RenderedText> rendered_text = |
4809 | 102 | UI::g_fh->render(as_uifont(description, UI_FONT_SIZE_SMALL, PROGRESS_FONT_COLOR_FG)); | 99 | UI::g_fh->render(as_richtext_paragraph(description, style_.font())); |
4810 | 103 | UI::center_vertically(rendered_text->height(), &label_center_); | 100 | UI::center_vertically(rendered_text->height(), &label_center_); |
4811 | 104 | rendered_text->draw(rt, label_center_, UI::Align::kCenter); | 101 | rendered_text->draw(rt, label_center_, UI::Align::kCenter); |
4812 | 105 | 102 | ||
4813 | 106 | 103 | ||
4814 | === modified file 'src/ui_basic/progresswindow.h' | |||
4815 | --- src/ui_basic/progresswindow.h 2019-02-23 11:00:49 +0000 | |||
4816 | +++ src/ui_basic/progresswindow.h 2019-05-26 02:00:17 +0000 | |||
4817 | @@ -67,6 +67,7 @@ | |||
4818 | 67 | Recti label_rectangle_; | 67 | Recti label_rectangle_; |
4819 | 68 | VisualizationArray visualizations_; | 68 | VisualizationArray visualizations_; |
4820 | 69 | std::string background_; | 69 | std::string background_; |
4821 | 70 | const UI::ProgressbarStyleInfo& style_; | ||
4822 | 70 | 71 | ||
4823 | 71 | void draw(RenderTarget&) override; | 72 | void draw(RenderTarget&) override; |
4824 | 72 | void update(bool repaint); | 73 | void update(bool repaint); |
4825 | 73 | 74 | ||
4826 | === modified file 'src/ui_basic/slider.cc' | |||
4827 | --- src/ui_basic/slider.cc 2019-03-16 07:46:10 +0000 | |||
4828 | +++ src/ui_basic/slider.cc 2019-05-26 02:00:17 +0000 | |||
4829 | @@ -72,7 +72,7 @@ | |||
4830 | 72 | highlighted_(false), | 72 | highlighted_(false), |
4831 | 73 | pressed_(false), | 73 | pressed_(false), |
4832 | 74 | enabled_(enabled), | 74 | enabled_(enabled), |
4834 | 75 | cursor_style_(g_gr->styles().slider_style(style)), | 75 | cursor_style_(&g_gr->styles().slider_style(style).background()), |
4835 | 76 | x_gap_(x_gap), | 76 | x_gap_(x_gap), |
4836 | 77 | y_gap_(y_gap), | 77 | y_gap_(y_gap), |
4837 | 78 | bar_size_(bar_size), | 78 | bar_size_(bar_size), |
4838 | @@ -487,22 +487,23 @@ | |||
4839 | 487 | const uint32_t w, | 487 | const uint32_t w, |
4840 | 488 | const uint32_t h, | 488 | const uint32_t h, |
4841 | 489 | const std::vector<std::string>& labels_in, | 489 | const std::vector<std::string>& labels_in, |
4844 | 490 | uint32_t value_, | 490 | uint32_t init_value, |
4845 | 491 | SliderStyle style, | 491 | SliderStyle init_style, |
4846 | 492 | const std::string& tooltip_text, | 492 | const std::string& tooltip_text, |
4847 | 493 | const uint32_t cursor_size, | 493 | const uint32_t cursor_size, |
4848 | 494 | const bool enabled) | 494 | const bool enabled) |
4849 | 495 | : Panel(parent, x, y, w, h, tooltip_text), | 495 | : Panel(parent, x, y, w, h, tooltip_text), |
4850 | 496 | style(g_gr->styles().slider_style(init_style)), | ||
4851 | 496 | slider(this, | 497 | slider(this, |
4852 | 497 | // here, we take into account the h_gap introduced by HorizontalSlider | 498 | // here, we take into account the h_gap introduced by HorizontalSlider |
4853 | 498 | w / (2 * labels_in.size()) - cursor_size / 2, | 499 | w / (2 * labels_in.size()) - cursor_size / 2, |
4854 | 499 | 0, | 500 | 0, |
4855 | 500 | w - (w / labels_in.size()) + cursor_size, | 501 | w - (w / labels_in.size()) + cursor_size, |
4857 | 501 | h - text_height(UI_FONT_SIZE_SMALL - 2, UI::FontSet::Face::kCondensed) - 2, | 502 | h - text_height(style.font()) - 2, |
4858 | 502 | 0, | 503 | 0, |
4859 | 503 | labels_in.size() - 1, | 504 | labels_in.size() - 1, |
4862 | 504 | value_, | 505 | init_value, |
4863 | 505 | style, | 506 | init_style, |
4864 | 506 | tooltip_text, | 507 | tooltip_text, |
4865 | 507 | cursor_size, | 508 | cursor_size, |
4866 | 508 | enabled), | 509 | enabled), |
4867 | @@ -524,7 +525,7 @@ | |||
4868 | 524 | 525 | ||
4869 | 525 | for (uint32_t i = 0; i < labels.size(); i++) { | 526 | for (uint32_t i = 0; i < labels.size(); i++) { |
4870 | 526 | std::shared_ptr<const UI::RenderedText> rendered_text = | 527 | std::shared_ptr<const UI::RenderedText> rendered_text = |
4872 | 527 | UI::g_fh->render(as_condensed(labels[i], UI::Align::kCenter, UI_FONT_SIZE_SMALL - 2)); | 528 | UI::g_fh->render(as_richtext_paragraph(labels[i], style.font())); |
4873 | 528 | rendered_text->draw( | 529 | rendered_text->draw( |
4874 | 529 | dst, Vector2i(gap_1 + i * gap_n, get_h() - rendered_text->height()), UI::Align::kCenter); | 530 | dst, Vector2i(gap_1 + i * gap_n, get_h() - rendered_text->height()), UI::Align::kCenter); |
4875 | 530 | } | 531 | } |
4876 | @@ -542,7 +543,7 @@ | |||
4877 | 542 | assert(labels.size()); | 543 | assert(labels.size()); |
4878 | 543 | slider.set_pos(Vector2i(w / (2 * labels.size()) - slider.cursor_size_ / 2, 0)); | 544 | slider.set_pos(Vector2i(w / (2 * labels.size()) - slider.cursor_size_ / 2, 0)); |
4879 | 544 | slider.set_size(w - (w / labels.size()) + slider.cursor_size_, | 545 | slider.set_size(w - (w / labels.size()) + slider.cursor_size_, |
4881 | 545 | h - text_height(UI_FONT_SIZE_SMALL - 2, UI::FontSet::Face::kCondensed) + 2); | 546 | h - text_height(style.font()) + 2); |
4882 | 546 | Panel::layout(); | 547 | Panel::layout(); |
4883 | 547 | } | 548 | } |
4884 | 548 | } // namespace UI | 549 | } // namespace UI |
4885 | 549 | 550 | ||
4886 | === modified file 'src/ui_basic/slider.h' | |||
4887 | --- src/ui_basic/slider.h 2019-03-16 07:28:07 +0000 | |||
4888 | +++ src/ui_basic/slider.h 2019-05-26 02:00:17 +0000 | |||
4889 | @@ -21,6 +21,7 @@ | |||
4890 | 21 | 21 | ||
4891 | 22 | #include <boost/signals2.hpp> | 22 | #include <boost/signals2.hpp> |
4892 | 23 | 23 | ||
4893 | 24 | #include "graphic/styles/text_panel_style.h" | ||
4894 | 24 | #include "ui_basic/panel.h" | 25 | #include "ui_basic/panel.h" |
4895 | 25 | 26 | ||
4896 | 26 | namespace UI { | 27 | namespace UI { |
4897 | @@ -236,6 +237,11 @@ | |||
4898 | 236 | void draw(RenderTarget& dst) override; | 237 | void draw(RenderTarget& dst) override; |
4899 | 237 | void layout() override; | 238 | void layout() override; |
4900 | 238 | 239 | ||
4901 | 240 | private: | ||
4902 | 241 | // We need the style to initialize the slider, so it has to come first. | ||
4903 | 242 | const UI::TextPanelStyleInfo& style; | ||
4904 | 243 | |||
4905 | 244 | protected: | ||
4906 | 239 | HorizontalSlider slider; | 245 | HorizontalSlider slider; |
4907 | 240 | 246 | ||
4908 | 241 | private: | 247 | private: |
4909 | 242 | 248 | ||
4910 | === modified file 'src/ui_basic/spinbox.cc' | |||
4911 | --- src/ui_basic/spinbox.cc 2019-02-23 11:00:49 +0000 | |||
4912 | +++ src/ui_basic/spinbox.cc 2019-05-26 02:00:17 +0000 | |||
4913 | @@ -31,7 +31,6 @@ | |||
4914 | 31 | #include "graphic/font_handler.h" | 31 | #include "graphic/font_handler.h" |
4915 | 32 | #include "graphic/graphic.h" | 32 | #include "graphic/graphic.h" |
4916 | 33 | #include "graphic/text/font_set.h" | 33 | #include "graphic/text/font_set.h" |
4917 | 34 | #include "graphic/text_constants.h" | ||
4918 | 35 | #include "ui_basic/button.h" | 34 | #include "ui_basic/button.h" |
4919 | 36 | #include "ui_basic/multilinetextarea.h" | 35 | #include "ui_basic/multilinetextarea.h" |
4920 | 37 | #include "ui_basic/textarea.h" | 36 | #include "ui_basic/textarea.h" |
4921 | 38 | 37 | ||
4922 | === modified file 'src/ui_basic/table.cc' | |||
4923 | --- src/ui_basic/table.cc 2019-04-18 16:50:35 +0000 | |||
4924 | +++ src/ui_basic/table.cc 2019-05-26 02:00:17 +0000 | |||
4925 | @@ -22,14 +22,13 @@ | |||
4926 | 22 | #include <boost/bind.hpp> | 22 | #include <boost/bind.hpp> |
4927 | 23 | 23 | ||
4928 | 24 | #include "graphic/font_handler.h" | 24 | #include "graphic/font_handler.h" |
4929 | 25 | #include "graphic/graphic.h" | ||
4930 | 25 | #include "graphic/rendertarget.h" | 26 | #include "graphic/rendertarget.h" |
4931 | 26 | #include "graphic/text/bidi.h" | 27 | #include "graphic/text/bidi.h" |
4932 | 27 | #include "graphic/text/font_set.h" | 28 | #include "graphic/text/font_set.h" |
4933 | 28 | #include "graphic/text_constants.h" | ||
4934 | 29 | #include "graphic/text_layout.h" | 29 | #include "graphic/text_layout.h" |
4935 | 30 | #include "graphic/texture.h" | 30 | #include "graphic/texture.h" |
4936 | 31 | #include "ui_basic/mouse_constants.h" | 31 | #include "ui_basic/mouse_constants.h" |
4937 | 32 | #include "ui_basic/scrollbar.h" | ||
4938 | 33 | 32 | ||
4939 | 34 | namespace UI { | 33 | namespace UI { |
4940 | 35 | 34 | ||
4941 | @@ -49,8 +48,9 @@ | |||
4942 | 49 | TableRows rowtype) | 48 | TableRows rowtype) |
4943 | 50 | : Panel(parent, x, y, w, h), | 49 | : Panel(parent, x, y, w, h), |
4944 | 51 | total_width_(0), | 50 | total_width_(0), |
4947 | 52 | headerheight_(text_height() + 4), | 51 | lineheight_(text_height(g_gr->styles().table_style(style).enabled())), |
4948 | 53 | lineheight_(text_height()), | 52 | headerheight_(lineheight_ + 4), |
4949 | 53 | style_(style), | ||
4950 | 54 | button_style_(style == UI::PanelStyle::kFsMenu ? UI::ButtonStyle::kFsMenuMenu : | 54 | button_style_(style == UI::PanelStyle::kFsMenu ? UI::ButtonStyle::kFsMenuMenu : |
4951 | 55 | UI::ButtonStyle::kWuiSecondary), | 55 | UI::ButtonStyle::kWuiSecondary), |
4952 | 56 | scrollbar_(nullptr), | 56 | scrollbar_(nullptr), |
4953 | @@ -239,7 +239,7 @@ | |||
4954 | 239 | for (uint32_t i = 0, curx = 0; i < nr_columns; ++i) { | 239 | for (uint32_t i = 0, curx = 0; i < nr_columns; ++i) { |
4955 | 240 | const Column& column = columns_[i]; | 240 | const Column& column = columns_[i]; |
4956 | 241 | const int curw = column.width; | 241 | const int curw = column.width; |
4958 | 242 | Align alignment = mirror_alignment(column.alignment); | 242 | Align alignment = mirror_alignment(column.alignment, g_fh->fontset()->is_rtl()); |
4959 | 243 | 243 | ||
4960 | 244 | const Image* entry_picture = er.get_picture(i); | 244 | const Image* entry_picture = er.get_picture(i); |
4961 | 245 | const std::string& entry_string = er.get_string(i); | 245 | const std::string& entry_string = er.get_string(i); |
4962 | @@ -300,12 +300,19 @@ | |||
4963 | 300 | curx += curw; | 300 | curx += curw; |
4964 | 301 | continue; | 301 | continue; |
4965 | 302 | } | 302 | } |
4968 | 303 | std::shared_ptr<const UI::RenderedText> rendered_text = UI::g_fh->render( | 303 | |
4969 | 304 | as_uifont(richtext_escape(entry_string), UI_FONT_SIZE_SMALL, er.get_color())); | 304 | const UI::FontStyleInfo& font_style = |
4970 | 305 | er.font_style() != nullptr ? | ||
4971 | 306 | *er.font_style() : | ||
4972 | 307 | er.is_disabled() ? | ||
4973 | 308 | g_gr->styles().table_style(style_).disabled() : | ||
4974 | 309 | g_gr->styles().table_style(style_).enabled(); | ||
4975 | 310 | std::shared_ptr<const UI::RenderedText> rendered_text = | ||
4976 | 311 | UI::g_fh->render(as_richtext_paragraph(richtext_escape(entry_string), font_style)); | ||
4977 | 305 | 312 | ||
4978 | 306 | // Fix text alignment for BiDi languages if the entry contains an RTL character. We want | 313 | // Fix text alignment for BiDi languages if the entry contains an RTL character. We want |
4979 | 307 | // this always on, e.g. for mixed language savegame filenames. | 314 | // this always on, e.g. for mixed language savegame filenames. |
4981 | 308 | alignment = mirror_alignment(column.alignment, entry_string); | 315 | alignment = mirror_alignment(column.alignment, i18n::has_rtl_character(entry_string.c_str(), 20)); |
4982 | 309 | 316 | ||
4983 | 310 | // Position the text according to alignment | 317 | // Position the text according to alignment |
4984 | 311 | switch (alignment) { | 318 | switch (alignment) { |
4985 | @@ -718,7 +725,7 @@ | |||
4986 | 718 | return ea.get_string(column) < eb.get_string(column); | 725 | return ea.get_string(column) < eb.get_string(column); |
4987 | 719 | } | 726 | } |
4988 | 720 | 727 | ||
4990 | 721 | Table<void*>::EntryRecord::EntryRecord(void* const e) : entry_(e), clr(UI_FONT_CLR_FG) { | 728 | Table<void*>::EntryRecord::EntryRecord(void* const e) : entry_(e), font_style_(nullptr), disabled_(false) { |
4991 | 722 | } | 729 | } |
4992 | 723 | 730 | ||
4993 | 724 | void Table<void*>::EntryRecord::set_picture(uint8_t const col, | 731 | void Table<void*>::EntryRecord::set_picture(uint8_t const col, |
4994 | 725 | 732 | ||
4995 | === modified file 'src/ui_basic/table.h' | |||
4996 | --- src/ui_basic/table.h 2019-04-18 16:50:35 +0000 | |||
4997 | +++ src/ui_basic/table.h 2019-05-26 02:00:17 +0000 | |||
4998 | @@ -29,12 +29,12 @@ | |||
4999 | 29 | 29 | ||
5000 | 30 | #include "graphic/align.h" | 30 | #include "graphic/align.h" |
Continuous integration builds have changed state:
Travis build 4882. State: passed. Details: https:/ /travis- ci.org/ widelands/ widelands/ builds/ 528138938. /ci.appveyor. com/project/ widelands- dev/widelands/ build/_ widelands_ dev_widelands_ font_size_ lua-4663.
Appveyor build 4663. State: success. Details: https:/