diff options
-rw-r--r-- | doc/classes/AudioEffectRecord.xml | 6 | ||||
-rw-r--r-- | doc/classes/ProjectSettings.xml | 1 | ||||
-rwxr-xr-x | doc/tools/make_rst.py | 72 | ||||
-rw-r--r-- | doc/translations/extract.py | 19 | ||||
-rw-r--r-- | platform/windows/key_mapping_windows.cpp | 317 | ||||
-rw-r--r-- | scene/gui/texture_button.cpp | 12 |
6 files changed, 277 insertions, 150 deletions
diff --git a/doc/classes/AudioEffectRecord.xml b/doc/classes/AudioEffectRecord.xml index 0b6c5287cf..d523472b8e 100644 --- a/doc/classes/AudioEffectRecord.xml +++ b/doc/classes/AudioEffectRecord.xml @@ -1,10 +1,12 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="AudioEffectRecord" inherits="AudioEffect" version="4.0"> <brief_description> - Audio effect used for recording sound from a microphone. + Audio effect used for recording the sound from an audio bus. </brief_description> <description> - Allows the user to record sound from a microphone. It sets and gets the format in which the audio file will be recorded (8-bit, 16-bit, or compressed). It checks whether or not the recording is active, and if it is, records the sound. It then returns the recorded sample. + Allows the user to record the sound from an audio bus. This can include all audio output by Godot when used on the "Master" audio bus. + Can be used (with an [AudioStreamMicrophone]) to record from a microphone. + It sets and gets the format in which the audio file will be recorded (8-bit, 16-bit, or compressed). It checks whether or not the recording is active, and if it is, records the sound. It then returns the recorded sample. </description> <tutorials> <link title="Recording with microphone">$DOCS_URL/tutorials/audio/recording_with_microphone.html</link> diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml index 7034fc1f75..a249786388 100644 --- a/doc/classes/ProjectSettings.xml +++ b/doc/classes/ProjectSettings.xml @@ -188,6 +188,7 @@ ProjectSettings.SetSetting("application/config/name", "Example"); [/csharp] [/codeblocks] + This can also be used to erase custom project settings. To do this change the setting value to [code]null[/code]. </description> </method> </methods> diff --git a/doc/tools/make_rst.py b/doc/tools/make_rst.py index 4cb9de6d58..9e18866ca3 100755 --- a/doc/tools/make_rst.py +++ b/doc/tools/make_rst.py @@ -19,10 +19,11 @@ GODOT_DOCS_PATTERN = re.compile(r"^\$DOCS_URL/(.*)\.html(#.*)?$") MARKUP_ALLOWED_PRECEDENT = " -:/'\"<([{" MARKUP_ALLOWED_SUBSEQUENT = " -.,:;!?\\/'\")]}>" -# Used to translate the section headings when required with --lang argument. -# The HEADINGS list should be synced with what we actually write with `make_heading`, -# and also hardcoded in `doc/translations/extract.py`. -HEADINGS = [ +# Used to translate section headings and other hardcoded strings when required with +# the --lang argument. The BASE_STRINGS list should be synced with what we actually +# write in this script (check `translate()` uses), and also hardcoded in +# `doc/translations/extract.py` to include them in the source POT file. +BASE_STRINGS = [ "Description", "Tutorials", "Properties", @@ -38,8 +39,21 @@ HEADINGS = [ "Method Descriptions", "Operator Descriptions", "Theme Property Descriptions", + "Inherits:", + "Inherited By:", + "(overrides %s)", + "Default", + "Setter", + "value", + "Getter", + "This method should typically be overridden by the user to have any effect.", + "This method has no side effects. It doesn't modify any of the instance's member variables.", + "This method accepts any number of arguments after the ones described here.", + "This method is used to construct a type.", + "This method doesn't need an instance to be called, so it can be called directly using the class name.", + "This method describes a valid operator to use with this type as left-hand operand.", ] -headings_l10n = {} +strings_l10n = {} def print_error(error, state): # type: (str, State) -> None @@ -408,13 +422,13 @@ def main(): # type: () -> None try: import polib except ImportError: - print("Section heading localization requires `polib`.") + print("Base template strings localization requires `polib`.") exit(1) pofile = polib.pofile(lang_file) for entry in pofile.translated_entries(): - if entry.msgid in HEADINGS: - headings_l10n[entry.msgid] = entry.msgstr + if entry.msgid in BASE_STRINGS: + strings_l10n[entry.msgid] = entry.msgstr else: print("No PO file at '{}' for language '{}'.".format(lang_file, args.lang)) @@ -494,6 +508,14 @@ def main(): # type: () -> None exit(1) +def translate(string): # type: (str) -> str + """Translate a string based on translations sourced from `doc/translations/*.po` + for a language if defined via the --lang command line argument. + Returns the original string if no translation exists. + """ + return strings_l10n.get(string, string) + + def make_rst_class(class_def, state, dry_run, output_dir): # type: (ClassDef, State, bool, str) -> None class_name = class_def.name @@ -515,7 +537,7 @@ def make_rst_class(class_def, state, dry_run, output_dir): # type: (ClassDef, S # Ascendants if class_def.inherits: inh = class_def.inherits.strip() - f.write("**Inherits:** ") + f.write("**" + translate("Inherits:") + "** ") first = True while inh in state.classes: if not first: @@ -538,7 +560,7 @@ def make_rst_class(class_def, state, dry_run, output_dir): # type: (ClassDef, S inherited.append(c.name) if len(inherited): - f.write("**Inherited By:** ") + f.write("**" + translate("Inherited By:") + "** ") for i, child in enumerate(inherited): if i > 0: f.write(", ") @@ -569,7 +591,8 @@ def make_rst_class(class_def, state, dry_run, output_dir): # type: (ClassDef, S default = property_def.default_value if default is not None and property_def.overrides: ref = ":ref:`{1}<class_{1}_property_{0}>`".format(property_def.name, property_def.overrides) - ml.append((type_rst, property_def.name, default + " (overrides " + ref + ")")) + # Not using translate() for now as it breaks table formatting. + ml.append((type_rst, property_def.name, default + " " + "(overrides %s)" % ref)) else: ref = ":ref:`{0}<class_{1}_property_{0}>`".format(property_def.name, class_name) ml.append((type_rst, ref, default)) @@ -687,12 +710,13 @@ def make_rst_class(class_def, state, dry_run, output_dir): # type: (ClassDef, S f.write("- {} **{}**\n\n".format(property_def.type_name.to_rst(state), property_def.name)) info = [] + # Not using translate() for now as it breaks table formatting. if property_def.default_value is not None: - info.append(("*Default*", property_def.default_value)) + info.append(("*" + "Default" + "*", property_def.default_value)) if property_def.setter is not None and not property_def.setter.startswith("_"): - info.append(("*Setter*", property_def.setter + "(value)")) + info.append(("*" + "Setter" + "*", property_def.setter + "(" + "value" + ")")) if property_def.getter is not None and not property_def.getter.startswith("_"): - info.append(("*Getter*", property_def.getter + "()")) + info.append(("*" + "Getter" + "*", property_def.getter + "()")) if len(info) > 0: format_table(f, info) @@ -781,7 +805,8 @@ def make_rst_class(class_def, state, dry_run, output_dir): # type: (ClassDef, S info = [] if theme_item_def.default_value is not None: - info.append(("*Default*", theme_item_def.default_value)) + # Not using translate() for now as it breaks table formatting. + info.append(("*" + "Default" + "*", theme_item_def.default_value)) if len(info) > 0: format_table(f, info) @@ -1306,8 +1331,9 @@ def make_method_signature( def make_heading(title, underline, l10n=True): # type: (str, str, bool) -> str if l10n: - if title in headings_l10n: - title = headings_l10n.get(title) + new_title = translate(title) + if new_title != title: + title = new_title underline *= 2 # Double length to handle wide chars. return title + "\n" + (underline * len(title)) + "\n\n" @@ -1317,12 +1343,12 @@ def make_footer(): # type: () -> str # This way, we avoid bloating the generated rST with duplicate abbreviations. # fmt: off return ( - ".. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`\n" - ".. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`\n" - ".. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`\n" - ".. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`\n" - ".. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`\n" - ".. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`\n" + ".. |virtual| replace:: :abbr:`virtual (" + translate("This method should typically be overridden by the user to have any effect.") + ")`\n" + ".. |const| replace:: :abbr:`const (" + translate("This method has no side effects. It doesn't modify any of the instance's member variables.") + ")`\n" + ".. |vararg| replace:: :abbr:`vararg (" + translate("This method accepts any number of arguments after the ones described here.") + ")`\n" + ".. |constructor| replace:: :abbr:`constructor (" + translate("This method is used to construct a type.") + ")`\n" + ".. |static| replace:: :abbr:`static (" + translate("This method doesn't need an instance to be called, so it can be called directly using the class name.") + ")`\n" + ".. |operator| replace:: :abbr:`operator (" + translate("This method describes a valid operator to use with this type as left-hand operand.") + ")`\n" ) # fmt: on diff --git a/doc/translations/extract.py b/doc/translations/extract.py index 45e747d5dd..f8223701d5 100644 --- a/doc/translations/extract.py +++ b/doc/translations/extract.py @@ -26,7 +26,7 @@ msgstr "" """ # Some strings used by make_rst.py are normally part of the editor translations, # so we need to include them manually here for the online docs. -HEADINGS = [ +BASE_STRINGS = [ "Description", "Tutorials", "Properties", @@ -42,6 +42,19 @@ HEADINGS = [ "Method Descriptions", "Operator Descriptions", "Theme Property Descriptions", + "Inherits:", + "Inherited By:", + "(overrides %s)", + "Default", + "Setter", + "value", + "Getter", + "This method should typically be overridden by the user to have any effect.", + "This method has no side effects. It doesn't modify any of the instance's member variables.", + "This method accepts any number of arguments after the ones described here.", + "This method is used to construct a type.", + "This method doesn't need an instance to be called, so it can be called directly using the class name.", + "This method describes a valid operator to use with this type as left-hand operand.", ] ## <xml-line-number-hack from="https://stackoverflow.com/a/36430270/10846399"> @@ -229,12 +242,12 @@ def _make_translation_catalog(classes): def _generate_translation_catalog_file(unique_msgs, output, location_line=False): with open(output, "w", encoding="utf8") as f: f.write(HEADER) - for msg in HEADINGS: + for msg in BASE_STRINGS: f.write("#: doc/tools/make_rst.py\n") f.write('msgid "{}"\n'.format(msg)) f.write('msgstr ""\n\n') for msg in unique_msgs: - if len(msg) == 0 or msg in HEADINGS: + if len(msg) == 0 or msg in BASE_STRINGS: continue f.write("#:") diff --git a/platform/windows/key_mapping_windows.cpp b/platform/windows/key_mapping_windows.cpp index 938a777de6..e32dc0d1a6 100644 --- a/platform/windows/key_mapping_windows.cpp +++ b/platform/windows/key_mapping_windows.cpp @@ -32,117 +32,134 @@ #include <stdio.h> +// This provides translation from Windows virtual key codes to Godot and back. +// See WinUser.h and the below for documentation: +// https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes + struct _WinTranslatePair { Key keysym; unsigned int keycode; }; static _WinTranslatePair _vk_to_keycode[] = { - { Key::BACKSPACE, VK_BACK }, // (0x08) // backspace - { Key::TAB, VK_TAB }, //(0x09) - - //VK_CLEAR (0x0C) - - { Key::ENTER, VK_RETURN }, //(0x0D) - - { Key::SHIFT, VK_SHIFT }, //(0x10) - - { Key::CTRL, VK_CONTROL }, //(0x11) - - { Key::ALT, VK_MENU }, //(0x12) - - { Key::PAUSE, VK_PAUSE }, //(0x13) + // VK_LBUTTON (0x01) + // VK_RBUTTON (0x02) + // VK_CANCEL (0x03) + // VK_MBUTTON (0x04) + // VK_XBUTTON1 (0x05) + // VK_XBUTTON2 (0x06) + // We have no mappings for the above, as we only map keyboard buttons here. - { Key::CAPSLOCK, VK_CAPITAL }, //(0x14) + // 0x07 is undefined. - { Key::ESCAPE, VK_ESCAPE }, //(0x1B) + { Key::BACKSPACE, VK_BACK }, // (0x08) + { Key::TAB, VK_TAB }, // (0x09) - { Key::SPACE, VK_SPACE }, //(0x20) + // 0x0A-0B are reserved. - { Key::PAGEUP, VK_PRIOR }, //(0x21) + { Key::CLEAR, VK_CLEAR }, // (0x0C) + { Key::ENTER, VK_RETURN }, // (0x0D) - { Key::PAGEDOWN, VK_NEXT }, //(0x22) + // 0x0E-0F are undefined. - { Key::END, VK_END }, //(0x23) + { Key::SHIFT, VK_SHIFT }, // (0x10) + { Key::CTRL, VK_CONTROL }, // (0x11) + { Key::ALT, VK_MENU }, // (0x12) + { Key::PAUSE, VK_PAUSE }, // (0x13) + { Key::CAPSLOCK, VK_CAPITAL }, // (0x14) - { Key::HOME, VK_HOME }, //(0x24) + // 0x15-1A are IME keys. We have no mapping. - { Key::LEFT, VK_LEFT }, //(0x25) + { Key::ESCAPE, VK_ESCAPE }, // (0x1B) - { Key::UP, VK_UP }, //(0x26) - - { Key::RIGHT, VK_RIGHT }, //(0x27) + // 0x1C-1F are IME keys. We have no mapping. + { Key::SPACE, VK_SPACE }, // (0x20) + { Key::PAGEUP, VK_PRIOR }, // (0x21) + { Key::PAGEDOWN, VK_NEXT }, // (0x22) + { Key::END, VK_END }, // (0x23) + { Key::HOME, VK_HOME }, // (0x24) + { Key::LEFT, VK_LEFT }, // (0x25) + { Key::UP, VK_UP }, // (0x26) + { Key::RIGHT, VK_RIGHT }, // (0x27) { Key::DOWN, VK_DOWN }, // (0x28) - //VK_SELECT (0x29) + // VK_SELECT (0x29) + // Old select key, e.g. on Digital Equipment Corporation keyboards. + // Old and uncommon, we have no mapping. { Key::PRINT, VK_PRINT }, // (0x2A) + // Old IBM key, modern keyboards use VK_SNAPSHOT. Map to VK_SNAPSHOT. - //VK_EXECUTE (0x2B) + // VK_EXECUTE (0x2B) + // Old and uncommon, we have no mapping. { Key::PRINT, VK_SNAPSHOT }, // (0x2C) - { Key::INSERT, VK_INSERT }, // (0x2D) - { Key::KEY_DELETE, VK_DELETE }, // (0x2E) { Key::HELP, VK_HELP }, // (0x2F) - - { Key::KEY_0, (0x30) }, ////0 key - { Key::KEY_1, (0x31) }, ////1 key - { Key::KEY_2, (0x32) }, ////2 key - { Key::KEY_3, (0x33) }, ////3 key - { Key::KEY_4, (0x34) }, ////4 key - { Key::KEY_5, (0x35) }, ////5 key - { Key::KEY_6, (0x36) }, ////6 key - { Key::KEY_7, (0x37) }, ////7 key - { Key::KEY_8, (0x38) }, ////8 key - { Key::KEY_9, (0x39) }, ////9 key - { Key::A, (0x41) }, ////A key - { Key::B, (0x42) }, ////B key - { Key::C, (0x43) }, ////C key - { Key::D, (0x44) }, ////D key - { Key::E, (0x45) }, ////E key - { Key::F, (0x46) }, ////F key - { Key::G, (0x47) }, ////G key - { Key::H, (0x48) }, ////H key - { Key::I, (0x49) }, ////I key - { Key::J, (0x4A) }, ////J key - { Key::K, (0x4B) }, ////K key - { Key::L, (0x4C) }, ////L key - { Key::M, (0x4D) }, ////M key - { Key::N, (0x4E) }, ////N key - { Key::O, (0x4F) }, ////O key - { Key::P, (0x50) }, ////P key - { Key::Q, (0x51) }, ////Q key - { Key::R, (0x52) }, ////R key - { Key::S, (0x53) }, ////S key - { Key::T, (0x54) }, ////T key - { Key::U, (0x55) }, ////U key - { Key::V, (0x56) }, ////V key - { Key::W, (0x57) }, ////W key - { Key::X, (0x58) }, ////X key - { Key::Y, (0x59) }, ////Y key - { Key::Z, (0x5A) }, ////Z key - - { (Key)KeyModifierMask::META, VK_LWIN }, //(0x5B) - { (Key)KeyModifierMask::META, VK_RWIN }, //(0x5C) - { Key::MENU, VK_APPS }, //(0x5D) - { Key::STANDBY, VK_SLEEP }, //(0x5F) - { Key::KP_0, VK_NUMPAD0 }, //(0x60) - { Key::KP_1, VK_NUMPAD1 }, //(0x61) - { Key::KP_2, VK_NUMPAD2 }, //(0x62) - { Key::KP_3, VK_NUMPAD3 }, //(0x63) - { Key::KP_4, VK_NUMPAD4 }, //(0x64) - { Key::KP_5, VK_NUMPAD5 }, //(0x65) - { Key::KP_6, VK_NUMPAD6 }, //(0x66) - { Key::KP_7, VK_NUMPAD7 }, //(0x67) - { Key::KP_8, VK_NUMPAD8 }, //(0x68) - { Key::KP_9, VK_NUMPAD9 }, //(0x69) + // Old and uncommon, but we have a mapping. + + { Key::KEY_0, (0x30) }, // 0 key. + { Key::KEY_1, (0x31) }, // 1 key. + { Key::KEY_2, (0x32) }, // 2 key. + { Key::KEY_3, (0x33) }, // 3 key. + { Key::KEY_4, (0x34) }, // 4 key. + { Key::KEY_5, (0x35) }, // 5 key. + { Key::KEY_6, (0x36) }, // 6 key. + { Key::KEY_7, (0x37) }, // 7 key. + { Key::KEY_8, (0x38) }, // 8 key. + { Key::KEY_9, (0x39) }, // 9 key. + // 0x3A-40 are undefined. + { Key::A, (0x41) }, // A key. + { Key::B, (0x42) }, // B key. + { Key::C, (0x43) }, // C key. + { Key::D, (0x44) }, // D key. + { Key::E, (0x45) }, // E key. + { Key::F, (0x46) }, // F key. + { Key::G, (0x47) }, // G key. + { Key::H, (0x48) }, // H key. + { Key::I, (0x49) }, // I key + { Key::J, (0x4A) }, // J key. + { Key::K, (0x4B) }, // K key. + { Key::L, (0x4C) }, // L key. + { Key::M, (0x4D) }, // M key. + { Key::N, (0x4E) }, // N key. + { Key::O, (0x4F) }, // O key. + { Key::P, (0x50) }, // P key. + { Key::Q, (0x51) }, // Q key. + { Key::R, (0x52) }, // R key. + { Key::S, (0x53) }, // S key. + { Key::T, (0x54) }, // T key. + { Key::U, (0x55) }, // U key. + { Key::V, (0x56) }, // V key. + { Key::W, (0x57) }, // W key. + { Key::X, (0x58) }, // X key. + { Key::Y, (0x59) }, // Y key. + { Key::Z, (0x5A) }, // Z key. + + { (Key)KeyModifierMask::META, VK_LWIN }, // (0x5B) + { (Key)KeyModifierMask::META, VK_RWIN }, // (0x5C) + { Key::MENU, VK_APPS }, // (0x5D) + // 0x5E is reserved. + { Key::STANDBY, VK_SLEEP }, // (0x5F) + { Key::KP_0, VK_NUMPAD0 }, // (0x60) + { Key::KP_1, VK_NUMPAD1 }, // (0x61) + { Key::KP_2, VK_NUMPAD2 }, // (0x62) + { Key::KP_3, VK_NUMPAD3 }, // (0x63) + { Key::KP_4, VK_NUMPAD4 }, // (0x64) + { Key::KP_5, VK_NUMPAD5 }, // (0x65) + { Key::KP_6, VK_NUMPAD6 }, // (0x66) + { Key::KP_7, VK_NUMPAD7 }, // (0x67) + { Key::KP_8, VK_NUMPAD8 }, // (0x68) + { Key::KP_9, VK_NUMPAD9 }, // (0x69) { Key::KP_MULTIPLY, VK_MULTIPLY }, // (0x6A) { Key::KP_ADD, VK_ADD }, // (0x6B) - //VK_SEPARATOR (0x6C) + { Key::KP_PERIOD, VK_SEPARATOR }, // (0x6C) + // VK_SEPERATOR (key 0x6C) is not found on US keyboards. + // It is used on some Brazilian and Far East keyboards. + // We don't have a direct mapping, map to period. { Key::KP_SUBTRACT, VK_SUBTRACT }, // (0x6D) { Key::KP_PERIOD, VK_DECIMAL }, // (0x6E) { Key::KP_DIVIDE, VK_DIVIDE }, // (0x6F) @@ -162,8 +179,17 @@ static _WinTranslatePair _vk_to_keycode[] = { { Key::F14, VK_F14 }, // (0x7D) { Key::F15, VK_F15 }, // (0x7E) { Key::F16, VK_F16 }, // (0x7F) + // We have no mappings for F17-F24. (0x80-87) + // 0x88-8F are reserved for UI navigation. { Key::NUMLOCK, VK_NUMLOCK }, // (0x90) { Key::SCROLLLOCK, VK_SCROLL }, // (0x91) + + { Key::EQUAL, VK_OEM_NEC_EQUAL }, // (0x92) + // OEM NEC PC-9800 numpad '=' key. + + // 0x93-96 are OEM specific (e.g. used by Fujitsu/OASYS), we have no mappings. + // 0x97-9F are unassigned. + { Key::SHIFT, VK_LSHIFT }, // (0xA0) { Key::SHIFT, VK_RSHIFT }, // (0xA1) { Key::CTRL, VK_LCONTROL }, // (0xA2) @@ -172,70 +198,124 @@ static _WinTranslatePair _vk_to_keycode[] = { { Key::MENU, VK_RMENU }, // (0xA5) { Key::BACK, VK_BROWSER_BACK }, // (0xA6) - { Key::FORWARD, VK_BROWSER_FORWARD }, // (0xA7) - { Key::REFRESH, VK_BROWSER_REFRESH }, // (0xA8) - { Key::STOP, VK_BROWSER_STOP }, // (0xA9) - { Key::SEARCH, VK_BROWSER_SEARCH }, // (0xAA) - { Key::FAVORITES, VK_BROWSER_FAVORITES }, // (0xAB) - { Key::HOMEPAGE, VK_BROWSER_HOME }, // (0xAC) - { Key::VOLUMEMUTE, VK_VOLUME_MUTE }, // (0xAD) - { Key::VOLUMEDOWN, VK_VOLUME_DOWN }, // (0xAE) - { Key::VOLUMEUP, VK_VOLUME_UP }, // (0xAF) - { Key::MEDIANEXT, VK_MEDIA_NEXT_TRACK }, // (0xB0) - { Key::MEDIAPREVIOUS, VK_MEDIA_PREV_TRACK }, // (0xB1) - { Key::MEDIASTOP, VK_MEDIA_STOP }, // (0xB2) - //VK_MEDIA_PLAY_PAUSE (0xB3) + { Key::MEDIAPLAY, VK_MEDIA_PLAY_PAUSE }, // (0xB3) + // Media button play/pause toggle. + // Map to media play (there is no other 'play' mapping on Windows). { Key::LAUNCHMAIL, VK_LAUNCH_MAIL }, // (0xB4) - { Key::LAUNCHMEDIA, VK_LAUNCH_MEDIA_SELECT }, // (0xB5) - { Key::LAUNCH0, VK_LAUNCH_APP1 }, // (0xB6) - { Key::LAUNCH1, VK_LAUNCH_APP2 }, // (0xB7) + // 0xB8-B9 are reserved. + { Key::SEMICOLON, VK_OEM_1 }, // (0xBA) + // Misc. character, can vary by keyboard/region. + // Windows 2000/XP: For US standard keyboards, the ';:' key. - { Key::EQUAL, VK_OEM_PLUS }, // (0xBB) // Windows 2000/XP: For any country/region, the '+' key - { Key::COMMA, VK_OEM_COMMA }, // (0xBC) // Windows 2000/XP: For any country/region, the ',' key - { Key::MINUS, VK_OEM_MINUS }, // (0xBD) // Windows 2000/XP: For any country/region, the '-' key - { Key::PERIOD, VK_OEM_PERIOD }, // (0xBE) // Windows 2000/XP: For any country/region, the '.' key - { Key::SLASH, VK_OEM_2 }, // (0xBF) //Windows 2000/XP: For the US standard keyboard, the '/?' key + { Key::EQUAL, VK_OEM_PLUS }, // (0xBB) + // Windows 2000/XP: For any country/region, the '+' key. + { Key::COMMA, VK_OEM_COMMA }, // (0xBC) + // Windows 2000/XP: For any country/region, the ',' key. + { Key::MINUS, VK_OEM_MINUS }, // (0xBD) + // Windows 2000/XP: For any country/region, the '-' key. + { Key::PERIOD, VK_OEM_PERIOD }, // (0xBE) + // Windows 2000/XP: For any country/region, the '.' key. + + { Key::SLASH, VK_OEM_2 }, // (0xBF) + // Windows 2000/XP: For US standard keyboards, the '/?' key. { Key::QUOTELEFT, VK_OEM_3 }, // (0xC0) - { Key::BRACELEFT, VK_OEM_4 }, // (0xDB) + // Windows 2000/XP: For US standard keyboards, the '`~' key. + + // 0xC1-D7 are reserved. 0xD8-DA are unassigned. + // TODO: 0xC3-DA may be used for old gamepads? Maybe we want to support this? See WinUser.h. + + { Key::BRACKETLEFT, VK_OEM_4 }, // (0xDB) + // Misc. character, can vary by keyboard/region. + // Windows 2000/XP: For US standard keyboards, the '[{' key. + { Key::BACKSLASH, VK_OEM_5 }, // (0xDC) - { Key::BRACERIGHT, VK_OEM_6 }, // (0xDD) + // Misc. character, can vary by keyboard/region. + // Windows 2000/XP: For US standard keyboards, the '\|' key. + + { Key::BRACKETRIGHT, VK_OEM_6 }, // (0xDD) + // Misc. character, can vary by keyboard/region. + // Windows 2000/XP: For US standard keyboards, the ']}' key. + { Key::APOSTROPHE, VK_OEM_7 }, // (0xDE) - /* -{VK_OEM_8 (0xDF) -{VK_OEM_102 (0xE2) // Windows 2000/XP: Either the angle bracket key or the backslash key on the RT 102-key keyboard -*/ - //{ Key::PLAY, VK_PLAY},// (0xFA) + // Misc. character, can vary by keyboard/region. + // Windows 2000/XP: For US standard keyboards, single quote/double quote. + + // VK_OEM_8 (0xDF) + // Misc. character, can vary by keyboard/region. We have no mapping. + + // 0xE0 is reserved. 0xE1 is OEM specific, we have no mapping. + + // VK_OEM_102 (0xE2) + // Either angle bracket or backslash key on the RT 102-key keyboard. + // Old and uncommon, we have no mapping. + + { Key::HELP, VK_ICO_HELP }, // (0xE3) + // OEM (ICO) help key. Map to help. + + // 0xE4 is OEM (e.g. ICO) specific, we have no mapping. + + // VK_PROCESSKEY (0xE5) + // For IME, we have no mapping. + + { Key::CLEAR, VK_ICO_CLEAR }, // (0xE6) + // OEM (ICO) clear key. Map to clear. + + // VK_PACKET (0xE7) + // Used to pass Unicode characters as if they were keystrokes. + // See Win32 API docs. We have no mapping. + + // 0xE8 is unassigned, 0xE9-F5 are OEM (Nokia/Ericsson) specific, we have no mappings. + + { Key::ESCAPE, VK_ATTN }, // (0xF6) + // Old IBM 'ATTN' key used on midrange computers, e.g. AS/400, map to Escape. + + { Key::TAB, VK_CRSEL }, // (0xF7) + // Old IBM 3270 'CrSel' (cursor select) key, used to select data fields, map to Tab. + + // VK_EXSEL (0xF7) + // Old IBM 3270 extended selection key. No mapping. + + // VK_EREOF (0xF8) + // Old IBM 3270 erase to end of field key. No mapping. + + { Key::MEDIAPLAY, VK_PLAY }, // (0xFA) + // Old IBM 3270 'Play' key. Map to media play. + + // VK_ZOOM (0xFB) + // Old IBM 3290 'Zoom' key. No mapping. + + // VK_NONAME (0xFC) + // Reserved. No mapping. + + // VK_PA1 (0xFD) + // Old IBM 3270 PA1 key. No mapping. + + { Key::CLEAR, VK_OEM_CLEAR }, // (0xFE) + // OEM specific clear key. Unclear how it differs from normal clear. Map to clear. { Key::UNKNOWN, 0 } }; -/* -VK_ZOOM (0xFB) -VK_NONAME (0xFC) -VK_PA1 (0xFD) -VK_OEM_CLEAR (0xFE) -*/ - static _WinTranslatePair _scancode_to_keycode[] = { { Key::ESCAPE, 0x01 }, { Key::KEY_1, 0x02 }, @@ -320,7 +400,6 @@ static _WinTranslatePair _scancode_to_keycode[] = { { Key::PAGEDOWN, 0x51 }, { Key::INSERT, 0x52 }, { Key::KEY_DELETE, 0x53 }, - //{ Key::???, 0x56 }, //NON US BACKSLASH { Key::F11, 0x57 }, { Key::F12, 0x58 }, { Key::META, 0x5B }, @@ -336,8 +415,6 @@ static _WinTranslatePair _scancode_to_keycode[] = { Key KeyMappingWindows::get_keysym(unsigned int p_code) { for (int i = 0; _vk_to_keycode[i].keysym != Key::UNKNOWN; i++) { if (_vk_to_keycode[i].keycode == p_code) { - //printf("outcode: %x\n",_vk_to_keycode[i].keysym); - return _vk_to_keycode[i].keysym; } } diff --git a/scene/gui/texture_button.cpp b/scene/gui/texture_button.cpp index 4c2229acb7..da202c1c8f 100644 --- a/scene/gui/texture_button.cpp +++ b/scene/gui/texture_button.cpp @@ -170,6 +170,12 @@ void TextureButton::_notification(int p_what) { Point2 ofs; Size2 size; + bool draw_focus = (has_focus() && focused.is_valid()); + + // If no other texture is valid, try using focused texture. + if (!texdraw.is_valid() && draw_focus) { + texdraw = focused; + } if (texdraw.is_valid()) { size = texdraw->get_size(); @@ -226,7 +232,9 @@ void TextureButton::_notification(int p_what) { size.width *= hflip ? -1.0f : 1.0f; size.height *= vflip ? -1.0f : 1.0f; - if (_tile) { + if (texdraw == focused) { + // Do nothing, we only needed to calculate the rectangle. + } else if (_tile) { draw_texture_rect(texdraw, Rect2(ofs, size), _tile); } else { draw_texture_rect_region(texdraw, Rect2(ofs, size), _texture_region); @@ -235,7 +243,7 @@ void TextureButton::_notification(int p_what) { _position_rect = Rect2(); } - if (has_focus() && focused.is_valid()) { + if (draw_focus) { draw_texture_rect(focused, Rect2(ofs, size), false); }; } break; |