Color picker panel; sliders don't work yet

This commit is contained in:
Paul Chote
2010-07-16 21:54:35 +12:00
parent 8abc8e03cb
commit 44e1b8311f
5 changed files with 192 additions and 2 deletions

View File

@@ -231,6 +231,7 @@
<Compile Include="Widgets\ListBoxWidget.cs" />
<Compile Include="Widgets\SliderWidget.cs" />
<Compile Include="Widgets\TimerWidget.cs" />
<Compile Include="Widgets\ShpImageWidget.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">

View File

@@ -125,6 +125,12 @@ namespace OpenRA.Widgets.Delegates
return true;
};
var colorChooser = lobby.GetWidget("COLOR_CHOOSER");
colorChooser.GetWidget<ButtonWidget>("BUTTON_OK").OnMouseUp = mi =>
{
colorChooser.IsVisible = () => false;
return true;
};
}
void UpdateCurrentMap()
@@ -169,7 +175,11 @@ namespace OpenRA.Widgets.Delegates
name.OnLoseFocus = () => name.OnEnterKey();
var color = template.GetWidget<ButtonWidget>("COLOR");
//color.OnMouseUp = CyclePalette;
color.OnMouseUp = mi =>
{
Chrome.rootWidget.GetWidget("SERVER_LOBBY").GetWidget("COLOR_CHOOSER").IsVisible = () => true;
return true;
};
var colorBlock = color.GetWidget<ColorBlockWidget>("COLORBLOCK");
colorBlock.GetColor = () => c.Color;

View File

@@ -1,3 +1,22 @@
#region Copyright & License Information
/*
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
* This file is part of OpenRA.
*
* OpenRA is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenRA is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
*/
#endregion
using System;
using OpenRA.Graphics;

View File

@@ -0,0 +1,77 @@
#region Copyright & License Information
/*
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
* This file is part of OpenRA.
*
* OpenRA is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenRA is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
*/
#endregion
using System;
using OpenRA.Graphics;
namespace OpenRA.Widgets
{
public class ShpImageWidget : Widget
{
public string Image = "";
public int Frame = 0;
public string Palette = "chrome";
public Func<string> GetImage;
public Func<int> GetFrame;
public Func<string> GetPalette;
public ShpImageWidget()
: base()
{
GetImage = () => { return Image; };
GetFrame = () => { return Frame; };
GetPalette = () => { return Palette; };
}
protected ShpImageWidget(ShpImageWidget other)
: base(other)
{
Image = other.Image;
Frame = other.Frame;
Palette = other.Palette;
GetImage = other.GetImage;
GetFrame = other.GetFrame;
GetPalette = other.GetPalette;
}
public override Widget Clone() { return new ShpImageWidget(this); }
Sprite sprite = null;
string cachedImage = null;
int cachedFrame= -1;
public override void DrawInner(World world)
{
var image = GetImage();
var frame = GetFrame();
var palette = GetPalette();
if (image != cachedImage || frame != cachedFrame)
{
sprite = SpriteSheetBuilder.LoadAllSprites(image)[frame];
cachedImage = image;
cachedFrame = frame;
}
Game.chrome.renderer.WorldSpriteRenderer.DrawSprite(sprite,RenderOrigin, palette);
}
}
}

View File

@@ -251,6 +251,89 @@ Container@ROOT:
Width: 80
Height: 20
Text: Lock Teams
Background@COLOR_CHOOSER:
Id:COLOR_CHOOSER
Width:500
Height:195
X:(WINDOW_RIGHT - WIDTH)/2 - PARENT_LEFT
Y:100
Visible:false
Children:
Button@BUTTON_OK:
Id:BUTTON_OK
X:PARENT_RIGHT - 180
Y:PARENT_BOTTOM - 45
Width:160
Height:25
Text:Ok
Bold:True
ShpImage@MCV:
Id:MCV
X:PARENT_RIGHT - 90
Y:20
Image:mcv
Frame:8
ShpImage@FACT:
Id:FACT
X:PARENT_RIGHT - 100
Y:70
Image:fact
Label@HUE_LABEL:
X:0
Y:30
Width:110
Height:20
Align: Right
Text: Hue:
Slider@HUE:
Id:HUE_SLIDER
X:120
Y:30
Width:260
Height:20
Ticks:5
Label@SAT_LABEL:
X:0
Y:60
Width:110
Height:20
Align: Right
Text: Saturation:
Slider@SAT:
Id:SAT_SLIDER
X:120
Y:60
Width:260
Height:20
Ticks:5
Label@LUM_LABEL:
X:0
Y:90
Width:110
Height:20
Align: Right
Text: Brightness:
Slider@LUM:
Id:LUM_SLIDER
X:120
Y:90
Width:260
Height:20
Ticks:5
Label@RANGE_LABEL:
X:0
Y:120
Width:110
Height:20
Align: Right
Text: Range:
Slider@RANGE:
Id:RANGE_SLIDER
X:120
Y:120
Width:260
Height:20
Ticks:5
Background@MAP_CHOOSER:
Id:MAP_CHOOSER
X:(WINDOW_RIGHT - WIDTH)/2