Skip to content

Commit 0191d11

Browse files
author
cyruz-git
committed
Updated resources
1 parent 26cfa73 commit 0191d11

File tree

9 files changed

+24
-16
lines changed

9 files changed

+24
-16
lines changed

DocsEmbedder.ahk

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
; ===[ CONSTANTS ]======================================================================================================
2727
SCRIPTNAME := "DocsEmbedder"
28-
SCRIPTVERSION := "0.1"
28+
SCRIPTVERSION := "0.1.1"
2929
HELPWIDTH := 1024
3030
HELPHEIGHT := 500
3131
DOCPATH := ( A_IsCompiled ) ? "res://" A_ScriptFullPath "/index.html" : A_ScriptDir "\docs\site\index.html"
@@ -51,7 +51,7 @@ If ( A_IsCompiled )
5151
GoSub, 1ADDPICTURE
5252
Else
5353
; Gui width: 500. Logo width: 376. To center it (500-376)/2 = 67.
54-
Gui, 1:Add, Picture, x67, %A_ScriptDir%\Logo.png
54+
Gui, 1:Add, Picture, x67, %A_ScriptDir%\res\logo.png
5555

5656
Gui, 1:Add, GroupBox, w480 h120 x10 y+15, Required Parameters:
5757
Gui, 1:Add, Text, w60 x20 yp+30, PE File:
@@ -75,15 +75,15 @@ Return
7575
1ADDPICTURE:
7676
; Code based on http://www.autohotkey.com/forum/viewtopic.php?p=147052
7777
Gui, 1:Add, Text, w376 h110 x67 +0xE hwnd1TEXT_A_HWND
78-
szData := 0, pData := UpdRes_LockResource("LOGO.PNG", 10, szData)
78+
szData := 0, pData := UpdRes_LockResource(0, "RES\LOGO.PNG", 10, szData)
7979
hBitmap := BinGet_Bitmap(pData, szData)
8080
SendMessage, 0x172, 0, hBitmap,, ahk_id %1TEXT_A_HWND% ; 0x172 = STM_SETIMAGE, 0 = IMAGE_BITMAP
8181
GuiControl, 1:Move, %1TEXT_A_HWND%, w376 h110
8282
Return
8383
;1ADDPICTURE
8484

8585
1DUMMY:
86-
FileInstall, Logo.png, DUMMY
86+
FileInstall, res\logo.png, DUMMY
8787
Return
8888
;1DUMMY
8989

@@ -111,13 +111,15 @@ Return
111111
GuiControl, 1:Disable, 1BTN_C
112112
sFinalFile := 1EDIT_A, sFinalDir := 1EDIT_B
113113

114-
If ( sFinalFile == "" || sFinalDir == "" ) {
114+
If ( sFinalFile == "" || sFinalDir == "" )
115+
{
115116
MsgBox, 0x10, %SCRIPTNAME%, PE File or/and Html Folder missing.
116117
GuiControl, 1:Enable, 1BTN_C
117118
Return
118119
}
119120

120-
If ( (sErrMsg := CheckDirAndFilenames(sFinalDir, 1CBOX_A)) != "" ) {
121+
If ( (sErrMsg := CheckDirAndFilenames(sFinalDir, 1CBOX_A)) != "" )
122+
{
121123
MsgBox, 0x10, %SCRIPTNAME%, %sErrMsg%
122124
GuiControl, 1:Enable, 1BTN_C
123125
Return
@@ -134,7 +136,7 @@ Return
134136
, PECreateEmpty(sFinalFile)
135137

136138
SB_SetText("Embedding resources...")
137-
; 0 = DELETE OLD, 23 = RT_HTML, 0 = NEUTRAL LANG ID
139+
; DELETE OLD = 0, RT_HTML = 23, NEUTRAL LANG ID = 0
138140
UpdRes_UpdateDirOfResources(sFinalDir, sFinalFile, 0, 23, 0)
139141

140142
; Remove the temporary folder if the checkboxes are both selected.
@@ -182,14 +184,16 @@ GUICLOSE:
182184
; ======================================================================================================================
183185

184186
; Check if a directory contains any file.
185-
IsDirEmpty(sDir, nRecur:=0) {
187+
IsDirEmpty(sDir, nRecur:=0)
188+
{
186189
Loop, %sDir%\*, 0, %nRecur%
187190
Return 0
188191
Return 1
189192
}
190193

191194
; Check directory for emptyness and files for malformed file names (e.g. only numbers).
192-
CheckDirAndFilenames(sDir, bFlatten) {
195+
CheckDirAndFilenames(sDir, bFlatten)
196+
{
193197
sRegex = iS)^[\d\W]+(?!\w)
194198

195199
bFlagFlatt := IsDirEmpty(sDir)
@@ -209,10 +213,12 @@ CheckDirAndFilenames(sDir, bFlatten) {
209213
}
210214

211215
; Move all the files to the root directory, flattening it.
212-
FlattenFiles(sDir, sTempDir:="") {
216+
FlattenFiles(sDir, sTempDir:="")
217+
{
213218
If ( isDirEmpty(sDir, 1) )
214219
Return 0
215-
If ( sTempDir != "" ) {
220+
If ( sTempDir != "" )
221+
{
216222
If ( InStr(FileExist(sTempDir), "D") )
217223
FileRemoveDir, %sTempDir%, 1
218224
FileCopyDir, %sDir%, %sTempDir%, 1
@@ -232,15 +238,17 @@ FlattenFiles(sDir, sTempDir:="") {
232238

233239
; Replace the href/src/url attributes inside html and css files.
234240
; The directory must be flattened.
235-
ReplaceHrefs(sDir) {
241+
ReplaceHrefs(sDir)
242+
{
236243
sRegex_htm = iS)(?:(href|src)\s*=\s*("|')\s*[^:"']*(?:\/|\\))(?=[^\/\\:"']+\s*["'])
237244
sSubst_htm = $1=$2
238245
sRegex_css = iS)(?:url\s*\(("|')\s*[^:"']*(?:\/|\\))(?=[^\/\\:"']+\s*["'])
239246
sSubst_css = url($1
240247

241248
Loop, %sDir%\*.* ; No recursion.
242249
{
243-
If ( InStr(A_LoopFileExt, "htm") || InStr(A_LoopFileExt, "css") ) {
250+
If ( InStr(A_LoopFileExt, "htm") || InStr(A_LoopFileExt, "css") )
251+
{
244252
FileRead, sContent, %A_LoopFileLongPath%
245253
sRegex := ( InStr(A_LoopFileExt, "htm") ) ? sRegex_htm : sRegex_css
246254
sSubst := ( InStr(A_LoopFileExt, "htm") ) ? sSubst_htm : sSubst_css
@@ -252,7 +260,8 @@ ReplaceHrefs(sDir) {
252260
}
253261

254262
; Show a res:// url in an embedded WebBrowser ActiveX object.
255-
ShowBrowser(nW, nH, sGuiName, sResUrl) {
263+
ShowBrowser(nW, nH, sGuiName, sResUrl)
264+
{
256265
Static 2AX_A, 2AX_A_HWND
257266

258267
Gui, 2:Destroy

Icon.ico

-1.92 KB
Binary file not shown.

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,11 @@ The build archive is [here on GitHub](https://github.com/cyruz-git/DocsEmbedder/
2020
Name | Description
2121
-----|------------
2222
docs\ | Folder containing the documentation, built with MkDocs.
23+
res\ | Folder containing icon resources and program logo.
2324
COPYING | GNU General Public License.
2425
COPYING.LESSER | GNU Lesser General Public License.
2526
DocsEmbedder.ahk | Main source file.
26-
Icon.ico | Program's icon file.
2727
LibSetup.ahk | Libraries setup script.
28-
Logo.png | Program's logo file.
2928
README.md | This document.
3029

3130
### How to compile

docs/docs/img/img001.png

4.46 KB
Loading

docs/docs/img/img002.png

6.34 KB
Loading

docs/site/img/img001.png

4.46 KB
Loading

docs/site/img/img002.png

6.34 KB
Loading

res/icon.ico

31.3 KB
Binary file not shown.
File renamed without changes.

0 commit comments

Comments
 (0)