8000 Add renamepet by johangu · Pull Request #4 · johangu/Razor · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add renamepet #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions FastColoredTextBox/SyntaxHighlighter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ protected void InitRazorRegex()

RazorCommandRegex =
new Regex(
@"\b(attack|cast|dress|undress|dressconfig|target|targettype|targetrelloc|dress|drop|waitfortarget|wft|dclick|dclicktype|dclickvar|usetype|useobject|droprelloc|lift|lifttype|waitforgump|gumpresponse|gumpclose|menu|menuresponse|waitformenu|promptresponse|waitforprompt|hotkey|say|msg|overhead|sysmsg|wait|pause|waitforstat|setability|setlasttarget|lasttarget|setvar|skill|useskill|walk|script|useonce|organizer|organize|org|restock|scav|scavenger|potion|clearsysmsg|clearjournal|whisper|yell|guild|alliance|emote|waitforsysmsg|wfsysmsg|clearall|virtue)\b",
@"\b(pathfind|renamepet|attack|cast|dress|undress|dressconfig|target|targettype|targetrelloc|dress|drop|waitfortarget|wft|dclick|dclicktype|dclickvar|usetype|useobject|droprelloc|lift|lifttype|waitforgump|gumpresponse|gumpclose|menu|menuresponse|waitformenu|promptresponse|waitforprompt|hotkey|say|msg|overhead|sysmsg|wait|pause|waitforstat|setability|setlasttarget|lasttarget|setvar|skill|useskill|walk|script|useonce|organizer|organize|org|restock|scav|scavenger|potion|clearsysmsg|clearjournal|whisper|yell|guild|alliance|emote|waitforsysmsg|wfsysmsg|clearall|virtue)\b",
RegexCompiledOption);

RazorLayerRegex =
Expand Down Expand Up @@ -472,4 +472,4 @@ public enum Language
{
Razor
}
}
}
3 changes: 3 additions & 0 deletions Razor/Core/Targeting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,9 @@ public static void CancelTarget()

m_FromGrabHotKey = false;

ScriptManager.SetVariableActive = false;
ScriptManager.SetLastTargetActive = false;

if (m_HasTarget)
{
Client.Instance.SendToServer(new TargetCancelResponse(m_CurrentID));
Expand Down
2 changes: 1 addition & 1 deletion Razor/HotKeys/HotKeys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -938,4 +938,4 @@ public static void Save(XmlTextWriter xml)
}
}
}
}
}
10 changes: 9 additions & 1 deletion Razor/Network/Packets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1825,4 +1825,12 @@ internal VirtueRequest(byte id) : base(0x12)
WriteAsciiNull(id.ToString());
}
}
}

public sealed class RenamePet : Packet
{
public RenamePet(Serial serial, string name) : base(0x75, 30) {
Write((int) serial);
WriteAsciiFixed(name, 30);
}
}
}
215 changes: 207 additions & 8 deletions Razor/Platform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -229,25 +229,224 @@ internal static void BringToFront(IntPtr window)
{
XRaiseWindow(Display, window);
}

/* List of mappings between:
* Windows 'Virtual Key Codes' (https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes)
* and
* Unix X11 Keysyms (https://cgit.freedesktop.org/xorg/proto/x11proto/tree/keysymdef.h)
*
* Testing was done on Gentoo Linux with an Unicomp New Model M, standard ANSI 104-key layout. (https://www.pckeyboard.com/page/product/NEW_M)
* The keyboard used may affect the results for some of the more ambiguous keysyms and keycodes. Hopefully this works for most folks.
*/
static Dictionary<int, int> m_MapX11Key = new Dictionary<int, int>()
{
// Utility keys.
// For many of these, Windows lists one keycode while unix has a separate keysym for each symbol on the key.
// In such cases, the primary symbol is used for the mapping.
{0x08, 0xFF08}, // Backspace
{0x09, 0xFF09}, // Tab
{0x0C, 0xFF0B}, // Clear
{0x0D, 0xFF0D}, // Return
{0x20, 0x0020}, // Space
{0xDE, 0x0027}, // Single/Double quote key
{0xDB, 0x005B}, // Bracket left
{0xDD, 0x005D}, // Bracket right
{0xBC, 0x002C}, // Comma / Less than (<)
{0xBE, 0x002E}, // Period / Greater than (>)
{0xDC, 0x005C}, // Backslash
{0xBB, 0x003D}, // Addition / Equals
{0xBF, 0x002F}, // Forward slash
{0xBD, 0x002D}, // Dash / Minus
{0xC0, 0x0060}, // Grave / Tilde
{0xBA, 0x003B}, // Semi-Colon / Colon
{0x13, 0xFF13}, // Pause
{0x1B, 0xFF1B}, // Escape
{0x26, 0xFF52}, // Up arrow
{0x28, 0xFF54}, // Down arrow
{0x25, 0xFF51}, // Left arrow
{0x27, 0xFF53}, // Right arrow
{0x2D, 0xFF63}, // Insert
{0x2E, 0xFFFF}, // Delete
{0x24, 0xFF50}, // Home
{0x23, 0xFF57}, // End
{0x21, 0xFF55}, // Page Up
{0x22, 0xFF56}, // Page Down
{0x14, 0xFFE5}, // Caps Lock
{0x91, 0xFF14}, // Scroll Lock
// Same physical key as scroll lock, unlikely to be needed for UO
//{0x91, 0xFF15}, // SysRq

// Modifier keys
// Unix has no combined keysym for these, handled separately in GetAsyncKeyState() below.
//{0x10, 0xFF??}, // Shift
//{0x11, 0xFF??}, // Control
//{0x12, 0xFF??}, // Alt
{0xA0, 0xFFE1}, // LSHIFT
{0xA1, 0xFFE2}, // RSHIFT
{0xA2, 0xFFE3}, // LCONTROL
{0xA3, 0xFFE4}, // RCONTROL
{0xA4, 0xFFE9}, // LALT
{0xA5, 0xFFEA}, // RALT
// These are pretty ambiguous and I don't have a windows machine handy to verify them.
//{0x5B, 0x00EB}, // Super L / Windows key L
//{0x5C, 0x00EC}, // Super R / Windows key R
//{0x5D, 0x0067}, // Menu

// Numeric Keypad
{0x90, 0xFFBE}, // Num lock
{0x60, 0xFFB0}, // Numpad0
{0x61, 0xFFB1},
{0x62, 0xFFB2},
{0x63, 0xFFB3},
{0x64, 0xFFB4},
{0x65, 0xFFB5},
{0x66, 0xFFB6},
{0x67, 0xFFB7},
{0x68, 0xFFB8},
{0x69, 0xFFB0}, // Numpad9
{0x6F, 0xFFAF}, // Divide
{0x6A, 0xFFAA}, // Multiply
{0x6D, 0xFFAD}, // Subtract
{0x6B, 0xFFAB}, // Add
{0x6C, 0xFFAE}, // Decimal
// Windows has no separate keycode for these, so ignore them for now.
// Should probably be handled similar to how Shift/Control/Alt are, below.
//{0x, 0xFF95}, // KP_Home
//{0x, 0xFF97}, // KP_Up
//{0x, 0xFF9A}, // KP_PageUp
//{0x, 0xFF96}, // KP_Left
//{0x, 0xFF98}, // KP_Right
//{0x, 0xFF9C}, // KP_End
//{0x, 0xFF99}, // KP_Down
//{0x, 0xFF9B}, // KP_PageDown
//{0x, 0xFF8D}, // KP_Enter

// F1-F24
{0x70, 0xFFBE},
{0x71, 0xFFBF},
{0x72, 0xFFC0},
{0x73, 0xFFC1},
{0x74, 0xFFC2},
{0x75, 0xFFC3},
{0x76, 0xFFC4},
{0x77, 0xFFC5},
{0x78, 0xFFC6},
{0x79, 0xFFC7},
{0x7A, 0xFFC8},
{0x7B, 0xFFC9},
{0x7C, 0xFFCA},
{0x7D, 0xFFCB},
{0x7E, 0xFFCC},
{0x7F, 0xFFCD},
{0x80, 0xFFCE},
{0x81, 0xFFCF},
{0x82, 0xFFD0},
{0x83, 0xFFD1},
{0x84, 0xFFD2},
{0x85, 0xFFD3},
{0x86, 0xFFD4},
{0x87, 0xFFD5},

// 0-9 map directly
{0x30, 0x0030},
{0x31, 0x0031},
{0x32, 0x0032},
{0x33, 0x0033},
{0x34, 0x0034},
{0x35, 0x0035},
{0x36, 0x0036},
{0x37, 0x0037},
{0x38, 0x0038},
{0x39, 0x0039},

// Captial A-Z map directly.
{0x41, 0x0041},
{0x42, 0x0042},
{0x43, 0x0043},
{0x44, 0x0044},
{0x45, 0x0045},
{0x46, 0x0046},
{0x47, 0x0047},
{0x48, 0x0048},
{0x49, 0x0049},
{0x4A, 0x004A},
{0x4B, 0x004B},
{0x4C, 0x004C},
{0x4D, 0x004D},
{0x4E, 0x004E},
{0x4F, 0x004F},
{0x50, 0x0050},
{0x51, 0x0051},
{0x52, 0x0052},
{0x53, 0x0053},
{0x54, 0x0054},
{0x55, 0x0055},
{0x56, 0x0056},
{0x57, 0x0057},
{0x58, 0x0058},
{0x59, 0x0059},
{0x5A, 0x005A},

// Windows doesn't have lowercase A-Z keycodes.
};

internal static int MapX11Key(int key)
{
int keycode;

internal static ushort GetAsyncKeyState(int key)
// If no mapping is found, pass the unmapped code back out.
// Can't be any worse than the way it used to work.
if (!m_MapX11Key.TryGetValue(key, out keycode))
keycode = key;

return keycode;
}

// A linux-version of WinUser.dll's GetAsyncKeyState()
// Take the (Windows) Virtual Key Code, convert it to an X11 KeySym, then back to the X11 Keycode, then check if it's pressed.
internal static ushort GetAsyncKeyState(int winkey)
{
try
{
int key = 0; int key2 = 0;
bool pressed = false; bool pressed2 = false;

// Convert Windows Virtual Key Code to an X11 Keysym.
// Code elsewhere distills Left/Right modifier keys to Window's single keycode. Un-distill them here
if (winkey == 0x10) { key = 0xFFE1; key2 = 0xFFE2; } // Any shift key
else if (winkey == 0x11) { key = 0xFFE3; key2 = 0xFFE4; } // Any ctrl key
else if (winkey == 0x12) { key = 0xFFE9; key2 = 0xFFEA; } // Any alt key
else { key = LinuxPlatform.MapX11Key (winkey); } // Any other key, map the keycode to a keysym

// Get physical keyboard state - every key being pressed is listed in the byte array
var szKey = new byte[32];
int res = XQueryKeymap(Display, szKey);
//foreach(var xx in szKey)
//Console.WriteLine(xx + "-");

// Convert X11 Keysym to X11 Keycode
int code = XKeysymToKeycode(Display, (int) key);
bool pressed = (szKey[code >> 3] & (1 << (code & 7))) == 0;

// Check if keycode is included in the keyboard state.
var r = szKey[code / 8];
var s = (1 << (code % 8));
var x = r & s;
return r == s ? (ushort) 0xFF00 : (ushort) 0;
pressed = Convert.ToBoolean(r & s);

// Check the second modifier key if required
if (key2 > 0)
{
int code2 = XKeysymToKeycode(Display, (int) key2);
var r2 = szKey[code2 / 8];
var s2 = (1 << (code2 % 8));
pressed2 = Convert.ToBoolean(r2 & s2);
}

if (pressed || pressed2)
return (ushort) 0xFF00;
else
return (ushort) 0;
}
catch
{
return 0;
return (ushort) 0;
}
}

Expand Down Expand Up @@ -345,4 +544,4 @@ internal static void DisableCloseButton(IntPtr handle)
}
}
}
}
}
2 changes: 1 addition & 1 deletion Razor/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:

[assembly: AssemblyVersion("1.6.9.0")]
[assembly: AssemblyVersion("1.6.10.0")]

//
// In order to sign your assembly you must specify a key to use. Refer to the
Expand Down
Loading
0