summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/util
diff options
context:
space:
mode:
authorzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2008-07-17 17:12:41 +0000
committerzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2008-07-17 17:12:41 +0000
commit3e5fbd50de561ffc9e84fba6c4b2d0a2e13b118a (patch)
tree8e08d60e131656353d4210e0b01f8235506374aa /crawl-ref/source/util
parent1210d4439b7da2cea42e15892f7a09a03c6f0814 (diff)
downloadcrawl-ref-3e5fbd50de561ffc9e84fba6c4b2d0a2e13b118a.tar.gz
crawl-ref-3e5fbd50de561ffc9e84fba6c4b2d0a2e13b118a.zip
Do "keypress -> command_type" via keybindings. Solves bug 2018200,
where you couldn't do macros with the old 3.4 keymap since the 3.4 keys were done via macros and macros can't recursively invoke macros. Has the little snag that it doesn't exactly reproduce the 3.4 "fire ammo" command since 3.4 automatically goes to the inventory list but 4.0 doesn't. TODO: * Get levelmap commands to use keybindings instead of hardcoded mappings. * Let function keys and alt keys be bound to commands. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6587 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/util')
-rwxr-xr-xcrawl-ref/source/util/cmd-name.pl76
1 files changed, 76 insertions, 0 deletions
diff --git a/crawl-ref/source/util/cmd-name.pl b/crawl-ref/source/util/cmd-name.pl
new file mode 100755
index 0000000000..6a452575ff
--- /dev/null
+++ b/crawl-ref/source/util/cmd-name.pl
@@ -0,0 +1,76 @@
+#!/usr/bin/perl -w
+
+use strict;
+
+my ($infile, $outfile);
+
+if (-e "enum.h")
+{
+ $infile = "enum.h";
+ $outfile = "cmd-name.h";
+}
+elsif (-e "../enum.h")
+{
+ $infile = "../enum.h";
+ $outfile = "../cmd-name.h";
+}
+else {
+ die "Can't find 'enum.h'";
+}
+
+unless (open(INFILE, "<$infile")) {
+ die "Couldn't open '$infile' for reading: $!\n";
+}
+
+unless (open(OUTFILE, ">$outfile")) {
+ die "Couldn't open '$outfile' for writing: $!\n";
+}
+
+# All set, now get to first command
+while (<INFILE>) {
+ last if (/^ *CMD_NO_CMD/);
+}
+
+unless (/^ *CMD_NO_CMD/) {
+ die "Couldn't find CMD_NO_CMD in enum.h\n";
+}
+
+print OUTFILE "// Generated by util/cmd-name.pl\n\n";
+
+while (<INFILE>) {
+ # Pass through pre-processor directives
+ if (/^#/) {
+ print OUTFILE $_;
+ next;
+ }
+
+ s|//.*||; # Strip comments
+ s/=.*//; # Strip enum asignments
+ s/\s//g; # Strip whitespace
+ s/,$//; # Strip comma
+
+ next if (/^$/); # Skip blank lines
+
+ my $cmd = $_;
+
+ unless ($cmd =~ /^CMD_/) {
+ die "'$cmd' doesn't start with CMD_\n";
+ }
+
+ # Don't include synthetic keys
+ last if ($cmd eq "CMD_DISABLE_MORE");
+
+ # Skip MIN or MAX enums, since they aren't commands
+ next if ($cmd =~ /^CMD_(MIN|MAX)_/);
+
+ print OUTFILE "{$cmd, \"$cmd\"},\n";
+}
+
+# End of array sentinel
+print OUTFILE "\n";
+print OUTFILE "{CMD_NO_CMD, NULL}\n";
+
+close (INFILE);
+close (OUTFILE);
+
+exit (0);