Skip to content

Commit 27252df

Browse files
dragunoffPunkPun
authored andcommitted
Rename *_RIGHT to *_WIDTH and *_BOTTOM to *_HEIGHT in integer expressions for widgets
The terms "width" and "height" are clearer and they match what the values actually represent (window or parent width/height). The YAML changes are generated with the update rule.
1 parent bb17cfa commit 27252df

File tree

125 files changed

+3503
-3457
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+3503
-3457
lines changed

OpenRA.Game/Widgets/Widget.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,10 +290,10 @@ public virtual void Initialize(WidgetArgs args)
290290
new Dictionary<string, int>((Dictionary<string, int>)subs) :
291291
new Dictionary<string, int>();
292292

293-
substitutions.Add("WINDOW_RIGHT", Game.Renderer.Resolution.Width);
294-
substitutions.Add("WINDOW_BOTTOM", Game.Renderer.Resolution.Height);
295-
substitutions.Add("PARENT_RIGHT", parentBounds.Width);
296-
substitutions.Add("PARENT_BOTTOM", parentBounds.Height);
293+
substitutions.Add("WINDOW_WIDTH", Game.Renderer.Resolution.Width);
294+
substitutions.Add("WINDOW_HEIGHT", Game.Renderer.Resolution.Height);
295+
substitutions.Add("PARENT_WIDTH", parentBounds.Width);
296+
substitutions.Add("PARENT_HEIGHT", parentBounds.Height);
297297

298298
var readOnlySubstitutions = new ReadOnlyDictionary<string, int>(substitutions);
299299
var width = Width?.Evaluate(readOnlySubstitutions) ?? 0;
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#region Copyright & License Information
2+
/*
3+
* Copyright (c) The OpenRA Developers and Contributors
4+
* This file is part of OpenRA, which is free software. It is made
5+
* available to you under the terms of the GNU General Public License
6+
* as published by the Free Software Foundation, either version 3 of
7+
* the License, or (at your option) any later version. For more
8+
* information, see COPYING.
9+
*/
10+
#endregion
11+
12+
using System.Collections.Generic;
13+
using System.Linq;
14+
15+
namespace OpenRA.Mods.Common.UpdateRules.Rules
16+
{
17+
public class RenameWidgetSubstitutions : UpdateRule
18+
{
19+
public override string Name => "Rename *_RIGHT to *_WIDTH and *_BOTTOM to *_HEIGHT in integer expressions for widgets.";
20+
21+
public override string Description =>
22+
"PARENT_RIGHT -> PARENT_WIDTH, PARENT_BOTTOM -> PARENT_HEIGHT, " +
23+
"WINDOW_RIGHT -> WINDOW_WIDTH, WINDOW_BOTTOM -> WINDOW_HEIGHT " +
24+
"in integer expressions for width, height and position.";
25+
26+
public override IEnumerable<string> UpdateChromeNode(ModData modData, MiniYamlNodeBuilder chromeNode)
27+
{
28+
var dimensionFields =
29+
chromeNode.ChildrenMatching("Width")
30+
.Concat(chromeNode.ChildrenMatching("Height"))
31+
.Concat(chromeNode.ChildrenMatching("X"))
32+
.Concat(chromeNode.ChildrenMatching("Y")).ToArray();
33+
34+
foreach (var field in dimensionFields)
35+
{
36+
field.ReplaceValue(field.Value.Value.Replace("PARENT_RIGHT", "PARENT_WIDTH"));
37+
field.ReplaceValue(field.Value.Value.Replace("PARENT_BOTTOM", "PARENT_HEIGHT"));
38+
field.ReplaceValue(field.Value.Value.Replace("WINDOW_RIGHT", "WINDOW_WIDTH"));
39+
field.ReplaceValue(field.Value.Value.Replace("WINDOW_BOTTOM", "WINDOW_HEIGHT"));
40+
}
41+
42+
yield break;
43+
}
44+
}
45+
}

OpenRA.Mods.Common/UpdateRules/UpdatePath.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ public sealed class UpdatePath
9191
new MovePreviewFacing(),
9292
new RenameOnDeath(),
9393
new RemoveParentTopParentLeftSubstitutions(),
94+
new RenameWidgetSubstitutions(),
9495

9596
// Execute these rules last to avoid premature yaml merge crashes.
9697
new ReplaceCloakPalette(),

OpenRA.Mods.Common/Widgets/Logic/ServerListLogic.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ void ToggleFilterFlag(MPGameFilters f)
243243
{
244244
// HACK: MULTIPLAYER_FILTER_PANEL doesn't follow our normal procedure for dropdown creation
245245
// but we still need to be able to set the dropdown width based on the parent
246-
// The yaml should use PARENT_RIGHT instead of DROPDOWN_WIDTH
246+
// The yaml should use PARENT_WIDTH instead of DROPDOWN_WIDTH
247247
var filtersPanel = Ui.LoadWidget("MULTIPLAYER_FILTER_PANEL", filtersButton, new WidgetArgs());
248248
filtersButton.Children.Remove(filtersPanel);
249249

OpenRA.Mods.Common/Widgets/Logic/Settings/DisplaySettingsLogic.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -517,10 +517,10 @@ static void RecalculateWidgetLayout(Widget w, bool insideScrollPanel = false)
517517

518518
var substitutions = new Dictionary<string, int>
519519
{
520-
{ "WINDOW_RIGHT", Game.Renderer.Resolution.Width },
521-
{ "WINDOW_BOTTOM", Game.Renderer.Resolution.Height },
522-
{ "PARENT_RIGHT", parentBounds.Width },
523-
{ "PARENT_BOTTOM", parentBounds.Height }
520+
{ "WINDOW_WIDTH", Game.Renderer.Resolution.Width },
521+
{ "WINDOW_HEIGHT", Game.Renderer.Resolution.Height },
522+
{ "PARENT_WIDTH", parentBounds.Width },
523+
{ "PARENT_HEIGHT", parentBounds.Height }
524524
};
525525

526526
var readOnlySubstitutions = new ReadOnlyDictionary<string, int>(substitutions);

mods/cnc/chrome/assetbrowser.yaml

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
Container@ASSETBROWSER_PANEL:
22
Logic: AssetBrowserLogic
3-
X: (WINDOW_RIGHT - WIDTH) / 2
4-
Y: (WINDOW_BOTTOM - HEIGHT) / 2
3+
X: (WINDOW_WIDTH - WIDTH) / 2
4+
Y: (WINDOW_HEIGHT - HEIGHT) / 2
55
Width: 900
66
Height: 540
77
Children:
88
LogicTicker@ANIMATION_TICKER:
99
Label@ASSETBROWSER_TITLE:
10-
Width: PARENT_RIGHT
10+
Width: PARENT_WIDTH
1111
Height: 25
1212
Y: 0 - 34
1313
Font: BigBold
1414
Contrast: true
1515
Align: Center
1616
Text: label-assetbrowser-panel-title
1717
Background@bg:
18-
Width: PARENT_RIGHT
19-
Height: PARENT_BOTTOM
18+
Width: PARENT_WIDTH
19+
Height: PARENT_HEIGHT
2020
Background: panel-black
2121
Children:
2222
Label@SOURCE_SELECTOR_DESC:
@@ -59,86 +59,86 @@ Container@ASSETBROWSER_PANEL:
5959
X: 15
6060
Y: 155
6161
Width: 195
62-
Height: PARENT_BOTTOM - 205
62+
Height: PARENT_HEIGHT - 205
6363
CollapseHiddenChildren: True
6464
Children:
6565
ScrollItem@ASSET_TEMPLATE:
66-
Width: PARENT_RIGHT - 27
66+
Width: PARENT_WIDTH - 27
6767
Height: 25
6868
X: 2
6969
Visible: false
7070
EnableChildMouseOver: True
7171
Children:
7272
LabelWithTooltip@TITLE:
7373
X: 10
74-
Width: PARENT_RIGHT - 15
74+
Width: PARENT_WIDTH - 15
7575
Height: 25
7676
TooltipContainer: TOOLTIP_CONTAINER
7777
TooltipTemplate: SIMPLE_TOOLTIP
7878
Label@SPRITE_SCALE:
79-
X: PARENT_RIGHT - WIDTH - 440
79+
X: PARENT_WIDTH - WIDTH - 440
8080
Y: 31
8181
Width: 50
8282
Height: 25
8383
Font: Bold
8484
Align: Left
8585
Text: label-bg-sprite-scale
8686
Slider@SPRITE_SCALE_SLIDER:
87-
X: PARENT_RIGHT - WIDTH - 330
87+
X: PARENT_WIDTH - WIDTH - 330
8888
Y: 35
8989
Width: 100
9090
Height: 20
9191
MinimumValue: 0.5
9292
MaximumValue: 4
9393
Label@PALETTE_DESC:
94-
X: PARENT_RIGHT - WIDTH - 270
94+
X: PARENT_WIDTH - WIDTH - 270
9595
Y: 31
9696
Width: 150
9797
Height: 25
9898
Font: Bold
9999
Align: Right
100100
Text: label-bg-palette-desc
101101
DropDownButton@PALETTE_SELECTOR:
102-
X: PARENT_RIGHT - WIDTH - 110
102+
X: PARENT_WIDTH - WIDTH - 110
103103
Y: 30
104104
Width: 150
105105
Height: 25
106106
Font: Bold
107107
DropDownButton@COLOR:
108-
X: PARENT_RIGHT - WIDTH - 15
108+
X: PARENT_WIDTH - WIDTH - 15
109109
Y: 30
110110
Width: 80
111111
Height: 25
112112
Children:
113113
ColorBlock@COLORBLOCK:
114114
X: 5
115115
Y: 6
116-
Width: PARENT_RIGHT - 35
117-
Height: PARENT_BOTTOM - 12
116+
Width: PARENT_WIDTH - 35
117+
Height: PARENT_HEIGHT - 12
118118
Background@SPRITE_BG:
119119
X: 225
120120
Y: 65
121-
Width: PARENT_RIGHT - 195 - 45
122-
Height: PARENT_BOTTOM - 115
121+
Width: PARENT_WIDTH - 195 - 45
122+
Height: PARENT_HEIGHT - 115
123123
Background: scrollpanel-bg
124124
Children:
125125
Sprite@SPRITE:
126-
Width: PARENT_RIGHT
127-
Height: PARENT_BOTTOM
126+
Width: PARENT_WIDTH
127+
Height: PARENT_HEIGHT
128128
VideoPlayer@PLAYER:
129-
Width: PARENT_RIGHT
130-
Height: PARENT_BOTTOM
129+
Width: PARENT_WIDTH
130+
Height: PARENT_HEIGHT
131131
AspectRatio: 1
132132
Label@ERROR:
133-
Width: PARENT_RIGHT
134-
Height: PARENT_BOTTOM
133+
Width: PARENT_WIDTH
134+
Height: PARENT_HEIGHT
135135
Align: Center
136136
Visible: false
137137
Text: label-sprite-bg-error
138138
Container@FRAME_SELECTOR:
139139
X: 225
140-
Y: PARENT_BOTTOM - 40
141-
Width: PARENT_RIGHT - 225
140+
Y: PARENT_HEIGHT - 40
141+
Width: PARENT_WIDTH - 225
142142
Children:
143143
Button@BUTTON_PREV:
144144
Width: 26
@@ -208,19 +208,19 @@ Container@ASSETBROWSER_PANEL:
208208
Slider@FRAME_SLIDER:
209209
X: 140
210210
Y: 3
211-
Width: PARENT_RIGHT - 140 - 85
211+
Width: PARENT_WIDTH - 140 - 85
212212
Height: 20
213213
MinimumValue: 0
214214
Label@FRAME_COUNT:
215-
X: PARENT_RIGHT - WIDTH + 5
215+
X: PARENT_WIDTH - WIDTH + 5
216216
Y: 0
217217
Width: 80
218218
Height: 25
219219
Font: TinyBold
220220
Align: Left
221221
Button@CLOSE_BUTTON:
222222
Key: escape
223-
Y: PARENT_BOTTOM - 1
223+
Y: PARENT_HEIGHT - 1
224224
Width: 140
225225
Height: 35
226226
Text: button-back
@@ -235,5 +235,5 @@ ScrollPanel@ASSET_TYPES_PANEL:
235235
Checkbox@ASSET_TYPE_TEMPLATE:
236236
X: 5
237237
Y: 5
238-
Width: PARENT_RIGHT - 29
238+
Width: PARENT_WIDTH - 29
239239
Height: 20

mods/cnc/chrome/color-picker.yaml

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -29,78 +29,78 @@ Background@COLOR_CHOOSER:
2929
Animate: true
3030
Button@MIXER_TAB_BUTTON:
3131
X: 5
32-
Y: PARENT_BOTTOM - 30
32+
Y: PARENT_HEIGHT - 30
3333
Height: 25
3434
Width: 80
3535
Text: button-color-chooser-mixer-tab
3636
Font: Bold
3737
Button@PALETTE_TAB_BUTTON:
3838
X: 90
39-
Y: PARENT_BOTTOM - 30
39+
Y: PARENT_HEIGHT - 30
4040
Height: 25
4141
Width: 80
4242
Text: button-color-chooser-palette-tab
4343
Font: Bold
4444
Container@MIXER_TAB:
4545
X: 5
4646
Y: 5
47-
Width: PARENT_RIGHT - 91
48-
Height: PARENT_BOTTOM - 34
47+
Width: PARENT_WIDTH - 91
48+
Height: PARENT_HEIGHT - 34
4949
Children:
5050
Background@HUEBG:
5151
Background: panel-black
5252
X: 0
5353
Y: 0
54-
Width: PARENT_RIGHT
54+
Width: PARENT_WIDTH
5555
Height: 17
5656
Children:
5757
HueSlider@HUE_SLIDER:
5858
X: 2
5959
Y: 2
60-
Width: PARENT_RIGHT - 4
61-
Height: PARENT_BOTTOM - 4
60+
Width: PARENT_WIDTH - 4
61+
Height: PARENT_HEIGHT - 4
6262
Ticks: 5
6363
Background@MIXERBG:
6464
Background: panel-black
6565
X: 0
6666
Y: 21
67-
Width: PARENT_RIGHT
68-
Height: PARENT_BOTTOM - 21
67+
Width: PARENT_WIDTH
68+
Height: PARENT_HEIGHT - 21
6969
Children:
7070
ColorMixer@MIXER:
7171
X: 2
7272
Y: 2
73-
Width: PARENT_RIGHT - 4
74-
Height: PARENT_BOTTOM - 4
73+
Width: PARENT_WIDTH - 4
74+
Height: PARENT_HEIGHT - 4
7575
Background@PALETTE_TAB:
7676
Background: panel-black
7777
X: 5
7878
Y: 5
79-
Width: PARENT_RIGHT - 91
80-
Height: PARENT_BOTTOM - 34
79+
Width: PARENT_WIDTH - 91
80+
Height: PARENT_HEIGHT - 34
8181
Visible: false
8282
Children:
8383
Container@PALETTE_TAB_PANEL:
8484
X: 0
8585
Y: 0
86-
Width: PARENT_RIGHT
87-
Height: PARENT_BOTTOM
86+
Width: PARENT_WIDTH
87+
Height: PARENT_HEIGHT
8888
Children:
8989
Background@PRESET_HEADER:
9090
Background: panel-black
91-
Width: PARENT_RIGHT - 4
91+
Width: PARENT_WIDTH - 4
9292
Height: 13
9393
X: 2
9494
Y: 2
9595
Children:
9696
Label@LABEL:
9797
Font: TinyBold
98-
Width: PARENT_RIGHT
98+
Width: PARENT_WIDTH
9999
Height: 13
100100
Align: Center
101101
Text: label-preset-header
102102
Container@PRESET_AREA:
103-
Width: PARENT_RIGHT - 4
103+
Width: PARENT_WIDTH - 4
104104
Height: 58
105105
X: 2
106106
Y: 16
@@ -114,19 +114,19 @@ Background@COLOR_CHOOSER:
114114
ClickSound: ClickSound
115115
Background@CUSTOM_HEADER:
116116
Background: panel-black
117-
Width: PARENT_RIGHT - 4
117+
Width: PARENT_WIDTH - 4
118118
Height: 13
119119
X: 2
120120
Y: 71
121121
Children:
122122
Label@LABEL:
123123
Font: TinyBold
124-
Width: PARENT_RIGHT
124+
Width: PARENT_WIDTH
125125
Height: 13
126126
Align: Center
127127
Text: label-custom-header
128128
Container@CUSTOM_AREA:
129-
Width: PARENT_RIGHT - 4
129+
Width: PARENT_WIDTH - 4
130130
Height: 31
131131
X: 2
132132
Y: 85

0 commit comments

Comments
 (0)