v50 Steam/Premium information for editors
  • v50 information can now be added to pages in the main namespace. v0.47 information can still be found in the DF2014 namespace. See here for more details on the new versioning policy.
  • Use this page to report any issues related to the migration.
This notice may be cached—the current version can be found here.

User:Daedalusai

From Dwarf Fortress Wiki
Revision as of 02:06, 20 December 2008 by Daedalusai (talk | contribs)
Jump to navigation Jump to search

Some interface utilities

Tile Counter or Scrolling Accelerator

Lack of reference make me feel really stupid while planning digging area,so i tried to make a utility that shows coordinate.

This utility intercept arrow key strokes,then send keystrokes to game according to which key being pressed down(physiaclly),while counting how many keystrokes have been sent. As a side effect of sending keystrokes directly to the game,keystrokes can be sent much faster,result in much faster scrolling speed.

Note: This utility can't see where the cursor is in game,so if you move cursor over edge of map,the counter will not stop. If you want to measure how many tiles between edge of map and a giving spot,start measuring from edge of map. Otherwise,the counter is quite accurate as long as you don't touch the border.

Hotkey

Shift+r: Reset counter


;init config
SetTitleMatchMode, 3
#InstallKeybdHook

;Create Gui
Gui, Add, Text, x6 y10 w100 h20 vTXvalue, X: 0
Gui, Add, Text, x6 y30 w100 h20 vTYvalue, Y: 0
Gui, Add, Button, x106 y0 w40 h50 vBReset gReset, Reset
; Generated using SmartGUI Creator 4.0
Gui, Show, x554 y336 h53 w149, ShowXY

;var
x := 0
y := 0
	
;timer
SetTimer, supplementchk, 20
SetTimer, supplementchk, Off
SetTimer, supplementchkswitch, -90
SetTimer, supplementchkswitch, Off

;init routine
ownPID := DllCall("GetCurrentProcessId")
WinSet, AlwaysOnTop, On, ahk_pid %ownPID%
SendMode, Play
BlockInput, Off
BlockInput, Default

Return

;Hotkeys
Left::
Right::
Up::
Down::
SetTimer, supplementchkswitch, Off
SetTimer, supplementchk, Off
if ChkaxisX(x) != 0
GuiControl, Text, TXvalue, % "X: " x
if ChkaxisY(y) != 0
GuiControl, Text, TYvalue, % "Y: " y
SetTimer, supplementchkswitch, On
Return

;Button
Reset:
+r::
x := 0
y := 0
GuiControl, Text, TXvalue, % "X: " x
GuiControl, Text, TYvalue, % "Y: " y
Return

;timer routine
supplementchk:
if (ChkaxisX(x) + ChkaxisY(y) = 0)
{
	SetTimer, supplementchk, Off
	Return
}
GuiControl, Text, TXvalue, % "X: " x
GuiControl, Text, TYvalue, % "Y: " y
Return

supplementchkswitch:
SetTimer, supplementchk, On
Return


;Functions
ChkaxisX(ByRef x)
{
xmove := 0
GetKeyState, state, Left, P
if state = D
xmove += 1
GetKeyState, state, Right, P
if state = D
xmove += 3
if xmove != 4
{
	if xmove != 0
	{
		if xmove = 1
		{
			Send { Left }
			x -= 1
		Return 1
		}
		else
		{
			Send { Right }
			x += 1
		Return 3
		}
	}
	else
	{
	Return 0
	}
}
else
{
Return 4
}
Return
}

ChkaxisY(ByRef y)
{
ymove := 0
GetKeyState, state, Up, P
if state = D
ymove += 1
GetKeyState, state, Down, P
if state = D
ymove += 3
if ymove != 4
{
	if ymove != 0
	{
		if ymove = 1
		{
			Send { Up }
			y += 1
		Return 1
		}
		else
		{
			Send { Down }
			y -= 1
		Return 3
		}
	}
	else
	{
	Return 0
	}
}
else
{
Return 4
}
Return
}

;build-in function
GuiClose:
ExitApp