weird picture behavior

Ask gaming related questions (AHK v1.1 and older)
hikori
Posts: 2
Joined: 19 Mar 2018, 12:23

weird picture behavior

19 Mar 2018, 12:44

Hello. I'm coding some overlay helper for a game and found weird behavior. Script load plain red and green png.

Code: Select all

#SingleInstance force
guisize:=9
gamexpos:=0
gameypos:=0
gs:=guisize*2
xs:=985+56
ys:=457
posa:=-1
rdrol:=0
posr:=0
posg:=0
global arrayposition:=[]
populate()

ta:=1
tb:=1
gui, base:new,,base
gui, base:add, button, x20 y10 GMyButton,button
Gui, base:Add, Edit, x20 y35 w180 h100 vMyEdit +ReadOnly , Edit
Gui, base:Show, x20 y20 w279 h179, base

gui, gcoverlay:new,+AlwaysOnTop -0x800000 +E0x20 -Caption,gcoverlay
gui, gcoverlay:add, Picture, w%guisize% h%guisize% vPicgr1 x-50 y0, D:\AutoHotkey\pics\green.png
gui, gcoverlay:add, Picture, w%guisize% h%guisize% vPicrd1 x-50 y0, D:\AutoHotkey\pics\red.png
gui, show, w1088 h612,gcoverlay
WinSet, Transparent, 100,gcoverlay

chkgamesize()
{
	WinGet, Style, Style, GemCraft Chasing Shadows
	if (Style & 0x40000)  ; check for resizing
	{
		WinGetPos,x,y,w,h,GemCraft Chasing Shadows
		WinSet, Style, -0x40000, GemCraft Chasing Shadows
		winmove, GemCraft Chasing Shadows,,x+5,y+5,w-10,h-10
	}
}

loop
{
	chkgamesize()
	WinGetPos,x,y,,,GemCraft Chasing Shadows
	if(gamexpos!=x or gameypos!=y)
	{
		gamexpos:=x
		gameypos:=y
		gosub, redrawoverlay
	}
	if(rdrol==1)
	{
		GuiControl,base:text,MyEdit,%lineout%
		rdrol:=0
		tempx:=arrayposition[posg,1,1]
		tempy:=arrayposition[posg,1,2]
		guicontrol,move,Picgr1, x%tempx% y%tempy%
		tempx:=arrayposition[posr,1,1]
		tempy:=arrayposition[posr,1,2]
		guicontrol,move,Picrd1, x%tempx% y%tempy%
	}
	
	sleep, 10
	
}
return

baseGuiClose:
WinGetPos,x,y,w,h,GemCraft Chasing Shadows
WinSet, Style, +0x40000,GemCraft Chasing Shadows
winmove, GemCraft Chasing Shadows,,x-5,y-5,w+10,h+10
ExitApp

redrawoverlay:

	x:=gamexpos+3
	y:=gameypos+26
	winmove,gcoverlay,,x,y
return

MyButton:
FileSelectFile, filer1 
FileRead, Contents1,%filer1%
posr:=0
posg:=0
pos:=1
array1:=[]
while pos := RegExMatch(Contents1, "\s?(.*?): (.*?) (.*?)(\v|\z)", m, pos+StrLen(m))
{
    array1[m1, 1] := m2
    array1[m1, 2] := m3
}
posa:=1
GuiControl,base:text, edit1,4f
gosub,redrawmain
rdrol:=1
return

redrawmain:
lineout:=""
ddd1:=posa-2
ddd2:=posa-1
ddd4:=posa+1
ddd5:=posa+2
if(ddd2==0)
{
    lineout:="`n`n> " . lout(array1,posa) . " <`n" . "   " . lout(array1,ddd4) . "`n" . "   " . lout(array1,ddd5)
}
else if(ddd1==0)
{
    lineout:="`n" . "   " . lout(array1,ddd2) . "`n> " . lout(array1,posa) . " <`n" . "   " . lout(array1,ddd4) . "`n" . "   " . lout(array1,ddd5)
}
else if(array1[posa,1] = "")
{
	posa--
    return
}
else
{
    lineout:="   " . lout(array1,ddd1) . "`n" . "   " . lout(array1,ddd2) . "`n> " . lout(array1,posa) . " <`n" . "   " . lout(array1,ddd4) . "`n" . "   " . lout(array1,ddd5)
}
Length := StrLen(array1[posa,2])
if(Length<4)
{
	posg:=array1[posa,2]
	posr:=0
}
else
{
	RegExMatch(array1[posa,2], "\s?(.*?)>(.*?)(\v|\z)", m, 1)
	posr:=m2
	posg:=m1
}
rdrol:=1
return

lout(var1,var2)
{
	space:=" "
	if (var1[var2,1]=="Dupe")
	{
		space:="      "
	}
	line:=var1[var2,1] . space . var1[var2,2]
	return line
}

pgup::
if(posa>1)
	posa--
gosub,redrawmain
return
pgdn::
posa++
gosub,redrawmain
return

populate()
{
	arrayposition[0,1,1]:=-10
	arrayposition[0,1,2]:=-10
	arrayposition[0,2,1]:=-10
	arrayposition[0,2,2]:=-10
	y:=1
	x:=1
	while(y<13)
	{
		while(x<4)
		{
			temp:= y . ntol(x)
			basex:=100
			basey:=100
			offset:=10
			arrayposition[temp,1,1]:=basex+(x*offset)
			arrayposition[temp,1,2]:=basey-(y*offset)
			arrayposition[temp,2,1]:=basex+(x*offset)
			arrayposition[temp,2,2]:=basey-(y*offset)
			x++
		}
		x:=1
		y++
	}
}
ntol(a)
{
	if(a==1)
		return "A"
	else if(a==2)
		return "B"
	else
		return "C"
}
press button and load txt file

Code: Select all

1: Dupe 1A>1B
2: Upgrade 1B
3: Dupe 1A>1C
4: Dupe 1B>2A
5: Combine 2A>1C
6: Dupe 1A>2A
7: Dupe 1C>2B
Page down till "combine". Both pictures are the same. is that a bug or I'm coding it wrong?
hikori
Posts: 2
Joined: 19 Mar 2018, 12:23

Re: weird picture behavior

19 Mar 2018, 16:43

solved with GDIp

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: Shoobis and 101 guests