Subversion Repositories AndroidProjects

Rev

Blame | Last modification | View Log | RSS feed

unit app_ini;

interface

uses sux_constant, sux_object, app_constant;

type
  TSDisplay = record
    width, height: SXInt;
    hz: SXInt;
    fullscreen: SXBool;
    vsync: SXBool;
    gamma: SXFloat;
    motionblur: SXBool;
    motionblurframes: SXInt;
  end;
  TSSound = record
    volume: SXFloat;
    backgroundmusic: SXBool;
  end;
  TSControls = record
    accept: SXState;
    cancel: SXState;
  end;
  TSPlayer = record
    playername: SXStringL;
    cpuname: SXStringL;
    texttoentergame: SXStringL;
    keyup, keydown: SXState;
    joypad: SXInt;
  end;
  TSPingk = record
    color: SXColorRGB;
  end;
  TSGameplay = record
    maxpaddlespeed: SXFloat;
    hitzoneangledeviation: SXFloat;
    topspinintensity: SXFloat;
    ballstartspeed: SXFloat;
    ballspeeduptimer: SXFloat;
    ballspeedupincrease: SXFloat;
    ballsteepestanglereflectfromboard: SXFloat;
    ballsteepestanglehitpaddle: SXFloat;
    ballmaximumangularspeed: SXFloat;
    ballangularspeeddecrease: SXFloat;
    playertimeoutduration: SXFloat;
    poweruptimer: SXFloat;
    maximumpowerupspresent: SXInt;
    spawnpowerupbomboncrystals: SXInt;
    poweruprandomcrystal: SXInt;
    poweruprandomconcave: SXInt;
    poweruprandompixel: SXInt;
    poweruprandomflowers: SXInt;
    poweruprandomslowmotion: SXInt;
    poweruprandombomb: SXInt;
    paddleinertiaincreasemultiplier: SXFloat;
    paddleinertiadecrease: SXFloat;
  end;
  TSMenu = record
    candisplaymenu: SXBool;
    canquit: SXBool;
  end;
  TSettings = record
    display: TSDisplay;
    sound: TSSound;
    controls: TSControls;
    player1, player2: TSPlayer;
    pingk: TSPingk;
    gameplay: TSGameplay;
    menu: TSMenu;
  end;
  SAIni = class(SUXObject)
    settings: TSettings;

    procedure loadFromFile(filename:SXStringL);

    procedure initialize;
    constructor Create(parent:TObject);
    destructor Destroy; override;
  end;

implementation

uses main, IniFiles;


// --- SAIni


procedure SAIni.loadFromFile(filename:SXStringL);
var ini:TIniFile;
    fullfilename:SXStringL;
begin
  fullfilename:=sx.fs.getFullFileName(filename,SX_FILE_INI);
  if (not sx.fs.exists(fullfilename,true)) then exit;

  ini:=TIniFile.Create(fullfilename);

  with settings do
  begin
    display.width:=ini.ReadInteger('DISPLAY','Width',640);
    display.height:=ini.ReadInteger('DISPLAY','Height',480);
    display.hz:=ini.ReadInteger('DISPLAY','Hz',60);
    display.fullscreen:=ini.ReadBool('DISPLAY','Fullscreen',true);
    display.vsync:=ini.ReadBool('DISPLAY','VSync',true);
    display.gamma:=ini.ReadFloat('DISPLAY','Gamma',1);
    display.motionblur:=ini.ReadBool('DISPLAY','MotionBlur',true);
    display.motionblurframes:=ini.ReadInteger('DISPLAY','MotionBlurFrames',10);

    sound.volume:=ini.ReadFloat('SOUND','Volume',1);
    sound.backgroundmusic := ini.ReadBool('SOUND', 'BackgroundMusic', true);

    controls.accept := ini.ReadInteger('CONTROLS', 'Accept', SX_NONE);
    controls.cancel := ini.ReadInteger('CONTROLS', 'Cancel', SX_NONE);

    player1.playername:=ini.ReadString('PLAYER1','PlayerName','');
    player1.cpuname:=ini.ReadString('PLAYER1','CPUName','');
    player1.texttoentergame:=ini.ReadString('PLAYER1','TextToEnterGame','');
    player1.keyup:=ini.ReadInteger('PLAYER1','KeyUp',SX_NONE);
    player1.keydown:=ini.ReadInteger('PLAYER1','KeyDown',SX_NONE);
    player1.joypad:=ini.ReadInteger('PLAYER1','Joypad',0);

    player2.playername:=ini.ReadString('PLAYER2','PlayerName','');
    player2.cpuname:=ini.ReadString('PLAYER2','CPUName','');
    player2.texttoentergame:=ini.ReadString('PLAYER2','TextToEnterGame','');
    player2.keyup:=ini.ReadInteger('PLAYER2','KeyUp',SX_NONE);
    player2.keydown:=ini.ReadInteger('PLAYER2','KeyDown',SX_NONE);
    player2.joypad:=ini.ReadInteger('PLAYER2','Joypad',0);

    pingk.color.r:=ini.ReadFloat('PINGK','ColorR',1);
    pingk.color.g:=ini.ReadFloat('PINGK','ColorG',0);
    pingk.color.b:=ini.ReadFloat('PINGK','ColorB',1);

    gameplay.maxpaddlespeed:=ini.ReadFloat('GAMEPLAY','MaxPaddleSpeed',400);
    gameplay.hitzoneangledeviation:=ini.ReadFloat('GAMEPLAY','HitZoneAngleDeviation',0.4);
    gameplay.topspinintensity:=ini.ReadFloat('GAMEPLAY','TopSpinIntensity',0.18);
    gameplay.ballstartspeed:=ini.ReadFloat('GAMEPLAY','BallStartSpeed',400);
    gameplay.ballspeeduptimer:=ini.ReadFloat('GAMEPLAY','BallSpeedUpTimer',1);
    gameplay.ballspeedupincrease:=ini.ReadFloat('GAMEPLAY','BallSpeedUpIncrease',25);
    gameplay.ballsteepestanglereflectfromboard:=ini.ReadFloat('GAMEPLAY','BallSteepestAngleReflectFromBoard',0);
    gameplay.ballsteepestanglehitpaddle:=ini.ReadFloat('GAMEPLAY','BallSteepestAngleHitPaddle',30);
    gameplay.ballmaximumangularspeed:=ini.ReadFloat('GAMEPLAY','BallMaximumAngularSpeed',500);
    gameplay.ballangularspeeddecrease:=ini.ReadFloat('GAMEPLAY','BallAngularSpeedDecrease',10);
    gameplay.playertimeoutduration := ini.ReadFloat('GAMEPLAY', 'PlayerTimeOutDuration', 10);
    gameplay.poweruptimer := ini.ReadFloat('GAMEPLAY', 'PowerUpTimer', 13);
    gameplay.maximumpowerupspresent := ini.ReadInteger('GAMEPLAY', 'MaximumPowerUpsPresent', 3);
    gameplay.spawnpowerupbomboncrystals := ini.ReadInteger('GAMEPLAY', 'SpawnPowerUpBombOnCrystals', 10);
    gameplay.poweruprandomcrystal := ini.ReadInteger('GAMEPLAY', 'PowerUpRandomCrystal', 2);
    gameplay.poweruprandomconcave := ini.ReadInteger('GAMEPLAY', 'PowerUpRandomConcave', 2);
    gameplay.poweruprandompixel := ini.ReadInteger('GAMEPLAY', 'PowerUpRandomPixel', 2);
    gameplay.poweruprandomflowers := ini.ReadInteger('GAMEPLAY', 'PowerUpRandomFlowers', 2);
    gameplay.poweruprandomslowmotion := ini.ReadInteger('GAMEPLAY', 'PowerUpRandomSlowMotion', 1);
    gameplay.poweruprandombomb := ini.ReadInteger('GAMEPLAY', 'PowerUpRandomBomb', 1);
    gameplay.paddleinertiaincreasemultiplier := ini.ReadFloat('GAMEPLAY', 'PaddleInertiaIncreaseMultiplier', 3.5);
    gameplay.paddleinertiadecrease := ini.ReadFloat('GAMEPLAY', 'PaddleInertiaDecrease', 300);

    menu.candisplaymenu := ini.ReadBool('MENU', 'CanDisplayMenu', true);
    menu.canquit := ini.ReadBool('MENU', 'CanQuit', true);
  end;

  ini.Free;
end;




procedure SAIni.initialize;
begin
  loadFromFile('pingk');
end;


constructor SAIni.Create(parent:TObject);
begin
  inherited Create(parent,'Ini');
end;


destructor SAIni.Destroy;
begin
  inherited;
end;


end.