Fix lobby color picker
This commit is contained in:
@@ -25,7 +25,7 @@ namespace OpenRA.Widgets
|
|||||||
private float Offset = 0;
|
private float Offset = 0;
|
||||||
|
|
||||||
int2 lastMouseLocation;
|
int2 lastMouseLocation;
|
||||||
bool isMoving = false;
|
protected bool isMoving = false;
|
||||||
|
|
||||||
public SliderWidget()
|
public SliderWidget()
|
||||||
: base()
|
: base()
|
||||||
@@ -159,7 +159,7 @@ namespace OpenRA.Widgets
|
|||||||
|
|
||||||
public override Widget Clone() { return new SliderWidget(this); }
|
public override Widget Clone() { return new SliderWidget(this); }
|
||||||
|
|
||||||
Rectangle thumbRect
|
protected Rectangle thumbRect
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
|||||||
48
OpenRA.Mods.Cnc/CncColorPickerPaletteModifier.cs
Normal file
48
OpenRA.Mods.Cnc/CncColorPickerPaletteModifier.cs
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
#region Copyright & License Information
|
||||||
|
/*
|
||||||
|
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||||
|
* This file is part of OpenRA, which is free software. It is made
|
||||||
|
* available to you under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation. For more information,
|
||||||
|
* see COPYING.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using OpenRA.FileFormats;
|
||||||
|
using OpenRA.Graphics;
|
||||||
|
using OpenRA.Mods.Cnc.Widgets;
|
||||||
|
using OpenRA.Traits;
|
||||||
|
|
||||||
|
namespace OpenRA.Mods.Cnc
|
||||||
|
{
|
||||||
|
class CncColorPickerPaletteModifierInfo : ITraitInfo
|
||||||
|
{
|
||||||
|
public string PlayerPalette = "player";
|
||||||
|
public object Create( ActorInitializer init ) { return new CncColorPickerPaletteModifier( this ); }
|
||||||
|
}
|
||||||
|
|
||||||
|
class CncColorPickerPaletteModifier : IPalette, IPaletteModifier
|
||||||
|
{
|
||||||
|
CncColorPickerPaletteModifierInfo Info;
|
||||||
|
PaletteFormat format;
|
||||||
|
|
||||||
|
public CncColorPickerPaletteModifier(CncColorPickerPaletteModifierInfo info) { Info = info; }
|
||||||
|
|
||||||
|
public void InitPalette( WorldRenderer wr )
|
||||||
|
{
|
||||||
|
var info = Rules.Info["player"].Traits.WithInterface<PlayerColorPaletteInfo>()
|
||||||
|
.Where(p => p.BaseName == Info.PlayerPalette)
|
||||||
|
.First();
|
||||||
|
format = info.PaletteFormat;
|
||||||
|
wr.AddPalette("colorpicker", wr.GetPalette(info.BasePalette));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AdjustPalette(Dictionary<string, Palette> palettes)
|
||||||
|
{
|
||||||
|
palettes["colorpicker"] = new Palette(palettes["colorpicker"],
|
||||||
|
new PlayerColorRemap(CncLobbyLogic.CurrentColorPreview, format));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -81,6 +81,7 @@
|
|||||||
<Compile Include="Widgets\CncIngameChromeLogic.cs" />
|
<Compile Include="Widgets\CncIngameChromeLogic.cs" />
|
||||||
<Compile Include="Widgets\CncInstallLogic.cs" />
|
<Compile Include="Widgets\CncInstallLogic.cs" />
|
||||||
<Compile Include="Widgets\CncMusicPlayerLogic.cs" />
|
<Compile Include="Widgets\CncMusicPlayerLogic.cs" />
|
||||||
|
<Compile Include="CncColorPickerPaletteModifier.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
||||||
|
|||||||
@@ -229,5 +229,45 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
|
|
||||||
public override Widget Clone() { return new CncTextFieldWidget(this); }
|
public override Widget Clone() { return new CncTextFieldWidget(this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class CncSliderWidget : SliderWidget
|
||||||
|
{
|
||||||
|
public Func<bool> IsDisabled = () => false;
|
||||||
|
|
||||||
|
public CncSliderWidget() : base() { }
|
||||||
|
public CncSliderWidget(CncSliderWidget other) : base(other) { }
|
||||||
|
|
||||||
|
|
||||||
|
public override Widget Clone() { return new CncSliderWidget(this); }
|
||||||
|
public override void DrawInner()
|
||||||
|
{
|
||||||
|
if (!IsVisible())
|
||||||
|
return;
|
||||||
|
|
||||||
|
var tr = thumbRect;
|
||||||
|
var trackWidth = RenderBounds.Width - tr.Width;
|
||||||
|
var trackOrigin = RenderBounds.X + tr.Width / 2;
|
||||||
|
var trackRect = new Rectangle(trackOrigin - 1, RenderBounds.Y + (RenderBounds.Height - TrackHeight) / 2, trackWidth + 2, TrackHeight);
|
||||||
|
|
||||||
|
// Tickmarks (hacked until we have real art)
|
||||||
|
for (int i = 0; i < Ticks; i++)
|
||||||
|
{
|
||||||
|
var tickRect = new Rectangle(trackOrigin - 1 + (int)(i * trackWidth * 1f / (Ticks - 1)),
|
||||||
|
RenderBounds.Y + RenderBounds.Height / 2, 2, RenderBounds.Height / 2);
|
||||||
|
WidgetUtils.DrawPanel("button-hover", tickRect);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Track
|
||||||
|
WidgetUtils.DrawPanel("button-pressed", trackRect);
|
||||||
|
|
||||||
|
// Thumb
|
||||||
|
var state = IsDisabled() ? "button-disabled" :
|
||||||
|
isMoving ? "button-pressed" :
|
||||||
|
tr.Contains(Viewport.LastMousePos) ? "button-hover" :
|
||||||
|
"button";
|
||||||
|
|
||||||
|
WidgetUtils.DrawPanel(state, tr);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -380,14 +380,14 @@ Container@SERVER_LOBBY:
|
|||||||
Text:Start Game
|
Text:Start Game
|
||||||
Background@COLOR_CHOOSER:
|
Background@COLOR_CHOOSER:
|
||||||
Id:COLOR_CHOOSER
|
Id:COLOR_CHOOSER
|
||||||
Background:dialog2
|
Background:panel-black
|
||||||
Width:310
|
Width:315
|
||||||
Height:120
|
Height:120
|
||||||
Children:
|
Children:
|
||||||
Button@BUTTON_OK:
|
CncMenuButton@BUTTON_OK:
|
||||||
Id:BUTTON_OK
|
Id:BUTTON_OK
|
||||||
X:210
|
X:210
|
||||||
Y:85
|
Y:80
|
||||||
Width:90
|
Width:90
|
||||||
Height:25
|
Height:25
|
||||||
Text:Ok
|
Text:Ok
|
||||||
@@ -395,17 +395,18 @@ Background@COLOR_CHOOSER:
|
|||||||
ShpImage@FACT:
|
ShpImage@FACT:
|
||||||
Id:FACT
|
Id:FACT
|
||||||
X:220
|
X:220
|
||||||
Y:10
|
Y:15
|
||||||
Image:fact
|
Image:fact
|
||||||
Palette:colorpicker
|
Palette:colorpicker
|
||||||
Label@HUE_LABEL:
|
Label@HUE_LABEL:
|
||||||
X:0
|
X:5
|
||||||
Y:5
|
Y:5
|
||||||
Width:40
|
Width:40
|
||||||
Height:20
|
Height:20
|
||||||
Align:Right
|
Align:Right
|
||||||
Text:Hue:
|
Text:Hue:
|
||||||
Slider@HUE:
|
Font:Bold
|
||||||
|
CncSlider@HUE:
|
||||||
Id:HUE_SLIDER
|
Id:HUE_SLIDER
|
||||||
X:43
|
X:43
|
||||||
Y:10
|
Y:10
|
||||||
@@ -413,13 +414,14 @@ Background@COLOR_CHOOSER:
|
|||||||
Height:20
|
Height:20
|
||||||
Ticks:5
|
Ticks:5
|
||||||
Label@SAT_LABEL:
|
Label@SAT_LABEL:
|
||||||
X:0
|
X:5
|
||||||
Y:30
|
Y:30
|
||||||
Width:40
|
Width:40
|
||||||
Height:20
|
Height:20
|
||||||
Align:Right
|
Align:Right
|
||||||
Text:Sat:
|
Text:Sat:
|
||||||
Slider@SAT:
|
Font:Bold
|
||||||
|
CncSlider@SAT:
|
||||||
Id:SAT_SLIDER
|
Id:SAT_SLIDER
|
||||||
X:43
|
X:43
|
||||||
Y:35
|
Y:35
|
||||||
@@ -427,13 +429,14 @@ Background@COLOR_CHOOSER:
|
|||||||
Height:20
|
Height:20
|
||||||
Ticks:5
|
Ticks:5
|
||||||
Label@LUM_LABEL:
|
Label@LUM_LABEL:
|
||||||
X:0
|
X:5
|
||||||
Y:55
|
Y:55
|
||||||
Width:40
|
Width:40
|
||||||
Height:20
|
Height:20
|
||||||
Align:Right
|
Align:Right
|
||||||
Text:Lum:
|
Text:Lum:
|
||||||
Slider@LUM:
|
Font:Bold
|
||||||
|
CncSlider@LUM:
|
||||||
Id:LUM_SLIDER
|
Id:LUM_SLIDER
|
||||||
X:43
|
X:43
|
||||||
Y:60
|
Y:60
|
||||||
@@ -442,13 +445,14 @@ Background@COLOR_CHOOSER:
|
|||||||
Ticks:5
|
Ticks:5
|
||||||
Range:0.2,1
|
Range:0.2,1
|
||||||
Label@RANGE_LABEL:
|
Label@RANGE_LABEL:
|
||||||
X:0
|
X:5
|
||||||
Y:80
|
Y:80
|
||||||
Width:40
|
Width:40
|
||||||
Height:20
|
Height:20
|
||||||
Align:Right
|
Align:Right
|
||||||
Text:Ran:
|
Text:Ran:
|
||||||
Slider@RANGE:
|
Font:Bold
|
||||||
|
CncSlider@RANGE:
|
||||||
Id:RANGE_SLIDER
|
Id:RANGE_SLIDER
|
||||||
X:43
|
X:43
|
||||||
Y:85
|
Y:85
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ World:
|
|||||||
G: 0
|
G: 0
|
||||||
B: 0
|
B: 0
|
||||||
A: 180
|
A: 180
|
||||||
ColorPickerPaletteModifier:
|
CncColorPickerPaletteModifier:
|
||||||
ShroudPalette@shroud:
|
ShroudPalette@shroud:
|
||||||
ShroudPalette@fog:
|
ShroudPalette@fog:
|
||||||
IsFog: yes
|
IsFog: yes
|
||||||
|
|||||||
Reference in New Issue
Block a user