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 14:19, 21 December 2008 by Daedalusai (talk | contribs) (now response to shift+arrow keys,shift+r retain original function)
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
SendMode, Play

;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%
Return

;Hotkeys

Left::
Right::
Up::
Down::
+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

~+r::
;Button
Reset:
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
steps := 1
prefix := ""
GetKeyState, state, Left, P
if state = D
xmove += 1
GetKeyState, state, Right, P
if state = D
xmove += 3
GetKeyState, state, Shift, P
if state = D
{
	prefix := prefix "+"
	steps := 10
}
GetKeyState, state,Ctrl,
if state = D
{
	prefix := prefix "^"
	steps := 0
}
GetKeyState, state, Alt,
if state = D
{
	prefix := prefix "!"
	steps := 0
}
if xmove != 4
{
	if xmove != 0
	{
		if xmove = 1
		{
			Send %prefix%{Left}
			x -= %steps%
		Return 1
		}
		else
		{
			Send %prefix%{Right}
			x += %steps%
		Return 3
		}
	}
	else
	{
	Return 0
	}
}
else
{
Return 4
}
Return
}

ChkaxisY(ByRef y)
{
ymove := 0
steps := 1
prefix := ""
GetKeyState, state, Up, P
if state = D
ymove += 1
GetKeyState, state, Down, P
if state = D
ymove += 3
GetKeyState, state, Shift,
if state = D
{
	prefix := prefix "+"
	steps := 10
}
GetKeyState, state,Ctrl,
if state = D
{
	prefix := prefix "^"
	steps := 0
}
GetKeyState, state, Alt,
if state = D
{
	prefix := prefix "!"
	steps := 0
}
if ymove != 4
{
	if ymove != 0
	{
		if ymove = 1
		{
			Send %prefix%{Up}
			y += %steps%
		Return 1
		}
		else
		{
			Send %prefix%{Down}
			y -= %steps%
		Return 3
		}
	}
	else
	{
	Return 0
	}
}
else
{
Return 4
}
Return
}

;build-in function
GuiClose:
ExitApp