Skip to content

Commit cac503f

Browse files
authored
Merge pull request #30 from primetime43/develop
Develop to main v2.0.0
2 parents 311b001 + 029046b commit cac503f

File tree

65 files changed

+17065
-4229
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+17065
-4229
lines changed

.github/workflows/release.yml

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
name: Build and Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
workflow_dispatch:
8+
inputs:
9+
version:
10+
description: 'Version tag (e.g., v1.0.0)'
11+
required: true
12+
default: 'v1.0.0'
13+
14+
env:
15+
DOTNET_VERSION: '10.0.x'
16+
PROJECT_PATH: 'ToonTown Rewritten Bot/ToonTown Rewritten Bot.csproj'
17+
OUTPUT_NAME: 'ToonTown-Rewritten-Bot'
18+
19+
jobs:
20+
build:
21+
runs-on: windows-latest
22+
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@v4
26+
27+
- name: Setup .NET
28+
uses: actions/setup-dotnet@v4
29+
with:
30+
dotnet-version: ${{ env.DOTNET_VERSION }}
31+
32+
- name: Restore dependencies
33+
run: dotnet restore "${{ env.PROJECT_PATH }}"
34+
35+
- name: Publish single-file executable
36+
run: |
37+
dotnet publish "${{ env.PROJECT_PATH }}" `
38+
--configuration Release `
39+
--runtime win-x64 `
40+
--self-contained true `
41+
--output ./publish `
42+
-p:PublishSingleFile=true `
43+
-p:IncludeNativeLibrariesForSelfExtract=true `
44+
-p:EnableCompressionInSingleFile=true
45+
46+
- name: Download Tesseract language data
47+
run: |
48+
# Create tessdata folder in publish directory
49+
New-Item -ItemType Directory -Force -Path "./publish/tessdata"
50+
51+
# Download eng.traineddata from tessdata_fast
52+
$url = "https://github.com/tesseract-ocr/tessdata_fast/raw/main/eng.traineddata"
53+
$output = "./publish/tessdata/eng.traineddata"
54+
55+
Write-Host "Downloading Tesseract language data..."
56+
Invoke-WebRequest -Uri $url -OutFile $output
57+
58+
# Verify download
59+
if (Test-Path $output) {
60+
$size = (Get-Item $output).Length
61+
Write-Host "Downloaded eng.traineddata ($size bytes)"
62+
} else {
63+
Write-Error "Failed to download tessdata"
64+
exit 1
65+
}
66+
67+
- name: Copy required folders
68+
run: |
69+
# Build folder path (where intermediate files are)
70+
$buildFolder = "ToonTown Rewritten Bot/bin/Release/net10.0-windows/win-x64"
71+
72+
# Create the release folder structure
73+
New-Item -ItemType Directory -Force -Path "./release"
74+
75+
# Copy the single-file executable
76+
Copy-Item "./publish/*.exe" -Destination "./release/" -Force
77+
78+
# Copy tessdata folder (already created and populated above)
79+
if (Test-Path "./publish/tessdata") {
80+
Copy-Item -Path "./publish/tessdata" -Destination "./release/tessdata" -Recurse -Force
81+
}
82+
83+
# Copy x64 native DLLs (Tesseract) from build folder
84+
if (Test-Path "$buildFolder/x64") {
85+
Copy-Item -Path "$buildFolder/x64" -Destination "./release/x64" -Recurse -Force
86+
}
87+
88+
# Copy Templates folder from build folder
89+
if (Test-Path "$buildFolder/Templates") {
90+
Copy-Item -Path "$buildFolder/Templates" -Destination "./release/Templates" -Recurse -Force
91+
}
92+
93+
# Copy Custom Golf Actions folder from build folder
94+
if (Test-Path "$buildFolder/Custom Golf Actions") {
95+
Copy-Item -Path "$buildFolder/Custom Golf Actions" -Destination "./release/Custom Golf Actions" -Recurse -Force
96+
}
97+
98+
# Copy Custom Fishing Actions folder from build folder
99+
if (Test-Path "$buildFolder/Custom Fishing Actions") {
100+
Copy-Item -Path "$buildFolder/Custom Fishing Actions" -Destination "./release/Custom Fishing Actions" -Recurse -Force
101+
}
102+
103+
# List contents for verification
104+
Write-Host "Release folder contents:"
105+
Get-ChildItem -Path "./release" -Recurse | Select-Object FullName
106+
107+
- name: Get version
108+
id: get_version
109+
run: |
110+
if ("${{ github.event_name }}" -eq "workflow_dispatch") {
111+
$version = "${{ github.event.inputs.version }}"
112+
} else {
113+
$version = "${{ github.ref_name }}"
114+
}
115+
echo "VERSION=$version" >> $env:GITHUB_OUTPUT
116+
echo "Version: $version"
117+
118+
- name: Create ZIP archive
119+
run: |
120+
$version = "${{ steps.get_version.outputs.VERSION }}"
121+
$zipName = "${{ env.OUTPUT_NAME }}-$version-win-x64.zip"
122+
Compress-Archive -Path "./release/*" -DestinationPath "./$zipName" -Force
123+
echo "ZIP_NAME=$zipName" >> $env:GITHUB_OUTPUT
124+
id: create_zip
125+
126+
- name: Create GitHub Release
127+
uses: softprops/action-gh-release@v1
128+
with:
129+
tag_name: ${{ steps.get_version.outputs.VERSION }}
130+
name: Release ${{ steps.get_version.outputs.VERSION }}
131+
body: |
132+
## Toontown Rewritten Bot ${{ steps.get_version.outputs.VERSION }}
133+
134+
### Installation
135+
1. Download the ZIP file below
136+
2. Extract to a folder of your choice
137+
3. Run `ToonTown Rewritten Bot.exe`
138+
139+
### Requirements
140+
- Windows 10/11 (64-bit)
141+
- No additional .NET runtime needed (self-contained)
142+
143+
### Included Files
144+
- Single-file executable
145+
- Tesseract OCR data (tessdata folder)
146+
- Native Tesseract DLLs (x64 folder)
147+
- Templates folder
148+
- Custom Golf Actions
149+
- Custom Fishing Actions
150+
files: |
151+
${{ steps.create_zip.outputs.ZIP_NAME }}
152+
draft: false
153+
prerelease: false
154+
env:
155+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
156+
157+
- name: Upload build artifact
158+
uses: actions/upload-artifact@v4
159+
with:
160+
name: ${{ env.OUTPUT_NAME }}-${{ steps.get_version.outputs.VERSION }}
161+
path: ./release/
162+
retention-days: 30

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Table of Contents
6666
</details>
6767

6868
## Requirements
69-
- [Microsoft .NET Framework 7.0](https://dotnet.microsoft.com/en-us/download/dotnet/7.0)
69+
- [Microsoft .NET 10.0](https://dotnet.microsoft.com/en-us/download/dotnet/10.0)
7070

7171
<br>
7272

ToonTown Rewritten Bot/Models/Coordinates.cs

Lines changed: 10 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
using System.Text;
66
using System.Threading.Tasks;
77
using System.Windows.Forms;
8+
using ToonTown_Rewritten_Bot.Utilities;
89
using static ToonTown_Rewritten_Bot.Models.Coordinates;
910

1011
namespace ToonTown_Rewritten_Bot.Models
1112
{
1213
/// <summary>
1314
/// Represents actions associated with coordinates in the UI, such as button locations.
15+
/// Now uses file-based definitions via TemplateDefinitionManager.
1416
/// </summary>
1517
public class CoordinateActions : ICoordinateData
1618
{
@@ -19,78 +21,24 @@ public class CoordinateActions : ICoordinateData
1921
public int X { get; set; }
2022
public int Y { get; set; }
2123

22-
private static readonly Dictionary<string, string> _actionDescriptionMap = new Dictionary<string, string>();
23-
24-
/// <summary>
25-
/// Static constructor to initialize the action description map.
26-
/// </summary>
27-
static CoordinateActions()
28-
{
29-
CreateActionDescriptionMap();
30-
}
31-
32-
/// <summary>
33-
/// Initializes the description map with keys and corresponding descriptions.
34-
/// This map is what is used when creating the default UIElementCoordinates.json file
35-
/// </summary>
36-
private static void CreateActionDescriptionMap()
37-
{
38-
// Gardening Actions
39-
_actionDescriptionMap.Add("1", "Plant Flower/Remove Button");
40-
_actionDescriptionMap.Add("2", "Red Jellybean Button");
41-
_actionDescriptionMap.Add("3", "Green Jellybean Button");
42-
_actionDescriptionMap.Add("4", "Orange Jellybean Button");
43-
_actionDescriptionMap.Add("5", "Purple Jellybean Button");
44-
_actionDescriptionMap.Add("6", "Blue Jellybean Button");
45-
_actionDescriptionMap.Add("7", "Pink Jellybean Button");
46-
_actionDescriptionMap.Add("8", "Yellow Jellybean Button");
47-
_actionDescriptionMap.Add("9", "Cyan Jellybean Button");
48-
_actionDescriptionMap.Add("10", "Silver Jellybean Button");
49-
_actionDescriptionMap.Add("11", "Blue Plant Button");
50-
_actionDescriptionMap.Add("12", "Blue Ok Button");
51-
_actionDescriptionMap.Add("13", "Watering Can Button");
52-
_actionDescriptionMap.Add("14", "Blue Yes Button");
53-
54-
// Fishing Actions
55-
_actionDescriptionMap.Add("15", "Red Fishing Button");
56-
_actionDescriptionMap.Add("16", "Exit Fishing Button");
57-
_actionDescriptionMap.Add("17", "Blue Sell All Button");
58-
59-
// Doodle Training Actions
60-
_actionDescriptionMap.Add("18", "Feed Doodle Button");
61-
_actionDescriptionMap.Add("19", "Scratch Doodle Button");
62-
_actionDescriptionMap.Add("20", "Green SpeedChat Button");
63-
_actionDescriptionMap.Add("21", "Pets Tab in SpeedChat");
64-
_actionDescriptionMap.Add("22", "Tricks Tab in SpeedChat");
65-
_actionDescriptionMap.Add("23", "Jump Trick Option in SpeedChat");
66-
_actionDescriptionMap.Add("24", "Beg Trick Option in SpeedChat");
67-
_actionDescriptionMap.Add("25", "Play Dead Trick Option in SpeedChat");
68-
_actionDescriptionMap.Add("26", "Rollover Trick Option in SpeedChat");
69-
_actionDescriptionMap.Add("27", "Backflip Trick Option in SpeedChat");
70-
_actionDescriptionMap.Add("28", "Dance Trick Option in SpeedChat");
71-
_actionDescriptionMap.Add("29", "Speak Trick Option in SpeedChat");
72-
}
73-
7424
/// <summary>
7525
/// Retrieves the description for a given key.
7626
/// </summary>
7727
/// <param name="key">The key whose description is to be retrieved.</param>
7828
/// <returns>The description if found; otherwise, null.</returns>
7929
public static string GetDescription(string key)
8030
{
81-
if (_actionDescriptionMap.TryGetValue(key, out var description))
82-
{
83-
return description;
84-
}
85-
86-
return null; // Or throw an exception, depending on your needs
31+
return TemplateDefinitionManager.Instance.GetDescriptionByKey(key);
8732
}
8833

8934
/// <summary>
90-
/// Provides access to the complete plantComboDictionary of action descriptions.
35+
/// Provides access to all action descriptions mapped by their keys.
9136
/// </summary>
92-
/// <returns>A plantComboDictionary of all descriptions mapped by their keys.</returns>
93-
public static Dictionary<string, string> GetAllDescriptions() => _actionDescriptionMap;
37+
/// <returns>A dictionary of all descriptions mapped by their keys.</returns>
38+
public static Dictionary<string, string> GetAllDescriptions()
39+
{
40+
return TemplateDefinitionManager.Instance.GetAllDescriptions();
41+
}
9442

9543
/// <summary>
9644
/// Finds the key for a given description.
@@ -99,17 +47,7 @@ public static string GetDescription(string key)
9947
/// <returns>The key if found; otherwise, null.</returns>
10048
public static string GetKeyFromDescription(string description)
10149
{
102-
// Iterate over the key-value pairs in the map
103-
foreach (var pair in _actionDescriptionMap)
104-
{
105-
// Check if the value matches the provided description
106-
if (pair.Value == description)
107-
{
108-
return pair.Key; // Return the key that matches the description
109-
}
110-
}
111-
112-
return null; // Return null if no match is found
50+
return TemplateDefinitionManager.Instance.GetKeyByDescription(description);
11351
}
11452
}
11553

ToonTown Rewritten Bot/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.0.0.0")]
36-
[assembly: AssemblyFileVersion("1.0.0.0")]
35+
[assembly: AssemblyVersion("2.0.0.0")]
36+
[assembly: AssemblyFileVersion("2.0.0.0")]

ToonTown Rewritten Bot/Properties/Settings.Designer.cs

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
11
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
6-
using WindowsInput;
72
using System.Threading;
3+
using System.Threading.Tasks;
84
using System.Windows.Forms;
9-
using ToonTown_Rewritten_Bot.Views;
10-
using ToonTown_Rewritten_Bot.Models;
5+
using WindowsInput;
116

127
namespace ToonTown_Rewritten_Bot.Services
138
{
149
public class BotFunctions
1510
{
16-
private static Dictionary<string, string> _dataFileMap = new Dictionary<string, string>();
1711
public static bool SendMessage(string message, int spamCount, bool spam, NumericUpDown upDown)
1812
{
1913
DialogResult confirmation;
@@ -58,7 +52,7 @@ private static void Send(string text)
5852

5953
public static async Task KeepToonAwake(int timeInSeconds, CancellationToken cancellationToken)
6054
{
61-
CoreFunctionality.MaximizeAndFocusTTRWindow(); // Ensure the game window is focused
55+
CoreFunctionality.FocusTTRWindow(); // Ensure the game window is focused
6256
DateTime endTime = DateTime.Now.AddSeconds(timeInSeconds); // Calculate the end time based on seconds
6357
CoreFunctionality.DoMouseClick(); // Initial action to "keep awake"
6458

@@ -75,47 +69,5 @@ public static async Task KeepToonAwake(int timeInSeconds, CancellationToken canc
7569
{
7670
}
7771
}
78-
79-
/*public static Dictionary<string, string> GetDataFileMap()
80-
{
81-
return _dataFileMap;
82-
}*/
83-
84-
public static void CreateItemsDataFileMap()
85-
{
86-
//Gardening Coords
87-
_dataFileMap.Add(((int)Coordinates.GardeningCoordinatesEnum.PlantFlowerRemoveButton).ToString(), "Plant Flower/Remove Button");
88-
_dataFileMap.Add(((int)Coordinates.GardeningCoordinatesEnum.RedJellybeanButton).ToString(), "Red Jellybean Button");
89-
_dataFileMap.Add(((int)Coordinates.GardeningCoordinatesEnum.GreenJellybeanButton).ToString(), "Green Jellybean Button");
90-
_dataFileMap.Add(((int)Coordinates.GardeningCoordinatesEnum.OrangeJellybeanButton).ToString(), "Orange Jellybean Button");
91-
_dataFileMap.Add(((int)Coordinates.GardeningCoordinatesEnum.PurpleJellybeanButton).ToString(), "Purple Jellybean Button");
92-
_dataFileMap.Add(((int)Coordinates.GardeningCoordinatesEnum.BlueJellybeanButton).ToString(), "Blue Jellybean Button");
93-
_dataFileMap.Add(((int)Coordinates.GardeningCoordinatesEnum.PinkJellybeanButton).ToString(), "Pink Jellybean Button");
94-
_dataFileMap.Add(((int)Coordinates.GardeningCoordinatesEnum.YellowJellybeanButton).ToString(), "Yellow Jellybean Button");
95-
_dataFileMap.Add(((int)Coordinates.GardeningCoordinatesEnum.CyanJellybeanButton).ToString(), "Cyan Jellybean Button");
96-
_dataFileMap.Add(((int)Coordinates.GardeningCoordinatesEnum.SilverJellybeanButton).ToString(), "Silver Jellybean Button");
97-
_dataFileMap.Add(((int)Coordinates.GardeningCoordinatesEnum.BluePlantButton).ToString(), "Blue Plant Button");
98-
_dataFileMap.Add(((int)Coordinates.GardeningCoordinatesEnum.BlueOkButton).ToString(), "Blue Ok Button");
99-
_dataFileMap.Add(((int)Coordinates.GardeningCoordinatesEnum.WateringCanButton).ToString(), "Watering Can Button");
100-
_dataFileMap.Add(((int)Coordinates.GardeningCoordinatesEnum.BlueYesButton).ToString(), "Blue Yes Button");
101-
//Fishing Coords
102-
_dataFileMap.Add(((int)Coordinates.FishingCoordinatesEnum.RedFishingButton).ToString(), "Red Fishing Button");
103-
_dataFileMap.Add(((int)Coordinates.FishingCoordinatesEnum.ExitFishingButton).ToString(), "Exit Fishing Button");
104-
_dataFileMap.Add(((int)Coordinates.FishingCoordinatesEnum.BlueSellAllButton).ToString(), "Blue Sell All Button");
105-
//Racing Coords
106-
//Doodle Training Coords
107-
_dataFileMap.Add(((int)Coordinates.DoodleTrainingCoordinatesEnum.FeedDoodleButton).ToString(), "Feed Doodle Button");
108-
_dataFileMap.Add(((int)Coordinates.DoodleTrainingCoordinatesEnum.ScratchDoodleButton).ToString(), "Scratch Doodle Button");
109-
_dataFileMap.Add(((int)Coordinates.DoodleTrainingCoordinatesEnum.GreenSpeedChatButton).ToString(), "Green SpeedChat Button");
110-
_dataFileMap.Add(((int)Coordinates.DoodleTrainingCoordinatesEnum.PetsTabInSpeedChat).ToString(), "Pets Tab in SpeedChat");
111-
_dataFileMap.Add(((int)Coordinates.DoodleTrainingCoordinatesEnum.TricksTabInSpeedChat).ToString(), "Tricks Tab in SpeedChat");
112-
_dataFileMap.Add(((int)Coordinates.DoodleTrainingCoordinatesEnum.JumpTrickOptionInSpeedChat).ToString(), "Jump Trick Option in SpeedChat");
113-
_dataFileMap.Add(((int)Coordinates.DoodleTrainingCoordinatesEnum.BegTrickOptionInSpeedChat).ToString(), "Beg Trick Option in SpeedChat");
114-
_dataFileMap.Add(((int)Coordinates.DoodleTrainingCoordinatesEnum.PlayDeadTrickOptionInSpeedChat).ToString(), "Play Dead Trick Option in SpeedChat");
115-
_dataFileMap.Add(((int)Coordinates.DoodleTrainingCoordinatesEnum.RolloverTrickOptionInSpeedChat).ToString(), "Rollover Trick Option in SpeedChat");
116-
_dataFileMap.Add(((int)Coordinates.DoodleTrainingCoordinatesEnum.BackflipTrickOptionInSpeedChat).ToString(), "Backflip Trick Option in SpeedChat");
117-
_dataFileMap.Add(((int)Coordinates.DoodleTrainingCoordinatesEnum.DanceTrickOptionInSpeedChat).ToString(), "Dance Trick Option in SpeedChat");
118-
_dataFileMap.Add(((int)Coordinates.DoodleTrainingCoordinatesEnum.SpeakTrickOptionInSpeedChat).ToString(), "Speak Trick Option in SpeedChat");
119-
}
12072
}
12173
}

0 commit comments

Comments
 (0)