Support custom checkbox symbols. Add a crossed variant to C&C. Correctly copies checkbox state when copying checkboxes.
This commit is contained in:
@@ -17,20 +17,30 @@ namespace OpenRA.Widgets
|
||||
{
|
||||
public class CheckboxWidget : ButtonWidget
|
||||
{
|
||||
public string CheckType = "checked";
|
||||
public Func<string> GetCheckType;
|
||||
public Func<bool> IsChecked = () => false;
|
||||
public int BaseLine = 1;
|
||||
public int CheckOffset = 2;
|
||||
public bool HasPressedState = ChromeMetrics.Get<bool>("CheckboxPressedState");
|
||||
|
||||
public CheckboxWidget()
|
||||
: base()
|
||||
{
|
||||
GetCheckType = () => CheckType;
|
||||
}
|
||||
|
||||
protected CheckboxWidget(CheckboxWidget widget)
|
||||
: base(widget)
|
||||
|
||||
protected CheckboxWidget(CheckboxWidget other)
|
||||
: base(other)
|
||||
{
|
||||
CheckType = other.CheckType;
|
||||
GetCheckType = other.GetCheckType;
|
||||
IsChecked = other.IsChecked;
|
||||
BaseLine = other.BaseLine;
|
||||
CheckOffset = other.CheckOffset;
|
||||
HasPressedState = other.HasPressedState;
|
||||
}
|
||||
|
||||
|
||||
public override void DrawInner()
|
||||
{
|
||||
var disabled = IsDisabled();
|
||||
@@ -49,9 +59,14 @@ namespace OpenRA.Widgets
|
||||
new float2(rect.Left + rect.Height * 1.5f, RenderOrigin.Y - BaseLine + (Bounds.Height - textSize.Y)/2), Color.White);
|
||||
|
||||
if (IsChecked() || (Depressed && HasPressedState && !disabled))
|
||||
WidgetUtils.DrawRGBA(
|
||||
ChromeProvider.GetImage("checkbox-bits", HasPressedState && (Depressed || disabled) ? "pressed" : "checked"),
|
||||
new float2(rect.Left + 2, rect.Top + 2));
|
||||
{
|
||||
var checkType = GetCheckType();
|
||||
if (HasPressedState && (Depressed || disabled))
|
||||
checkType += "-disabled";
|
||||
|
||||
var offset = new float2(rect.Left + CheckOffset, rect.Top + CheckOffset);
|
||||
WidgetUtils.DrawRGBA(ChromeProvider.GetImage("checkbox-bits", checkType), offset);
|
||||
}
|
||||
}
|
||||
|
||||
public override Widget Clone() { return new CheckboxWidget(this); }
|
||||
|
||||
@@ -54,22 +54,22 @@
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="1.2402344"
|
||||
inkscape:cx="237.05193"
|
||||
inkscape:cy="255.99995"
|
||||
inkscape:zoom="3.5079126"
|
||||
inkscape:cx="281.38029"
|
||||
inkscape:cy="461.49752"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="false"
|
||||
inkscape:window-width="1386"
|
||||
inkscape:window-height="856"
|
||||
inkscape:window-x="54"
|
||||
inkscape:window-y="22"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:window-x="77"
|
||||
inkscape:window-y="72"
|
||||
inkscape:window-maximized="1"
|
||||
showguides="true"
|
||||
inkscape:guide-bbox="true">
|
||||
<sodipodi:guide
|
||||
orientation="0,1"
|
||||
position="288.14601,448.3057"
|
||||
position="136.40591,448.05848"
|
||||
id="guide3073" />
|
||||
<sodipodi:guide
|
||||
orientation="0,1"
|
||||
@@ -92,7 +92,7 @@
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title />
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
@@ -673,5 +673,29 @@
|
||||
inkscape:export-filename="/Users/paul/src/OpenRA/mods/cnc/uibits/rect3776.png"
|
||||
inkscape:export-xdpi="90"
|
||||
inkscape:export-ydpi="90" />
|
||||
<path
|
||||
style="fill:#ffffff;fill-opacity:1;stroke:none"
|
||||
d="m 272,590.88925 2.527,-2.527 13.473,13.47264 -2.52704,2.52731 z"
|
||||
id="path3086"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="ccccc" />
|
||||
<path
|
||||
sodipodi:nodetypes="ccccc"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path3088"
|
||||
d="m 288,590.88925 -2.527,-2.527 -13.473,13.47264 2.52704,2.52731 z"
|
||||
style="fill:#ffffff;fill-opacity:1;stroke:none" />
|
||||
<path
|
||||
sodipodi:nodetypes="ccccc"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path3090"
|
||||
d="m 288,590.88925 2.527,-2.527 13.473,13.47264 -2.52704,2.52731 z"
|
||||
style="fill:#808080;fill-opacity:1;stroke:none" />
|
||||
<path
|
||||
style="fill:#808080;fill-opacity:1;stroke:none"
|
||||
d="m 304,590.88925 -2.527,-2.527 -13.473,13.47264 2.52704,2.52731 z"
|
||||
id="path3092"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="ccccc" />
|
||||
</g>
|
||||
</svg>
|
||||
|
||||
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 33 KiB |
@@ -359,7 +359,9 @@ spawnpoints: chrome.png
|
||||
|
||||
checkbox-bits: chrome.png
|
||||
checked: 288,16,16,16
|
||||
pressed: 288,32,16,16
|
||||
checked-disabled: 288,32,16,16
|
||||
crossed: 272,48,16,16
|
||||
crossed-disabled: 288,48,16,16
|
||||
|
||||
scrollbar: chrome.png
|
||||
down_arrow: 304,0,16,16
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 37 KiB |
Reference in New Issue
Block a user