Skip to content

Commit 2272de4

Browse files
committed
Fixed code generation still generating Blend assignments in Gum state setters if a skipped variable is defined in a base class
Added derived tests to testscreen
1 parent 3a49ab9 commit 2272de4

File tree

7 files changed

+330
-0
lines changed

7 files changed

+330
-0
lines changed

FRBDK/Glue/GumPlugin/GumPlugin/CodeGeneration/StateCodeGenerator.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,8 @@ private bool GetIfShouldGenerateStateVariable(Gum.DataTypes.Variables.VariableSa
494494
toReturn = false;
495495
}
496496

497+
498+
497499
if (toReturn && typeSpecificVariableNamesToSkipForStates.ContainsKey(container.Name))
498500
{
499501
var typeSpecificVariables = typeSpecificVariableNamesToSkipForStates[container.Name];
@@ -504,6 +506,21 @@ private bool GetIfShouldGenerateStateVariable(Gum.DataTypes.Variables.VariableSa
504506
}
505507
}
506508

509+
// check this and any of its base types:
510+
var baseTypes = ObjectFinder.Self.GetBaseElements(container);
511+
512+
foreach(var baseType in baseTypes)
513+
{
514+
if(toReturn && typeSpecificVariableNamesToSkipForStates.ContainsKey(baseType.Name))
515+
{
516+
var typeSpecificVariables = typeSpecificVariableNamesToSkipForStates[baseType.Name];
517+
if (typeSpecificVariables.Contains(variableRootName))
518+
{
519+
toReturn = false;
520+
}
521+
}
522+
}
523+
507524
bool hasSourceObject = !string.IsNullOrEmpty(variable.SourceObject);
508525

509526
if (toReturn && hasSourceObject)
Lines changed: 240 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,240 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<ComponentSave xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
3+
<Name>UserControlDerived</Name>
4+
<BaseType>DefaultForms/UserControl</BaseType>
5+
<State>
6+
<Name>Default</Name>
7+
<Variable>
8+
<Type>int</Type>
9+
<Name>Alpha</Name>
10+
<Value xsi:type="xsd:int">255</Value>
11+
<Category>Rendering</Category>
12+
<SetsValue>true</SetsValue>
13+
</Variable>
14+
<Variable>
15+
<Type>int</Type>
16+
<Name>AutoGridHorizontalCells</Name>
17+
<Value xsi:type="xsd:int">4</Value>
18+
<Category>Children</Category>
19+
<SetsValue>true</SetsValue>
20+
</Variable>
21+
<Variable>
22+
<Type>int</Type>
23+
<Name>AutoGridVerticalCells</Name>
24+
<Value xsi:type="xsd:int">4</Value>
25+
<Category>Children</Category>
26+
<SetsValue>true</SetsValue>
27+
</Variable>
28+
<Variable>
29+
<Type>Blend</Type>
30+
<Name>Blend</Name>
31+
<Value xsi:type="xsd:int">0</Value>
32+
<Category>Rendering</Category>
33+
<SetsValue>true</SetsValue>
34+
</Variable>
35+
<Variable>
36+
<Type>ChildrenLayout</Type>
37+
<Name>ChildrenLayout</Name>
38+
<Value xsi:type="xsd:int">0</Value>
39+
<Category>Children</Category>
40+
<SetsValue>true</SetsValue>
41+
</Variable>
42+
<Variable>
43+
<Type>bool</Type>
44+
<Name>ClipsChildren</Name>
45+
<Value xsi:type="xsd:boolean">false</Value>
46+
<Category>Children</Category>
47+
<SetsValue>true</SetsValue>
48+
</Variable>
49+
<Variable>
50+
<Type>string</Type>
51+
<Name>ContainedType</Name>
52+
<Category>Children</Category>
53+
<SetsValue>true</SetsValue>
54+
</Variable>
55+
<Variable>
56+
<Type>bool</Type>
57+
<Name>ExposeChildrenEvents</Name>
58+
<Value xsi:type="xsd:boolean">true</Value>
59+
<Category>Behavior</Category>
60+
<SetsValue>true</SetsValue>
61+
</Variable>
62+
<Variable>
63+
<Type>bool</Type>
64+
<Name>FlipHorizontal</Name>
65+
<Value xsi:type="xsd:boolean">false</Value>
66+
<Category>Flip and Rotation</Category>
67+
<SetsValue>true</SetsValue>
68+
</Variable>
69+
<Variable>
70+
<Type>bool</Type>
71+
<Name>HasEvents</Name>
72+
<Value xsi:type="xsd:boolean">true</Value>
73+
<Category>Behavior</Category>
74+
<SetsValue>true</SetsValue>
75+
</Variable>
76+
<Variable>
77+
<Type>float</Type>
78+
<Name>Height</Name>
79+
<Value xsi:type="xsd:float">150</Value>
80+
<Category>Dimensions</Category>
81+
<SetsValue>true</SetsValue>
82+
</Variable>
83+
<Variable>
84+
<Type>DimensionUnitType</Type>
85+
<Name>HeightUnits</Name>
86+
<Value xsi:type="xsd:int">0</Value>
87+
<Category>Dimensions</Category>
88+
<SetsValue>true</SetsValue>
89+
</Variable>
90+
<Variable>
91+
<Type>bool</Type>
92+
<Name>IgnoredByParentSize</Name>
93+
<Value xsi:type="xsd:boolean">false</Value>
94+
<Category>Parent</Category>
95+
<SetsValue>true</SetsValue>
96+
</Variable>
97+
<Variable>
98+
<Type>bool</Type>
99+
<Name>IsRenderTarget</Name>
100+
<Value xsi:type="xsd:boolean">false</Value>
101+
<Category>Rendering</Category>
102+
<SetsValue>true</SetsValue>
103+
</Variable>
104+
<Variable>
105+
<Type>float?</Type>
106+
<Name>MaxHeight</Name>
107+
<Category>Dimensions</Category>
108+
<SetsValue>true</SetsValue>
109+
</Variable>
110+
<Variable>
111+
<Type>float?</Type>
112+
<Name>MaxWidth</Name>
113+
<Category>Dimensions</Category>
114+
<SetsValue>true</SetsValue>
115+
</Variable>
116+
<Variable>
117+
<Type>float?</Type>
118+
<Name>MinHeight</Name>
119+
<Category>Dimensions</Category>
120+
<SetsValue>true</SetsValue>
121+
</Variable>
122+
<Variable>
123+
<Type>float?</Type>
124+
<Name>MinWidth</Name>
125+
<Category>Dimensions</Category>
126+
<SetsValue>true</SetsValue>
127+
</Variable>
128+
<Variable>
129+
<Type>string</Type>
130+
<Name>Parent</Name>
131+
<Category>Parent</Category>
132+
<SetsValue>true</SetsValue>
133+
</Variable>
134+
<Variable>
135+
<Type>float</Type>
136+
<Name>Rotation</Name>
137+
<Value xsi:type="xsd:float">0</Value>
138+
<Category>Flip and Rotation</Category>
139+
<SetsValue>true</SetsValue>
140+
</Variable>
141+
<Variable>
142+
<Type>float</Type>
143+
<Name>StackSpacing</Name>
144+
<Value xsi:type="xsd:float">0</Value>
145+
<Category>Children</Category>
146+
<SetsValue>true</SetsValue>
147+
</Variable>
148+
<Variable>
149+
<Type>State</Type>
150+
<Name>State</Name>
151+
<Value xsi:type="xsd:string">Default</Value>
152+
<Category>States and Visibility</Category>
153+
<SetsValue>false</SetsValue>
154+
</Variable>
155+
<Variable>
156+
<Type>bool</Type>
157+
<Name>Visible</Name>
158+
<Value xsi:type="xsd:boolean">true</Value>
159+
<Category>States and Visibility</Category>
160+
<SetsValue>true</SetsValue>
161+
</Variable>
162+
<Variable>
163+
<Type>float</Type>
164+
<Name>Width</Name>
165+
<Value xsi:type="xsd:float">150</Value>
166+
<Category>Dimensions</Category>
167+
<SetsValue>true</SetsValue>
168+
</Variable>
169+
<Variable>
170+
<Type>DimensionUnitType</Type>
171+
<Name>WidthUnits</Name>
172+
<Value xsi:type="xsd:int">0</Value>
173+
<Category>Dimensions</Category>
174+
<SetsValue>true</SetsValue>
175+
</Variable>
176+
<Variable>
177+
<Type>bool</Type>
178+
<Name>WrapsChildren</Name>
179+
<Value xsi:type="xsd:boolean">false</Value>
180+
<Category>Children</Category>
181+
<SetsValue>true</SetsValue>
182+
</Variable>
183+
<Variable>
184+
<Type>float</Type>
185+
<Name>X</Name>
186+
<Value xsi:type="xsd:float">0</Value>
187+
<Category>Position</Category>
188+
<SetsValue>true</SetsValue>
189+
</Variable>
190+
<Variable>
191+
<Type>HorizontalAlignment</Type>
192+
<Name>XOrigin</Name>
193+
<Value xsi:type="xsd:int">0</Value>
194+
<Category>Position</Category>
195+
<SetsValue>true</SetsValue>
196+
</Variable>
197+
<Variable>
198+
<Type>PositionUnitType</Type>
199+
<Name>XUnits</Name>
200+
<Value xsi:type="xsd:int">0</Value>
201+
<Category>Position</Category>
202+
<SetsValue>true</SetsValue>
203+
</Variable>
204+
<Variable>
205+
<Type>float</Type>
206+
<Name>Y</Name>
207+
<Value xsi:type="xsd:float">0</Value>
208+
<Category>Position</Category>
209+
<SetsValue>true</SetsValue>
210+
</Variable>
211+
<Variable>
212+
<Type>VerticalAlignment</Type>
213+
<Name>YOrigin</Name>
214+
<Value xsi:type="xsd:int">0</Value>
215+
<Category>Position</Category>
216+
<SetsValue>true</SetsValue>
217+
</Variable>
218+
<Variable>
219+
<Type>PositionUnitType</Type>
220+
<Name>YUnits</Name>
221+
<Value xsi:type="xsd:int">1</Value>
222+
<Category>Position</Category>
223+
<SetsValue>true</SetsValue>
224+
</Variable>
225+
<VariableList xsi:type="VariableListSaveOfString">
226+
<Type>string</Type>
227+
<Name>VariableReferences</Name>
228+
<Category>References</Category>
229+
<IsFile>false</IsFile>
230+
<IsHiddenInPropertyGrid>false</IsHiddenInPropertyGrid>
231+
<Value />
232+
</VariableList>
233+
</State>
234+
<Instance>
235+
<Name>ColoredFrameInstance</Name>
236+
<BaseType>DefaultForms/ColoredFrame</BaseType>
237+
<DefinedByBase>true</DefinedByBase>
238+
</Instance>
239+
<Behaviors />
240+
</ComponentSave>

Tests/TestProjectDesktopNet6/TestProjectDesktopNet6/Content/GumProject/GumProject.gumx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,11 @@
339339
<ElementType>Component</ElementType>
340340
<LinkType>ReferenceOriginal</LinkType>
341341
</ComponentReference>
342+
<ComponentReference>
343+
<Name>UserControlDerived</Name>
344+
<ElementType>Component</ElementType>
345+
<LinkType>ReferenceOriginal</LinkType>
346+
</ComponentReference>
342347
<StandardElementReference>
343348
<Name>Arc</Name>
344349
<ElementType>Standard</ElementType>

Tests/TestProjectDesktopNet6/TestProjectDesktopNet6/Content/GumProject/Screens/FormsScreenGum.gusx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,30 @@
177177
<Value xsi:type="xsd:float">289</Value>
178178
<SetsValue>true</SetsValue>
179179
</Variable>
180+
<Variable>
181+
<Type>float</Type>
182+
<Name>UserControlDerivedInstance.Height</Name>
183+
<Value xsi:type="xsd:float">123</Value>
184+
<SetsValue>true</SetsValue>
185+
</Variable>
186+
<Variable>
187+
<Type>float</Type>
188+
<Name>UserControlDerivedInstance.Width</Name>
189+
<Value xsi:type="xsd:float">113</Value>
190+
<SetsValue>true</SetsValue>
191+
</Variable>
192+
<Variable>
193+
<Type>float</Type>
194+
<Name>UserControlDerivedInstance.X</Name>
195+
<Value xsi:type="xsd:float">176</Value>
196+
<SetsValue>true</SetsValue>
197+
</Variable>
198+
<Variable>
199+
<Type>float</Type>
200+
<Name>UserControlDerivedInstance.Y</Name>
201+
<Value xsi:type="xsd:float">72</Value>
202+
<SetsValue>true</SetsValue>
203+
</Variable>
180204
<Variable>
181205
<Type>float</Type>
182206
<Name>UserControlInstance.X</Name>
@@ -279,5 +303,10 @@
279303
<BaseType>DefaultForms/TextBox</BaseType>
280304
<DefinedByBase>false</DefinedByBase>
281305
</Instance>
306+
<Instance>
307+
<Name>UserControlDerivedInstance</Name>
308+
<BaseType>UserControlDerived</BaseType>
309+
<DefinedByBase>false</DefinedByBase>
310+
</Instance>
282311
<Behaviors />
283312
</ScreenSave>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
5+
namespace GlueTestProject.GumRuntimes
6+
{
7+
public partial class UserControlDerivedRuntime
8+
{
9+
partial void CustomInitialize ()
10+
{
11+
}
12+
}
13+
}

Tests/TestProjectDesktopNet6/TestProjectDesktopNet6/Screens/FormsScreen.glsj

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,24 @@
1212
"ProjectsToExcludeFrom": []
1313
}
1414
],
15+
"CustomVariables": [
16+
{
17+
"Properties": [
18+
{
19+
"Name": "Type",
20+
"Value": "string",
21+
"Type": "String"
22+
},
23+
{
24+
"Name": "Category",
25+
"Value": "Layer",
26+
"Type": "String"
27+
}
28+
],
29+
"Name": "DefaultLayer",
30+
"Category": "Layer"
31+
}
32+
],
1533
"Name": "Screens\\FormsScreen",
1634
"CustomClassesForExport": []
1735
}

Tests/TestProjectDesktopNet6/TestProjectDesktopNet6/TestProjectDesktopNet6.csproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,10 @@
722722
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
723723
<Name>UsedToInheritFromTextComponent</Name>
724724
</None>
725+
<None Include="Content\GumProject\Components\UserControlDerived.gucx">
726+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
727+
<Name>UserControlDerived</Name>
728+
</None>
725729
<None Include="Content\GumProject\FontCache\Font14Arial.fnt">
726730
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
727731
<Name>Font14Arial</Name>
@@ -2357,6 +2361,10 @@
23572361
<Compile Include="GumRuntimes\UsedToInheritFromTextComponentRuntime.Generated.cs">
23582362
<DependentUpon>UsedToInheritFromTextComponentRuntime.cs</DependentUpon>
23592363
</Compile>
2364+
<Compile Include="GumRuntimes\UserControlDerivedRuntime.cs" />
2365+
<Compile Include="GumRuntimes\UserControlDerivedRuntime.Generated.cs">
2366+
<DependentUpon>UserControlDerivedRuntime.cs</DependentUpon>
2367+
</Compile>
23602368
<Compile Include="GumRuntimes\VariantScreenGumRuntime.cs" />
23612369
<Compile Include="GumRuntimes\VariantScreenGumRuntime.Generated.cs">
23622370
<DependentUpon>VariantScreenGumRuntime.cs</DependentUpon>

0 commit comments

Comments
 (0)