mirror of
https://github.com/SourMesen/Mesen2.git
synced 2025-04-02 10:21:44 -04:00
GB palette config
This commit is contained in:
parent
7b0d9c5f31
commit
8a1ea20e98
5 changed files with 149 additions and 38 deletions
|
@ -18,18 +18,9 @@ namespace Mesen.GUI.Config
|
|||
|
||||
[Reactive] public RamState RamPowerOnState { get; set; } = RamState.Random;
|
||||
|
||||
[Reactive] public UInt32 BgColor0 { get; set; } = 0xFFFFFF;
|
||||
[Reactive] public UInt32 BgColor1 { get; set; } = 0xB0B0B0;
|
||||
[Reactive] public UInt32 BgColor2 { get; set; } = 0x686868;
|
||||
[Reactive] public UInt32 BgColor3 { get; set; } = 0x000000;
|
||||
[Reactive] public UInt32 Obj0Color0 { get; set; } = 0xFFFFFF;
|
||||
[Reactive] public UInt32 Obj0Color1 { get; set; } = 0xB0B0B0;
|
||||
[Reactive] public UInt32 Obj0Color2 { get; set; } = 0x686868;
|
||||
[Reactive] public UInt32 Obj0Color3 { get; set; } = 0x000000;
|
||||
[Reactive] public UInt32 Obj1Color0 { get; set; } = 0xFFFFFF;
|
||||
[Reactive] public UInt32 Obj1Color1 { get; set; } = 0xB0B0B0;
|
||||
[Reactive] public UInt32 Obj1Color2 { get; set; } = 0x686868;
|
||||
[Reactive] public UInt32 Obj1Color3 { get; set; } = 0x000000;
|
||||
[Reactive] public UInt32[] BgColors { get; set; } = new UInt32[] { 0xFFFFFFFF, 0xFFB0B0B0, 0xFF686868, 0xFF000000 };
|
||||
[Reactive] public UInt32[] Obj0Colors { get; set; } = new UInt32[] { 0xFFFFFFFF, 0xFFB0B0B0, 0xFF686868, 0xFF000000 };
|
||||
[Reactive] public UInt32[] Obj1Colors { get; set; } = new UInt32[] { 0xFFFFFFFF, 0xFFB0B0B0, 0xFF686868, 0xFF000000 };
|
||||
|
||||
[Reactive] public UInt32 Square1Vol { get; set; } = 100;
|
||||
[Reactive] public UInt32 Square2Vol { get; set; } = 100;
|
||||
|
@ -47,18 +38,9 @@ namespace Mesen.GUI.Config
|
|||
|
||||
RamPowerOnState = RamPowerOnState,
|
||||
|
||||
BgColor0 = BgColor0,
|
||||
BgColor1 = BgColor1,
|
||||
BgColor2 = BgColor2,
|
||||
BgColor3 = BgColor3,
|
||||
Obj0Color0 = Obj0Color0,
|
||||
Obj0Color1 = Obj0Color1,
|
||||
Obj0Color2 = Obj0Color2,
|
||||
Obj0Color3 = Obj0Color3,
|
||||
Obj1Color0 = Obj1Color0,
|
||||
Obj1Color1 = Obj1Color1,
|
||||
Obj1Color2 = Obj1Color2,
|
||||
Obj1Color3 = Obj1Color3,
|
||||
BgColors = BgColors,
|
||||
Obj0Colors = Obj0Colors,
|
||||
Obj1Colors = Obj1Colors,
|
||||
|
||||
Square1Vol = Square1Vol,
|
||||
Square2Vol = Square2Vol,
|
||||
|
@ -79,18 +61,14 @@ namespace Mesen.GUI.Config
|
|||
|
||||
public RamState RamPowerOnState;
|
||||
|
||||
public UInt32 BgColor0;
|
||||
public UInt32 BgColor1;
|
||||
public UInt32 BgColor2;
|
||||
public UInt32 BgColor3;
|
||||
public UInt32 Obj0Color0;
|
||||
public UInt32 Obj0Color1;
|
||||
public UInt32 Obj0Color2;
|
||||
public UInt32 Obj0Color3;
|
||||
public UInt32 Obj1Color0;
|
||||
public UInt32 Obj1Color1;
|
||||
public UInt32 Obj1Color2;
|
||||
public UInt32 Obj1Color3;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
public UInt32[] BgColors;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
public UInt32[] Obj0Colors;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
public UInt32[] Obj1Colors;
|
||||
|
||||
public UInt32 Square1Vol;
|
||||
public UInt32 Square2Vol;
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace Mesen.Debugger.Controls
|
|||
|
||||
public static readonly StyledProperty<PaletteSelectionMode> SelectionModeProperty = AvaloniaProperty.Register<PaletteSelector, PaletteSelectionMode>(nameof(SelectionMode));
|
||||
public static readonly StyledProperty<int> ColumnCountProperty = AvaloniaProperty.Register<PaletteSelector, int>(nameof(ColumnCount), 16);
|
||||
public static readonly StyledProperty<int> BlockSizeProperty = AvaloniaProperty.Register<PaletteSelector, int>(nameof(BlockSize), 16);
|
||||
public static readonly StyledProperty<int> BlockSizeProperty = AvaloniaProperty.Register<PaletteSelector, int>(nameof(BlockSize), 0);
|
||||
public static readonly StyledProperty<UInt32[]> PaletteColorsProperty = AvaloniaProperty.Register<PaletteSelector, UInt32[]>(nameof(PaletteColors));
|
||||
public static readonly StyledProperty<bool> ShowIndexesProperty = AvaloniaProperty.Register<PaletteSelector, bool>(nameof(ShowIndexes));
|
||||
|
||||
|
|
|
@ -406,6 +406,12 @@
|
|||
<Control ID="lblGbObj1">Sprites #2:</Control>
|
||||
<Control ID="btnSelectPreset">Select Preset...</Control>
|
||||
|
||||
<Control ID="lblGrayscale">Grayscale</Control>
|
||||
<Control ID="lblGrayscaleHighContrast">Grayscale (high contrast)</Control>
|
||||
<Control ID="lblGreen">Green</Control>
|
||||
<Control ID="lblBrown">Brown</Control>
|
||||
|
||||
|
||||
<Control ID="lblLcdSettings">LCD Settings</Control>
|
||||
<Control ID="chkGbBlendFrames">Enable LCD frame blending</Control>
|
||||
<Control ID="chkGbcAdjustColors">Enable GBC LCD color emulation</Control>
|
||||
|
|
|
@ -18,6 +18,15 @@
|
|||
<vm:GameboyConfigViewModel />
|
||||
</Design.DataContext>
|
||||
|
||||
<UserControl.Styles>
|
||||
<Style Selector="dc|PaletteSelector">
|
||||
<Setter Property="SelectionMode" Value="None" />
|
||||
<Setter Property="ColumnCount" Value="4" />
|
||||
<Setter Property="Width" Value="80" />
|
||||
<Setter Property="Height" Value="20" />
|
||||
</Style>
|
||||
</UserControl.Styles>
|
||||
|
||||
<TabControl TabStripPlacement="Top" SelectedIndex="0">
|
||||
<TabItem Header="{l:Translate tpgGeneral}">
|
||||
<StackPanel>
|
||||
|
@ -43,10 +52,49 @@
|
|||
<TabItem Header="{l:Translate tpgVideo}">
|
||||
<StackPanel>
|
||||
<c:OptionSection Header="{l:Translate lblGameboyPalette}" Margin="0">
|
||||
<Grid ColumnDefinitions="Auto,Auto,Auto" RowDefinitions="Auto,Auto,Auto">
|
||||
<TextBlock Text="{l:Translate lblGbBackground}" />
|
||||
<Border BorderBrush="#555" BorderThickness="1" Margin="0 1 5 0" Grid.Column="1" Width="82">
|
||||
<dc:PaletteSelector
|
||||
PaletteColors="{CompiledBinding Config.BgColors}"
|
||||
ColorClick="BgColor_OnClick"
|
||||
/>
|
||||
</Border>
|
||||
<Button
|
||||
Grid.Column="2"
|
||||
Content="{l:Translate btnSelectPreset}"
|
||||
Click="btnSelectPreset_OnClick"
|
||||
>
|
||||
<Button.ContextMenu>
|
||||
<ContextMenu PlacementMode="Bottom">
|
||||
<MenuItem Header="{l:Translate lblGrayscale}" Click="mnuGrayscalePreset_Click" />
|
||||
<MenuItem Header="{l:Translate lblGrayscaleHighContrast}" Click="mnuGrayscaleHighContrastPreset_Click" />
|
||||
<MenuItem Header="{l:Translate lblGreen}" Click="mnuGreenPreset_Click" />
|
||||
<MenuItem Header="{l:Translate lblBrown}" Click="mnuBrownPreset_Click" />
|
||||
</ContextMenu>
|
||||
</Button.ContextMenu>
|
||||
</Button>
|
||||
|
||||
<TextBlock Text="{l:Translate lblGbObj0}" Grid.Row="1" />
|
||||
<Border BorderBrush="#555" BorderThickness="1" Margin="0 1 5 0" Grid.Column="1" Grid.Row="1" Width="82">
|
||||
<dc:PaletteSelector
|
||||
PaletteColors="{CompiledBinding Config.Obj0Colors}"
|
||||
ColorClick="Obj0Color_OnClick"
|
||||
/>
|
||||
</Border>
|
||||
|
||||
<TextBlock Text="{l:Translate lblGbObj1}" Grid.Row="2" />
|
||||
<Border BorderBrush="#555" BorderThickness="1" Margin="0 1 5 0" Grid.Column="1" Grid.Row="2" Width="82">
|
||||
<dc:PaletteSelector
|
||||
PaletteColors="{CompiledBinding Config.Obj1Colors}"
|
||||
ColorClick="Obj1Color_OnClick"
|
||||
/>
|
||||
</Border>
|
||||
</Grid>
|
||||
</c:OptionSection>
|
||||
<c:OptionSection Header="{l:Translate lblLcdSettings}">
|
||||
<CheckBox IsChecked="{CompiledBinding Config.BlendFrames}" Content="{l:Translate chkGbBlendFrames}" />
|
||||
<CheckBox IsChecked="{CompiledBinding Config.GbcAdjustColors}" Content="{l:Translate chkGbcAdjustColors}"/>
|
||||
<CheckBox IsChecked="{CompiledBinding Config.BlendFrames}" Content="{l:Translate chkGbBlendFrames}" />
|
||||
</c:OptionSection>
|
||||
</StackPanel>
|
||||
</TabItem>
|
||||
|
|
|
@ -3,6 +3,13 @@ using Avalonia.Controls;
|
|||
using Avalonia.Markup.Xaml;
|
||||
using Mesen.Utilities;
|
||||
using Mesen.GUI.Config;
|
||||
using Mesen.Debugger.Controls;
|
||||
using Mesen.ViewModels;
|
||||
using Mesen.Windows;
|
||||
using System;
|
||||
using Avalonia.Media;
|
||||
using System.Threading.Tasks;
|
||||
using Avalonia.Interactivity;
|
||||
|
||||
namespace Mesen.Views
|
||||
{
|
||||
|
@ -17,5 +24,77 @@ namespace Mesen.Views
|
|||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
|
||||
private async Task<Color> SelectColor(Color color)
|
||||
{
|
||||
ColorPickerViewModel model = new ColorPickerViewModel() { Color = color };
|
||||
ColorPickerWindow wnd = new ColorPickerWindow() {
|
||||
DataContext = model
|
||||
};
|
||||
wnd.WindowStartupLocation = WindowStartupLocation.CenterOwner;
|
||||
|
||||
bool success = await wnd.ShowDialog<bool>(VisualRoot as Window);
|
||||
if(success) {
|
||||
return model.Color;
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
private async void BgColor_OnClick(object sender, PaletteSelector.ColorClickEventArgs e)
|
||||
{
|
||||
Color color = await SelectColor(e.Color);
|
||||
UInt32[] colors = (UInt32[])(DataContext as GameboyConfigViewModel).Config.BgColors.Clone();
|
||||
colors[e.ColorIndex] = color.ToUint32();
|
||||
(DataContext as GameboyConfigViewModel).Config.BgColors = colors;
|
||||
}
|
||||
|
||||
private async void Obj0Color_OnClick(object sender, PaletteSelector.ColorClickEventArgs e)
|
||||
{
|
||||
Color color = await SelectColor(e.Color);
|
||||
UInt32[] colors = (UInt32[])(DataContext as GameboyConfigViewModel).Config.Obj0Colors.Clone();
|
||||
colors[e.ColorIndex] = color.ToUint32();
|
||||
(DataContext as GameboyConfigViewModel).Config.Obj0Colors = colors;
|
||||
}
|
||||
|
||||
private async void Obj1Color_OnClick(object sender, PaletteSelector.ColorClickEventArgs e)
|
||||
{
|
||||
Color color = await SelectColor(e.Color);
|
||||
UInt32[] colors = (UInt32[])(DataContext as GameboyConfigViewModel).Config.Obj1Colors.Clone();
|
||||
colors[e.ColorIndex] = color.ToUint32();
|
||||
(DataContext as GameboyConfigViewModel).Config.Obj1Colors = colors;
|
||||
}
|
||||
|
||||
private void btnSelectPreset_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
((Button)sender).ContextMenu.Open();
|
||||
}
|
||||
|
||||
private void mnuGrayscalePreset_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
SetPalette(Color.FromArgb(255, 232, 232, 232), Color.FromArgb(255, 160, 160, 160), Color.FromArgb(255, 88, 88, 88), Color.FromArgb(255, 16, 16, 16));
|
||||
}
|
||||
|
||||
private void mnuGrayscaleHighContrastPreset_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
SetPalette(Color.FromArgb(255, 255, 255, 255), Color.FromArgb(255, 176, 176, 176), Color.FromArgb(255, 104, 104, 104), Color.FromArgb(255, 0, 0, 0));
|
||||
}
|
||||
|
||||
private void mnuGreenPreset_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
SetPalette(Color.FromArgb(255, 224, 248, 208), Color.FromArgb(255, 136, 192, 112), Color.FromArgb(255, 52, 104, 86), Color.FromArgb(255, 8, 24, 32));
|
||||
}
|
||||
|
||||
private void mnuBrownPreset_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
SetPalette(Color.FromArgb(255, 248, 224, 136), Color.FromArgb(255, 216, 176, 88), Color.FromArgb(255, 152, 120, 56), Color.FromArgb(255, 72, 56, 24));
|
||||
}
|
||||
|
||||
private void SetPalette(Color color0, Color color1, Color color2, Color color3)
|
||||
{
|
||||
GameboyConfigViewModel model = this.DataContext as GameboyConfigViewModel;
|
||||
model.Config.BgColors = new UInt32[] { color0.ToUint32(), color1.ToUint32(), color2.ToUint32(), color3.ToUint32() };
|
||||
model.Config.Obj0Colors = new UInt32[] { color0.ToUint32(), color1.ToUint32(), color2.ToUint32(), color3.ToUint32() };
|
||||
model.Config.Obj1Colors = new UInt32[] { color0.ToUint32(), color1.ToUint32(), color2.ToUint32(), color3.ToUint32() };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue