Skip to content

Commit

Permalink
Merge branch 'dev' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
LawTotem committed Nov 1, 2021
2 parents a56e84c + 0edc005 commit edf4576
Show file tree
Hide file tree
Showing 10 changed files with 1,419 additions and 1,203 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
heists.txt
local_heists.txt
services.txt
general_enchants.txt
local_general_enchants.txt
Capture2Text
mockups
.vscode
snipper.dll
snap*png
PoE-Enchantress.exe
*.zip
*.zip
enchant*.txt
113 changes: 104 additions & 9 deletions PoE-Enchantress.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ SendMode Input ; Recommended for new scripts due to its superior speed and reli
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.


global version := "0.3.0"
global version := "0.4.0"
global show_update := false

global PID := DllCall("Kernel32\GetCurrentProcessId")

Expand Down Expand Up @@ -152,10 +153,20 @@ tooltip, Ready
sleep, 250
Tooltip

global last_version_grab := 0
global last_heist_grab := 0
global last_enchant_grab := 0

if (FirstRun == 1) {
goto help
}

if (checkUpdate())
{
global show_update := true
MsgBox A new version of the tool is available, check https://github.com/LawTotem/PoE-Enchantress/releases
}

Return
Return

Expand Down Expand Up @@ -236,12 +247,13 @@ newGUI() {
{
Gui add, picture, x5 y5 w50 h50 gHelp , resources\ScalesOfJustice.png
}
Gui, add, text, x65 y20 w50, PoE-Enchantress v%version%
Gui, add, text, x65 y20 w100 vversiontext, PoE-Enchantress v%version%
Gui, add, picture, x520 y10 w120 h40 gSettings, resources\settings.png

Gui, add, text, x10 y60 vValue, Captured String
Gui, add, edit, x10 y80 vCaptureS r5 w600
Gui, add, picture, x10 y180 gReprossEnchant, resources\enchant.png
Gui, add, picture, x240 y180 gDumpRaw, resources\dumpraw.png
Gui, add, picture, x490 y180 gReprossHeist, resources\heist.png

loop, 15 {
Expand Down Expand Up @@ -307,6 +319,10 @@ ReprossHeist:
heistSort()
Return

DumpRaw:
GuiControl,, CaptureS, %RawTextCapture%
Return

Settings:
Gui Settings:new,, PoE-Enchantress Settings

Expand Down Expand Up @@ -334,7 +350,7 @@ Settings:
Gui, font, s10
offset := addOption("User", "HeistPriceTxt", offset, "Heist Price File")
offset := addOption("User", "ServiceEnchantTxt", offset, "Service Enchant File")
offset := addOption("User", "GeneralEnchantTxt", offset, "Geneneral Enchant File")
offset := addOption("User", "GeneralEnchantTxt", offset, "General Enchant File")
offset := addOption("User", "HeistRemappingTxt", offset, "Heist Text Remapping File")
offset := addOption("User", "EnchantRemappingTxt", offset, "Enchant Text Remapping File")
offset := addOption("User", "SnapshotScreen", offset, "Save a snapshot when OCRing screen")
Expand Down Expand Up @@ -364,7 +380,7 @@ SaveSettings:
saveOption("General", "HeistScanKey", offset, "Grab Heist Item Key Sequence")
saveOption("User", "HeistPriceTxt", offset, "Heist Price File")
saveOption("User", "ServiceEnchantTxt", offset, "Service Enchant File")
saveOption("User", "GeneralEnchantTxt", offset, "Geneneral Enchant File")
saveOption("User", "GeneralEnchantTxt", offset, "General Enchant File")
saveOption("User", "HeistRemappingTxt", offset, "Heist Text Remapping File")
saveOption("User", "EnchantRemappingTxt", offset, "Enchant Text Remapping File")
saveOption("User", "SnapshotScreen", offset, "Save a snapshot when OCRing screen")
Expand All @@ -378,6 +394,52 @@ SettingsGuiClose:
Gui, Settings:Destroy
Return

getHeistPrices(heist_price_txt)
{
if (SubStr(heist_price_txt,1,4) = "http")
{
global last_heist_grab
Delta := %A_Now%
EnvSub Delta, %last_heist_grab%, hours
if (last_heist_grab = 0 or Delta > 1)
{
UrlDownloadToFile, %heist_price_txt%, local_heists.txt
last_heist_grab = %A_Now%
}
FileRead, HeistFile, local_heists.txt
return HeistFile
}
if (FileExist(heist_price_txt))
{
FileRead, HeistFile, %heist_price_txt%
return HeistFile
}
return ""
}

getGeneralEnchants(general_enchants_txt)
{
if (SubStr(general_enchants_txt,1,4) = "http")
{
global last_enchant_grab
Delta := %A_Now%
EnvSub Delta, %last_enchant_grab%, hours
if (last_enchant_grab = 0 or Delta > 1)
{
UrlDownloadToFile, %general_enchants_txt%, local_general_enchants.txt
last_enchant_grab = %A_Now%
}
FileRead, EnchantFile, local_general_enchants.txt
return EnchantFile
}
if (FileExist(general_enchants_txt))
{
FileRead, EnchantFile, %general_enchants_txt%
return EnchantFile
}
return ""
}

addOption(sect, set_name, offset, title)
{
global
Expand Down Expand Up @@ -426,6 +488,18 @@ grabScreen(whitelist) {
FormatTime, RawCaptureTime,, yyyy_MM_dd_HH_mm_ss

GuiControl,, CaptureS, %RawTextCapture%

if (checkUpdate())
{
global show_update
if (!show_update)
{
MsgBox A new version of the tool is available, check https://github.com/LawTotem/PoE-Enchantress/releases
show_update := true
}

GuiControl, Text, versiontext, PoE-Enchantress v%version% Update
}
return true
}

Expand Down Expand Up @@ -471,10 +545,11 @@ enchantSort() {
GuiControl,, enchant_%current_row%, No Service File
current_row := current_row + 1
}

IniRead, GeneralEnchantTxt, %SettingsPath%, User, GeneralEnchantTxt
if (FileExist(GeneralEnchantTxt))
GeneralFile := getGeneralEnchants(GeneralEnchantTxt)
if (StrLen(GeneralFile) > 0)
{
FileRead, GeneralFile, %GeneralEnchantTxt%
loop, parse, GeneralFile, `n, `r
{
enchantLine := % A_LoopField
Expand Down Expand Up @@ -507,10 +582,10 @@ heistSort() {
}

IniRead, HeistPriceTxt, %SettingsPath%, User, HeistPriceTxt
current_row := 1
if (FileExist(HeistPriceTxt))
current_row := 1
HeistFile := getHeistPrices(HeistPriceTxt)
if (StrLen(HeistFile) > 0)
{
FileRead, HeistFile, %HeistPriceTxt%
loop, parse, HeistFile, `n, `r
{
heistLine := % A_LoopField
Expand Down Expand Up @@ -676,4 +751,24 @@ SelectArea() {
}
Gui, EnchantressUI:Default
return areaRect
}

checkUpdate() {
global last_version_grab
Delta := %A_Now%
EnvSub Delta, %last_version_grab%, hours
if (last_version_grab = 0 or Delta > 1)
{
whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
whr.Open("Get","https://raw.githubusercontent.com/LawTotem/PoE-Enchantress/dev/version.txt", true)
whr.Send()
whr.WaitForResponse()
online_version := whr.ResponseText()
last_version_grab = %A_Now%
if (online_version > version)
{
return true
}
}
return false
}
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ To practice you can snapshot any text which has the name of the item/enchant to

# Features

## Feature Requests
There is a discussions page on the github page, <https://github.com/LawTotem/PoE-Enchantress/discussions>, or you can find me, LawTotem, on discord.

## Heist Pricing
To price heist items press the heist hotkey, default Ctrl-u, and select a relatively tight selection of the screen which includes the name of the unique, jewel, or heist base. The tool will then attempt to provide you with a price for the item based on the contents of the <code>HeistPriceTxt</code>, defaults to <code>heists.txt</code>.
The file follows the format "heists item name":"price", when the item is matched a line "item name" --price-- "price" will appear on one of the lines below the captured text.
Expand Down Expand Up @@ -46,11 +49,13 @@ The key sequence to start a Heist screen grab, defaults to Ctrl-u
## User
### HeistPriceTxt
The file to use when pricing items from a Heist scan.
Can also be a url that starts with http which will be fetched every hour on use, for example https://pastebin.com/raw/Z5udVRZS
### ServiceEnchantTxt
The file to use when alerting to enchant services, always appears before general enchants.
### GeneralEnchantTxt
The file to use when giving general enchant recommendations.
The format is "string to look for":"string to show". See <code>examples/general_enchants.txt</code> for an example.
Can also be a url that starts with http which will be fetched every hour on use, for example https://pastebin.com/raw/Za0fgKzg
### HeistRemappingTxt
This file provides the string remapping for Heist, see the ORC remapping feature.

Expand All @@ -73,7 +78,13 @@ Untested but maybe allows for monitor selection.

# Change List

## 0.x.0
## 0.4.0
- Added genearl enchants from http like pastebin.
- Added ability to dump raw capture to text. In the case where the remapping failed it should help.
- Added update detection. The tool will now check gitlab to see if there is an update and display a message to user.
- Added heist pricing from http like pastebin.

## 0.3.0
- Added an enchant scraper, still requires hand data analysis to create general_enchants.txt.
- Added league variables to tools.
- Corrected seperator in heist price scraper.
Expand All @@ -85,4 +96,4 @@ Untested but maybe allows for monitor selection.
- Added more complete Heist prices
- Added example Lab services and base enchant files
- Update GUI
- Added OCR string fixing
- Added OCR string fixing
Loading

0 comments on commit edf4576

Please sign in to comment.