Skip to content

Instantly share code, notes, and snippets.

@johnfredcee
Created May 16, 2011 10:30
Show Gist options
  • Save johnfredcee/974208 to your computer and use it in GitHub Desktop.
Save johnfredcee/974208 to your computer and use it in GitHub Desktop.
Emacs Unreal Development Kit Support Functions
;; -- UNREALSCRIPT --------------------------------------------------------------
(require 'unrealscript-mode)
(defcustom udk-location "C:\\UDK\\UDK-2011-11\\"
"Directory where udk executables are found"
:type 'directory
:group 'udk)
(defcustom udk-map "TestMap"
"Name of the map to launch the Unreal game with"
:type 'string
:group 'udk)
(defcustom udk-game "AwesomeGame.AwesomeGameInfo"
"Name of the Game Info Class in Unrealscript that runs the game"
:type 'string
:group 'udk)
(defcustom udk-executable (concat udk-location "Binaries\\UDKLift.exe")
"Executable to launch game or editor with"
:type 'file
:group 'udk)
(defcustom udk-log (concat udk-location "UDKGame\\Logs\\Launch.log")
"Log file to monitor for game progress"
:type 'file
:group 'udk)
(defun udk-build (arg)
(interactive "P")
(shell-command (concat udk-executable " make " (if arg "" " -DEBUG")) "*Build*" "*UDK Build Errors*")
(select-window (split-window))
(find-file-read-only udk-log)
(end-of-buffer)
(compilation-minor-mode 1)
(auto-revert-tail-mode 1))
(defun udk-rebuild (arg)
(interactive "P")
(shell-command (concat udk-executable " make " (if arg "" " -debug") " -full") "*UDK Rebuild*" "*UDK Rebuild Errors*")
(select-window (split-window))
(find-file-read-only udk-log)
(end-of-buffer)
(compilation-minor-mode 1)
(auto-revert-tail-mode 1))
(defun udk-game ()
(interactive)
(shell-command (concat udk-executable (format " %s?%s -vadebug -nomoviestartup -ConsolePosX=0 -ConsolePosY=0" udk-map udk-game " &") "*UDK Game*" "*UDK Game Errors*")
(select-window (split-window))
(find-file-read-only udk-log)
(end-of-buffer)
(compilation-minor-mode 1)
(auto-revert-tail-mode 1)))
(defun udk-edit ()
(interactive)
(shell-command (concat udk-executable " editor " (format "%s.upk" udk-map) " &"))
(select-window (split-window))
(find-file-read-only udk-log)
(end-of-buffer)
(compilation-minor-mode 1)
(auto-revert-tail-mode 1))
(defconst unrealscript-keywords
(sort
(list
"abstract" "always" "array" "arraycount" "assert"
"auto" "automated" "bool" "break" "button"
"byte" "case" "class" "coerce" "collapsecategories"
"config" "const" "continue" "default" "defaultproperties"
"delegate" "dependson" "deprecated" "do" "dontcollapsecategories"
"edfindable" "editconst" "editconstarray" "editinline" "editinlinenew"
"editinlinenotify" "editinlineuse" "else" "enum" "enumcount"
"event" "exec" "expands" "export" "exportstructs"
"extends" "false" "final" "float" "for"
"foreach" "function" "global" "globalconfig" "goto"
"guid" "hidecategories" "if" "ignores" "import"
"init" "input" "insert" "instanced" "int"
"intrinsic" "invariant" "iterator" "latent" "length"
"local" "localized" "name" "native" "nativereplication"
"new" "noexport" "none" "noteditinlinenew" "notplaceable"
"nousercreate" "operator" "optional" "out" "perobjectconfig"
"placeable" "pointer" "postoperator" "preoperator" "private"
"protected" "reliable" "remove" "replication" "return"
"rng" "rot" "safereplace" "self" "showcategories"
"simulated" "singular" "skip" "state" "static"
"stop" "string" "struct" "super" "switch"
"transient" "travel" "true" "unreliable" "until"
"var" "vect" "while" "within") #'(lambda (a b) (> (length a) (length b))))
"Source for unrealscript keywords.")
(defvar ac-source-unrealscript-keywords
'((candidates
. (lambda ()
(all-completions ac-target unrealscript-keywords))))
(add-hook 'unrealascript-mode-hook
(lambda ()
(mirror-mode 1)
(setq ac-sources '(ac-source-unrealscript-keywords ac-source-words-in-same-mode-buffers ac-source-etags))
(auto-complete-mode 1)
;; (yas/minor-mode-on) when we try adding snippets
(c-set-style "unrealscript"))))
(defun grep-udk (pattern)
;; This needs to be set for grep to work under Win32. Path must point to GnuWin32 find and not windows find
(setq grep-find-template "find . <X> -type f <F> -print0 | xargs -0 -e grep <C> -inH -e <R>")
(interactive "MSearch for: ")
(rgrep pattern "*.uc" udk-location))
(defun tag-unrealscript ()
(interactive)
(shell-command
(concat
"dir /b /s " udk-location "Development\\Src\\*.uc | ectags --verbose -e -o " udk-location "\\Development\\Src\\TAGS --options=\"" (expand-file-name "~/ectags.cnf") "\" --language-force=unrealscript -L - &")))
(defun load-udk-tags ()
(interactive)
(visit-tags-table (concat udk-location "Development\\Src\\TAGS")))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment