anchor.diff:        Radio_Options_Lang.OnChange := Change;
   
       // Keybindings button
  -    Button_Options_Keys := TKMButton.Create(Panel_Options, 60, 520, 280, 30, gResTexts[TX_MENU_OPTIONS_EDIT_KEYS], bsMenu);
  -    Button_Options_Keys.Anchors := [anLeft];
  -    Button_Options_Keys.OnClick := KeybindClick;
  +    Button_OptionsKeys := TKMButton.Create(Panel_Options, 60, 520, 280, 30, gResTexts[TX_MENU_OPTIONS_EDIT_KEYS], bsMenu);
  +    Button_OptionsKeys.Anchors := [anLeft];
  +    Button_OptionsKeys.OnClick := KeysClick;
   
       // Back button
  -    Button_Options_Back:=TKMButton.Create(Panel_Options,60,630,280,30,gResTexts[TX_MENU_BACK],bsMenu);
  -    Button_Options_Back.Anchors := [anLeft];
  -    Button_Options_Back.OnClick := BackClick;
  +    Button_OptionsBack := TKMButton.Create(Panel_Options,60,630,280,30,gResTexts[TX_MENU_BACK],bsMenu);
  +    Button_OptionsBack.Anchors := [anLeft];
  +    Button_OptionsBack.OnClick := BackClick;
   
       // Panel_Options_Keys
  -    PopUp_Options_Keys := TKMPopUpMenu.Create(Panel_Options, 700);
  -    PopUp_Options_Keys.Height := 600;
  -    // Keep the pop-up centered
  -    PopUp_Options_Keys.Anchors := [];
  -    PopUp_Options_Keys.Left := (Panel_Options.Width Div 2) - 350;
  -    PopUp_Options_Keys.Top := (Panel_Options.Height Div 2) - 300;
  -
  -      TKMBevel.Create(PopUp_Options_Keys, -1000,  -1000, 4000, 4000);
  -
  -      Image_Options_Keys := TKMImage.Create(PopUp_Options_Keys,0,0, 700, 600, 15, rxGuiMain);
  -      Image_Options_Keys.ImageStretch;
  -
  -      Label_Options_Keys_Title := TKMLabel.Create(PopUp_Options_Keys, 20, 35, 660, 30, gResTexts[TX_MENU_OPTIONS_KEYBIND], fnt_Outline, taCenter);
  -      Label_Options_Keys_Title.Anchors := [anLeft,anBottom];
  -
  -      Button_Options_Keys_Reset := TKMButton.Create(PopUp_Options_Keys, 20, 550, 200, 30, gResTexts[TX_MENU_OPTIONS_RESET], bsMenu);
  -      Button_Options_Keys_Reset.Anchors := [anLeft,anBottom];
  -      Button_Options_Keys_Reset.OnClick := KeybindClick;
  -
  -      Button_Options_Keys_OK := TKMButton.Create(PopUp_Options_Keys, 230, 550, 200, 30, gResTexts[TX_MENU_OPTIONS_OK], bsMenu);
  -      Button_Options_Keys_OK.Anchors := [anLeft,anBottom];
  -      Button_Options_Keys_OK.OnClick := KeybindClick;
  -
  -      ColumnBox_Options_Keys := TKMColumnBox.Create(PopUp_Options_Keys, 20, 110, 660, 400, fnt_Metal, bsMenu);
  -      ColumnBox_Options_Keys.SetColumns(fnt_Outline, [gResTexts[TX_MENU_OPTIONS_FUNCTION], gResTexts[TX_MENU_OPTIONS_KEY]], [0, 350]);
  -      ColumnBox_Options_Keys.Anchors := [anLeft,anTop,anBottom];
  -      ColumnBox_Options_Keys.ShowLines := True;
  -      ColumnBox_Options_Keys.PassAllKeys := True;
  -      ColumnBox_Options_Keys.OnChange := KeybindClick;
  -      ColumnBox_Options_Keys.OnKeyDown := Keybind_ListKeySave;
  -
  -      Label_Options_Keys_Unassignable := TKMLabel.Create(PopUp_Options_Keys, 20, 520, 660, 30, '* ' + gResTexts[TX_KEY_UNASSIGNABLE], fnt_Metal, taLeft);
  +    PopUp_OptionsKeys := TKMPopUpMenu.Create(Panel_Options, 700);
  +    PopUp_OptionsKeys.Height := 600;
  +    PopUp_OptionsKeys.Anchors := []; // Keep centered, don't stretch already poor BG image
  +    PopUp_OptionsKeys.Left := (Panel_Options.Width - 700) div 2;
  +    PopUp_OptionsKeys.Top := (Panel_Options.Height - 600) div 2;
  +
  +      TKMBevel.Create(PopUp_OptionsKeys, -1000, -1000, 4000, 4000);
  +
  +      TKMImage.Create(PopUp_OptionsKeys, 0, 0, 700, 600, 15, rxGuiMain).ImageStretch;
  +
  +      TKMLabel.Create(PopUp_OptionsKeys, 20, 35, 660, 30, gResTexts[TX_MENU_OPTIONS_KEYBIND], fnt_Outline, taCenter).Anchors := [anLeft,anBottom];
  +
  +      ColumnBox_OptionsKeys := TKMColumnBox.Create(PopUp_OptionsKeys, 20, 110, 660, 400, fnt_Metal, bsMenu);
  +      ColumnBox_OptionsKeys.SetColumns(fnt_Outline, [gResTexts[TX_MENU_OPTIONS_FUNCTION], gResTexts[TX_MENU_OPTIONS_KEY]], [0, 350]);
  +      ColumnBox_OptionsKeys.Anchors := [anLeft,anTop,anBottom];
  +      ColumnBox_OptionsKeys.ShowLines := True;
  +      ColumnBox_OptionsKeys.PassAllKeys := True;
  +      ColumnBox_OptionsKeys.OnChange := KeysClick;
  +      ColumnBox_OptionsKeys.OnKeyDown := KeysUpdate;
  +
  +      TKMLabel.Create(PopUp_OptionsKeys, 20, 520, 660, 30, '* ' + gResTexts[TX_KEY_UNASSIGNABLE], fnt_Metal, taLeft);
  +
  +      Button_OptionsKeysReset := TKMButton.Create(PopUp_OptionsKeys, 20, 550, 200, 30, gResTexts[TX_MENU_OPTIONS_RESET], bsMenu);
  +      Button_OptionsKeysReset.OnClick := KeysClick;
  +
  +      Button_OptionsKeysOK := TKMButton.Create(PopUp_OptionsKeys, 230, 550, 200, 30, gResTexts[TX_MENU_OPTIONS_OK], bsMenu);
  +      Button_OptionsKeysOK.OnClick := KeysClick;
   end;
   
   
  
positive.code: end;
  
  
  
  procedure TKMMenuOptions.KeybindClick(Sender: TObject);
  begin
    if ColumnBox_Options_Keys.TopIndex < 0 then Exit;
  
    if Sender = Button_Options_Keys then
    begin
      // Reload the keymap in case player changed it and checks his changes in game
      gResKeys.LoadKeymapFile;
      RefreshKeyList;
      PopUp_Options_Keys.Show;
    end;
  
    if Sender = Button_Options_Keys_OK then
    begin
      PopUp_Options_Keys.Hide;
      gResKeys.SaveKeymap;
    end;
  
    if Sender = Button_Options_Keys_Reset then
    begin
      gResKeys.ResetKeymap;
      RefreshKeyList;
    end;
  
    if Sender = ColumnBox_Options_Keys then
      ColumnBox_Options_Keys.HighlightError := False;
  end;
  
  
  procedure TKMMenuOptions.Keybind_ListKeySave(Key: Word; Shift: TShiftState);
  var
    id: Integer;
  begin
    ColumnBox_Options_Keys.HighlightError := False;
    id := ColumnBox_Options_Keys.Rows[ColumnBox_Options_Keys.ItemIndex].Tag;
  
    if not InRange(id, 0, gResKeys.Count - 1) then Exit;
  
    if not gResKeys.AllowKeySet(gResKeys[id].Area, Key) then
    begin
      ColumnBox_Options_Keys.HighlightError := True;
      gSoundPlayer.Play(sfxn_Error);
      Exit;
    end;
  
    gResKeys.SetKey(id, Key);
  
    RefreshKeyList;
  end;
  
  
  
negative.code:         DropBox_Options_Resolution: TKMDropList;
          DropBox_Options_RefreshRate: TKMDropList;
          Button_Options_ResApply: TKMButton;
        Button_OptionsKeys: TKMButton;
        PopUp_OptionsKeys: TKMPopUpMenu;
          ColumnBox_OptionsKeys: TKMColumnBox;
          Button_OptionsKeysReset: TKMButton;
          Button_OptionsKeysOK: TKMButton;
        Button_OptionsBack: TKMButton;
    public
      constructor Create(aParent: TKMPanel; aOnPageChange: TGUIEventText);
  
  