Skip to content

Commit 3bcffdb

Browse files
committed
improve downloaded template button style #147
1 parent c11f256 commit 3bcffdb

File tree

2 files changed

+25
-26
lines changed

2 files changed

+25
-26
lines changed

UnityLauncherPro/NewProject.xaml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,12 @@
142142
</Button>
143143
<!-- Downloaded indicator badge -->
144144
<Border Background="#CC2E7D32"
145-
CornerRadius="3"
146145
HorizontalAlignment="Right"
147146
VerticalAlignment="Top"
148-
Padding="4,2"
149-
Margin="2">
147+
Height="32"
148+
Width="32"
149+
Padding="0"
150+
Margin="1">
150151
<Border.Style>
151152
<Style TargetType="Border">
152153
<Setter Property="Visibility" Value="Collapsed"/>
@@ -157,10 +158,7 @@
157158
</Style.Triggers>
158159
</Style>
159160
</Border.Style>
160-
<TextBlock Text=""
161-
FontSize="10"
162-
FontWeight="Bold"
163-
Foreground="White"/>
161+
<TextBlock Text="" ToolTip="Already downloaded" FontSize="18" VerticalAlignment="Center" TextAlignment="Center" FontWeight="Bold" Foreground="White"/>
164162
</Border>
165163
</Grid>
166164
<TextBlock Text="{Binding Name}"

UnityLauncherPro/NewProject.xaml.cs

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ private List<OnlineTemplateItem> ParseTemplatesFromJson(string json)
590590
// Parse individual fields
591591
var tarballUrl = ExtractNestedJsonString(nodeJson, "\"tarball\"", "\"url\"");
592592
var rawDescription = ExtractJsonString(nodeJson, "\"description\"");
593-
var splitDescription = SplitDescriptionIntoThree(rawDescription);
593+
var splitDescription = SplitTextToRows(rawDescription, 3);
594594

595595
var template = new OnlineTemplateItem
596596
{
@@ -633,24 +633,6 @@ private List<OnlineTemplateItem> ParseTemplatesFromJson(string json)
633633
return templates;
634634
}
635635

636-
private string SplitDescriptionIntoThree(string description)
637-
{
638-
if (string.IsNullOrEmpty(description)) return description;
639-
640-
int len = description.Length;
641-
if (len <= 2) return description; // too short to split meaningfully
642-
643-
int firstCut = (len / 3);
644-
int secondCut = (len * 2) / 3;
645-
646-
// Raw split strictly by length/3 as requested
647-
string part1 = description.Substring(0, firstCut).Trim();
648-
string part2 = description.Substring(firstCut, secondCut - firstCut).Trim();
649-
string part3 = description.Substring(secondCut).Trim();
650-
651-
return part1 + Environment.NewLine + part2 + Environment.NewLine + part3;
652-
}
653-
654636
private string ExtractJsonString(string json, string key)
655637
{
656638
int keyIndex = json.IndexOf(key + ":");
@@ -849,6 +831,25 @@ private async void btnDownloadTemplate_Click(object sender, RoutedEventArgs e)
849831
button.Content = "⬇";
850832
}
851833
}
834+
} // btnDownloadTemplate_Click
835+
836+
private string SplitTextToRows(string description, int rows)
837+
{
838+
if (rows < 2) return description;
839+
if (string.IsNullOrEmpty(description)) return description;
840+
841+
int len = description.Length;
842+
if (len <= rows) return description; // too short to split meaningfully
843+
844+
int firstCut = (len / rows);
845+
int secondCut = (len * 2) / rows;
846+
847+
string part1 = description.Substring(0, firstCut).Trim();
848+
string part2 = description.Substring(firstCut, secondCut - firstCut).Trim();
849+
string part3 = description.Substring(secondCut).Trim();
850+
851+
return part1 + Environment.NewLine + part2 + Environment.NewLine + part3;
852852
}
853+
853854
} // class NewProject
854855
} // namespace UnityLauncherPro

0 commit comments

Comments
 (0)