예제 #1
0
 { public void action() => HotkeyHelper.updateBinds(); }
예제 #2
0
        private bool ReadersInit(string sProfName)
        {
            bool
                bSetVK,
                bRet = false;

            do
            {// MHL drivers
                hKeyb = new MHLDriver();
                try
                {
                    hKeyb.Open("Keyboard");
                }
                catch (Exception ex)
                {
                    throw new Exception("Клавиатура не открыта!");
                }
                // Hotkey capture
                hotkeyHelper = new HotkeyHelper();

                hScan = new MHLDriver();
                try
                {
                    hScan.Open("Scanner");
                    bRet = hScan.SetDword("Scanner.Timeout", 5);

                    bSetVK = hKeyb.SetDword("Keyboard.ScanMode", 0);
                    bSetVK = hKeyb.SetDword("SpecialKey.Scan.All.VK", BarCodeScanKey);
                }
                catch (Exception ex)
                {
                    throw new Exception("Сканер не открыт!");
                }

                if (RFIDScanKey > 0)
                {
                    hRfid = new MHLDriver();
                    try
                    {
                        hRfid.Open("RFID");
                    }
                    catch (Exception ex)
                    {
                        throw new Exception("RFID Driver failure: " + ex.ToString());
                    }
                    if (hRfid.IsOpen())
                    {
                        try
                        {
                            //hRfid.SetString("RFID.TagType", "EPC C1G2");
                        }
                        catch (Exception ex)
                        {
                            throw new Exception("RFID Ttype failure: " + ex.ToString());
                        }
                    }
                }


                if (hKeyb.IsOpen())
                {
                    // Save current keyboard map
                    hKeyb.SaveProfile(sProfName);
                    // Map "Scan" button to VK_F12 (0x7B)
                    if (RFIDScanKey > 0)
                    {
                        //hKeyb.SetDword("SpecialKey.Square.All.VK", 0);
                        if (base.nTermType == TERM_TYPE.NRDMERLIN)
                        {
                            bool bn = hKeyb.SetDword("SpecialKey.Circle.All.VK", RFIDScanKey);
                        }
                    }
                    // Reload map
                    hKeyb.SetDword("Keyboard.Reload", 1);
                }


                hotkeyHelper.SetCallbackDelegate(new HotkeyHelper.HotkeyCallback(HandleScanKey));
                // Register BarCodeScanKey as global hotkey
                hotkeyHelper.RegisterKey(BarCodeScanKey, KeyModifiers.None);

                //hkHelperRFID = new HotkeyHelper();
                //hkHelperRFID.SetCallbackDelegate(new HotkeyHelper.HotkeyCallback(HandleRFIDScanKey));
                //hkHelperRFID.RegisterKey(RFIDScanKey, KeyModifiers.None);


                bRet = true;
            } while (false);

            return(bRet);
        }
예제 #3
0
        public void FillItems(NamelessGame game)
        {
            var selectedIndex = SelectedTable?.Items.IndexOf(SelectedItem);


            EquipmentBox.Items.Clear();
            ItemBox.Items.Clear();

            var playerEntity = game.PlayerEntity;

            var itemsHolder = playerEntity.GetComponentOfType <ItemsHolder>();
            var equipment   = playerEntity.GetComponentOfType <EquipmentSlots>();

            char hotkey = Char.MinValue;

            var headerEquipmentItem = new TableItem(3);

            headerEquipmentItem.Cells[0].Widgets.Add(new Label()
            {
                Text = "Hotkey", HorizontalAlignment = HorizontalAlignment.Center
            });
            headerEquipmentItem.Cells[1].Widgets.Add(new Label()
            {
                Text = "Slot",
            });
            headerEquipmentItem.Cells[2].Widgets.Add(new Label()
            {
                Text = "Name",
            });
            EquipmentBox.Items.Add(headerEquipmentItem);
            {
                int i = 0;
                foreach (var equipmentSlot in equipment.Slots)
                {
                    if (i == 0)
                    {
                        hotkey = HotkeyHelper.alphabet.First();
                    }
                    else
                    {
                        hotkey = HotkeyHelper.GetNextKey(hotkey);
                    }

                    var         eq   = equipmentSlot.Item2.Equipment;
                    Description desc = null;
                    if (eq != null)
                    {
                        var itemEntity = game.GetEntity(eq.ParentEntityId);
                        desc = itemEntity.GetComponentOfType <Description>();
                    }
                    var text = desc != null ? desc.Name : "Nothing";

                    var tableItem = new TableItem(3);
                    tableItem.Hotkey = hotkey;
                    tableItem.Tag    = equipmentSlot.Item1;
                    tableItem.Cells[0].Widgets.Add(new Label()
                    {
                        Text = hotkey.ToString(), HorizontalAlignment = HorizontalAlignment.Center
                    });
                    tableItem.Cells[1].Widgets.Add(new Label()
                    {
                        Text = equipmentSlot.Item1.ToString(),
                    });
                    tableItem.Cells[2].Widgets.Add(new Label()
                    {
                        Text = text
                    });
                    EquipmentBox.Items.Add(tableItem);
                    i++;
                }
            }

            var headerItem = new TableItem(6);

            headerItem.Cells[0].Widgets.Add(new Label()
            {
                Text = "Hotkey", HorizontalAlignment = HorizontalAlignment.Center
            });
            headerItem.Cells[1].Widgets.Add(new Label()
            {
                Text = "Name",
            });
            headerItem.Cells[2].Widgets.Add(new Label()
            {
                Text = "Quality",
            });
            headerItem.Cells[3].Widgets.Add(new Label()
            {
                Text = "Weight",
            });
            headerItem.Cells[4].Widgets.Add(new Label()
            {
                Text = "Type",
            });
            headerItem.Cells[5].Widgets.Add(new Label()
            {
                Text = "Amount",
            });
            ItemBox.Items.Add(headerItem);

            List <IEntity> list = itemsHolder.Items;

            for (int i = 0; i < list.Count; i++)
            {
                IEntity entity = list[i];

                hotkey = HotkeyHelper.GetNextKey(hotkey);

                Description desc = entity.GetComponentOfType <Description>();
                Item        item = entity.GetComponentOfType <Item>();

                var tableItem = new TableItem(6);
                tableItem.Tag    = entity;
                tableItem.Hotkey = hotkey;
                tableItem.Cells[0].Widgets.Add(new Label()
                {
                    Text = hotkey.ToString(), HorizontalAlignment = HorizontalAlignment.Center
                });
                tableItem.Cells[1].Widgets.Add(new Label()
                {
                    Text = desc.Name,
                });
                tableItem.Cells[2].Widgets.Add(new Label()
                {
                    Text = item.Quality.ToString(),
                });
                tableItem.Cells[3].Widgets.Add(new Label()
                {
                    Text = (item.Weight * item.Amount).ToString(),
                });
                tableItem.Cells[4].Widgets.Add(new Label()
                {
                    Text = item.Type.ToString(),
                });
                tableItem.Cells[5].Widgets.Add(new Label()
                {
                    Text = item.Amount.ToString(),
                });
                ItemBox.Items.Add(tableItem);
            }


            if (selectedIndex >= SelectedTable?.Items.Count)
            {
                if (SelectedTable != null)
                {
                    SelectedTable.SelectedIndex = 0;
                    SelectedItem = SelectedTable.SelectedItem;
                }
            }
            else
            {
                if (SelectedTable != null)
                {
                    SelectedTable.SelectedIndex = selectedIndex;
                    SelectedItem = SelectedTable.SelectedItem;
                }
            }
        }
        private void OnGUIHotkey()
        {
            if (!string.IsNullOrEmpty(_waitingHotkeyName) && HotkeyHelper.ReadKey(out BindingKeysData newKey))
            {
                Mod.Core.Hotkeys.SetHotkey(_waitingHotkeyName, newKey);
                _waitingHotkeyName = null;
            }

            IDictionary <string, BindingKeysData> hotkeys = Mod.Core.Hotkeys.Hotkeys;

            using (new GUILayout.HorizontalScope())
            {
                using (new GUILayout.VerticalScope())
                {
                    foreach (KeyValuePair <string, BindingKeysData> item in hotkeys)
                    {
                        GUIHelper.ToggleButton(item.Value != null, Local[item.Key], _labelStyle, GUILayout.ExpandWidth(false));
                    }
                }

                GUILayout.Space(10f);

                using (new GUILayout.VerticalScope())
                {
                    foreach (BindingKeysData key in hotkeys.Values)
                    {
                        GUILayout.Label(HotkeyHelper.GetKeyText(key));
                    }
                }

                GUILayout.Space(10f);

                using (new GUILayout.VerticalScope())
                {
                    foreach (string name in hotkeys.Keys)
                    {
                        bool waitingThisHotkey = _waitingHotkeyName == name;
                        if (GUILayout.Button(Local["Menu_Btn_Set"], waitingThisHotkey ? _downButtonStyle : _buttonStyle))
                        {
                            if (waitingThisHotkey)
                            {
                                _waitingHotkeyName = null;
                            }
                            else
                            {
                                _waitingHotkeyName = name;
                            }
                        }
                    }
                }

                using (new GUILayout.VerticalScope())
                {
                    string hotkeyToClear = default;
                    foreach (string name in hotkeys.Keys)
                    {
                        if (GUILayout.Button(Local["Menu_Btn_Clear"], _buttonStyle))
                        {
                            hotkeyToClear = name;

                            if (_waitingHotkeyName == name)
                            {
                                _waitingHotkeyName = null;
                            }
                        }
                    }
                    if (!string.IsNullOrEmpty(hotkeyToClear))
                    {
                        Mod.Core.Hotkeys.SetHotkey(hotkeyToClear, null);
                    }
                }

                using (new GUILayout.VerticalScope())
                {
                    foreach (KeyValuePair <string, BindingKeysData> item in hotkeys)
                    {
                        if (item.Value != null && !HotkeyHelper.CanBeRegistered(item.Key, item.Value))
                        {
                            GUILayout.Label(Local["Menu_Txt_Duplicated"].Color(RGBA.yellow));
                        }
                        else
                        {
                            GUILayout.Label(string.Empty);
                        }
                    }
                }

                GUILayout.FlexibleSpace();
            }

            ToggleFiveFootStepOnRightClickGround =
                GUIHelper.ToggleButton(ToggleFiveFootStepOnRightClickGround,
                                       Local["Menu_Opt_ToggleFiveFootStepOnRightClickGround"], _buttonStyle, GUILayout.ExpandWidth(false));
        }
예제 #5
0
        public void FillItems(NamelessGame namelessGame)
        {
            var selectedIndex = SelectedTable?.Items.IndexOf(SelectedItem);

            ItemsTable.Items.Clear();

            var playerEntity = game.PlayerEntity;

            var itemsHolder = playerEntity.GetComponentOfType <ItemsHolder>();
            var equipment   = playerEntity.GetComponentOfType <EquipmentSlots>();

            char hotkey = Char.MinValue;

            var headerItem = new TableItem(4);

            headerItem.Cells[0].Widgets.Add(new Label()
            {
                Text = "Hotkey", HorizontalAlignment = HorizontalAlignment.Center
            });
            headerItem.Cells[1].Widgets.Add(new Label()
            {
                Text = "Name",
            });
            headerItem.Cells[2].Widgets.Add(new Label()
            {
                Text = "Weight",
            });
            headerItem.Cells[3].Widgets.Add(new Label()
            {
                Text = "Type",
            });
            ItemsTable.Items.Add(headerItem);


            IEntity        worldEntity   = namelessGame.TimelineEntity;
            IWorldProvider worldProvider = null;

            if (worldEntity != null)
            {
                worldProvider = worldEntity.GetComponentOfType <TimeLine>().CurrentTimelineLayer
                                .Chunks;
            }


            var position   = playerEntity.GetComponentOfType <Position>();
            var itemHolder = playerEntity.GetComponentOfType <ItemsHolder>();
            var tile       = worldProvider.GetTile(position.Point.X, position.Point.Y);

            List <IEntity> itemsToPickUp = new List <IEntity>();

            foreach (var entityOnTIle in tile.GetEntities())
            {
                var itemComponent = entityOnTIle.GetComponentOfType <Item>();
                if (itemComponent != null)
                {
                    itemsToPickUp.Add(entityOnTIle);
                }
            }



            List <IEntity> list = itemsToPickUp;

            for (int i = 0; i < list.Count; i++)
            {
                IEntity entity = list[i];

                if (i == 0)
                {
                    hotkey = HotkeyHelper.alphabet.First();
                }
                else
                {
                    hotkey = HotkeyHelper.GetNextKey(hotkey);
                }

                Description desc = entity.GetComponentOfType <Description>();
                Item        item = entity.GetComponentOfType <Item>();

                var tableItem = new TableItem(4);
                tableItem.Tag    = entity;
                tableItem.Hotkey = hotkey;
                tableItem.Cells[0].Widgets.Add(new Label()
                {
                    Text = hotkey.ToString(), HorizontalAlignment = HorizontalAlignment.Center
                });
                tableItem.Cells[1].Widgets.Add(new Label()
                {
                    Text = desc.Name,
                });
                tableItem.Cells[2].Widgets.Add(new Label()
                {
                    Text = item.Weight.ToString(),
                });
                tableItem.Cells[3].Widgets.Add(new Label()
                {
                    Text = item.Type.ToString(),
                });
                ItemsTable.Items.Add(tableItem);
            }


            if (selectedIndex > SelectedTable?.Items.Count)
            {
                if (SelectedTable != null)
                {
                    SelectedTable.SelectedIndex = 0;
                    SelectedItem = SelectedTable.SelectedItem;
                }
            }
            else
            {
                if (SelectedTable != null)
                {
                    SelectedTable.SelectedIndex = selectedIndex;
                    SelectedItem = SelectedTable.SelectedItem;
                }
            }
        }
예제 #6
0
        void OnDisable()
        {
            Mod.Debug(MethodBase.GetCurrentMethod());

            HotkeyHelper.Unbind(HOTKEY_FOR_TOGGLE_MOVEMENT_INDICATOR, HandleToggleMovementIndicator);
        }