⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 joypadoptions.pas

📁 一个不出名的GBA模拟器
💻 PAS
字号:
//////////////////////////////////////////////////////////////////////
//                                                                  //
// JoypadOptions.pas: Joypad Options Dialog                         //
//                                                                  //
// The contents of this file are subject to the Bottled Light       //
// Public License Version 1.0 (the "License"); you may not use this //
// file except in compliance with the License. You may obtain a     //
// copy of the License at http://www.bottledlight.com/BLPL/         //
//                                                                  //
// Software distributed under the License is distributed on an      //
// "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or   //
// implied. See the License for the specific language governing     //
// rights and limitations under the License.                        //
//                                                                  //
// The Original Code is the Mappy VM User Interface, released       //
// April 1st, 2003. The Initial Developer of the Original Code is   //
// Bottled Light, Inc. Portions created by Bottled Light, Inc. are  //
// Copyright (C) 2001-2003 Bottled Light, Inc. All Rights Reserved. //
//                                                                  //
// Author(s):                                                       //
//   Michael Noland (joat), michael@bottledlight.com                //
//                                                                  //
// Changelog:                                                       //
//   1.0: First public release (April 1st, 2003)                    //
//                                                                  //
// Notes:                                                           //
//   None at present.                                               //
//                                                                  //
//////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////
unit JoypadOptions; //////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////
interface ////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, IniFiles, KeyEdit, CpuObservers, nexus, console;

//////////////////////////////////////////////////////////////////////

type
  TJoypadOptionsDialog = class(TCpuObserver)
    keyBindingsGroup: TGroupBox;
    lLeft: TLabel;
    kLeft: TKeyEdit;
    lRight: TLabel;
    kRight: TKeyEdit;
    lUp: TLabel;
    kUp: TKeyEdit;
    lDown: TLabel;
    kDown: TKeyEdit;
    lStart: TLabel;
    kStart: TKeyEdit;
    lSelect: TLabel;
    kSelect: TKeyEdit;
    lA: TLabel;
    kA: TKeyEdit;
    lB: TLabel;
    kB: TKeyEdit;
    lLeftS: TLabel;
    kLeftS: TKeyEdit;
    lRightS: TLabel;
    kRightS: TKeyEdit;
    procedure FormCreate(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure changeKeys(Sender: TObject);
  private
    loadingKeys: boolean;
  public
    procedure UpdateObserver; override;
    class function OCaption: string; override;
    procedure LoadSettings(ini: TIniFile); override;
    procedure SaveSettings(ini: TIniFile); override;
  end;

//////////////////////////////////////////////////////////////////////

var
  JoypadOptionsDialog: TJoypadOptionsDialog;
  keyCodes: array[0..9] of integer;

//////////////////////////////////////////////////////////////////////

procedure LoadJoypadOptions(ini: TIniFile);
procedure SaveJoypadOptions(ini: TIniFile);

//////////////////////////////////////////////////////////////////////
implementation ///////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////

{$R *.DFM}

//////////////////////////////////////////////////////////////////////
// TJoypadOptionsDialog //////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////

procedure TJoypadOptionsDialog.FormCreate(Sender: TObject);
begin
  HelpContext := LinkHelp('joypad_options.html');
end;

//////////////////////////////////////////////////////////////////////

procedure TJoypadOptionsDialog.FormShow(Sender: TObject);
begin
  loadingKeys := true;
  kA.VirtualKeyCode := keyCodes[0];
  kB.VirtualKeyCode := keyCodes[1];
  kSelect.VirtualKeyCode := keyCodes[2];
  kStart.VirtualKeyCode := keyCodes[3];
  kRight.VirtualKeyCode := keyCodes[4];
  kLeft.VirtualKeyCode := keyCodes[5];
  kUp.VirtualKeyCode := keyCodes[6];
  kDown.VirtualKeyCode := keyCodes[7];
  kRightS.VirtualKeyCode := keyCodes[8];
  kLeftS.VirtualKeyCode := keyCodes[9];
  loadingKeys := false;

  // Load the translation
  LoadTranslation(self, translation);
end;

//////////////////////////////////////////////////////////////////////

procedure TJoypadOptionsDialog.changeKeys(Sender: TObject);
begin
  if not loadingKeys then begin
    keyCodes[0] := kA.VirtualKeyCode;
    keyCodes[1] := kB.VirtualKeyCode;
    keyCodes[2] := kSelect.VirtualKeyCode;
    keyCodes[3] := kStart.VirtualKeyCode;
    keyCodes[4] := kRight.VirtualKeyCode;
    keyCodes[5] := kLeft.VirtualKeyCode;
    keyCodes[6] := kUp.VirtualKeyCode;
    keyCodes[7] := kDown.VirtualKeyCode;
    keyCodes[8] := kRightS.VirtualKeyCode;
    keyCodes[9] := kLeftS.VirtualKeyCode;
  end;
end;

//////////////////////////////////////////////////////////////////////
// Joypad Preferences ////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////

procedure LoadJoypadOptions(ini: TIniFile);
begin
  keyCodes[0] := ini.ReadInteger('Joypad', 'A', Ord('A'));
  keyCodes[1] := ini.ReadInteger('Joypad', 'B', Ord('B'));
  keyCodes[2] := ini.ReadInteger('Joypad', 'Select', Ord('2'));
  keyCodes[3] := ini.ReadInteger('Joypad', 'Start', Ord('1'));
  keyCodes[4] := ini.ReadInteger('Joypad', 'Right', VK_RIGHT);
  keyCodes[5] := ini.ReadInteger('Joypad', 'Left', VK_LEFT);
  keyCodes[6] := ini.ReadInteger('Joypad', 'Up', VK_UP);
  keyCodes[7] := ini.ReadInteger('Joypad', 'Down', VK_DOWN);
  keyCodes[8] := ini.ReadInteger('Joypad', 'R', Ord('R'));
  keyCodes[9] := ini.ReadInteger('Joypad', 'L', Ord('L'));
end;

//////////////////////////////////////////////////////////////////////

procedure SaveJoypadOptions(ini: TIniFile);
begin
  ini.WriteInteger('Joypad', 'A', keyCodes[0]);
  ini.WriteInteger('Joypad', 'B', keyCodes[1]);
  ini.WriteInteger('Joypad', 'Select', keyCodes[2]);
  ini.WriteInteger('Joypad', 'Start', keyCodes[3]);
  ini.WriteInteger('Joypad', 'Right', keyCodes[4]);
  ini.WriteInteger('Joypad', 'Left', keyCodes[5]);
  ini.WriteInteger('Joypad', 'Up', keyCodes[6]);
  ini.WriteInteger('Joypad', 'Down', keyCodes[7]);
  ini.WriteInteger('Joypad', 'R', keyCodes[8]);
  ini.WriteInteger('Joypad', 'L', keyCodes[9]);
end;

//////////////////////////////////////////////////////////////////////

procedure TJoypadOptionsDialog.LoadSettings(ini: TIniFile);
begin
  inherited;
//
end;

//////////////////////////////////////////////////////////////////////

class function TJoypadOptionsDialog.OCaption: string;
begin
  Result := 'Joypad Options';
end;

//////////////////////////////////////////////////////////////////////

procedure TJoypadOptionsDialog.SaveSettings(ini: TIniFile);
begin
  inherited;
//
end;

//////////////////////////////////////////////////////////////////////

procedure TJoypadOptionsDialog.UpdateObserver;
begin
//
end;

//////////////////////////////////////////////////////////////////////

initialization
  RegisterDialog(TJoypadOptionsDialog);
end.

//////////////////////////////////////////////////////////////////////

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -