Skip to content

Commit

Permalink
Merge pull request #48 from FN-FAL113/Dev/enchancements-to-presets-an…
Browse files Browse the repository at this point in the history
…d-more

preset enhancements and chores
  • Loading branch information
FN-FAL113 authored Mar 25, 2024
2 parents f570409 + b26f159 commit a333dbb
Show file tree
Hide file tree
Showing 19 changed files with 668 additions and 188 deletions.
57 changes: 37 additions & 20 deletions CS2ServerPicker/App.Designer.vb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 11 additions & 7 deletions CS2ServerPicker/App.vb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
My.Settings.Save()
My.Settings.Reload()

Await Should_Block_All_Servers(False)
Await Block_Unblock_All_Servers(False)
Else
Ping_All_Servers()
End If
Expand All @@ -89,25 +89,29 @@
End Sub

Private Async Sub BlockAllButton_Click(sender As Object, e As EventArgs) Handles BlockAllButton.Click
Await Should_Block_All_Servers(True)
Await Block_Unblock_All_Servers(True)
End Sub

Private Async Sub UnblockAllButton_Click(sender As Object, e As EventArgs) Handles UnblockAllButton.Click
Await Should_Block_All_Servers(False)
Await Block_Unblock_All_Servers(False)
End Sub

Private Sub BlockSelectedButton_Click(sender As Object, e As EventArgs) Handles BlockSelectedButton.Click
Should_Block_Selected_Servers(True)
Block_Unblock_Selected_Servers(True)
End Sub

Private Sub UnblockSelectedButton_Click(sender As Object, e As EventArgs) Handles UnblockSelectedButton.Click
Should_Block_Selected_Servers(False)
Block_Unblock_Selected_Servers(False)
End Sub

Private Sub PictureBox1_Click(sender As Object, e As EventArgs) Handles PictureBox1.Click
Process.Start("https://github.com/FN-FAL113/csgo-server-picker")
End Sub

Private Sub PictureBox2_Click(sender As Object, e As EventArgs) Handles PictureBox2.Click
Process.Start("https://www.paypal.com/paypalme/ameliaOrbeta")
End Sub

Private Sub InfoButton_Click(sender As Object, e As EventArgs) Handles InfoButton.Click
MessageBox.Show(
"How to select server/s:" + Environment.NewLine +
Expand All @@ -121,7 +125,7 @@
Environment.NewLine +
"Author: FN-FAL113 (github username)" + Environment.NewLine +
"License: GNU General Public License V3" + Environment.NewLine +
"App Version: 2.0.7",
"App Version: 2.0.9",
"App Info"
)
End Sub
Expand Down Expand Up @@ -154,7 +158,7 @@

MessageBox.Show("App will unblock all servers before " + IIf(isClustered, "unclustering", "clustering") + " servers. Please standby...", "Info")

Await Should_Block_All_Servers(False, False)
Await Block_Unblock_All_Servers(False, False)

Clear_DataGridView_Rows()

Expand Down
12 changes: 12 additions & 0 deletions CS2ServerPicker/CS2ServerPicker.vbproj
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@
<Compile Include="Presets\Presets.vb">
<SubType>Form</SubType>
</Compile>
<Compile Include="Presets\UpdatePresetForm.Designer.vb">
<DependentUpon>UpdatePresetForm.vb</DependentUpon>
</Compile>
<Compile Include="Presets\UpdatePresetForm.vb">
<SubType>Form</SubType>
</Compile>
<Compile Include="Services\DataGridViewService.vb" />
<Compile Include="Services\PingService.vb" />
<Compile Include="My Project\AssemblyInfo.vb" />
Expand Down Expand Up @@ -179,6 +185,9 @@
<EmbeddedResource Include="Presets\Presets.resx">
<DependentUpon>Presets.vb</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Presets\UpdatePresetForm.resx">
<DependentUpon>UpdatePresetForm.vb</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="app.manifest" />
Expand Down Expand Up @@ -209,5 +218,8 @@
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<None Include="asset\Paypal.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
</Project>
4 changes: 2 additions & 2 deletions CS2ServerPicker/My Project/AssemblyInfo.vb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ Imports System.Runtime.InteropServices
' by using the '*' as shown below:
' <Assembly: AssemblyVersion("1.0.*")>

<Assembly: AssemblyVersion("2.0.8.0")>
<Assembly: AssemblyFileVersion("2.0.8.0")>
<Assembly: AssemblyVersion("2.0.9.0")>
<Assembly: AssemblyFileVersion("2.0.9.0")>
<Assembly: NeutralResourcesLanguage("en")>
10 changes: 10 additions & 0 deletions CS2ServerPicker/My Project/Resources.Designer.vb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions CS2ServerPicker/My Project/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,7 @@
<data name="GitHub-Mark" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\asset\GitHub-Mark.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Paypal" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\asset\Paypal.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>
20 changes: 17 additions & 3 deletions CS2ServerPicker/Presets/AddPresetForm.Designer.vb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 20 additions & 9 deletions CS2ServerPicker/Presets/AddPresetForm.vb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Public Class AddPresetForm
Private Sub AddPresetButton_Click(sender As Object, e As EventArgs) Handles AddPresetButton.Click
' add/create a preset from selected servers on add preset button click
Dim presetName As String = AddPresetNameTextBox.Text
Dim presetNameTrimmed = presetName.Replace(" ", "")
Dim regex As Text.RegularExpressions.Regex = New Text.RegularExpressions.Regex("[^a-zA-Z0-9 ]")

If String.IsNullOrWhiteSpace(presetName) Or regex.IsMatch(presetName) Then
Expand All @@ -33,35 +34,45 @@ Public Class AddPresetForm
End If

Try
' deserialize presets back to its complex form
Dim jObj As JObject = JObject.Parse(File.ReadAllText("presets.json"))

If jObj.ContainsKey(presetName.Replace(" ", "")) Then
If jObj.ContainsKey(presetNameTrimmed) Then
MessageBox.Show("Given preset name already exists.", "Info")

Return
End If

' create property using preset name trimmed as key with object as value that contains necessary props
' "presetName" prop with untrimmed preset name as string value and "servers" prop contains the checked items as JArray value
jObj.Add(presetName.Replace(" ", ""), New JObject(
' property uses trimmed preset name, access unmodified name through child prop (presetName)
jObj.Add(presetNameTrimmed, New JObject(
New JProperty("presetName", presetName),
New JProperty("clustered", App.Get_Is_Clustered()),
New JProperty("servers", JArray.FromObject(PresetServersCheckedListBox.CheckedItems))
)
)

' serialize jObj to presets json file
' serialize jObj to primitive form in presets json file
File.WriteAllText("presets.json", JsonConvert.SerializeObject(jObj, Formatting.Indented))

' refresh/reload presets control data grids
Load_Presets()
Presets.Load_Presets()

MessageBox.Show("Succesfully added preset!", "Info")
Catch ex As Exception
MessageBox.Show("An error has occured while adding preset! Please report to github issue-tracker. Error: " _
MessageBox.Show("An error has occured while adding preset! Error: " _
+ Environment.NewLine + Environment.NewLine + ex.Message, "Add Preset Error")
End Try
End Sub

Private Sub ResetPresetSelectionButton_Click(sender As Object, e As EventArgs) Handles ResetPresetSelectionButton.Click
Dim checkedIndexes As CheckedListBox.CheckedIndexCollection = PresetServersCheckedListBox.CheckedIndices

If checkedIndexes.Count = 0 Then
Return
End Try
End If

MessageBox.Show("Succesfully added preset!")
For Each selectedIndex As Integer In checkedIndexes
PresetServersCheckedListBox.SetItemChecked(selectedIndex, False)
Next
End Sub
End Class
Loading

0 comments on commit a333dbb

Please sign in to comment.