diff --git a/.gitignore b/.gitignore index 8bbb03b..c108db4 100644 --- a/.gitignore +++ b/.gitignore @@ -62,3 +62,4 @@ Archived/Amidst Seed Hunter/StringSize.au3 Archived/Amidst Seed Hunter/Toast.au3 Archived/Toast.zip Settings.ini +Settings.ini diff --git a/AmidstSeedHunter.au3 b/AmidstSeedHunter.au3 index 48709cb..cc20f9e 100644 --- a/AmidstSeedHunter.au3 +++ b/AmidstSeedHunter.au3 @@ -22,175 +22,21 @@ AutoItSetOption("MustDeclareVars", 1) #include #include #include +#include #include #include #include +#include #include #include -#include "Include\Toast.au3" -#include "Include\GuiFunctions.au3" -#include "Include\AmidstFunctions.au3" -#include "Include\SearchFunctions.au3" -#include "Include\PresetFunctions.au3" -#Region Globals -Global $debugBuffer, $searchResults, $newSearch -Global $versionNumber = "0.2.2" - -; GUI control globals -Global $form, $tabSet, $biomesTab, $structuresTab, $optionsTab, $resultsTab, $debugTab -Global $cancelQuitButton, $beginSearchButton, $currentTab, $previousTab - -Global $availableBiomeList, $includedBiomeList, $excludedBiomeList -Global $availableBiomeLabel, $includedBiomeLabel, $excludedBiomeLabel -Global $includeBiomeButton, $removeIncludedBiomeButton, $removeAllIncludedBiomeButton -Global $excludeBiomeButton, $removeExcludedBiomeButton, $removeAllExcludedBiomeButton -Global $preset0Button, $preset1Button, $preset2Button, $preset3Button, $preset4Button - -Global $availableStructList, $includedStructList, $excludedStructList -Global $availableStructLabel, $includedStructLabel, $excludedStructLabel -Global $includeStructButton, $removeIncludedStructButton, $removeAllIncludedStructButton -Global $excludeStructButton, $removeExcludedStructButton, $removeAllExcludedStructButton -Global $preset5Button, $preset6Button, $preset7Button, $preset8Button, $preset9Button - -Global $seedOptionsGroup, $searchOptionsGroup, $otherOptionsGroup -Global $useRandomSeedsRadio, $useSeedListFileRadio, $seedListFileLabel, $seedListFileInput -Global $seedListFileBrowseButton, $seedOffsetLabel, $seedOffsetInput, $seedListInfoLabel -Global $searchForBiomeChkbx, $searchForStructChkbx, $saveResultsToFileChkbx -Global $includeRejectedSeedsChkbx, $resultsOutputFileLabel, $resultsOutputFileInput -Global $resultsOutputFileBrowseButton, $overwriteOutputFileChkbx -Global $maxSeedsLabel, $maxSeedsInput, $numSeedsToEvaluateLabel, $numSeedsToEvaluateInput -Global $guidedAmidstSetupChkbx, $saveScreenshotChkbx, $rememberAmidstWinSizeChkbx -Global $macLinuxCompatChkbx, $showProgressPopupChkbx, $showResultsTabChkbx, $enableDebugChkbx -Global $restoreHiddenDialogsButton, $reloadSettingsINIButton, $resetAllOptionsButton -Global $removePresetButton - -Global $resultsEdit, $clearResultsButton, $copyResultsButton, $saveResultsButton - -Global $debugEdit, $clearDebugButton, $copyDebugButton, $saveDebugButton - -Global $biomeTabControlsArray = [] -Global $structTabControlsArray = [] -Global $optionsTabControlsArray = [] -Global $resultsTabControlsArray = [] -Global $debugTabControlsArray = [] - -Global $removePresetsForm = -1 -Global $msg, $cancelButton, $okButton -Global $preset0Chkbx, $preset1Chkbx, $preset2Chkbx, $preset3Chkbx, $preset4Chkbx -Global $preset5Chkbx, $preset6Chkbx, $preset7Chkbx, $preset8Chkbx, $preset9Chkbx -Global $presetsSet = [] - -; Settings globals -Global $settingsINIFile, $useRandomSeeds, $seedListFile, $seedOffset, $seedFileInfo -Global $searchForBiomes, $searchForStructures, $saveSearchResultsToFile, $includeRejectedSeeds -Global $maxSeedsToEvaluate, $seedsToFind, $resultsFile, $overwriteResults, $guidedAmidstSetup -Global $saveScreenshots, $rememberAmidstWindowSize, $showProgressPopupWindow, $macLinuxCompatibility -Global $showResultsTab, $enableDebugging -Global $amidstSetupComplete = False -Global $presetArray = [] -Global $biomeArray = [] -Global $structArray = [] -Global $amidstWindowTitle = "Amidst v4.2" - -Func UpdateGlobals() - $settingsINIFile = @ScriptDir & "\Settings.ini" - - If FileExists($settingsINIFile) Then - $useRandomSeeds = IniRead($settingsINIFile, "Options", "UseRandomSeeds", 1) - $seedListFile = IniRead($settingsINIFile, "Options", "SeedListFile", "") - $seedOffset = IniRead($settingsINIFile, "Options", "SeedOffset", 0) - $seedFileInfo = IniRead($settingsINIFile, "Options", "SeedFileInfo", "") - $searchForBiomes = IniRead($settingsINIFile, "Options", "SearchForBiomes", 1) - $saveSearchResultsToFile = IniRead($settingsINIFile, "Options", "SaveSearchResultsToFile", 0) - $searchForStructures = IniRead($settingsINIFile, "Options", "SearchForStructures", 0) - $includeRejectedSeeds = IniRead($settingsINIFile, "Options", "IncludeRejectedSeeds", 0) - $maxSeedsToEvaluate = IniRead($settingsINIFile, "Options", "MaxSeedsToEvaluate", 100) - $seedsToFind = IniRead($settingsINIFile, "Options", "SeedsToFind", 1) - $resultsFile = IniRead($settingsINIFile, "Options", "ResultsFile", "") - $overwriteResults = IniRead($settingsINIFile, "Options", "OverwriteResults", 0) - $guidedAmidstSetup = IniRead($settingsINIFile, "Options", "GuidedAmidstSetup", 1) - $saveScreenshots = IniRead($settingsINIFile, "Options", "SaveScreenshots", 0) - $rememberAmidstWindowSize = IniRead($settingsINIFile, "Options", "RememberAmidstWindowSize", 0) - $showProgressPopupWindow = IniRead($settingsINIFile, "Options", "ShowProgressPopupWindow", 1) - $macLinuxCompatibility = IniRead($settingsINIFile, "Options", "MacLinuxCompatibility", 0) - $showResultsTab = IniRead($settingsINIFile, "Options", "ShowResultsTab", 0) - $enableDebugging = IniRead($settingsINIFile, "Options", "EnableDebugging", 0) - $presetArray = IniReadSection($settingsINIFile, "Presets") - $biomeArray = IniReadSection($settingsINIFile, "BiomeList") - $structArray = IniReadSection($settingsINIFile, "StructureList") - Else - DoResetINIFileToDefaults(False) ; Create INI File - IniWriteSection($settingsINIFile, "Presets", "Preset0Name=" & @LF & "Preset0Include=" & @LF & _ - "Preset0Exclude=" & @LF & "Preset1Name=" & @LF & "Preset1Include=" & @LF & "Preset1Exclude=" & _ - @LF & "Preset2Name=" & @LF & "Preset2Include=" & @LF & "Preset2Exclude=" & @LF & "Preset3Name=" _ - & @LF & "Preset3Include=" & @LF & "Preset3Exclude=" & @LF & "Preset4Name=" & @LF & _ - "Preset4Include=" & @LF & "Preset4Exclude=" & @LF & "Preset5Name=" & @LF & "Preset5Include=" & _ - @LF & "Preset5Exclude=" & @LF & "Preset6Name=" & @LF & "Preset6Include=" & @LF & _ - "Preset6Exclude=" & @LF & "Preset7Name=" & @LF & "Preset7Include=" & @LF & "Preset7Exclude=" & _ - @LF & "Preset8Name=" & @LF & "Preset8Include=" & @LF & "Preset8Exclude=" & @LF & "Preset9Name=" _ - & @LF & "Preset9Include=" & @LF & "Preset9Exclude=") - IniWriteSection($settingsINIFile, "BiomeList", "Beach=0xFADE55" & @LF & "Beach M=0xFFFF7D" & @LF & _ - "Birch Forest=0x307444" & @LF & "Birch Forest Hills=0x1F5F32" & @LF & _ - "Birch Forest Hills M=0x47875A" & @LF & "Birch Forest M=0x589C6C" & @LF & "Cold Beach=0xFAF0C0" _ - & @LF & "Cold Beach M=0xFFFFE8" & @LF & "Cold Taiga=0x31554A" & @LF & "Cold Taiga Hills=0x243F36" _ - & @LF & "Cold Taiga Hills M=0x4C675E" & @LF & "Cold Taiga M=0x597D72" & @LF & "Deep Ocean=0x000030" _ - & @LF & "Deep Ocean M=0x282858" & @LF & "Desert=0xFA9418" & @LF & "Desert Hills=0xD25F12" & @LF & _ - "Desert Hills M=0xFA873A" & @LF & "Desert M=0xFFBC40" & @LF & "Extreme Hills+=0x507050" & @LF & _ - "Extreme Hills=0x606060" & @LF & "Extreme Hills Edge=0x72789A" & @LF & _ - "Extreme Hills Edge M=0x9AA0C2" & @LF & "Extreme Hills M=0x888888" & @LF & _ - "Extreme Hills+ M=0x789878" & @LF & "Flower Forest=0x2D8E49" & @LF & "Forest=0x056621" & @LF & _ - "Forest Hills=0x22551C" & @LF & "Forest Hills M=0x4A7D44" & @LF & "Frozen Ocean=0x9090A0" & @LF _ - & "Frozen Ocean M=0xB8B8C8" & @LF & "Frozen River=0xA0A0FF" & @LF & "Frozen River M=0xC8C8FF" & _ - @LF & "Ice Mountains=0xA0A0A0" & @LF & "Ice Mountains M=0xC8C8C8" & @LF & "Ice Plains=0xFFFFFF" & _ - @LF & "Ice Plains Spikes=0xB4DCDC" & @LF & "Jungle=0x537B09" & @LF & "Jungle Edge=0x628B17" & @LF _ - & "Jungle Edge M=0x8AB33F" & @LF & "Jungle Hills=0x2C4205" & @LF & "Jungle Hills M=0x546A2D" & @LF _ - & "Jungle M=0x7BA331" & @LF & "Mega Spruce Taiga=0x818E79" & @LF & _ - "Mega Spruce Taiga (Hills)=0x6D7766" & @LF & "Mega Taiga=0x596651" & @LF & _ - "Mega Taiga Hills=0x454F3E" & @LF & "Mesa=0xD94515" & @LF & "Mesa (Bryce)=0xFF6D3D" & @LF & _ - "Mesa Plateau=0xCA8C65" & @LF & "Mesa Plateau F=0xB09765" & @LF & "Mesa Plateau F M=0xD8BF8D" & @LF _ - & "Mesa Plateau M=0xF2B48D" & @LF & "Mushroom Island=0xFF00FF" & @LF & "Mushroom Island M=0xFF28FF" _ - & @LF & "Mushroom Island Shore=0xA000FF" & @LF & "Mushroom Island Shore M=0xC828FF" & @LF & _ - "Ocean=0x000070" & @LF & "Ocean M=0x282898" & @LF & "Plains=0x8DB360" & @LF & "River=0x0000FF" & @LF _ - & "River M=0x2828FF" & @LF & "Roofed Forest=0x40511A" & @LF & "Roofed Forest M=0x687942" & @LF & _ - "Savanna=0xBDB25F" & @LF & "Savanna M=0xE5DA87" & @LF & "Savanna Plateau=0xA79D64" & @LF & _ - "Savanna Plateau M=0xCFC58C" & @LF & "Stone Beach=0xA2A284" & @LF & "Stone Beach M=0xCACAAC" & @LF & _ - "Sunflower Plains=0xB5DB88" & @LF & "Swampland=0x07F9B2" & @LF & "Swampland M=0x2FFFDA" & @LF & _ - "Taiga=0x0B6659" & @LF & "Taiga Hills=0x163933" & @LF & "Taiga Hills M=0x3E615B" & @LF & _ - "Taiga M=0x338E81") - IniWriteSection($settingsINIFile, "StructureList", "Desert Temple=0xBBB36D" & @LF & "Igloo=0xA7B8FF" & @LF & _ - "Jungle Temple=0x364636" & @LF & "Mineshaft=0x76613C" & @LF & "Nether Fortress=0x311E24" & @LF & _ - "Ocean Monument=0x285A45" & @LF & "Stronghold=0x4D5A35" & @LF & "Village=0x75472F" & @LF & _ - "Witch Hut=0x0F41FB") - UpdateGlobals() - EndIf -EndFunc -#EndRegion - -#Region Debug Functions -Func DebugWrite($data) - If $enableDebugging = 1 Then - Dim $timestampedData = GetTimestamp() & " >> " & $data & @CRLF - If @Compiled = 0 Then ConsoleWrite($timestampedData & @CRLF) - If $debugEdit = Null Then ; Debug edit control does not exist - $debugBuffer = $debugBuffer & $timestampedData - Else - _GUICtrlEdit_AppendText($debugEdit, $debugBuffer) - _GUICtrlEdit_AppendText($debugEdit, $timestampedData) - - ; Scroll to the bottom of the control - _GUICtrlEdit_LineScroll($debugEdit, 0, _GUICtrlEdit_GetLineCount($debugEdit)) - - ; Buffer is no longer needed, since control exists - $debugBuffer = "" - EndIf - EndIf -EndFunc - -Func GetTimestamp() - Return _Date_Time_SystemTimeToDateTimeStr(_Date_Time_GetLocalTime()) -EndFunc -#EndRegion +#include "Include\ASH_Amidst.au3" +#include "Include\ASH_Debug.au3" +#include "Include\ASH_Globals.au3" +#include "Include\ASH_GUI.au3" +#include "Include\ASH_Presets.au3" +#include "Include\ASH_Search.au3" +#include "Include\ASH_Toast.au3" ; This is a lightly modified version of Melba23's Toast UDF Func Main() UpdateGlobals() @@ -200,24 +46,34 @@ Func Main() DebugWrite("Initializing main GUI") DoBuildMainGUI() + ; Register message handlers + GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") + GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") + $previousTab = _GUICtrlTab_GetCurFocus($tabSet) ; Main loop While 1 $msg = GUIGetMsg($GUI_EVENT_ARRAY) - ;_ArrayDisplay($msg) - If $msg[1] = $form Then Switch $msg[0] Case $GUI_EVENT_CLOSE Exit + Case $GUI_EVENT_SECONDARYUP ; Right-click released + DoRightClickAction() Case $cancelQuitButton DebugWrite("Cancel/Quit button pressed") Exit Case $beginSearchButton DebugWrite("Begin Search button pressed") DoSearch() + Case $advancedSearchMenuItem + DoAdvancedSearch() + ;Case $includedBiomeGroupButton + ; DoBiomeGroupPopupMenu($includedBiomeGroupButton) + ;Case $excludedBiomeGroupButton + ; DoBiomeGroupPopupMenu($excludedBiomeGroupButton) Case $includeBiomeButton DebugWrite("Include biome button pressed") DoMoveListItems($availableBiomeList, $includedBiomeList) @@ -241,18 +97,33 @@ Func Main() Case $preset0Button DebugWrite("Preset 0 button pressed") DoPresetButton(0) + Case $removePreset0 + DoRemovePreset(0, True) + DoUpdatePresets() Case $preset1Button DebugWrite("Preset 1 button pressed") DoPresetButton(1) + Case $removePreset1 + DoRemovePreset(1, True) + DoUpdatePresets() Case $preset2Button DebugWrite("Preset 2 button pressed") DoPresetButton(2) + Case $removePreset2 + DoRemovePreset(2, True) + DoUpdatePresets() Case $preset3Button DebugWrite("Preset 3 button pressed") DoPresetButton(3) + Case $removePreset3 + DoRemovePreset(3, True) + DoUpdatePresets() Case $preset4Button DebugWrite("Preset 4 button pressed") DoPresetButton(4) + Case $removePreset4 + DoRemovePreset(4, True) + DoUpdatePresets() Case $includeStructButton DebugWrite("Include structure button pressed") DoMoveListItems($availableStructList, $includedStructList) @@ -276,18 +147,33 @@ Func Main() Case $preset5Button DebugWrite("Preset 5 button pressed") DoPresetButton(5) + Case $removePreset5 + DoRemovePreset(5, True) + DoUpdatePresets() Case $preset6Button DebugWrite("Preset 6 button pressed") DoPresetButton(6) + Case $removePreset6 + DoRemovePreset(6, True) + DoUpdatePresets() Case $preset7Button DebugWrite("Preset 7 button pressed") DoPresetButton(7) + Case $removePreset7 + DoRemovePreset(7, True) + DoUpdatePresets() Case $preset8Button DebugWrite("Preset 8 button pressed") DoPresetButton(8) + Case $removePreset8 + DoRemovePreset(8, True) + DoUpdatePresets() Case $preset9Button DebugWrite("Preset 9 button pressed") DoPresetButton(9) + Case $removePreset9 + DoRemovePreset(9, True) + DoUpdatePresets() Case $useRandomSeedsRadio If $useRandomSeeds = 0 Then IniWrite($settingsINIFile, "Options", "UseRandomSeeds", 1) @@ -326,6 +212,18 @@ Func Main() UpdateGlobals() DebugWrite("SearchForBiomes set to '" & $searchForBiomes & "'") EndIf + Case $enableBiomeGroupsChkbx + If $enableBiomeGroups = 0 Then + IniWrite($settingsINIFile, "Options", "EnableBiomeGroups", 1) + DoAddBiomeGroupsToList() + UpdateGlobals() + DebugWrite("EnableBiomeGroups set to '" & $enableBiomeGroups & "'") + Else + IniWrite($settingsINIFile, "Options", "EnableBiomeGroups", 0) + DoRemoveBiomeGroupsFromList() + UpdateGlobals() + DebugWrite("EnableBiomeGroups set to '" & $enableBiomeGroups & "'") + EndIf Case $searchForStructChkbx If $searchForStructures = 0 Then IniWrite($settingsINIFile, "Options", "SearchForStructures", 1) @@ -579,6 +477,36 @@ Func Main() ; Do nothing EndSwitch EndIf + + + + #cs + ; Show a tooltip for biome group items in the AvailableBiomeList + If $enableBiomeGroups = 1 Then + ; Tooltip on hover + Dim $cursorInfo = GUIGetCursorInfo($form) + + If $cursorInfo[4] = GUICtrlGetHandle($availableBiomeList) Then + ;Dim $itemIndex = _GUICtrlListBox_ItemFromPoint($availableBiomeList, $cursorInfo[0] - 8, $cursorInfo[1] - 55) + Dim $itemIndex = _GUICtrlListBox_GetSelItems($availableBiomeList) + If UBound($itemIndex) <> 2 Then + ToolTip("") + Else + Dim $itemText = _GUICtrlListBox_GetText($availableBiomeList, $itemIndex[1]) + Dim $itemLeft3Letters = StringLeft($itemText, 3) + If $itemLeft3Letters = "Any" Or $itemLeft3Letters = "All" Then + Dim $index = _ArraySearch($biomeGroupArray, $itemText) + Dim $tooltip = $biomeGroupArray[$index][1] + ToolTip($tooltip) + EndIf + EndIf + Else + ToolTip("") + EndIf + Else + ToolTip("") + EndIf + #ce Wend EndFunc diff --git a/Include/AmidstFunctions.au3 b/Include/ASH_Amidst.au3 similarity index 97% rename from Include/AmidstFunctions.au3 rename to Include/ASH_Amidst.au3 index 0c12671..ae0150b 100644 --- a/Include/AmidstFunctions.au3 +++ b/Include/ASH_Amidst.au3 @@ -1,12 +1,11 @@ ; ============================================================================= -; Amidst Seed Hunter - Amidst Functions (AmidstFunctions.au3) +; Amidst Seed Hunter - Amidst (ASH_Amidst.au3) ; -; Author: Azuntik (seedhunter@azuntik.com) -; Date: 2017.4.22 -; Download: https://github.com/azuntik/Amidst-Seed-Hunter/releases +; Author: Azuntik +; Date: 2017.5.2 ; License: CC BY-NC-SA 4.0 (https://creativecommons.org/licenses/by-nc-sa/4.0/) ; -; For use with Amidst v4.2 (https://github.com/toolbox4minecraft/amidst). +; This file is part of the Amidst Seed Hunter project ; ============================================================================= Func AmidstIsRunning() diff --git a/Include/ASH_Debug.au3 b/Include/ASH_Debug.au3 new file mode 100644 index 0000000..0ae08a5 --- /dev/null +++ b/Include/ASH_Debug.au3 @@ -0,0 +1,32 @@ +; ============================================================================= +; Amidst Seed Hunter - Debug (ASH_Debug.au3) +; +; Author: Azuntik +; Date: 2017.5.2 +; License: CC BY-NC-SA 4.0 (https://creativecommons.org/licenses/by-nc-sa/4.0/) +; +; This file is part of the Amidst Seed Hunter project +; ============================================================================= + +Func DebugWrite($data) + If $enableDebugging = 1 Then + Dim $timestampedData = GetTimestamp() & " >> " & $data & @CRLF + If @Compiled = 0 Then ConsoleWrite($timestampedData & @CRLF) + If $debugEdit = Null Then ; Debug edit control does not exist + $debugBuffer = $debugBuffer & $timestampedData + Else + _GUICtrlEdit_AppendText($debugEdit, $debugBuffer) + _GUICtrlEdit_AppendText($debugEdit, $timestampedData) + + ; Scroll to the bottom of the control + _GUICtrlEdit_LineScroll($debugEdit, 0, _GUICtrlEdit_GetLineCount($debugEdit)) + + ; Buffer is no longer needed, since control exists + $debugBuffer = "" + EndIf + EndIf +EndFunc + +Func GetTimestamp() + Return _Date_Time_SystemTimeToDateTimeStr(_Date_Time_GetLocalTime()) +EndFunc diff --git a/Include/GuiFunctions.au3 b/Include/ASH_GUI.au3 similarity index 81% rename from Include/GuiFunctions.au3 rename to Include/ASH_GUI.au3 index 5b169fb..4506454 100644 --- a/Include/GuiFunctions.au3 +++ b/Include/ASH_GUI.au3 @@ -1,12 +1,11 @@ ; ============================================================================= -; Amidst Seed Hunter - GUI Functions (GuiFunctions.au3) +; Amidst Seed Hunter - GUI (ASH_GUI.au3) ; -; Author: Azuntik (seedhunter@azuntik.com) -; Date: 2017.4.22 -; Download: https://github.com/azuntik/Amidst-Seed-Hunter/releases +; Author: Azuntik +; Date: 2017.5.2 ; License: CC BY-NC-SA 4.0 (https://creativecommons.org/licenses/by-nc-sa/4.0/) ; -; For use with Amidst v4.2 (https://github.com/toolbox4minecraft/amidst). +; This file is part of the Amidst Seed Hunter project ; ============================================================================= #Region Build GUI Functions @@ -16,6 +15,8 @@ Func DoBuildMainGUI() $tabSet = _GUICtrlTab_Create($form, 5, 5, 490, 457) $beginSearchButton = GUICtrlCreateButton("Begin Search...", 397, 467, 95, 25) + $searchContextMenu = GUICtrlCreateContextMenu($beginSearchButton) + $advancedSearchMenuItem = GUICtrlCreateMenuItem("Advanced Search...", $searchContextMenu) $cancelQuitButton = GUICtrlCreateButton("Cancel/Quit", 5, 467, 95, 25) If $searchForBiomes = 1 Then DoBuildBiomesTab() @@ -65,7 +66,22 @@ Func DoBuildBiomesTab() $excludedBiomeLabel = GUICtrlCreateLabel("Excluded Biomes:", 306, 233) GUICtrlSetBkColor($excludedBiomeLabel, $GUI_BKCOLOR_TRANSPARENT) _ArrayAdd($biomeTabControlsArray, $excludedBiomeLabel) - + + #cs + $includedBiomeGroupButton = GUICtrlCreateButton("Biome Group...", 392, 33, 94, 20, $BS_SPLITBUTTON) + ;$includedBiomeGroupButton = _GUICtrlButton_Create($form, "Biome Group...", 392, 33, 94, 20, $BS_SPLITBUTTON) + _ArrayAdd($biomeTabControlsArray, $includedBiomeGroupButton) + + $excludedBiomeGroupButton = GUICtrlCreateButton("Biome Group...", 392, 229, 94, 20, $BS_SPLITBUTTON) + ;$excludedBiomeGroupButton = _GUICtrlButton_Create($form, "Biome Group...", 392, 229, 94, 20, $BS_SPLITBUTTON) + _ArrayAdd($biomeTabControlsArray, $excludedBiomeGroupButton) + + If $enableBiomeGroups = 0 Then + GUICtrlSetState($includedBiomeGroupButton, $GUI_HIDE) + GUICtrlSetState($excludedBiomeGroupButton, $GUI_HIDE) + EndIf + #ce + $includeBiomeButton = GUICtrlCreateButton("Include ->", 203, 105, 90, 25) _ArrayAdd($biomeTabControlsArray, $includeBiomeButton) @@ -86,27 +102,43 @@ Func DoBuildBiomesTab() $temp = _ArraySearch($presetArray, "Preset0Name") $preset0Button = GUICtrlCreateButton($presetArray[$temp][1], 12, 429, 90, 25) + $preset0ContextMenu = GUICtrlCreateContextMenu($preset0Button) + $removePreset0 = GUICtrlCreateMenuItem("Remove this preset", $preset0ContextMenu) _ArrayAdd($biomeTabControlsArray, $preset0Button) $temp = _ArraySearch($presetArray, "Preset1Name") $preset1Button = GUICtrlCreateButton($presetArray[$temp][1], 108, 429, 90, 25) + $preset1ContextMenu = GUICtrlCreateContextMenu($preset1Button) + $removePreset1 = GUICtrlCreateMenuItem("Remove this preset", $preset1ContextMenu) _ArrayAdd($biomeTabControlsArray, $preset1Button) $temp = _ArraySearch($presetArray, "Preset2Name") $preset2Button = GUICtrlCreateButton($presetArray[$temp][1], 204, 429, 90, 25) + $preset2ContextMenu = GUICtrlCreateContextMenu($preset2Button) + $removePreset2 = GUICtrlCreateMenuItem("Remove this preset", $preset2ContextMenu) _ArrayAdd($biomeTabControlsArray, $preset2Button) $temp = _ArraySearch($presetArray, "Preset3Name") $preset3Button = GUICtrlCreateButton($presetArray[$temp][1], 300, 429, 90, 25) + $preset3ContextMenu = GUICtrlCreateContextMenu($preset3Button) + $removePreset3 = GUICtrlCreateMenuItem("Remove this preset", $preset3ContextMenu) _ArrayAdd($biomeTabControlsArray, $preset3Button) $temp = _ArraySearch($presetArray, "Preset4Name") $preset4Button = GUICtrlCreateButton($presetArray[$temp][1], 396, 429, 90, 25) + $preset4ContextMenu = GUICtrlCreateContextMenu($preset4Button) + $removePreset4 = GUICtrlCreateMenuItem("Remove this preset", $preset4ContextMenu) _ArrayAdd($biomeTabControlsArray, $preset4Button) For $i = 1 to UBound($biomeArray) - 1 _GUICtrlListBox_AddString($availableBiomeList, $biomeArray[$i][0]) Next + + If $enableBiomeGroups = 1 Then + For $i = 1 to UBound($biomeGroupArray) - 1 + _GUICtrlListBox_AddString($availableBiomeList, $biomeGroupArray[$i][0]) + Next + EndIf DoHideBiomesTab() EndFunc @@ -161,22 +193,32 @@ Func DoBuildStructuresTab() $temp = _ArraySearch($presetArray, "Preset5Name") $preset5Button = GUICtrlCreateButton($presetArray[$temp][1], 12, 429, 90, 25) + $preset5ContextMenu = GUICtrlCreateContextMenu($preset5Button) + $removePreset5 = GUICtrlCreateMenuItem("Remove this preset", $preset5ContextMenu) _ArrayAdd($structTabControlsArray, $preset5Button) $temp = _ArraySearch($presetArray, "Preset6Name") $preset6Button = GUICtrlCreateButton($presetArray[$temp][1], 108, 429, 90, 25) + $preset6ContextMenu = GUICtrlCreateContextMenu($preset6Button) + $removePreset6 = GUICtrlCreateMenuItem("Remove this preset", $preset6ContextMenu) _ArrayAdd($structTabControlsArray, $preset6Button) $temp = _ArraySearch($presetArray, "Preset7Name") $preset7Button = GUICtrlCreateButton($presetArray[$temp][1], 204, 429, 90, 25) + $preset7ContextMenu = GUICtrlCreateContextMenu($preset7Button) + $removePreset7 = GUICtrlCreateMenuItem("Remove this preset", $preset7ContextMenu) _ArrayAdd($structTabControlsArray, $preset7Button) $temp = _ArraySearch($presetArray, "Preset8Name") $preset8Button = GUICtrlCreateButton($presetArray[$temp][1], 300, 429, 90, 25) + $preset8ContextMenu = GUICtrlCreateContextMenu($preset8Button) + $removePreset8 = GUICtrlCreateMenuItem("Remove this preset", $preset8ContextMenu) _ArrayAdd($structTabControlsArray, $preset8Button) $temp = _ArraySearch($presetArray, "Preset9Name") $preset9Button = GUICtrlCreateButton($presetArray[$temp][1], 396, 429, 90, 25) + $preset9ContextMenu = GUICtrlCreateContextMenu($preset9Button) + $removePreset9 = GUICtrlCreateMenuItem("Remove this preset", $preset9ContextMenu) _ArrayAdd($structTabControlsArray, $preset9Button) For $i = 1 to UBound($structArray) - 1 @@ -242,17 +284,24 @@ Func DoBuildOptionsTab() If $searchForBiomes = 1 Then GUICtrlSetState($searchForBiomeChkbx, $GUI_CHECKED) _ArrayAdd($optionsTabControlsArray, $searchForBiomeChkbx) - $searchForStructChkbx = GUICtrlCreateCheckbox("Search for structures", 20, 169) + #cs + $enableBiomeGroupsChkbx = GUICtrlCreateCheckbox("Enable biome groups", 20, 169) + GUICtrlSetBkColor($enableBiomeGroupsChkbx, $COLOR_WHITE) ;$GUI_BKCOLOR_TRANSPARENT) + If $enableBiomeGroups = 1 Then GUICtrlSetState($enableBiomeGroupsChkbx, $GUI_CHECKED) + _ArrayAdd($optionsTabControlsArray, $enableBiomeGroupsChkbx) + #ce + + $searchForStructChkbx = GUICtrlCreateCheckbox("Search for structures", 20, 193) GUICtrlSetBkColor($searchForStructChkbx, $COLOR_WHITE) ;$GUI_BKCOLOR_TRANSPARENT) If $searchForStructures = 1 Then GUICtrlSetState($searchForStructChkbx, $GUI_CHECKED) _ArrayAdd($optionsTabControlsArray, $searchForStructChkbx) - $saveResultsToFileChkbx = GUICtrlCreateCheckbox("Save search results to file", 20, 193) + $saveResultsToFileChkbx = GUICtrlCreateCheckbox("Save search results to file", 20, 217) GUICtrlSetBkColor($saveResultsToFileChkbx, $COLOR_WHITE) ;$GUI_BKCOLOR_TRANSPARENT) If $saveSearchResultsToFile = 1 Then GUICtrlSetState($saveResultsToFileChkbx, $GUI_CHECKED) _ArrayAdd($optionsTabControlsArray, $saveResultsToFileChkbx) - $includeRejectedSeedsChkbx = GUICtrlCreateCheckbox("Include rejected seeds in search results", 20, 217) + $includeRejectedSeedsChkbx = GUICtrlCreateCheckbox("Include rejected seeds in search results", 275, 193) GUICtrlSetBkColor($includeRejectedSeedsChkbx, $COLOR_WHITE) ;$GUI_BKCOLOR_TRANSPARENT) If $includeRejectedSeeds = 1 Then GUICtrlSetState($includeRejectedSeedsChkbx, $GUI_CHECKED) _ArrayAdd($optionsTabControlsArray, $includeRejectedSeedsChkbx) @@ -295,6 +344,7 @@ Func DoBuildOptionsTab() If $guidedAmidstSetup = 1 Then GUICtrlSetState($guidedAmidstSetupChkbx, $GUI_CHECKED) _ArrayAdd($optionsTabControlsArray, $guidedAmidstSetupChkbx) + #cs $saveScreenshotChkbx = GUICtrlCreateCheckbox("Save screenshot of matching seed maps", 20, 312) GUICtrlSetBkColor($saveScreenshotChkbx, $COLOR_WHITE) ;$GUI_BKCOLOR_TRANSPARENT) If $saveScreenshots = 1 Then GUICtrlSetState($saveScreenshotChkbx, $GUI_CHECKED) @@ -309,7 +359,8 @@ Func DoBuildOptionsTab() GUICtrlSetBkColor($macLinuxCompatChkbx, $COLOR_WHITE) ;$GUI_BKCOLOR_TRANSPARENT) If $macLinuxCompatibility = 1 Then GUICtrlSetState($macLinuxCompatChkbx, $GUI_CHECKED) _ArrayAdd($optionsTabControlsArray, $macLinuxCompatChkbx) - + #ce + $showProgressPopupChkbx = GUICtrlCreateCheckbox("Show progress popup window", 275, 288) GUICtrlSetBkColor($showProgressPopupChkbx, $COLOR_WHITE) ;$GUI_BKCOLOR_TRANSPARENT) If $showProgressPopupWindow = 1 Then GUICtrlSetState($showProgressPopupChkbx, $GUI_CHECKED) @@ -423,6 +474,11 @@ Func DoShowBiomesTab() ControlShow($tabSet, "", $biomeTabControlsArray[$i]) GUICtrlSetState($biomeTabControlsArray[$i], $GUI_SHOW) Next + + If $enableBiomeGroups = 0 Then + GUICtrlSetState($includedBiomeGroupButton, $GUI_HIDE) + GUICtrlSetState($excludedBiomeGroupButton, $GUI_HIDE) + EndIf EndFunc Func DoHideBiomesTab() @@ -490,6 +546,89 @@ EndFunc #EndRegion #Region GUI Manipulation Functions +#cs +Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) + #forceref $hWnd, $iMsg + Local $nNotifyCode = BitShift($wParam, 16) + Local $nID = BitAND($wParam, 0x0000FFFF) + Local $hCtrl = $lParam + Local $sText = "" + + Switch $hCtrl + Case $g_idBtn, $g_idBtn2 + Switch $nNotifyCode + Case $BN_CLICKED + $sText = "$BN_CLICKED" & @CRLF + Case $BN_PAINT + $sText = "$BN_PAINT" & @CRLF + Case $BN_PUSHED, $BN_HILITE + $sText = "$BN_PUSHED, $BN_HILITE" & @CRLF + Case $BN_UNPUSHED, $BN_UNHILITE + $sText = "$BN_UNPUSHED" & @CRLF + Case $BN_DISABLE + $sText = "$BN_DISABLE" & @CRLF + Case $BN_DBLCLK, $BN_DOUBLECLICKED + $sText = "$BN_DBLCLK, $BN_DOUBLECLICKED" & @CRLF + Case $BN_SETFOCUS + $sText = "$BN_SETFOCUS" & @CRLF + Case $BN_KILLFOCUS + $sText = "$BN_KILLFOCUS" & @CRLF + EndSwitch + Return 0 ; Only workout clicking on the button + EndSwitch + ; Proceed the default AutoIt3 internal message commands. + ; You also can complete let the line out. + ; !!! But only 'Return' (without any value) will not proceed + ; the default AutoIt3-message in the future !!! + Return $GUI_RUNDEFMSG +EndFunc ;==>WM_COMMAND + +Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) + #forceref $hWnd, $iMsg, $wParam + Local Const $BCN_HOTITEMCHANGE = -1249 + Local $tNMBHOTITEM = DllStructCreate("hwnd hWndFrom;int IDFrom;int Code;dword dwFlags", $lParam) + Local $nNotifyCode = DllStructGetData($tNMBHOTITEM, "Code") + Local $nID = DllStructGetData($tNMBHOTITEM, "IDFrom") + Local $hCtrl = DllStructGetData($tNMBHOTITEM, "hWndFrom") + Local $iFlags = DllStructGetData($tNMBHOTITEM, "dwFlags") + Local $sText = "" + + DoBiomeGroupPopupMenu($hCtrl) + + Return $GUI_RUNDEFMSG +EndFunc ;==>WM_NOTIFY + +Func DoBiomeGroupPopupMenu($hCtrl) + Local $hMenu + Local Enum $e_idOpen = 1000, $e_idSave, $e_idInfo + $hMenu = _GUICtrlMenu_CreatePopup() + _GUICtrlMenu_InsertMenuItem($hMenu, 0, "Open", $e_idOpen) + _GUICtrlMenu_InsertMenuItem($hMenu, 1, "Save", $e_idSave) + _GUICtrlMenu_InsertMenuItem($hMenu, 3, "", 0) + _GUICtrlMenu_InsertMenuItem($hMenu, 3, "Info", $e_idInfo) + Switch _GUICtrlMenu_TrackPopupMenu($hMenu, $hCtrl, -1, -1, 1, 1, 2) + Case $e_idOpen + MemoWrite("Open - Selected") + Case $e_idSave + MemoWrite("Save - Selected") + Case $e_idInfo + MemoWrite("Info - Selected") + EndSwitch + _GUICtrlMenu_DestroyMenu($hMenu) +EndFunc + +Func DoUpdateBiomeGroup($list) + +EndFunc + +Func DoRightClickAction() + Dim $cursorInfo = GUIGetCursorInfo($form) + Dim $controlUnderMouse = $cursorInfo[4] + + ;MsgBox(0,"Right click", "You clicked " & $controlUnderMouse) +EndFunc +#ce + Func DoSelectAllListItems($list) DebugWrite("Selecting all items in list " & $list) Dim $numItems = _GUICtrlListBox_GetListBoxInfo($list) @@ -537,6 +676,23 @@ Func DoGetResultsOutputFile() DebugWrite("ResultsFile set to '" & $resultsFile & "'") EndFunc +#cs +Func DoAddBiomeGroupsToList() + For $i = 1 to UBound($biomeGroupArray) - 1 + ; Make sure the string doesn't exist before adding it + If _GUICtrlListBox_FindString($availableBiomeList, $biomeGroupArray[$i][0]) = -1 Then + _GUICtrlListBox_AddString($availableBiomeList, $biomeGroupArray[$i][0]) + EndIf + Next +EndFunc + +Func DoRemoveBiomeGroupsFromList() + For $i = 1 to UBound($biomeGroupArray) - 1 + _GUICtrlListBox_DeleteString($availableBiomeList, $biomeGroupArray[$i][0]) + Next +EndFunc +#ce + Func DoRestoreHiddenDialogs() Dim $response @@ -549,6 +705,8 @@ Func DoRestoreHiddenDialogs() RegDelete("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\DontShowMeThisDialogAgain", "{3AC815B9-2394-4E3C-92CA-E51BCBDEDE16}") ; Begin search info dialog box RegDelete("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\DontShowMeThisDialogAgain", "{2D6A1CA1-EE2B-4AD2-9FB8-60052F49C56B}") + ; Reset preset button dialog box + RegDelete("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\DontShowMeThisDialogAgain", "{E0E777CD-DA7B-40E0-9ECC-9ADD4F2BE0E9}") If @error = 0 Then MsgBox(BitOR($MB_OK, $MB_ICONINFORMATION), "Hidden messages restored", "All hidden messages have been restored.") @@ -579,6 +737,12 @@ Func DoUpdateOptionsTabFromINIFile() GUICtrlSetState($searchForBiomeChkbx, $GUI_CHECKED) EndIf + If $enableBiomeGroups = 0 Then + GUICtrlSetState($enableBiomeGroupsChkbx, $GUI_UNCHECKED) + Else + GUICtrlSetState($enableBiomeGroupsChkbx, $GUI_CHECKED) + EndIf + If $searchForStructures = 0 Then GUICtrlSetState($searchForStructChkbx, $GUI_UNCHECKED) Else @@ -665,6 +829,7 @@ Func DoResetINIFileToDefaults($prompt = True) IniWrite($settingsINIFile, "Options", "SeedOffset", 0) IniWrite($settingsINIFile, "Options", "SeedFileInfo", "") IniWrite($settingsINIFile, "Options", "SearchForBiomes", 1) + IniWrite($settingsINIFile, "Options", "EnableBiomeGroups", 0) IniWrite($settingsINIFile, "Options", "SaveSearchResultsToFile", 0) IniWrite($settingsINIFile, "Options", "SearchForStructures", 0) IniWrite($settingsINIFile, "Options", "IncludeRejectedSeeds", 0) diff --git a/Include/ASH_Globals.au3 b/Include/ASH_Globals.au3 new file mode 100644 index 0000000..33dc544 --- /dev/null +++ b/Include/ASH_Globals.au3 @@ -0,0 +1,268 @@ +; ============================================================================= +; Amidst Seed Hunter - Globals (ASH_Globals.au3) +; +; Author: Azuntik +; Date: 2017.5.2 +; License: CC BY-NC-SA 4.0 (https://creativecommons.org/licenses/by-nc-sa/4.0/) +; +; This file is part of the Amidst Seed Hunter project +; ============================================================================= + +Global $versionNumber = "0.2.3" +Global $debugBuffer, $searchResults, $newSearch + +; GUI control globals +Global $form, $tabSet, $biomesTab, $structuresTab, $optionsTab, $resultsTab, $debugTab +Global $cancelQuitButton, $beginSearchButton, $currentTab, $previousTab +Global $searchContextMenu, $advancedSearchMenuItem + +Global $availableBiomeList, $includedBiomeList, $excludedBiomeList +Global $availableBiomeLabel, $includedBiomeLabel, $excludedBiomeLabel +Global $includeBiomeButton, $removeIncludedBiomeButton, $removeAllIncludedBiomeButton +Global $excludeBiomeButton, $removeExcludedBiomeButton, $removeAllExcludedBiomeButton +Global $includedBiomeGroupButton, $excludedBiomeGroupButton, $biomeGroupMenu +Global $preset0Button, $preset0ContextMenu, $removePreset0 +Global $preset1Button, $preset1ContextMenu, $removePreset1 +Global $preset2Button, $preset2ContextMenu, $removePreset2 +Global $preset3Button, $preset3ContextMenu, $removePreset3 +Global $preset4Button, $preset4ContextMenu, $removePreset4 + +Global $availableStructList, $includedStructList, $excludedStructList +Global $availableStructLabel, $includedStructLabel, $excludedStructLabel +Global $includeStructButton, $removeIncludedStructButton, $removeAllIncludedStructButton +Global $excludeStructButton, $removeExcludedStructButton, $removeAllExcludedStructButton +Global $preset5Button, $preset5ContextMenu, $removePreset5 +Global $preset6Button, $preset6ContextMenu, $removePreset6 +Global $preset7Button, $preset7ContextMenu, $removePreset7 +Global $preset8Button, $preset8ContextMenu, $removePreset8 +Global $preset9Button, $preset9ContextMenu, $removePreset9 + +Global $seedOptionsGroup, $searchOptionsGroup, $otherOptionsGroup +Global $useRandomSeedsRadio, $useSeedListFileRadio, $seedListFileLabel, $seedListFileInput +Global $seedListFileBrowseButton, $seedOffsetLabel, $seedOffsetInput, $seedListInfoLabel +Global $searchForBiomeChkbx, $enableBiomeGroupsChkbx, $searchForStructChkbx, $saveResultsToFileChkbx +Global $includeRejectedSeedsChkbx, $resultsOutputFileLabel, $resultsOutputFileInput +Global $resultsOutputFileBrowseButton, $overwriteOutputFileChkbx +Global $maxSeedsLabel, $maxSeedsInput, $numSeedsToEvaluateLabel, $numSeedsToEvaluateInput +Global $guidedAmidstSetupChkbx, $saveScreenshotChkbx, $rememberAmidstWinSizeChkbx +Global $macLinuxCompatChkbx, $showProgressPopupChkbx, $showResultsTabChkbx, $enableDebugChkbx +Global $restoreHiddenDialogsButton, $reloadSettingsINIButton, $resetAllOptionsButton +Global $removePresetButton + +Global $resultsEdit, $clearResultsButton, $copyResultsButton, $saveResultsButton + +Global $debugEdit, $clearDebugButton, $copyDebugButton, $saveDebugButton + +Global $biomeTabControlsArray = [] +Global $structTabControlsArray = [] +Global $optionsTabControlsArray = [] +Global $resultsTabControlsArray = [] +Global $debugTabControlsArray = [] + +Global $removePresetsForm = -1 +Global $msg, $cancelButton, $okButton +Global $preset0Chkbx, $preset1Chkbx, $preset2Chkbx, $preset3Chkbx, $preset4Chkbx +Global $preset5Chkbx, $preset6Chkbx, $preset7Chkbx, $preset8Chkbx, $preset9Chkbx +Global $presetsSet = [] + +; Settings globals +Global $settingsINIFile, $useRandomSeeds, $seedListFile, $seedOffset, $seedFileInfo +Global $searchForBiomes, $enableBiomeGroups, $searchForStructures, $saveSearchResultsToFile +Global $maxSeedsToEvaluate, $seedsToFind, $resultsFile, $overwriteResults, $guidedAmidstSetup +Global $saveScreenshots, $rememberAmidstWindowSize, $showProgressPopupWindow, $macLinuxCompatibility +Global $showResultsTab, $enableDebugging, $includeRejectedSeeds +Global $amidstSetupComplete = False +Global $presetArray = [] +Global $biomeArray = [] +Global $biomeGroupArray = [] +Global $structArray = [] +Global $amidstWindowTitle = "Amidst v4.2" + +Func UpdateGlobals() + $settingsINIFile = @ScriptDir & "\Settings.ini" + + If FileExists($settingsINIFile) Then + $useRandomSeeds = IniRead($settingsINIFile, "Options", "UseRandomSeeds", 1) + $seedListFile = IniRead($settingsINIFile, "Options", "SeedListFile", "") + $seedOffset = IniRead($settingsINIFile, "Options", "SeedOffset", 0) + $seedFileInfo = IniRead($settingsINIFile, "Options", "SeedFileInfo", "") + $searchForBiomes = IniRead($settingsINIFile, "Options", "SearchForBiomes", 1) + ;$enableBiomeGroups = IniRead($settingsINIFile, "Options", "EnableBiomeGroups", 0) + $enableBiomeGroups = 0 + $saveSearchResultsToFile = IniRead($settingsINIFile, "Options", "SaveSearchResultsToFile", 0) + $searchForStructures = IniRead($settingsINIFile, "Options", "SearchForStructures", 0) + $includeRejectedSeeds = IniRead($settingsINIFile, "Options", "IncludeRejectedSeeds", 0) + $maxSeedsToEvaluate = IniRead($settingsINIFile, "Options", "MaxSeedsToEvaluate", 100) + $seedsToFind = IniRead($settingsINIFile, "Options", "SeedsToFind", 1) + $resultsFile = IniRead($settingsINIFile, "Options", "ResultsFile", "") + $overwriteResults = IniRead($settingsINIFile, "Options", "OverwriteResults", 0) + $guidedAmidstSetup = IniRead($settingsINIFile, "Options", "GuidedAmidstSetup", 1) + $saveScreenshots = IniRead($settingsINIFile, "Options", "SaveScreenshots", 0) + $rememberAmidstWindowSize = IniRead($settingsINIFile, "Options", "RememberAmidstWindowSize", 0) + $showProgressPopupWindow = IniRead($settingsINIFile, "Options", "ShowProgressPopupWindow", 1) + $macLinuxCompatibility = IniRead($settingsINIFile, "Options", "MacLinuxCompatibility", 0) + $showResultsTab = IniRead($settingsINIFile, "Options", "ShowResultsTab", 0) + $enableDebugging = IniRead($settingsINIFile, "Options", "EnableDebugging", 0) + $presetArray = IniReadSection($settingsINIFile, "Presets") + $biomeArray = IniReadSection($settingsINIFile, "BiomeList") + ;$biomeGroupArray = IniReadSection($settingsINIFile, "BiomeGroups") + $structArray = IniReadSection($settingsINIFile, "StructureList") + Else + DoResetINIFileToDefaults(False) ; Create INI File + IniWriteSection($settingsINIFile, "Presets", _ + "Preset0Name=" & @LF & _ + "Preset0Include=" & @LF & _ + "Preset0Exclude=" & @LF & _ + "Preset1Name=" & @LF & _ + "Preset1Include=" & @LF & _ + "Preset1Exclude=" & @LF & _ + "Preset2Name=" & @LF & _ + "Preset2Include=" & @LF & _ + "Preset2Exclude=" & @LF & _ + "Preset3Name=" & @LF & _ + "Preset3Include=" & @LF & _ + "Preset3Exclude=" & @LF & _ + "Preset4Name=" & @LF & _ + "Preset4Include=" & @LF & _ + "Preset4Exclude=" & @LF & _ + "Preset5Name=" & @LF & _ + "Preset5Include=" & @LF & _ + "Preset5Exclude=" & @LF & _ + "Preset6Name=" & @LF & _ + "Preset6Include=" & @LF & _ + "Preset6Exclude=" & @LF & _ + "Preset7Name=" & @LF & _ + "Preset7Include=" & @LF & _ + "Preset7Exclude=" & @LF & _ + "Preset8Name=" & @LF & _ + "Preset8Include=" & @LF & _ + "Preset8Exclude=" & @LF & _ + "Preset9Name=" & @LF & _ + "Preset9Include=" & @LF & _ + "Preset9Exclude=" ) + IniWriteSection($settingsINIFile, "BiomeList", _ + "Beach=0xFADE55" & @LF & _ + "Beach M=0xFFFF7D" & @LF & _ + "Birch Forest=0x307444" & @LF & _ + "Birch Forest Hills=0x1F5F32" & @LF & _ + "Birch Forest Hills M=0x47875A" & @LF & _ + "Birch Forest M=0x589C6C" & @LF & _ + "Cold Beach=0xFAF0C0" & @LF & _ + "Cold Beach M=0xFFFFE8" & @LF & _ + "Cold Taiga=0x31554A" & @LF & _ + "Cold Taiga Hills=0x243F36" & @LF & _ + "Cold Taiga Hills M=0x4C675E" & @LF & _ + "Cold Taiga M=0x597D72" & @LF & _ + "Deep Ocean=0x000030" & @LF & _ + "Deep Ocean M=0x282858" & @LF & _ + "Desert=0xFA9418" & @LF & _ + "Desert Hills=0xD25F12" & @LF & _ + "Desert Hills M=0xFA873A" & @LF & _ + "Desert M=0xFFBC40" & @LF & _ + "Extreme Hills+=0x507050" & @LF & _ + "Extreme Hills=0x606060" & @LF & _ + "Extreme Hills Edge=0x72789A" & @LF & _ + "Extreme Hills Edge M=0x9AA0C2" & @LF & _ + "Extreme Hills M=0x888888" & @LF & _ + "Extreme Hills+ M=0x789878" & @LF & _ + "Flower Forest=0x2D8E49" & @LF & _ + "Forest=0x056621" & @LF & _ + "Forest Hills=0x22551C" & @LF & _ + "Forest Hills M=0x4A7D44" & @LF & _ + "Frozen Ocean=0x9090A0" & @LF & _ + "Frozen Ocean M=0xB8B8C8" & @LF & _ + "Frozen River=0xA0A0FF" & @LF & _ + "Frozen River M=0xC8C8FF" & @LF & _ + "Ice Mountains=0xA0A0A0" & @LF & _ + "Ice Mountains M=0xC8C8C8" & @LF & _ + "Ice Plains=0xFFFFFF" & @LF & _ + "Ice Plains Spikes=0xB4DCDC" & @LF & _ + "Jungle=0x537B09" & @LF & _ + "Jungle Edge=0x628B17" & @LF & _ + "Jungle Edge M=0x8AB33F" & @LF & _ + "Jungle Hills=0x2C4205" & @LF & _ + "Jungle Hills M=0x546A2D" & @LF & _ + "Jungle M=0x7BA331" & @LF & _ + "Mega Spruce Taiga=0x818E79" & @LF & _ + "Mega Spruce Taiga (Hills)=0x6D7766" & @LF & _ + "Mega Taiga=0x596651" & @LF & _ + "Mega Taiga Hills=0x454F3E" & @LF & _ + "Mesa=0xD94515" & @LF & _ + "Mesa (Bryce)=0xFF6D3D" & @LF & _ + "Mesa Plateau=0xCA8C65" & @LF & _ + "Mesa Plateau F=0xB09765" & @LF & _ + "Mesa Plateau F M=0xD8BF8D" & @LF & _ + "Mesa Plateau M=0xF2B48D" & @LF & _ + "Mushroom Island=0xFF00FF" & @LF & _ + "Mushroom Island M=0xFF28FF" & @LF & _ + "Mushroom Island Shore=0xA000FF" & @LF & _ + "Mushroom Island Shore M=0xC828FF" & @LF & _ + "Ocean=0x000070" & @LF & _ + "Ocean M=0x282898" & @LF & _ + "Plains=0x8DB360" & @LF & _ + "River=0x0000FF" & @LF & _ + "River M=0x2828FF" & @LF & _ + "Roofed Forest=0x40511A" & @LF & _ + "Roofed Forest M=0x687942" & @LF & _ + "Savanna=0xBDB25F" & @LF & _ + "Savanna M=0xE5DA87" & @LF & _ + "Savanna Plateau=0xA79D64" & @LF & _ + "Savanna Plateau M=0xCFC58C" & @LF & _ + "Stone Beach=0xA2A284" & @LF & _ + "Stone Beach M=0xCACAAC" & @LF & _ + "Sunflower Plains=0xB5DB88" & @LF & _ + "Swampland=0x07F9B2" & @LF & _ + "Swampland M=0x2FFFDA" & @LF & _ + "Taiga=0x0B6659" & @LF & _ + "Taiga Hills=0x163933" & @LF & _ + "Taiga Hills M=0x3E615B" & @LF & _ + "Taiga M=0x338E81" ) + IniWriteSection($settingsINIFile, "BiomeGroups", _ + "Any Beach=Beach|Beach M|Cold Beach|Cold Beach M|Stone Beach|Stone Beach M" & @LF & _ + "Any Birch Forest=Birch Forest|Birch Forest Hills|Birch Forest Hills M|Birch Forest M" & @LF & _ + "Any Desert=Desert|Desert Hills|Desert Hills M|Desert M" & @LF & _ + "Any Extreme Hills=Extreme Hills|Extreme Hills Edge|Extreme Hills Edge M|Extreme Hills M|Extreme Hills+|Extreme Hills +M" & @LF & _ + "Any Forest=Flower Forest|Forest|Forest Hills|Forest Hills M" & @LF & _ + "Any Ice Mountains=Ice Mountains|Ice Mountains M" & @LF & _ + "Any Ice Plains=Ice Plains|Ice Plains Spikes" & @LF & _ + "Any Jungle=Jungle|Jungle Edge|Jungle Edge M|Jungle Hills|Jungle Hills M|Jungle M" & @LF & _ + "Any Mesa=Mesa|Mesa (Bryce)|Mesa Plateau|Mesa Plateau F|Mesa Plateau F M|Mesa Plateau M" & @LF & _ + "Any Mushroom Island=Mushroom Island|Mushroom Island M|Mushroom Island Shore|Mushroom Island Shore M" & @LF & _ + "Any Ocean=Deep Ocean|Deep Ocean M|Frozen Ocean|Frozen Ocean M|Ocean|Ocean M" & @LF & _ + "Any Plains=Plains|Sunflower Plains" & @LF & _ + "Any River=Frozen River|Frozen River M|River|River M" & @LF & _ + "Any Roofed Forest=Roofed Forest|Roofed Forest M" & @LF & _ + "Any Savanna=Savanna|Savanna M|Savanna Plateau|Savanna Plateau M" & @LF & _ + "Any Swampland=Swampland|Swampland M" & @LF & _ + "Any Taiga=Cold Taiga|Cold Taiga Hills|Cold Taiga Hills M|Cold Taiga M|Mega Spruce Taiga|Mega Spruce Taiga (Hills)|Mega Taiga|Mega Taiga Hills|Taiga|Taiga Hills|Taiga Hills M|Taiga M" & @LF & _ + "All Beaches=Beach|Beach M|Cold Beach|Cold Beach M|Stone Beach|Stone Beach M" & @LF & _ + "All Birch Forests=Birch Forest|Birch Forest Hills|Birch Forest Hills M|Birch Forest M" & @LF & _ + "All Deserts=Desert|Desert Hills|Desert Hills M|Desert M" & @LF & _ + "All Extreme Hills=Extreme Hills|Extreme Hills Edge|Extreme Hills Edge M|Extreme Hills M|Extreme Hills+|Extreme Hills +M" & @LF & _ + "All Forests=Flower Forest|Forest|Forest Hills|Forest Hills M" & @LF & _ + "All Ice Mountains=Ice Mountains|Ice Mountains M" & @LF & _ + "All Ice Plains=Ice Plains|Ice Plains Spikes" & @LF & _ + "All Jungles=Jungle|Jungle Edge|Jungle Edge M|Jungle Hills|Jungle Hills M|Jungle M" & @LF & _ + "All Mesas=Mesa|Mesa (Bryce)|Mesa Plateau|Mesa Plateau F|Mesa Plateau F M|Mesa Plateau M" & @LF & _ + "All Mushroom Islands=Mushroom Island|Mushroom Island M|Mushroom Island Shore|Mushroom Island Shore M" & @LF & _ + "All Oceans=Deep Ocean|Deep Ocean M|Frozen Ocean|Frozen Ocean M|Ocean|Ocean M" & @LF & _ + "All Plains=Plains|Sunflower Plains" & @LF & _ + "All Rivers=Frozen River|Frozen River M|River|River M" & @LF & _ + "All Roofed Forests=Roofed Forest|Roofed Forest M" & @LF & _ + "All Savannas=Savanna|Savanna M|Savanna Plateau|Savanna Plateau M" & @LF & _ + "All Swamplands=Swampland|Swampland M" & @LF & _ + "All Taigas=Cold Taiga|Cold Taiga Hills|Cold Taiga Hills M|Cold Taiga M|Mega Spruce Taiga|Mega Spruce Taiga (Hills)|Mega Taiga|Mega Taiga Hills|Taiga|Taiga Hills|Taiga Hills M|Taiga M") + IniWriteSection($settingsINIFile, "StructureList", _ + "Desert Temple=0xBBB36D" & @LF & _ + "Igloo=0xA7B8FF" & @LF & _ + "Jungle Temple=0x364636" & @LF & _ + "Mineshaft=0x76613C" & @LF & _ + "Nether Fortress=0x311E24" & @LF & _ + "Ocean Monument=0x285A45" & @LF & _ + "Stronghold=0x4D5A35" & @LF & _ + "Village=0x75472F" & @LF & _ + "Witch Hut=0x0F41FB" ) + + UpdateGlobals() + EndIf +EndFunc diff --git a/Include/PresetFunctions.au3 b/Include/ASH_Presets.au3 similarity index 89% rename from Include/PresetFunctions.au3 rename to Include/ASH_Presets.au3 index f3ea654..560d010 100644 --- a/Include/PresetFunctions.au3 +++ b/Include/ASH_Presets.au3 @@ -1,12 +1,11 @@ ; ============================================================================= -; Amidst Seed Hunter - Preset Functions (PresetFunctions.au3) +; Amidst Seed Hunter - Presets (ASH_Presets.au3) ; -; Author: Azuntik (seedhunter@azuntik.com) -; Date: 2017.4.22 -; Download: https://github.com/azuntik/Amidst-Seed-Hunter/releases +; Author: Azuntik +; Date: 2017.5.2 ; License: CC BY-NC-SA 4.0 (https://creativecommons.org/licenses/by-nc-sa/4.0/) ; -; For use with Amidst v4.2 (https://github.com/toolbox4minecraft/amidst). +; This file is part of the Amidst Seed Hunter project ; ============================================================================= Func DoPresetButton($preset) @@ -204,20 +203,28 @@ Func DoApplyPreset($preset) EndIf EndFunc -Func DoRemovePreset($preset) - Dim $arrayOffset +Func DoRemovePreset($preset, $prompt = False) + Dim $arrayOffset, $response - IniWrite($settingsINIFile, "Presets", "Preset" & $preset & "Name", "") - IniWrite($settingsINIFile, "Presets", "Preset" & $preset & "Include", "") - IniWrite($settingsINIFile, "Presets", "Preset" & $preset & "Exclude", "") - - $arrayOffset = $preset * 3 + 1 ; Each preset takes 3 rows, starting with row 1 + If $prompt Then + $response = _WinAPI_MessageBoxCheck(BitOR($MB_YESNO, $MB_ICONQUESTION), "Remove preset", "You are about to remove this preset. This action cannot be undone." & @CRLF & @CRLF & "Are you sure?", "{E0E777CD-DA7B-40E0-9ECC-9ADD4F2BE0E9}", $IDYES) + Else + $response = $IDYES + EndIf - $presetArray[$arrayOffset][1] = "" - $presetArray[$arrayOffset + 1][1] = "" - $presetArray[$arrayOffset + 2][1] = "" + If $response = $IDYES Then + IniWrite($settingsINIFile, "Presets", "Preset" & $preset & "Name", "") + IniWrite($settingsINIFile, "Presets", "Preset" & $preset & "Include", "") + IniWrite($settingsINIFile, "Presets", "Preset" & $preset & "Exclude", "") + + $arrayOffset = $preset * 3 + 1 ; Each preset takes 3 rows, starting with row 1 + + $presetArray[$arrayOffset][1] = "" + $presetArray[$arrayOffset + 1][1] = "" + $presetArray[$arrayOffset + 2][1] = "" - DebugWrite("Preset " & $preset & " removed") + DebugWrite("Preset " & $preset & " removed") + EndIf EndFunc Func DoUpdatePresets() diff --git a/Include/SearchFunctions.au3 b/Include/ASH_Search.au3 similarity index 93% rename from Include/SearchFunctions.au3 rename to Include/ASH_Search.au3 index 3396a54..96aedcb 100644 --- a/Include/SearchFunctions.au3 +++ b/Include/ASH_Search.au3 @@ -1,12 +1,11 @@ ; ============================================================================= -; Amidst Seed Hunter - Search Functions (SearchFunctions.au3) +; Amidst Seed Hunter - Search (ASH_Search.au3) ; -; Author: Azuntik (seedhunter@azuntik.com) -; Date: 2017.4.22 -; Download: https://github.com/azuntik/Amidst-Seed-Hunter/releases +; Author: Azuntik +; Date: 2017.5.2 ; License: CC BY-NC-SA 4.0 (https://creativecommons.org/licenses/by-nc-sa/4.0/) ; -; For use with Amidst v4.2 (https://github.com/toolbox4minecraft/amidst). +; This file is part of the Amidst Seed Hunter project ; ============================================================================= Func StopExecution() @@ -383,4 +382,27 @@ Func DoSearch() ; Unset hotkey HotKeySet("{ESC}") HotKeySet("{BACKSPACE}") +EndFunc + +Func DoAdvancedSearch() + MsgBox(BitOR($MB_OK, $MB_ICONERROR), "Feature not available", "We're sorry, but this feature is not currently available. Please watch for it in a future release.") + Return + + Dim $response + + $response = _WinAPI_MessageBoxCheck(BitOR($MB_YESNO, $MB_ICONQUESTION), "Advanced search", "Advanced search functionality allows you to be more specific in how you include and exclude biomes and structures in your search criteria. This feature is not for everyone, but can be very useful for advanced users. For more information, please visit our the Wiki on our Github repository." & @CRLF & @CRLF & "Do you wish to continue?", "{187F1EDF-1D86-4DAC-AC8F-137B3BA13634}", $IDYES) + + If $response = $IDYES Then + Dim $searchString + + SetError(0) + + $searchString = InputBox("Advanced search", "Enter your search string. Click OK to begin search.") + + If @error = 1 Then ; Cancel button was pressed + MsgBox(0,"","Advanced search canceled") + Return + EndIf + + EndIf EndFunc \ No newline at end of file diff --git a/Include/Toast.au3 b/Include/ASH_Toast.au3 similarity index 100% rename from Include/Toast.au3 rename to Include/ASH_Toast.au3 diff --git a/Include/ExtMsgBox.au3 b/Include/ExtMsgBox.au3 new file mode 100644 index 0000000..e3450e4 --- /dev/null +++ b/Include/ExtMsgBox.au3 @@ -0,0 +1,829 @@ +#include-once + +; #INDEX# ============================================================================================================ +; Title .........: ExtMsgBox +; AutoIt Version : v3.2.12.1 or higher +; Language ......: English +; Description ...: Generates user defined message boxes centred on a GUI, on screen or at defined coordinates +; Remarks .......: +; Note ..........: +; Author(s) .....: Melba23, based on some original code by photonbuddy & YellowLab, and KaFu (default font data) +; ==================================================================================================================== + +;#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w- 7 + +; #INCLUDES# ========================================================================================================= +#include "StringSize.au3" +#include +#include +#include + +; #GLOBAL CONSTANTS# ================================================================================================= +Global Const $EMB_ICONSTOP = 16 ; Stop-sign icon +Global Const $EMB_ICONQUERY = 32 ; Question-mark icon +Global Const $EMB_ICONEXCLAM = 48 ; Exclamation-point icon +Global Const $EMB_ICONINFO = 64 ; Icon consisting of an 'i' in a circle + +; #GLOBAL VARIABLES# ================================================================================================= + +Global $g_aEMB_Settings[13] +; [0] = Style [6] = Max Width +; [1] = Justification [7] = Absolute Width +; [2] = Back Colour [8] = Default Back Colour +; [3] = Text Colour [9] = Default Text Colour +; [4] = Font Size [10] = Default Font Size +; [5] = Font Name [11] = Default Font Name +; [12] = Title bar reduction + +; Default settings +; Font +Global $g_aEMB_TempArray = __EMB_GetDefaultFont() +$g_aEMB_Settings[10] = $g_aEMB_TempArray[0] +$g_aEMB_Settings[11] = $g_aEMB_TempArray[1] +; Colours +$g_aEMB_TempArray = DllCall("User32.dll", "int", "GetSysColor", "int", 15) ; $COLOR_3DFACE +$g_aEMB_Settings[8] = BitAND(BitShift(String(Binary($g_aEMB_TempArray[0])), 8), 0xFFFFFF) +$g_aEMB_TempArray = DllCall("User32.dll", "int", "GetSysColor", "int", 8) ; $COLOR_WINDOWTEXT +$g_aEMB_Settings[9] = BitAND(BitShift(String(Binary($g_aEMB_TempArray[0])), 8), 0xFFFFFF) +; Title bar width reduction by icon and [X] button in various themes +$g_aEMB_TempArray = DllCall("user32.dll", "int", "GetSystemMetrics", "int", 11) ; Title bar icon width +$g_aEMB_Settings[12] = $g_aEMB_TempArray[0] +$g_aEMB_TempArray = DllCall("user32.dll", "int", "GetSystemMetrics", "int", 30) ; Title bar button width +$g_aEMB_Settings[12] += ( ($g_aEMB_TempArray[0] < 30) ? ($g_aEMB_TempArray[0] * 3) : ($g_aEMB_TempArray[0]) ) ; Compensate for small buttons in some themes +$g_aEMB_TempArray = 0 +$g_aEMB_TempArray = DllCall("dwmapi.dll", "uint", "DwmIsCompositionEnabled", "int*", $g_aEMB_TempArray) ; Check for Aero enabled +If Not @error And $g_aEMB_TempArray[1] = True Then + $g_aEMB_TempArray = DllCall("user32.dll", "int", "GetSystemMetrics", "int", 7) ; GUI button frame width + $g_aEMB_Settings[12] += ($g_aEMB_TempArray[0] * 4) ; Add frames to compensate for incorrect Aero return +EndIf +$g_aEMB_TempArray = 0 + +; Set current settings +$g_aEMB_Settings[0] = 0 +$g_aEMB_Settings[1] = 0 +$g_aEMB_Settings[2] = $g_aEMB_Settings[8] +$g_aEMB_Settings[3] = $g_aEMB_Settings[9] +$g_aEMB_Settings[4] = $g_aEMB_Settings[10] +$g_aEMB_Settings[5] = $g_aEMB_Settings[11] +$g_aEMB_Settings[6] = 370 +$g_aEMB_Settings[7] = 500 + +; #CURRENT# ========================================================================================================== +; _ExtMsgBoxSet: Sets the GUI style, justification, colours, font and max width for subsequent _ExtMsgBox function calls +; _ExtMsgBox: Generates user defined message boxes centred on a GUI, on screen or at defined coordinates +; ==================================================================================================================== + +; #INTERNAL_USE_ONLY#================================================================================================= +; __EMB_GetDefaultFont: Determines Windows default MsgBox font size and name +; ==================================================================================================================== + +; #FUNCTION# ========================================================================================================= +; Name...........: _ExtMsgBoxSet +; Description ...: Sets the GUI style, justification, colours, font and max width for subsequent _ExtMsgBox function calls +; Syntax.........: _ExtMsgBoxSet($iStyle, $iJust, [$iBkCol, [$iCol, [$sFont_Size, [$iFont_Name, [$iWidth, [ $iWidth_Abs]]]]]]) +; Parameters ....: $iStyle -> 0 (Default) - Taskbar Button, TOPMOST, button in user font, no tab expansion, +; no checkbox, titlebar icon, active closure [X] and SysMenu close +; Combine following to change: +; 1 = No Taskbar Button +; 2 = TOPMOST Style not set +; 4 = Buttons use default font +; 8 = Expand Tabs to ensure adequate sizing of GUI +; 16 = "Do not display again" checkbox +; 32 = Show no icon on title bar +; 64 = Disable EMB closure [X] and SysMenu Close +; $iJust -> 0 = Left justified (Default), 1 = Centred , 2 = Right justified +; + 4 = Centred single button. Note: multiple buttons are always centred +; ($SS_LEFT, $SS_CENTER, $SS_RIGHT can also be used) +; $iBkCol -> The colour for the message box background. Default = system colour +; $iCol -> The colour for the message box text. Default = system colour +; $iFont_Size -> The font size in points to use for the message box. Default = system font size +; $sFont_Name -> The font to use for the message box. Default = system font +; $iWidth -> Normal max width for EMB. Default/min = 370 pixels - max = @DesktopWidth - 20 +; $iWidth_Abs -> Absolute max width for EMB. Default/min = 370 pixels - max = @DesktopWidth - 20 +; EMB will expand to this value to accommodate long unbroken character strings +; Forced to $iWidth value if less +; Requirement(s).: v3.2.12.1 or higher +; Return values .: Success - Returns 1 +; Failure - Returns 0 and sets @error to 1 with @extended set to incorrect parameter index number +; Remarks .......; Setting any parameter to -1 leaves the current value unchanged +; Setting the $iStyle parameter to 'Default' resets ALL parameters to default values <<<<<<<<<<<<<<<<<<<<<<< +; Setting any other parameter to "Default" only resets that parameter +; Author ........: Melba23 +; Example........; Yes +;===================================================================================================================== +Func _ExtMsgBoxSet($iStyle = -1, $iJust = -1, $iBkCol = -1, $iCol = -1, $iFont_Size = -1, $sFont_Name = -1, $iWidth = -1, $iWidth_Abs = -1) + + ; Set global EMB variables to required values + Switch $iStyle + Case Default + $g_aEMB_Settings[0] = 0 + $g_aEMB_Settings[1] = 0 + $g_aEMB_Settings[2] = $g_aEMB_Settings[8] + $g_aEMB_Settings[3] = $g_aEMB_Settings[9] + $g_aEMB_Settings[5] = $g_aEMB_Settings[11] + $g_aEMB_Settings[4] = $g_aEMB_Settings[10] + $g_aEMB_Settings[6] = 370 + $g_aEMB_Settings[7] = 370 + Return + Case -1 + ; Do nothing + Case 0 To 127 + $g_aEMB_Settings[0] = Int($iStyle) + Case Else + Return SetError(1, 1, 0) + EndSwitch + + Switch $iJust + Case Default + $g_aEMB_Settings[1] = 0 + Case -1 + ; Do nothing + Case 0, 1, 2, 4, 5, 6 + $g_aEMB_Settings[1] = $iJust + Case Else + Return SetError(1, 2, 0) + EndSwitch + + Switch $iBkCol + Case Default + $g_aEMB_Settings[2] = $g_aEMB_Settings[8] + Case -1 + ; Do nothing + Case 0 To 0xFFFFFF + $g_aEMB_Settings[2] = Int($iBkCol) + Case Else + Return SetError(1, 3, 0) + EndSwitch + + Switch $iCol + Case Default + $g_aEMB_Settings[3] = $g_aEMB_Settings[9] + Case -1 + ; Do nothing + Case 0 To 0xFFFFFF + $g_aEMB_Settings[3] = Int($iCol) + Case Else + Return SetError(1, 4, 0) + EndSwitch + + Switch $iFont_Size + Case Default + $g_aEMB_Settings[4] = $g_aEMB_Settings[10] + Case -1 + ; Do nothing + Case 8 To 72 + $g_aEMB_Settings[4] = Int($iFont_Size) + Case Else + Return SetError(1, 5, 0) + EndSwitch + + Switch $sFont_Name + Case Default + $g_aEMB_Settings[5] = $g_aEMB_Settings[11] + Case -1 + ; Do nothing + Case Else + If IsString($sFont_Name) Then + $g_aEMB_Settings[5] = $sFont_Name + Else + Return SetError(1, 6, 0) + EndIf + EndSwitch + + Switch $iWidth + Case Default + $g_aEMB_Settings[6] = 370 + Case -1 + ; Do nothing + Case 370 To @DesktopWidth - 20 + $g_aEMB_Settings[6] = Int($iWidth) + Case Else + Return SetError(1, 7, 0) + EndSwitch + + Switch $iWidth_Abs + Case Default + $g_aEMB_Settings[7] = 370 + Case -1 + ; Do nothing + Case 370 To @DesktopWidth - 20 + $g_aEMB_Settings[7] = Int($iWidth_Abs) + Case Else + Return SetError(1, 8, 0) + EndSwitch + + ; Check absolute width is at least max width + If $g_aEMB_Settings[7] < $g_aEMB_Settings[6] Then + $g_aEMB_Settings[7] = $g_aEMB_Settings[6] + EndIf + + Return 1 + +EndFunc ;==>_ExtMsgBoxSet + +; #FUNCTION# ========================================================================================================= +; Name...........: _ExtMsgBox +; Description ...: Generates user defined message boxes centred on a GUI, the desktop, or at defined coordinates +; Syntax.........: _ExtMsgBox ($vIcon, $vButton, $sTitle, $sText, [$iTimeout, [$hWin, [$iVPos, [$bMain = True[]]]) +; Parameters ....: $vIcon -> Icon to use: +; 0 - No icon +; 8 - UAC +; 16 - Stop ) +; 32 - Query ) or equivalent $MB/$EMB_ICON constant +; 48 - Exclamation ) +; 64 - Information ) +; 128 - Countdown digits if $iTimeout set +; Any other numeric value returns Error 1 +; If set to the name of an ico, that icom will be displayed +; If set to the name of an exe, the main icon of that exe will be displayed +; If set to the name of an image file, that image will be displayed +; $vButton -> Button text separated with "|" character. " " = no buttons. +; An ampersand (&) before the text indicates the default button. +; Two focus ampersands returns Error 2. A single button is always default +; Pressing Enter or Space fires default button +; Can also use $MB_ button numeric constants: 0 = "OK", 1 = "&OK|Cancel", +; 2 = "&Abort|Retry|Ignore", 3 = "&Yes|No|Cancel", 4 = "&Yes|No", 5 = "&Retry|Cancel", +; 6 = "&Cancel|Try Again|Continue". Other values returns Error 3 +; Default max width of 370 gives 1-4 buttons @ width 80, 5 @ width 60, 6 @ width 50 +; Min button width set at 50, so unless defaults changed 7 buttons returns Error 4 +; $sTitle -> The title of the message box. +; Procrustean truncation if too long to fit +; $sText -> The text to be displayed. Long lines will wrap. The box depth is adjusted to fit. +; If unbroken character strings in $sText too long for set max width, +; EMB expands to set absolute width. Error 6 if still not able to fit +; $iTimeout -> Timeout delay before EMB closes. 0 = no timeout (Default). +; If no buttons and no timeout set, delay automatically set to 5 +; $hWin -> Handle of the GUI in which EMB is centred +; If GUI hidden or no handle passed - EMB centred in desktop (Default) +; If not valid window handle, interpreted as horizontal coordinate for EMB location +; $iVPos -> Vertical coordinate for EMB location +; Only valid if $hWin parameter interpreted as horizontal coordinate (Default = 0) +; $bMain -> True (default) = Adjust dialog position to ensure dialog positioned on main screen +; False = Dialog positioned at user-defined coords, which can be on other screens +; Requirement(s).: v3.2.12.1 or higher +; Return values .: Success: Returns 1-based index of the button pressed, counting from the LEFT. +; Returns 0 if closed by a "CloseGUI" event (i.e. click [X] or press Escape) +; Returns 9 if timed out +; If "Not again" checkbox is present and checked, return value is negated +; Failure: Returns -1 and sets @error as follows: +; 1 - Icon error +; 2 - Multiple default button error +; 3 - Button constant error +; 4 - Too many buttons to fit in max available EMB width +; 5 - Button text too long for max available button width +; 6 - StringSize error +; 7 - GUI creation error +; Remarks .......; If $bMain set EMB adjusted to appear on main screen closest to required position +; Author ........: Melba23, based on some original code by photonbuddy & YellowLab +; Example........; Yes +;===================================================================================================================== +Func _ExtMsgBox($vIcon, $vButton, $sTitle, $sText, $iTimeOut = 0, $hWin = "", $iVPos = 0, $bMain = True) + + ; Set default sizes for message box + Local $iMsg_Width_Max = $g_aEMB_Settings[6], $iMsg_Width_Min = 150, $iMsg_Width_Abs = $g_aEMB_Settings[7] + Local $iMsg_Height_Min = 100 + Local $iButton_Width_Def = 80, $iButton_Width_Min = 50 + + ; Declare local variables + Local $iParent_Win = 0, $fCountdown = False, $cCheckbox, $aLabel_Size, $aRet, $iRet_Value, $iHpos + Local $sButton_Text, $iButton_Width, $iButton_Xpos + + ; Validate timeout value + $iTimeOut = Int(Number($iTimeOut)) + ; Set automatic timeout if no buttons and no timeout set + If $vButton == " " And $iTimeOut = 0 Then + $iTimeOut = 5 + EndIf + + ; Check for icon + ; Check for icon + Local $iIcon_Style = 0 + Local $iIcon_Reduction = 36 + Local $sDLL = "user32.dll" + Local $sImg = "" + If StringIsDigit($vIcon) Then + Switch $vIcon + Case 0 + $iIcon_Reduction = 0 + Case 8 + $sDLL = "imageres.dll" + $iIcon_Style = 78 + Case 16 ; Stop + $iIcon_Style = -4 + Case 32 ; Query + $iIcon_Style = -3 + Case 48 ; Exclam + $iIcon_Style = -2 + Case 64 ; Info + $iIcon_Style = -5 + Case 128 ; Countdown + If $iTimeOut > 0 Then + $fCountdown = True + Else + ContinueCase + EndIf + Case Else + Return SetError(1, 0, -1) + EndSwitch + Else + Switch StringLower(StringRight($vIcon, 3)) + Case "exe", "ico" + $sDLL = $vIcon + $iIcon_Style = 0 + Case "bmp", "jpg", "gif", "png" + $sImg = $vIcon + EndSwitch + EndIf + + ; Check if two buttons are seeking focus + StringRegExpReplace($vButton, "((? 1 Then + Return SetError(2, 0, -1) + EndIf + + ; Check if using constants or text + If IsNumber($vButton) Then + Switch $vButton + Case 0 + $vButton = "OK" + Case 1 + $vButton = "&OK|Cancel" + Case 2 + $vButton = "&Abort|Retry|Ignore" + Case 3 + $vButton = "&Yes|No|Cancel" + Case 4 + $vButton = "&Yes|No" + Case 5 + $vButton = "&Retry|Cancel" + Case 6 + $vButton = "&Cancel|Try Again|Continue" + Case Else + Return SetError(3, 0, -1) + EndSwitch + EndIf + + ; Set default values + Local $aButton_Text[1] = [0] + Local $iButton_Width_Req = 0 + ; Get required button size + If $vButton <> " " Then + ; Split button text into individual strings + $aButton_Text = StringSplit($vButton, "|") + + ; Get absolute available width for each button + Local $iButton_Width_Abs = Floor((($iMsg_Width_Max - 10) / $aButton_Text[0]) - 10) + ; Error if below min button size + If $iButton_Width_Abs < $iButton_Width_Min Then + Return SetError(4, 0, -1) + EndIf + ; Determine required size of buttons to fit text + Local $iButton_Width_Text = 0 + ; Loop through button text + For $i = 1 To $aButton_Text[0] + ; Remove a possible leading & + $sButton_Text = StringRegExpReplace($aButton_Text[$i], "^&?(.*)$", "$1") + ; Check on font to use + If BitAND($g_aEMB_Settings[0], 4) Then + $aRet = _StringSize($sButton_Text, $g_aEMB_Settings[10], Default, Default, $g_aEMB_Settings[11]) + Else + $aRet = _StringSize($sButton_Text, $g_aEMB_Settings[4], Default, Default, $g_aEMB_Settings[5]) + EndIf + If IsArray($aRet) And $aRet[2] + 10 > $iButton_Width_Text Then + ; Find max button width required for text + $iButton_Width_Text = $aRet[2] + 10 + EndIf + Next + ; Error if text would make required button width > absolute available + If $iButton_Width_Text > $iButton_Width_Abs Then + Return SetError(5, 0, -1) + EndIf + ; Determine button size to use - assume default + $iButton_Width = $iButton_Width_Def + ; If text requires wider then default + If $iButton_Width_Text > $iButton_Width_Def Then + ; Increase - cannot be > absolute + $iButton_Width = $iButton_Width_Text + EndIf + ; If absolute < default + If $iButton_Width_Abs < $iButton_Width_Def Then + ; If text > min (text must be < abs) + If $iButton_Width_Text > $iButton_Width_Min Then + ; Set text width + $iButton_Width = $iButton_Width_Text + Else + ; Set min width + $iButton_Width = $iButton_Width_Min + EndIf + EndIf + ; Determine GUI width required for all buttons at this width + $iButton_Width_Req = (($iButton_Width + 10) * $aButton_Text[0]) + 10 + EndIf + + ; Set tab expansion flag if required + Local $iExpTab = Default + If BitAND($g_aEMB_Settings[0], 8) Then + $iExpTab = 1 + EndIf + + ; Get message label size + While 1 + Local $aLabel_Pos = _StringSize($sText, $g_aEMB_Settings[4], Default, $iExpTab, $g_aEMB_Settings[5], $iMsg_Width_Max - 20 - $iIcon_Reduction) + If @error Then + If $iMsg_Width_Max >= $iMsg_Width_Abs Then + Return SetError(6, 0, -1) + Else + $iMsg_Width_Max += 10 + EndIf + Else + ExitLoop + EndIf + WEnd + ; Reset text to wrapped version + $sText = $aLabel_Pos[0] + ; Set label size + Local $iLabel_Width = $aLabel_Pos[2] + Local $iLabel_Height = $aLabel_Pos[3] + + ; Set GUI size + Local $iMsg_Width = $iLabel_Width + 20 + $iIcon_Reduction + ; Increase width to fit buttons if needed + If $iButton_Width_Req > $iMsg_Width Then $iMsg_Width = $iButton_Width_Req + If $iMsg_Width < $iMsg_Width_Min Then + $iMsg_Width = $iMsg_Width_Min + $iLabel_Width = $iMsg_Width_Min - 20 + EndIf + + ; Check if title sets width + Local $iDialog_Width = $iMsg_Width + ; Size title + Local $aTitleSize = _StringSize($sTitle, $g_aEMB_Settings[10], Default, Default, $g_aEMB_Settings[11]) + + ; Check if title wider than text + If $aTitleSize[2] > ($iMsg_Width - 70) Then ; Assume icon reduction of 50 regardless of icon setting + ; Adjust dialog width up to absolute dialog width value + $iDialog_Width = ( ($aTitleSize[2] < ($g_aEMB_Settings[7] - $g_aEMB_Settings[12])) ? ($aTitleSize[2] + $g_aEMB_Settings[12]) : ($g_aEMB_Settings[7]) ) + EndIf + + Local $iMsg_Height = $iLabel_Height + 35 + ; Increase height if buttons present + If $vButton <> " " Then + $iMsg_Height += 30 + EndIf + ; Increase height if checkbox required + If BitAND($g_aEMB_Settings[0], 16) Then + $iMsg_Height += 40 + EndIf + If $iMsg_Height < $iMsg_Height_Min Then $iMsg_Height = $iMsg_Height_Min + + ; If only single line, lower label to to centre text on icon + Local $iLabel_Vert = 20 + If StringInStr($sText, @CRLF) = 0 Then $iLabel_Vert = 27 + + ; Check for taskbar button style required + If Mod($g_aEMB_Settings[0], 2) = 1 Then ; Hide taskbar button so create as child + If IsHWnd($hWin) Then + $iParent_Win = $hWin ; Make child of that window + Else + $iParent_Win = WinGetHandle(AutoItWinGetTitle()) ; Make child of AutoIt window + EndIf + EndIf + + ; Determine EMB location + If $hWin = "" Then + ; No handle or position passed so centre on screen + $iHpos = (@DesktopWidth - $iDialog_Width) / 2 + $iVPos = (@DesktopHeight - $iMsg_Height) / 2 + Else + If IsHWnd($hWin) Then + ; Get parent GUI pos if visible + If BitAND(WinGetState($hWin), 2) Then + ; Set EMB to centre on parent + Local $aPos = WinGetPos($hWin) + $iHpos = ($aPos[2] - $iDialog_Width) / 2 + $aPos[0] - 3 + $iVPos = ($aPos[3] - $iMsg_Height) / 2 + $aPos[1] - 20 + Else + ; Set EMB to centre om screen + $iHpos = (@DesktopWidth - $iDialog_Width) / 2 + $iVPos = (@DesktopHeight - $iMsg_Height) / 2 + EndIf + Else + ; Assume parameter is horizontal coord + $iHpos = $hWin ; $iVpos already set + EndIf + EndIf + + ; If dialog is to appear on main display + If $bMain Then + ; Dialog is visible horizontally + If $iHpos < 10 Then $iHpos = 10 + If $iHpos + $iDialog_Width > @DesktopWidth - 20 Then $iHpos = @DesktopWidth - 20 - $iDialog_Width + ; Then vertically + If $iVPos < 10 Then $iVPos = 10 + If $iVPos + $iMsg_Height > @DesktopHeight - 60 Then $iVPos = @DesktopHeight - 60 - $iMsg_Height + EndIf + + ; Remove TOPMOST extended style if required + Local $iExtStyle = 0x00000008 ; $WS_TOPMOST + If BitAND($g_aEMB_Settings[0], 2) Then $iExtStyle = -1 + + ; Create GUI with $WS_POPUPWINDOW, $WS_CAPTION style and required extended style + Local $hMsgGUI = GUICreate($sTitle, $iDialog_Width, $iMsg_Height, $iHpos, $iVPos, BitOR(0x80880000, 0x00C00000), $iExtStyle, $iParent_Win) + If @error Then + Return SetError(7, 0, -1) + EndIf + + ; Check if titlebar icon hidden - actually uses transparent icon from AutoIt executable + If BitAND($g_aEMB_Settings[0], 32) Then + If @Compiled Then + GUISetIcon(@ScriptName, -2, $hMsgGUI) + Else + GUISetIcon(@AutoItExe, -2, $hMsgGUI) + EndIf + EndIf + If $g_aEMB_Settings[2] <> Default Then GUISetBkColor($g_aEMB_Settings[2]) + + ; Check if user closure permitted + If BitAND($g_aEMB_Settings[0], 64) Then + $aRet = DllCall("User32.dll", "hwnd", "GetSystemMenu", "hwnd", $hMsgGUI, "int", 0) + Local $hSysMenu = $aRet[0] + DllCall("User32.dll", "int", "RemoveMenu", "hwnd", $hSysMenu, "int", 0xF060, "int", 0) ; $SC_CLOSE + DllCall("User32.dll", "int", "DrawMenuBar", "hwnd", $hMsgGUI) + EndIf + + ; Set centring parameter + Local $iLabel_Style = 0 ; $SS_LEFT + If BitAND($g_aEMB_Settings[1], 1) = 1 Then + $iLabel_Style = 1 ; $SS_CENTER + ElseIf BitAND($g_aEMB_Settings[1], 2) = 2 Then + $iLabel_Style = 2 ; $SS_RIGHT + EndIf + + ; Create label + GUICtrlCreateLabel($sText, 10 + $iIcon_Reduction, $iLabel_Vert, $iLabel_Width, $iLabel_Height, $iLabel_Style) + GUICtrlSetFont(-1, $g_aEMB_Settings[4], Default, Default, $g_aEMB_Settings[5]) + If $g_aEMB_Settings[3] <> Default Then GUICtrlSetColor(-1, $g_aEMB_Settings[3]) + + ; Create checkbox if required + If BitAND($g_aEMB_Settings[0], 16) Then + Local $sAgain = " Do not show again" + Local $iY = $iLabel_Vert + $iLabel_Height + 10 + ; Create checkbox + $cCheckbox = GUICtrlCreateCheckbox("", 10 + $iIcon_Reduction, $iY, 20, 20) + ; Write text in separate checkbox label + Local $cCheckLabel = GUICtrlCreateLabel($sAgain, 20, 20, 20, 20) + GUICtrlSetColor($cCheckLabel, $g_aEMB_Settings[3]) + GUICtrlSetBkColor($cCheckLabel, $g_aEMB_Settings[2]) + ; Set font if required and size checkbox label text + If BitAND($g_aEMB_Settings[0], 4) Then + $aLabel_Size = _StringSize($sAgain) + Else + $aLabel_Size = _StringSize($sAgain, $g_aEMB_Settings[4], 400, 0, $g_aEMB_Settings[5]) + GUICtrlSetFont($cCheckLabel, $g_aEMB_Settings[4], 400, 0, $g_aEMB_Settings[5]) + EndIf + ; Move and resize checkbox label to fit + $iY = ($iY + 10) - ($aLabel_Size[3] - 4) / 2 + ControlMove($hMsgGUI, "", $cCheckLabel, 30 + $iIcon_Reduction, $iY, $iMsg_Width - (30 + $iIcon_Reduction), $aLabel_Size[3]) + EndIf + + ; Create icon, image or countdown timer + If $fCountdown = True Then + Local $cCountdown_Label = GUICtrlCreateLabel(StringFormat("%2s", $iTimeOut), 10, 20, 32, 32) + GUICtrlSetFont(-1, 18, Default, Default, $g_aEMB_Settings[5]) + GUICtrlSetColor(-1, $g_aEMB_Settings[3]) + Else + If $iIcon_Reduction Then + Switch StringLower(StringRight($sImg, 3)) + Case "bmp", "jpg", "gif" + GUICtrlCreatePic($sImg, 4, 4, 32, 32) + Case "png" + __EMB_ShowPNG($sImg) + Case Else + GUICtrlCreateIcon($sDLL, $iIcon_Style, 4, 4) + EndSwitch + EndIf + EndIf + + ; Create buttons + Local $aButtonCID[$aButton_Text[0] + 1] = [9999] ; Placeholder to prevent accel key firing if no buttons + If $vButton <> " " Then + + ; Create dummy control for Accel key + $aButtonCID[0] = GUICtrlCreateDummy() + ; Set Space key as Accel key + Local $aAccel_Key[1][2] = [["{SPACE}", $aButtonCID[0]]] + GUISetAccelerators($aAccel_Key) + + ; Calculate button horizontal start + If $aButton_Text[0] = 1 Then + If BitAND($g_aEMB_Settings[1], 4) = 4 Then + ; Single centred button + $iButton_Xpos = ($iMsg_Width - $iButton_Width) / 2 + Else + ; Single offset button + $iButton_Xpos = $iMsg_Width - $iButton_Width - 10 + EndIf + Else + ; Multiple centred buttons + $iButton_Xpos = ($iMsg_Width - ($iButton_Width_Req - 20)) / 2 + EndIf + ; Set default button code + Local $iDefButton_Code = 0 + ; Set default button style + Local $iDef_Button_Style = 0 + ; Work through button list + For $i = 0 To $aButton_Text[0] - 1 + Local $iButton_Text = $aButton_Text[$i + 1] + ; Set default button + If $aButton_Text[0] = 1 Then ; Only 1 button + $iDef_Button_Style = 0x0001 + ElseIf StringLeft($iButton_Text, 1) = "&" Then ; Look for & + $iDef_Button_Style = 0x0001 + $aButton_Text[$i + 1] = StringTrimLeft($iButton_Text, 1) + ; Set default button code for Accel key return + $iDefButton_Code = $i + 1 + EndIf + ; Draw button + $aButtonCID[$i + 1] = GUICtrlCreateButton($aButton_Text[$i + 1], $iButton_Xpos + ($i * ($iButton_Width + 10)), $iMsg_Height - 35, $iButton_Width, 25, $iDef_Button_Style) + ; Set font if required + If Not BitAND($g_aEMB_Settings[0], 4) Then GUICtrlSetFont(-1, $g_aEMB_Settings[4], 400, 0, $g_aEMB_Settings[5]) + ; Reset default style parameter + $iDef_Button_Style = 0 + Next + EndIf + + ; Show GUI + GUISetState(@SW_SHOW, $hMsgGUI) + + ; Begin timeout counter + Local $iTimeout_Begin = TimerInit() + Local $iCounter = 0 + + ; Declare GUIGetMsg return array here and not in loop + Local $aMsg + + ; Set MessageLoop mode + Local $iOrgMode = Opt('GUIOnEventMode', 0) + + While 1 + $aMsg = GUIGetMsg(1) + + If $aMsg[1] = $hMsgGUI Then + Select + Case $aMsg[0] = -3 ; $GUI_EVENT_CLOSE + $iRet_Value = 0 + ExitLoop + Case $aMsg[0] = $aButtonCID[0] + ; Accel key pressed so return default button code + If $iDefButton_Code Then + $iRet_Value = $iDefButton_Code + ExitLoop + EndIf + Case Else + ; Check for other buttons + For $i = 1 To UBound($aButtonCID) - 1 + If $aMsg[0] = $aButtonCID[$i] Then + $iRet_Value = $i + ; No point in looking further + ExitLoop 2 + EndIf + Next + EndSelect + EndIf + + ; Timeout if required + If TimerDiff($iTimeout_Begin) / 1000 >= $iTimeOut And $iTimeOut > 0 Then + $iRet_Value = 9 + ExitLoop + EndIf + + ; Show countdown if required + If $fCountdown = True Then + Local $iTimeRun = Int(TimerDiff($iTimeout_Begin) / 1000) + If $iTimeRun <> $iCounter Then + $iCounter = $iTimeRun + GUICtrlSetData($cCountdown_Label, StringFormat("%2s", $iTimeOut - $iCounter)) + EndIf + EndIf + + WEnd + + ; Reset original mode + Opt('GUIOnEventMode', $iOrgMode) + + If GUICtrlRead($cCheckbox) = 1 Then + ; Negate the return value + $iRet_Value *= -1 + EndIf + + GUIDelete($hMsgGUI) + + Return $iRet_Value + +EndFunc ;==>_ExtMsgBox + +; #INTERNAL_USE_ONLY#============================================================================================================ +; Name...........: _EMB_GetDefaultFont +; Description ...: Determines Windows default MsgBox font size and name +; Syntax.........: _EMB_GetDefaultFont() +; Return values .: Success - Array holding determined font data +; : Failure - Array holding default values +; Array elements - [0] = Size, [1] = Weight, [2] = Style, [3] = Name, [4] = Quality +; Author ........: KaFu +; Remarks .......: Used internally by ExtMsgBox UDF +; =============================================================================================================================== +Func __EMB_GetDefaultFont() + + ; Fill array with standard default data + Local $aDefFontData[2] = [9, "Tahoma"] + + ; Get AutoIt GUI handle + Local $hWnd = WinGetHandle(AutoItWinGetTitle()) + ; Open Theme DLL + Local $hThemeDLL = DllOpen("uxtheme.dll") + ; Get default theme handle + Local $hTheme = DllCall($hThemeDLL, 'ptr', 'OpenThemeData', 'hwnd', $hWnd, 'wstr', "Static") + If @error Then Return $aDefFontData + $hTheme = $hTheme[0] + ; Create LOGFONT structure + Local $tFont = DllStructCreate("long;long;long;long;long;byte;byte;byte;byte;byte;byte;byte;byte;wchar[32]") + Local $pFont = DllStructGetPtr($tFont) + ; Get MsgBox font from theme + DllCall($hThemeDLL, 'long', 'GetThemeSysFont', 'HANDLE', $hTheme, 'int', 805, 'ptr', $pFont) ; TMT_MSGBOXFONT + If @error Then Return $aDefFontData + ; Get default DC + Local $hDC = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hWnd) + If @error Then Return $aDefFontData + $hDC = $hDC[0] + ; Get font vertical size + Local $iPixel_Y = DllCall("gdi32.dll", "int", "GetDeviceCaps", "handle", $hDC, "int", 90) ; LOGPIXELSY + If Not @error Then + $iPixel_Y = $iPixel_Y[0] + $aDefFontData[0] = Int(2 * (.25 - DllStructGetData($tFont, 1) * 72 / $iPixel_Y)) / 2 + EndIf + ; Close DC + DllCall("user32.dll", "int", "ReleaseDC", "hwnd", $hWnd, "handle", $hDC) + ; Extract font data from LOGFONT structure + $aDefFontData[1] = DllStructGetData($tFont, 14) + + Return $aDefFontData + +EndFunc ;==>__EMB_GetDefaultFont + +; #INTERNAL_USE_ONLY#================================================================================================= +; Name...........: __EMB_ShowPNG +; Description ...: Set PNG as image +; Author ........: UEZ +; Modified.......: Melba23, guinness +; Remarks .......: +; ==================================================================================================================== +Func __EMB_ShowPNG($sImg) + + _GDIPlus_Startup() + Local $hPic = GUICtrlCreatePic("", 4, 4, 32, 32) + Local $hBitmap = _GDIPlus_BitmapCreateFromFile($sImg) + Local $hBitmap_Resized = _GDIPlus_BitmapCreateFromScan0(32, 32) + Local $hBMP_Ctxt = _GDIPlus_ImageGetGraphicsContext($hBitmap_Resized) + _GDIPlus_GraphicsSetInterpolationMode($hBMP_Ctxt, 7) + _GDIPlus_GraphicsDrawImageRect($hBMP_Ctxt, $hBitmap, 0, 0, 32, 32) + Local $hHBitmap = __EMB_BitmapCreateDIB($hBitmap_Resized) + _WinAPI_DeleteObject(GUICtrlSendMsg($hPic, 0x0172, 0, $hHBitmap)) ; $STM_SETIMAGE + _GDIPlus_BitmapDispose($hBitmap) + _GDIPlus_BitmapDispose($hBitmap_Resized) + _GDIPlus_GraphicsDispose($hBMP_Ctxt) + _WinAPI_DeleteObject($hHBitmap) + _GDIPlus_Shutdown() + +EndFunc ;==>__EMB_ShowPNG + +; #INTERNAL_USE_ONLY#================================================================================================= +; Name...........: __EMB_BitmapCreateDIB +; Description ...: Create bitmap +; Author ........: UEZ +; Modified.......: +; Remarks .......: +; ==================================================================================================================== +Func __EMB_BitmapCreateDIB($hBitmap) + + Local $hRet = 0 + + Local $aRet1 = DllCall($__g_hGDIPDll, "uint", "GdipGetImageDimension", "ptr", $hBitmap, "float*", 0, "float*", 0) + If (@error) Or ($aRet1[0]) Then Return 0 + Local $tData = _GDIPlus_BitmapLockBits($hBitmap, 0, 0, $aRet1[2], $aRet1[3], $GDIP_ILMREAD, $GDIP_PXF32ARGB) + Local $pBits = DllStructGetData($tData, "Scan0") + If Not $pBits Then Return 0 + Local $tBIHDR = DllStructCreate("dword;long;long;ushort;ushort;dword;dword;long;long;dword;dword") + DllStructSetData($tBIHDR, 1, DllStructGetSize($tBIHDR)) + DllStructSetData($tBIHDR, 2, $aRet1[2]) + DllStructSetData($tBIHDR, 3, $aRet1[3]) + DllStructSetData($tBIHDR, 4, 1) + DllStructSetData($tBIHDR, 5, 32) + DllStructSetData($tBIHDR, 6, 0) + Local $aRet2 = DllCall("gdi32.dll", "ptr", "CreateDIBSection", "hwnd", 0, "ptr", DllStructGetPtr($tBIHDR), "uint", 0, "ptr*", 0, "ptr", 0, "dword", 0) + If (Not @error) And ($aRet2[0]) Then + DllCall("gdi32.dll", "dword", "SetBitmapBits", "ptr", $aRet2[0], "dword", $aRet1[2] * $aRet1[3] * 4, "ptr", DllStructGetData($tData, "Scan0")) + $hRet = $aRet2[0] + EndIf + _GDIPlus_BitmapUnlockBits($hBitmap, $tData) + Return $hRet +EndFunc ;==>__EMB_BitmapCreateDIB