Skip to content

Commit

Permalink
Canvas update (#4)
Browse files Browse the repository at this point in the history
* Mudanças na UI, removendo code velho ou comentado, atualizando o app de conversão e agora pode usar faca para rasgar o quadro

* Update de UI do canvas

(cherry picked from commit a17a7ac)
  • Loading branch information
cosmosgc authored and LaryNevesPR committed Jan 16, 2025
1 parent 9877b61 commit 5cc8e5d
Show file tree
Hide file tree
Showing 14 changed files with 7,300 additions and 6,252 deletions.
101 changes: 60 additions & 41 deletions Content.Client/Canvas/Ui/CanvasWindow.xaml
Original file line number Diff line number Diff line change
@@ -1,56 +1,75 @@
<controls:FancyWindow xmlns="https://spacestation14.io"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
Title="Canvas"
Resizable="True"
SetSize="700 700"
MinSize="700 700">
<BoxContainer Orientation="Vertical">
<BoxContainer Name="HeaderColorPreview" Orientation="Horizontal" Align="Center" Margin="0 8 0 8">
<Label Text="Colour:" Margin="0 0 8 0"/>
<Button Name="ColorPreview" Text="Cor" Margin="8 0 0 0" />
</BoxContainer>
<BoxContainer Name="HeaderTools" Orientation="Horizontal" Margin="0 0 0 8">
<LineEdit Name="Search" PlaceHolder="Paint Code" HorizontalExpand="True" />
<Button Name="ImportButton" Text="Import" Margin="8 0 0 0" />
<Button Name="ExportButton" Text="Export" Margin="8 0 0 0" />
<Button Name="FinalizeButton" Text="Finalize" Margin="8 0 0 0" />
</BoxContainer>
<PanelContainer>
<PanelContainer.PanelOverride>
<gfx:StyleBoxFlat BackgroundColor="#1e1e1e" />
</PanelContainer.PanelOverride>
<BoxContainer Name="HeaderColorPreview" Orientation="Horizontal" Align="Center" Margin="0 8 0 8">
<Label Text="Colour:" Margin="0 0 8 0"/>
<Button Name="ColorPreview" Margin="8 0 0 0" />
</BoxContainer>
<BoxContainer Name="HeaderTools" Orientation="Horizontal" Margin="0 0 0 8">
<LineEdit Name="Search" PlaceHolder="Paint Code" HorizontalExpand="True" />
<Button Name="ImportButton" Text="Import" Margin="8 0 0 0" />
<Button Name="ExportButton" Text="Export" Margin="8 0 0 0" />
<Button Name="FinalizeButton" Text="Finalize" Margin="8 0 0 0" />
</BoxContainer>
</PanelContainer>

<ScrollContainer VerticalExpand="True">

<BoxContainer Orientation="Horizontal" Align="Begin">
<BoxContainer Name="ResolutionContainer" Orientation="Vertical" Align="Begin">
<Label Text="Resolution"/>
<BoxContainer Orientation="Horizontal">
<Slider Name="HeightSize"
MinValue="16"
MaxValue="64"
HorizontalExpand="True"
MinSize="80 0"
Rounded="True" />
<Control MinSize="8 0" />
<Label Name="HeightSizeLabel" Text="16" MinSize="48 0"/>
<Control MinSize="4 0"/>
<PanelContainer>
<PanelContainer.PanelOverride>
<gfx:StyleBoxFlat BackgroundColor="#3a3a3a" />
</PanelContainer.PanelOverride>
<BoxContainer Name="ResolutionContainer" Orientation="Vertical" Align="Begin">
<Label Text="Resolution"/>
<BoxContainer Orientation="Horizontal">
<Slider Name="HeightSize"
MinValue="16"
MaxValue="64"
HorizontalExpand="True"
MinSize="80 0"
Rounded="True" />
<Control MinSize="8 0" />
<Label Name="HeightSizeLabel" Text="16" MinSize="48 0"/>
<Control MinSize="4 0"/>

</BoxContainer>
<BoxContainer Orientation="Horizontal">
<Slider Name="WidthSize"
MinValue="16"
MaxValue="64"
HorizontalExpand="True"
MinSize="80 0"
Rounded="True" />
<Control MinSize="8 0" />
<Label Name="WidthSizeLabel" Text="16" MinSize="48 0"/>
<Control MinSize="4 0"/>
</BoxContainer>
<BoxContainer Orientation="Horizontal" Align="Center">
<LineEdit Name="ArtistSignature" PlaceHolder="Signature" HorizontalExpand="True" />
</BoxContainer>
<BoxContainer Name="ColorSelector" Orientation="Horizontal" Align="Center">
</BoxContainer>
</BoxContainer>
<BoxContainer Orientation="Horizontal">
<Slider Name="WidthSize"
MinValue="16"
MaxValue="64"
HorizontalExpand="True"
MinSize="80 0"
Rounded="True" />
<Control MinSize="8 0" />
<Label Name="WidthSizeLabel" Text="16" MinSize="48 0"/>
<Control MinSize="4 0"/>
</BoxContainer>
<BoxContainer Orientation="Horizontal" Align="Center">
<LineEdit Name="ArtistSignature" PlaceHolder="Signature" HorizontalExpand="True" />
</BoxContainer>
<BoxContainer Name="ColorSelector" Orientation="Horizontal" Align="Center">
</BoxContainer>
</BoxContainer>
<BoxContainer Name="Grids" Orientation="Vertical" Align="Center" VerticalExpand="True">
</BoxContainer>
</PanelContainer>

<PanelContainer>
<PanelContainer.PanelOverride>
<gfx:StyleBoxFlat BackgroundColor="#1b1b1e" />
</PanelContainer.PanelOverride>
<BoxContainer Name="Grids" Orientation="Vertical" Align="Center" VerticalExpand="True">
<!-- Add grid content dynamically here -->
</BoxContainer>
</PanelContainer>
</BoxContainer>

</ScrollContainer>
Expand Down
65 changes: 5 additions & 60 deletions Content.Client/Canvas/Ui/CanvasWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ public sealed partial class CanvasWindow : FancyWindow
private string? _selected;
private Color _color = Color.Black;

private const int ButtonSize = 30; // Size of each button (width and height)
private const int ColorsButtonSize = 24; // Size of each button (width and height)

private const int ButtonSize = 20; // Size of each button (width and height)

public event Action<Color>? OnColorSelected;
public event Action<string>? OnSelected;
Expand Down Expand Up @@ -152,13 +154,10 @@ private void SelectColor(Color color)
_color = color;

OnColorSelected?.Invoke(color);
//RefreshList();
}

private void SearchChanged(LineEdit.LineEditEventArgs obj)
{
//_autoSelected = ""; // Placeholder to kick off the auto-select in refreshlist()
//RefreshList();
}

public void UpdateState(BoundUserInterfaceState state)
Expand All @@ -177,19 +176,6 @@ public void UpdateState(BoundUserInterfaceState state)
}
public void AdvanceState(string drawn)
{
//var filter = Search.Text;
//if (!filter.Contains(',') || !filter.Contains(drawn))
// return;

//var first = filter[..filter.IndexOf(',')].Trim();

//if (first.Equals(drawn, StringComparison.InvariantCultureIgnoreCase))
//{
// Search.Text = filter[(filter.IndexOf(',') + 1)..].Trim();
// _autoSelected = first;
//}

//RefreshList();
}

private void HandleColorSelected(Color color)
Expand Down Expand Up @@ -229,8 +215,8 @@ public void PopulateColorSelector(List<Color> colors)
// Create a button for each color
var colorButton = new Button
{
MinSize = new Vector2(ButtonSize, ButtonSize),
MaxSize = new Vector2(ButtonSize, ButtonSize),
MinSize = new Vector2(ColorsButtonSize, ColorsButtonSize),
MaxSize = new Vector2(ColorsButtonSize, ColorsButtonSize),
ModulateSelfOverride = color, // Set the button background to the color
};

Expand Down Expand Up @@ -434,45 +420,6 @@ private Color GetColorFromCode(string colorCode)
Logger.ErrorS("canvas", $"color {colorCode} color code fail.");
return Color.White; // Default to white if parsing fails
}


/// <summary>
/// Converts a Color object to a color code character.
/// </summary>
private char GetCodeFromColor(Color color)
{
if (color == Color.Transparent) return 'Z';
if (color == Color.Red) return 'R';
if (color == Color.Green) return 'G';
if (color == Color.Blue) return 'B';
if (color == Color.Yellow) return 'Y';
if (color == Color.Cyan) return 'C';
if (color == Color.Magenta) return 'M';
if (color == new Color(1.0f, 0.65f, 0.0f)) return 'O'; // Orange
if (color == new Color(0.75f, 0.0f, 0.75f)) return 'P'; // Purple
if (color == new Color(0.33f, 0.55f, 0.2f)) return 'T'; // Teal
if (color == new Color(0.6f, 0.3f, 0.1f)) return 'N'; // Brown
if (color == new Color(0.9f, 0.8f, 0.7f)) return 'E'; // Beige
if (color == Color.LightGray) return 'L';
if (color == Color.DarkGray) return 'D';
if (color == new Color(0.5f, 0.5f, 1.0f)) return 'F'; // Pastel Blue
if (color == new Color(1.0f, 0.5f, 0.5f)) return 'I'; // Pastel Pink
if (color == new Color(0.0f, 0.5f, 0.5f)) return 'Q'; // Dark Cyan
if (color == new Color(0.4f, 0.2f, 0.6f)) return 'H'; // Deep Purple
if (color == Color.Black) return 'K';
return 'W'; // Default to white
}


public void InitializeFromYaml(string paintingCode)
{
if (!string.IsNullOrEmpty(paintingCode))
{
_paintingCode = paintingCode;
}

//PopulatePaintingGrid();
}
private void FixPaintingCode()
{
int requiredSegments = _width * _height;
Expand All @@ -495,7 +442,5 @@ private void FixPaintingCode()
_paintingCode = string.Join(";", paddedSegments);
}
}


}
}
5 changes: 5 additions & 0 deletions Resources/Prototypes/Entities/Objects/Fun/canvas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
artist: ""
height: 16
width: 16
- type: Butcherable
butcheringType: Knife
spawned:
- id: MaterialCloth1
amount: 1

- type: entity
parent: CanvasBase
Expand Down
Loading

0 comments on commit 5cc8e5d

Please sign in to comment.