unit UIni;

interface
                            
uses IniFiles,UMyUtils;

procedure ReadDifficulty;
procedure RewriteDifficulty;
procedure ReadRoomtypes;
procedure RewriteRoomtypes;
procedure RewriteOrigSizes; 
procedure ReadOrigSizes;
procedure ReadMPSet;
procedure RewriteMPSet;
procedure ReadPanelConfigs;
procedure RewritePanelConfigs;

var
  ini:TMyIni;
  ROOMini:TMyIni;
  PanelIni:TMyIni;

  OrigSizes:array[0..55] of Real;
  //Form1.Left,Form1.Top,Form1.Width,Form1.Height,Form1.BorderStyle,    0..4
  //Round(Panel8.Left/Form1.Width),Round(Panel8.Width/Form1.Width),     5..6
  //Round(Panel8.Top/Form1.Height),Round(Panel8.Height/Form1.Height),   7..8
  //Round(Panel9.Left/Form1.Width),Round(Panel9.Width/Form1.Width),     9..10
  //Round(Panel9.Top/Form1.Height),Round(Panel9.Height/Form1.Height),   11..12
  //MenuFont.Font.Size/Form1.Height,                                    13..13
  //PlayerGoalDistFont.Font.Size/Form1.Height                           14..14
  //MainMenu.Position.X/Form1.Width,                                    15..15
  //MainMenu.Position.Y/Form1.Height,                                   16..16
  //0,0,0,0,                                                            17..20
  //GLHUDText1.Position.X/Form1.Width,GLHUDText1.Position.Y/Form1.Height,21..22
  //GLHUDText2.Position.X/Form1.Width,GLHUDText2.Position.Y/Form1.Height,23..24
  //Round(Panel13.Left/Form1.Width),Round(Panel13.Width/Form1.Width),   25..26
  //Round(Panel13.Top/Form1.Height),Round(Panel13.Height/Form1.Height), 27..28
  //Round(Panel8.Font.Size/Form1.Width),                                29..29
  //Round(Panel9.Font.Size/Form1.Width),0,                              30..31
  //Round(Panel11.Font.Size/Form1.Width),MenuFont.Font.Size/Form1.Width,32..33
  //Round(Panel13.Font.Size/Form1.Width)                                34..34
  //RichEdit1.Left/Form1.Width,RichEdit1.Width/Form1.Width,             35..36
  //RichEdit1.Top/Form1.Height,RichEdit1.Height/Form1.Height            37..38
  //Richedit1.Font.Size/Form1.Height,                                   39..39
  //SettingsMenu.Position.X/Form1.Width,                                40..40
  //SettingsMenu.Position.Y/Form1.Height                                41..41
  //VideoMenu.Position.X/Form1.Width,                                   42..42
  //VideoMenu.Position.Y/Form1.Height                                   43..43
  //0,0                                                                 44..45
  //MPMenu.Position.X/Form1.Width,                                      46..46
  //MPMenu.Position.Y/Form1.Height,                                     47..47
  //MPHostMenu.Position.X/Form1.Width,                                  48..48
  //MPHostMenu.Position.Y/Form1.Height,                                 49..49
  //MPJoinMenu.Position.X/Form1.Width,                                  50..50
  //MPJoinMenu.Position.Y/Form1.Height,                                 51..51
  //ThrustBar.Top/Form1.Height,ThrustBar.Left/Form1.Width,              52..53
  //ThrustBar.Height/Form1.Height,ThrustBar.Width/Form1.Width,          54..55
implementation

uses Unit1,SysUtils,TypInfo,Forms,UNetwork,UCreateRaum,Windows;


procedure ReadRoomtypes;
var C1:Integer; S1,S2:string; C2:THeight;
begin
  C1:=0;
  repeat
    S2:='RT_'+IntToStr(C1);       
    ROOMini.SectionDefault:=ini.ReadString('Roomtypelist',S2,'');
    S1:=ini.ReadString('Roomtypelist',S2,'');
    if S1='' then Break;
    SetLength(Roomtypes,C1+1);
    Roomtypes[C1].ID:=C1;
    ROOMini.Read('Roomfrequenzy',
    Roomtypes[C1].Roomfrequenzy);
    ROOMini.Read('GreenWallsAround',
    Roomtypes[C1].GreenWallsAround);
    ROOMini.Read('ChangeWallsAtArrival',
    Roomtypes[C1].ChangeWallsAtArrival);
    ROOMini.Read('ChangeSpeedAtArrival',
    Roomtypes[C1].ChangeSpeedAtArrival);
    ROOMini.Read('TurnPlayer',
    Roomtypes[C1].TurnPlayer);
    ROOMini.Read('PortPlayerToCenter',
    Roomtypes[C1].PortPlayerToCenter);
    ROOMini.Read('ChangeOtherPlayerSpeed',
    Roomtypes[C1].ChangeOtherPlayerSpeed);
    ROOMini.Read('Contaminate',
    Roomtypes[C1].Contaminate);
    ROOMini.Read('OPTanzGegner',
    Roomtypes[C1].OPTanzGegner);
    ROOMini.Read('Passierbar',true,
    Roomtypes[C1].Passierbar);
    ROOMini.Read('NotAtSpawn',true,
    Roomtypes[C1].NotAtSpawn);
    ROOMini.Read('MaterialNameUp','Ceiling',
    Roomtypes[C1].MaterialName[Up]);
    ROOMini.Read('MaterialNameDown','Grass',
    Roomtypes[C1].MaterialName[Down]);
    ROOMini.Read('WinAtArrival',
    Roomtypes[C1].WinAtArrival);
    ROOMini.Read('WallCageTrap',
    Roomtypes[C1].WallCageTrap);
    ROOMini.Read('NotNextToSelf',
    Roomtypes[C1].NotNextToSelf);
    ROOMini.Read('SPInvisible',
    Roomtypes[C1].SPInvisible);



    for C2:=Low(THeight) to High(THeight) do begin
      ROOMini.Read(
      'ChangeAtArrivalTo'+GetEnumName(TypeInfo(THeight), Integer(C2)),-1,
      Roomtypes[C1].ChangeAtArrivalTo[C2]);
      ROOMini.Read(
      'Explode'+GetEnumName(TypeInfo(THeight), Integer(C2)),
      Roomtypes[C1].Explode[C2]);
      ROOMini.Read(
      'ExplodeOtherPlayer'+GetEnumName(TypeInfo(THeight), Integer(C2)),
      Roomtypes[C1].ExplodeOtherPlayer[C2]);
      ROOMini.Read(
      'PortTo'+GetEnumName(TypeInfo(THeight), Integer(C2)),
      Roomtypes[C1].PortTo[C2]);
      ROOMini.Read(
      'TurnToGoal'+GetEnumName(TypeInfo(THeight), Integer(C2)),
      Roomtypes[C1].TurnToGoal[C2]);
      ROOMini.Read(
      'YSNP'+GetEnumName(TypeInfo(THeight), Integer(C2)),
      Roomtypes[C1].YSNP[C2]);
      ROOMini.Read(
      'TurnRandom'+GetEnumName(TypeInfo(THeight), Integer(C2)),
      Roomtypes[C1].TurnRandom[C2]);
      ROOMini.Read(
      'PushPlayer'+GetEnumName(TypeInfo(THeight), Integer(C2)),
      Roomtypes[C1].PushPlayer[C2]);
      ROOMini.Read(
      'InkOthers'+GetEnumName(TypeInfo(THeight), Integer(C2)),
      Roomtypes[C1].InkOthers[C2]);
      ROOMini.Read(
      'ChangeSpeedRandom'+GetEnumName(TypeInfo(THeight), Integer(C2)),
      Roomtypes[C1].ChangeSpeedRandom[C2]);
    end;
    inc(C1);
  until false;
end;


procedure RewriteRoomtypes;
begin
  ini.SectionDefault:='Roomtypelist';
  ini.Write('RT_0','empty');
  ini.Write('RT_1','Arrow');
  ini.Write('RT_2','Goal');
  ini.Write('RT_3','YSNP');
  ini.Write('RT_4','Green');
  ini.Write('RT_5','GreenTrap');
  ini.Write('RT_6','WallTrap');
  ini.Write('RT_7','Speed');
  ini.Write('RT_8','RedSpeed');
  ini.Write('RT_9','GreenSpeed');
  ini.Write('RT_10','Turner');
  ini.Write('RT_11','UpDownPorter');
  ini.Write('RT_12','UpPorter');
  ini.Write('RT_13','DownPorter');
  ini.Write('RT_14','Explosion');
  ini.Write('RT_15','RainbowTrap');
  ini.Write('RT_16','PusherDown');
  ini.Write('RT_17','BlackExplosion');
  ini.Write('RT_18','Lightning');
  ini.Write('RT_19','Contamination');
  ini.Write('RT_20','PusherUp');
  ini.Write('RT_21','PusherUpDown');
  ini.Write('RT_22','InkDown');
  ini.Write('RT_23','InkUp');
  ini.Write('RT_24','InkUpDown');
  ini.Write('RT_25','OPTanzGegnerraum');
  ini.Write('RT_26','ArrowSpawner');
  ini.Write('RT_27','RandomSpeed');
  ini.Write('RT_28','OpenUp');
  ini.Write('RT_29','OpenDown');
  ini.Write('RT_30','OpenUpDown');
  ini.Write('RT_31','Bonbon');


  ROOMini.WriteInteger('empty','ID',0);
  ROOMini.WriteFloat('empty','Roomfrequenzy',0);
  ROOMini.WriteBool('empty','NotAtSpawn',false);

  ROOMini.WriteString('Arrow','MaterialNameDown','Grass');
  ROOMini.WriteString('Arrow','MaterialNameUp','Arrow');
  ROOMini.WriteInteger('Arrow','ID',1);
  ROOMini.WriteFloat('Arrow','Roomfrequenzy',0.02);
  ROOMini.WriteBool('Arrow','TurnToGoalUp',true);
  ROOMini.WriteBool('Arrow','NotAtSpawn',false);
  ROOMini.WriteBool('Arrow','NotNextToSelf',true);


  ROOMini.WriteString('Goal','MaterialNameUp','Goal');
  ROOMini.WriteInteger('Goal','ID',2);
  ROOMini.WriteFloat('Goal','Roomfrequenzy',0);
  ROOMini.WriteBool('Goal','WinAtArrival',true);
  ROOMini.WriteBool('Goal','TurnRandomUp',true);
  ROOMini.WriteBool('Goal','NotAtSpawn',false);
  ROOMini.WriteBool('Goal','NotNextToSelf',true);

  ROOMini.WriteString('YSNP','MaterialNameDown','YSNP');
  ROOMini.WriteString('YSNP','MaterialNameUp','Ceiling');
  ROOMini.WriteInteger('YSNP','ID',3);
  ROOMini.WriteFloat('YSNP','Roomfrequenzy',0.02);
  ROOMini.WriteBool('YSNP','YSNPUp',true);
  ROOMini.WriteBool('YSNP','YSNPDown',true);
  ROOMini.WriteBool('YSNP','TurnPlayer',false);
  ROOMini.WriteBool('YSNP','PortPlayerToCenter',false);
  ROOMini.WriteBool('YSNP','Passierbar',false);
  ROOMini.WriteBool('YSNP','TurnRandomDown',true);
  ROOMini.WriteBool('YSNP','NotNextToSelf',true);

  ROOMini.WriteString('Green','MaterialNameDown','Grass');
  ROOMini.WriteString('Green','MaterialNameUp','Ceiling');
  ROOMini.WriteInteger('Green','ID',4);
  ROOMini.WriteFloat('Green','Roomfrequenzy',0.042);
  ROOMini.WriteBool('Green','YSNPUp',false);
  ROOMini.WriteBool('Green','YSNPDown',false);
  ROOMini.WriteBool('Green','GreenWallsAround',true);
  ROOMini.WriteBool('Green','ChangeWallsAtArrival',false);
  ROOMini.WriteBool('Green','TurnPlayer',false);
  ROOMini.WriteBool('Green','PortPlayerToCenter',false);

  ROOMini.WriteString('GreenTrap','MaterialNameDown','Grass');
  ROOMini.WriteString('GreenTrap','MaterialNameUp','Ceiling');
  ROOMini.WriteInteger('GreenTrap','ID',5);
  ROOMini.WriteFloat('GreenTrap','Roomfrequenzy',0.042);
  ROOMini.WriteBool('GreenTrap','YSNPUp',false);
  ROOMini.WriteBool('GreenTrap','YSNPDown',false);
  ROOMini.WriteBool('GreenTrap','GreenWallsAround',false);
  ROOMini.WriteInteger('GreenTrap','ChangeAtArrivalToUp',4);
  ROOMini.WriteInteger('GreenTrap','ChangeAtArrivalToDown',4);
  ROOMini.WriteBool('GreenTrap','ChangeWallsAtArrival',false);
  ROOMini.WriteBool('GreenTrap','TurnPlayer',true);
  ROOMini.WriteBool('GreenTrap','PortPlayerToCenter',true);

  ROOMini.WriteInteger('WallTrap','ID',6);
  ROOMini.WriteFloat('WallTrap','Roomfrequenzy',0.035);
  ROOMini.WriteBool('WallTrap','YSNPUp',false);
  ROOMini.WriteBool('WallTrap','YSNPDown',false);
  ROOMini.WriteBool('WallTrap','GreenWallsAround',false);
  ROOMini.WriteInteger('WallTrap','ChangeAtArrivalToUp',0);
  ROOMini.WriteInteger('WallTrap','ChangeAtArrivalToDown',0);
  ROOMini.WriteBool('WallTrap','ChangeWallsAtArrival',true);
  ROOMini.WriteBool('WallTrap','TurnPlayer',false);
  ROOMini.WriteBool('WallTrap','PortPlayerToCenter',false);
  ROOMini.WriteBool('WallTrap','Passierbar',false);

  ROOMini.WriteString('Speed','MaterialNameDown','BlueSpeed');
  ROOMini.WriteInteger('Speed','ID',7);
  ROOMini.WriteFloat('Speed','Roomfrequenzy',0.07);
  ROOMini.WriteBool('Speed','YSNPUp',false);
  ROOMini.WriteBool('Speed','YSNPDown',false);
  ROOMini.WriteBool('Speed','GreenWallsAround',false);
  ROOMini.WriteInteger('Speed','ChangeAtArrivalToUp',0);
  ROOMini.WriteInteger('Speed','ChangeAtArrivalToDown',0);
  ROOMini.WriteBool('Speed','ChangeWallsAtArrival',false);
  ROOMini.WriteFloat('Speed','ChangeSpeedAtArrival',2);
  ROOMini.WriteBool('Speed','TurnPlayer',false);
  ROOMini.WriteBool('Speed','PortPlayerToCenter',false);
  ROOMini.WriteBool('Speed','TurnRandomDown',true);

  ROOMini.WriteString('RedSpeed','MaterialNameDown','RedSpeed');
  ROOMini.WriteInteger('RedSpeed','ID',8);
  ROOMini.WriteFloat('RedSpeed','Roomfrequenzy',0.015);
  ROOMini.WriteInteger('RedSpeed','ChangeAtArrivalToUp',0);
  ROOMini.WriteInteger('RedSpeed','ChangeAtArrivalToDown',0);
  ROOMini.WriteFloat('RedSpeed','ChangeSpeedAtArrival',-10);
  ROOMini.WriteBool('RedSpeed','TurnRandomDown',true);

  ROOMini.WriteString('GreenSpeed','MaterialNameDown','GreenSpeed');
  ROOMini.WriteInteger('GreenSpeed','ID',9);
  ROOMini.WriteFloat('GreenSpeed','Roomfrequenzy',0.008);
  ROOMini.WriteBool('GreenSpeed','YSNPUp',false);
  ROOMini.WriteBool('GreenSpeed','YSNPDown',false);
  ROOMini.WriteBool('GreenSpeed','GreenWallsAround',false);
  ROOMini.WriteInteger('GreenSpeed','ChangeAtArrivalToUp',0);
  ROOMini.WriteInteger('GreenSpeed','ChangeAtArrivalToDown',0);
  ROOMini.WriteBool('GreenSpeed','ChangeWallsAtArrival',false);
  ROOMini.WriteFloat('GreenSpeed','ChangeSpeedAtArrival',10);
  ROOMini.WriteBool('GreenSpeed','TurnPlayer',false);
  ROOMini.WriteBool('GreenSpeed','PortPlayerToCenter',false);
  ROOMini.WriteBool('GreenSpeed','TurnRandomDown',true);
  ROOMini.WriteBool('GreenSpeed','NotNextToSelf',true);

  ROOMini.WriteString('Turner','MaterialNameUp','Turner');
  ROOMini.WriteInteger('Turner','ID',10);
  ROOMini.WriteFloat('Turner','Roomfrequenzy',0.1);
  ROOMini.WriteBool('Turner','ExplodeDown',false);
  ROOMini.WriteBool('Turner','ExplodeUp',false);
  ROOMini.WriteBool('Turner','PortToUp',false);
  ROOMini.WriteBool('Turner','PortToDown',false);
  ROOMini.WriteBool('Turner','TurnToGoalUp',false);
  ROOMini.WriteBool('Turner','TurnToGoalDown',false);
  ROOMini.WriteBool('Turner','YSNPUp',false);
  ROOMini.WriteBool('Turner','YSNPDown',false);
  ROOMini.WriteBool('Turner','GreenWallsAround',false);
  ROOMini.WriteBool('Turner','ChangeWallsAtArrival',false);
  ROOMini.WriteFloat('Turner','ChangeSpeedAtArrival',0);
  ROOMini.WriteBool('Turner','TurnPlayer',true);
  ROOMini.WriteBool('Turner','PortPlayerToCenter',true);

  ROOMini.WriteString('UpDownPorter','MaterialNameDown','PortDownUp');
  ROOMini.WriteString('UpDownPorter','MaterialNameUp','PortUpDown');
  ROOMini.WriteInteger('UpDownPorter','ID',11);
  ROOMini.WriteFloat('UpDownPorter','Roomfrequenzy',0.015);
  ROOMini.WriteBool('UpDownPorter','ExplodeDown',false);
  ROOMini.WriteBool('UpDownPorter','ExplodeUp',false);
  ROOMini.WriteBool('UpDownPorter','PortToUp',true);
  ROOMini.WriteBool('UpDownPorter','PortToDown',true);
  ROOMini.WriteBool('UpDownPorter','TurnToGoalUp',false);
  ROOMini.WriteBool('UpDownPorter','TurnToGoalDown',false);
  ROOMini.WriteBool('UpDownPorter','YSNPUp',false);
  ROOMini.WriteBool('UpDownPorter','YSNPDown',false);
  ROOMini.WriteBool('UpDownPorter','GreenWallsAround',false);
//  ROOMini.WriteInteger('UpDownPorter','ChangeAtArrivalToUp',0);
//  ROOMini.WriteInteger('UpDownPorter','ChangeAtArrivalToDown',0);
  ROOMini.WriteBool('UpDownPorter','ChangeWallsAtArrival',false);
  ROOMini.WriteFloat('UpDownPorter','ChangeSpeedAtArrival',0);
  ROOMini.WriteBool('UpDownPorter','TurnPlayer',false);
  ROOMini.WriteBool('UpDownPorter','PortPlayerToCenter',false);
  ROOMini.WriteBool('UpDownPorter','NotNextToSelf',true);

  ROOMini.WriteString('UpPorter','MaterialNameDown','PortDownUp');
  ROOMini.WriteInteger('UpPorter','ID',12);
  ROOMini.WriteFloat('UpPorter','Roomfrequenzy',0.03);
  ROOMini.WriteBool('UpPorter','ExplodeDown',false);
  ROOMini.WriteBool('UpPorter','ExplodeUp',false);
  ROOMini.WriteBool('UpPorter','PortToUp',true);
  ROOMini.WriteBool('UpPorter','PortToDown',false);
  ROOMini.WriteBool('UpPorter','TurnToGoalUp',false);
  ROOMini.WriteBool('UpPorter','TurnToGoalDown',false);
  ROOMini.WriteBool('UpPorter','YSNPUp',false);
  ROOMini.WriteBool('UpPorter','YSNPDown',false);
  ROOMini.WriteBool('UpPorter','GreenWallsAround',false);
//  ROOMini.WriteInteger('UpPorter','ChangeAtArrivalToDown',0);
  ROOMini.WriteBool('UpPorter','ChangeWallsAtArrival',false);
  ROOMini.WriteFloat('UpPorter','ChangeSpeedAtArrival',0);
  ROOMini.WriteBool('UpPorter','TurnPlayer',false);
  ROOMini.WriteBool('UpPorter','PortPlayerToCenter',false);
  ROOMini.WriteBool('UpPorter','NotNextToSelf',true);

  ROOMini.WriteString('DownPorter','MaterialNameUp','PortUpDown');
  ROOMini.WriteInteger('DownPorter','ID',13);
  ROOMini.WriteFloat('DownPorter','Roomfrequenzy',0.03);
  ROOMini.WriteBool('DownPorter','ExplodeDown',false);
  ROOMini.WriteBool('DownPorter','ExplodeUp',false);
  ROOMini.WriteBool('DownPorter','PortToUp',false);
  ROOMini.WriteBool('DownPorter','PortToDown',true);
  ROOMini.WriteBool('DownPorter','TurnToGoalUp',false);
  ROOMini.WriteBool('DownPorter','TurnToGoalDown',false);
  ROOMini.WriteBool('DownPorter','YSNPUp',false);
  ROOMini.WriteBool('DownPorter','YSNPDown',false);
  ROOMini.WriteBool('DownPorter','GreenWallsAround',false);
//  ROOMini.WriteInteger('DownPorter','ChangeAtArrivalToUp',0);
  ROOMini.WriteBool('DownPorter','ChangeWallsAtArrival',false);
  ROOMini.WriteFloat('DownPorter','ChangeSpeedAtArrival',0);
  ROOMini.WriteBool('DownPorter','TurnPlayer',false);
  ROOMini.WriteBool('DownPorter','PortPlayerToCenter',false);
  ROOMini.WriteBool('DownPorter','NotNextToSelf',true);

  ROOMini.WriteString('Explosion','MaterialNameDown','Explosion');
  ROOMini.WriteInteger('Explosion','ID',14);
  ROOMini.WriteFloat('Explosion','Roomfrequenzy',0.005);
  ROOMini.WriteBool('Explosion','ExplodeDown',true);       
  ROOMini.WriteBool('Explosion','ExplodeUp',true);
  ROOMini.WriteInteger('Explosion','ChangeAtArrivalToUp',0);
  ROOMini.WriteInteger('Explosion','ChangeAtArrivalToDown',0);
  ROOMini.WriteBool('Explosion','ChangeWallsAtArrival',false);
  ROOMini.WriteFloat('Explosion','ChangeSpeedAtArrival',0);
  ROOMini.WriteBool('Explosion','TurnRandomDown',true);

  ROOMini.WriteInteger('RainbowTrap','ID',15);
  ROOMini.WriteFloat('RainbowTrap','Roomfrequenzy',0.05);
  ROOMini.WriteBool('RainbowTrap','PortToUp',true);
  ROOMini.WriteBool('RainbowTrap','PortToDown',true);
  ROOMini.WriteInteger('RainbowTrap','ChangeAtArrivalToUp',0);
  ROOMini.WriteInteger('RainbowTrap','ChangeAtArrivalToDown',0);

  ROOMini.WriteString('PusherDown','MaterialNameDown','PusherDown');
  ROOMini.WriteInteger('PusherDown','ID',16);
  ROOMini.WriteFloat('PusherDown','Roomfrequenzy',0.04);
  ROOMini.WriteBool('PusherDown','PushPlayerDown',true);
  ROOMini.WriteBool('PusherDown','TurnRandomDown',true);

//  ROOMini.WriteString('BlackExplosion','MaterialNameDown','BlackExplosion');
//  ROOMini.WriteInteger('BlackExplosion','ID',17);
//  ROOMini.WriteFloat('BlackExplosion','Roomfrequenzy',0.01);
//  ROOMini.WriteBool('BlackExplosion','ExplodeOtherPlayerUp',true);
//  ROOMini.WriteBool('BlackExplosion','ExplodeOtherPlayerDown',true);
//  ROOMini.WriteInteger('BlackExplosion','ChangeAtArrivalToUp',0);
//  ROOMini.WriteInteger('BlackExplosion','ChangeAtArrivalToDown',0);
//  ROOMini.WriteBool('BlackExplosion','TurnRandomDown',true);
//  ROOMini.WriteBool('BlackExplosion','NotNextToSelf',true);
//  ROOMini.WriteBool('BlackExplosion','SPInvisible',true);

//  ROOMini.WriteString('Lightning','MaterialNameUp','Lightning');
//  ROOMini.WriteInteger('Lightning','ID',18);
//  ROOMini.WriteFloat('Lightning','Roomfrequenzy',0.025);
//  ROOMini.WriteInteger('Lightning','ChangeAtArrivalToUp',0);
//  ROOMini.WriteInteger('Lightning','ChangeAtArrivalToDown',0);
//  ROOMini.WriteBool('Lightning','ChangeOtherPlayerSpeed',true);
//  ROOMini.WriteBool('Lightning','TurnRandomUp',true);
//  ROOMini.WriteBool('Lightning','NotNextToSelf',true);
//  ROOMini.WriteBool('Lightning','SPInvisible',true);

  ROOMini.WriteString('Contamination','MaterialNameDown','ContaminationDown');
  ROOMini.WriteString('Contamination','MaterialNameUp','ContaminationUp');
  ROOMini.WriteInteger('Contamination','ID',19);
  ROOMini.WriteFloat('Contamination','Roomfrequenzy',0.005);
  ROOMini.WriteBool('Contamination','Contaminate',true);
  ROOMini.WriteBool('Contamination','Passierbar',false);
  ROOMini.WriteBool('Contamination','TurnRandomUp',true);
  ROOMini.WriteBool('Contamination','TurnRandomDown',true);

  

  ROOMini.WriteString('PusherUp','MaterialNameUp','PusherUp');
  ROOMini.WriteInteger('PusherUp','ID',20);
  ROOMini.WriteFloat('PusherUp','Roomfrequenzy',0.04);
  ROOMini.WriteBool('PusherUp','PushPlayerUp',true);
  ROOMini.WriteBool('PusherUp','TurnRandomUp',true);

  ROOMini.WriteString('PusherUpDown','MaterialNameDown','PusherDown');
  ROOMini.WriteString('PusherUpDown','MaterialNameUp','PusherUp');
  ROOMini.WriteInteger('PusherUpDown','ID',21);
  ROOMini.WriteFloat('PusherUpDown','Roomfrequenzy',0.01);
  ROOMini.WriteBool('PusherUpDown','PushPlayerUp',true);
  ROOMini.WriteBool('PusherUpDown','PushPlayerDown',true);
  ROOMini.WriteBool('PusherUpDown','TurnRandomUp',true);
  ROOMini.WriteBool('PusherUpDown','TurnRandomDown',true);
  ROOMini.WriteBool('PusherUpDown','Passierbar',false);

//  ROOMini.WriteString('InkDown','MaterialNameDown','InkDown');
//  ROOMini.WriteInteger('InkDown','ID',22);
//  ROOMini.WriteFloat('InkDown','Roomfrequenzy',0.006);
//  ROOMini.WriteBool('InkDown','TurnRandomDown',true);
//  ROOMini.WriteBool('InkDown','InkOthersDown',true);
//  ROOMini.WriteInteger('InkDown','ChangeAtArrivalToDown',0);
//  ROOMini.WriteBool('InkDown','NotNextToSelf',true);
//  ROOMini.WriteBool('InkDown','SPInvisible',true);
//
//  ROOMini.WriteString('InkUp','MaterialNameUp','InkUp');
//  ROOMini.WriteInteger('InkUp','ID',23);
//  ROOMini.WriteFloat('InkUp','Roomfrequenzy',0.006);
//  ROOMini.WriteBool('InkUp','TurnRandomUp',true);
//  ROOMini.WriteBool('InkUp','InkOthersUp',true);
//  ROOMini.WriteInteger('InkUp','ChangeAtArrivalToUp',0);
//  ROOMini.WriteBool('InkDown','NotNextToSelf',true);
//  ROOMini.WriteBool('InkDown','SPInvisible',true);
//
//  ROOMini.WriteString('InkUpDown','MaterialNameDown','InkDown');
//  ROOMini.WriteString('InkUpDown','MaterialNameUp','InkUp');
//  ROOMini.WriteInteger('InkUpDown','ID',24);
//  ROOMini.WriteFloat('InkUpDown','Roomfrequenzy',0.002);
//  ROOMini.WriteBool('InkUpDown','TurnRandomDown',true);
//  ROOMini.WriteBool('InkUpDown','TurnRandomUp',true);
//  ROOMini.WriteBool('InkUpDown','InkOthersDown',true);
//  ROOMini.WriteBool('InkUpDown','InkOthersUp',true);
//  ROOMini.WriteInteger('InkUpDown','ChangeAtArrivalToDown',0);
//  ROOMini.WriteInteger('InkUpDown','ChangeAtArrivalToUp',0);
//  ROOMini.WriteBool('InkUpDown','NotNextToSelf',true);
//  ROOMini.WriteBool('InkUpDown','SPInvisible',true);

  ROOMini.WriteInteger('OPTanzGegnerraum','ID',25);
  ROOMini.WriteFloat('OPTanzGegnerraum','Roomfrequenzy',0.005);
  ROOMini.WriteBool('OPTanzGegnerraum','OPTanzGegner',true);
  ROOMini.WriteBool('OPTanzGegnerraum','Passierbar',false);
  ROOMini.WriteBool('OPTanzGegnerraum','NotNextToSelf',true);

//  ROOMini.WriteInteger('ArrowSpawner','ID',26);
//  ROOMini.WriteFloat('ArrowSpawner','Roomfrequenzy',0.005);
//  ROOMini.WriteString('ArrowSpawner','MaterialNameUp','ArrowSpawner');
//  ROOMini.WriteBool('ArrowSpawner','TurnRandomUp',true);
//  ROOMini.WriteInteger('ArrowSpawner','ChangeAtArrivalToDown',1);
//  ROOMini.WriteInteger('ArrowSpawner','ChangeAtArrivalToUp',1);
//  ROOMini.WriteBool('ArrowSpawner','NotNextToSelf',true);

//  ROOMini.WriteString('RandomSpeed','MaterialNameDown','RandomSpeed');
//  ROOMini.WriteInteger('RandomSpeed','ID',27);
//  ROOMini.WriteFloat('RandomSpeed','Roomfrequenzy',0.007);
//  ROOMini.WriteInteger('RandomSpeed','ChangeAtArrivalToUp',0);
//  ROOMini.WriteInteger('RandomSpeed','ChangeAtArrivalToDown',0);
//  ROOMini.WriteBool('RandomSpeed','ChangeSpeedRandomUp',true);
//  ROOMini.WriteBool('RandomSpeed','ChangeSpeedRandomDown',true);
//  ROOMini.WriteBool('RandomSpeed','TurnRandomDown',true);
//  ROOMini.WriteFloat('RandomSpeed','ChangeSpeedAtArrival',20);
//  ROOMini.WriteBool('RandomSpeed','NotNextToSelf',true);


  ROOMini.WriteString('OpenDown','MaterialNameDown','Open');
  ROOMini.WriteInteger('OpenDown','ID',28);
  ROOMini.WriteFloat('OpenDown','Roomfrequenzy',0.01);

  ROOMini.WriteString('OpenUp','MaterialNameUp','Open');
  ROOMini.WriteInteger('OpenUp','ID',29);
  ROOMini.WriteFloat('OpenUp','Roomfrequenzy',0.01);
                                                         
  ROOMini.WriteString('OpenUpDown','MaterialNameDown','Open');
  ROOMini.WriteString('OpenUpDown','MaterialNameUp','Open');
  ROOMini.WriteInteger('OpenUpDown','ID',30);
  ROOMini.WriteFloat('OpenUpDown','Roomfrequenzy',0.005);
  ROOMini.WriteBool('OpenUpDown','Passierbar',false);
                                                         
  ROOMini.WriteString('Bonbon','MaterialNameDown','Bonbon');
  ROOMini.WriteInteger('Bonbon','ID',31);
  ROOMini.WriteFloat('Bonbon','Roomfrequenzy',0.005);
  ROOMini.WriteBool('Bonbon','WallCageTrap',true);
  ROOMini.WriteBool('Bonbon','Passierbar',false);
  ROOMini.WriteBool('Bonbon','TurnRandomDown',true);
  ROOMini.WriteBool('Bonbon','NotNextToSelf',true);
end;


procedure ReadPanelConfigs;
var C1:Integer; S2:string;
begin
  C1:=0;
  repeat
    S2:='RT_'+IntToStr(C1);
    PanelIni.SectionDefault:='PC_'+ini.ReadString('Roomtypelist',S2,'');
    if PanelIni.SectionDefault='PC_' then Break;
    SetLength(PanelConfigs,C1+1);
    PanelConfigs[C1].ID:=C1;
    PanelIni.Read('TopDivH',64/Form1.Height,PanelConfigs[C1].TopDivH);
    PanelIni.Read('LeftDivW',136/Form1.Width,PanelConfigs[C1].LeftDivW);
    PanelIni.Read('WidthDivW',849/Form1.Width,PanelConfigs[C1].WidthDivW);
    PanelIni.Read('HeightDivH',49/Form1.Height,PanelConfigs[C1].HeightDivH);
    PanelIni.Read('Text',PanelConfigs[C1].Text);
    PanelIni.Read('FontColor',
    RGB(255,255,255),Integer(PanelConfigs[C1].FontColor));
    PanelIni.Read('BackGroundColor',
    RGB(38,38,38),Integer(PanelConfigs[C1].BackGroundColor));
    PanelIni.Read('FontSizeDivH',24/Form1.Height,PanelConfigs[C1].FontSizeDivH);
    PanelIni.Read('Seconds',3,PanelConfigs[C1].Seconds);
    PanelIni.Read('DontShowIfWon',PanelConfigs[C1].DontShowIfWon);
    PanelIni.Read('SpeedAtEnd',PanelConfigs[C1].SpeedAtEnd);
    inc(C1);
  until false;
end;


procedure RewritePanelConfigs;
begin
  PanelIni.SectionDefault:='PC_GreenTrap';
  PanelIni.Write('ID',5);
  PanelIni.Write('Text','hihihihihihihihihihihi');
  PanelIni.Write('FontColor',RGB(232,138,20));
  PanelIni.Write('BackGroundColor',RGB(10,23,7));
  PanelIni.Write('LeftDivW',139/Form1.Width);
  PanelIni.Write('TopDivH',253/Form1.Height);
  PanelIni.Write('DontShowIfWon',true);

  PanelIni.SectionDefault:='PC_WallTrap';
  PanelIni.Write('ID',6);
  PanelIni.Write('Text','Warping Walls!');
  PanelIni.Write('FontColor',RGB(52,52,219));
  PanelIni.Write('DontShowIfWon',true); 

  PanelIni.SectionDefault:='PC_Speed';
  PanelIni.Write('ID',7);
  PanelIni.Write('Text','Speed increased to');
  PanelIni.Write('FontColor',RGB(0,168,255));
  PanelIni.Write('SpeedAtEnd',true);

  PanelIni.SectionDefault:='PC_RedSpeed';
  PanelIni.Write('ID',8);
  PanelIni.Write('Text','Speed decreased to');
  PanelIni.Write('FontColor',RGB(150,25,25));   
  PanelIni.Write('DontShowIfWon',true);
  PanelIni.Write('SpeedAtEnd',true);  

  PanelIni.SectionDefault:='PC_GreenSpeed';
  PanelIni.Write('ID',9);
  PanelIni.Write('Text','Speed increased to');
  PanelIni.Write('FontColor',RGB(125,219,45));
  PanelIni.Write('SpeedAtEnd',true);

  PanelIni.SectionDefault:='PC_Explosion';
  PanelIni.Write('ID',14);
  PanelIni.Write('Text','BOOM');
  PanelIni.Write('FontColor',RGB(23,117,235));
  PanelIni.Write('BackGroundColor',RGB(232,138,20));
  PanelIni.Write('LeftDivW',0.05);
  PanelIni.Write('WidthDivW',0.9);
  PanelIni.Write('TopDivH',0.1);
  PanelIni.Write('HeightDivH',0.8);
  PanelIni.Write('Seconds',1.5);
  PanelIni.Write('FontSizeDivH',300/Form1.Height);
  PanelIni.Write('DontShowIfWon',true);  

  PanelIni.SectionDefault:='PC_RandomSpeed';
  PanelIni.Write('ID',27);
  PanelIni.Write('Text','Speed changed randomly to');
  PanelIni.Write('FontColor',RGB(0,0,0));
  PanelIni.Write('BackGroundColor',RGB(255,255,255));
  PanelIni.Write('DontShowIfWon',true);
                  
  PanelIni.SectionDefault:='PC_Bonbon';
  PanelIni.Write('ID',31);
  PanelIni.Write('Text','Trapped!');
  PanelIni.Write('FontColor',RGB(255,182,80));
  PanelIni.Write('DontShowIfWon',true);
end;

procedure RewriteOrigSizes;
var C1:Integer;
begin
  OrigSizes[0]:=Form1.Left;
  OrigSizes[1]:=Form1.Top;
  OrigSizes[2]:=Form1.Width;
  OrigSizes[3]:=Form1.Height;
  OrigSizes[4]:=Integer(Form1.BorderStyle);
  OrigSizes[5]:=Form1.Panel8.Left/Form1.Width;
  OrigSizes[6]:=Form1.Panel8.Width/Form1.Width;
  OrigSizes[7]:=Form1.Panel8.Top/Form1.Height;
  OrigSizes[8]:=Form1.Panel8.Height/Form1.Height;
  OrigSizes[9]:=Form1.Panel9.Left/Form1.Width;
  OrigSizes[10]:=Form1.Panel9.Width/Form1.Width;
  OrigSizes[11]:=Form1.Panel9.Top/Form1.Height;
  OrigSizes[12]:=Form1.Panel9.Height/Form1.Height;
  OrigSizes[13]:=Form1.MenuFont.Font.Size/Form1.Height;
  OrigSizes[14]:=Form1.PlayerGoalDistFont.Font.Size/Form1.Height;
  OrigSizes[15]:=Form1.MainMenu.Position.X/Form1.Width;
  OrigSizes[16]:=Form1.MainMenu.Position.Y/Form1.Height;
  OrigSizes[17]:=0;
  OrigSizes[18]:=0;
  OrigSizes[19]:=0;
  OrigSizes[20]:=0;

  OrigSizes[21]:=Form1.GLHUDText1.Position.X/Form1.Width;
  OrigSizes[22]:=Form1.GLHUDText1.Position.Y/Form1.Height;
  OrigSizes[23]:=Form1.GLHUDText2.Position.X/Form1.Width;
  OrigSizes[24]:=Form1.GLHUDText2.Position.Y/Form1.Height;

  OrigSizes[25]:=Form1.Panel13.Left/Form1.Width;
  OrigSizes[26]:=Form1.Panel13.Width/Form1.Width;
  OrigSizes[27]:=Form1.Panel13.Top/Form1.Height;
  OrigSizes[28]:=Form1.Panel13.Height/Form1.Height;
  OrigSizes[29]:=Form1.Panel8.Font.Size/Form1.Width;
  OrigSizes[30]:=Form1.Panel9.Font.Size/Form1.Width;
  OrigSizes[32]:=Form1.Panel11.Font.Size/Form1.Width;
  OrigSizes[33]:=Form1.MenuFont.Font.Size/Form1.Width;
  OrigSizes[34]:=Form1.Panel13.Font.Size/Form1.Width;
  OrigSizes[35]:=Form1.RichEdit1.Left/Form1.Width;
  OrigSizes[36]:=Form1.RichEdit1.Width/Form1.Width;
  OrigSizes[37]:=Form1.RichEdit1.Top/Form1.Height;
  OrigSizes[38]:=Form1.RichEdit1.Height/Form1.Height;
  OrigSizes[39]:=Form1.Richedit1.Font.Size/Form1.Height;

  OrigSizes[40]:=Form1.SettingsMenu.Position.X/Form1.Width;
  OrigSizes[41]:=Form1.SettingsMenu.Position.Y/Form1.Height;
  OrigSizes[42]:=Form1.VideoMenu.Position.X/Form1.Width;
  OrigSizes[43]:=Form1.VideoMenu.Position.Y/Form1.Height;
  OrigSizes[44]:=0;
  OrigSizes[45]:=0;
  OrigSizes[46]:=Form1.MPMenu.Position.X/Form1.Width;
  OrigSizes[47]:=Form1.MPMenu.Position.Y/Form1.Height;
  OrigSizes[48]:=Form1.MPHostMenu.Position.X/Form1.Width;
  OrigSizes[49]:=Form1.MPHostMenu.Position.Y/Form1.Height;
  OrigSizes[50]:=Form1.MPJoinMenu.Position.X/Form1.Width;
  OrigSizes[51]:=Form1.MPJoinMenu.Position.Y/Form1.Height;
  OrigSizes[52]:=Form1.ThrustBar.Top/Form1.Height;
  OrigSizes[53]:=Form1.ThrustBar.Left/Form1.Width;
  OrigSizes[54]:=Form1.ThrustBar.Height/Form1.Height;
  OrigSizes[55]:=Form1.ThrustBar.Width/Form1.Width;
    
  for C1:=Low(OrigSizes) to High(OrigSizes) do
  ini.WriteFloat('Proportions','OS_'+IntToStr(C1),OrigSizes[C1]);
end;

procedure ReadDifficulty;
begin
  MinGoalDist:=
  ini.ReadInteger('Difficulty','Minimum Goal Distance',MinGoalDist);
  MaxGoalDist:=
  ini.ReadInteger('Difficulty','Maximum Goal Distance',MaxGoalDist);
  GoalProtectionRadius:=
  ini.ReadInteger('Difficulty','GoalProtectionRadius',3);
  WallProb:=
  ini.ReadFloat('Difficulty','WallProb',WallProb);
  UPWallProb:=
  ini.ReadFloat('Difficulty','UPWallProb',UPWallProb);
  DownWallProb:=
  ini.ReadFloat('Difficulty','DownWallProb',0.11);
  StartSpeed:=
  ini.ReadFloat('Difficulty','StartSpeed',15);
end;

procedure RewriteDifficulty;
begin
  ini.WriteInteger('Difficulty','Minimum Goal Distance',MinGoalDist);
  ini.WriteInteger('Difficulty','Maximum Goal Distance',MaxGoalDist);
  ini.WriteInteger('Difficulty','GoalProtectionRadius',GoalProtectionRadius);
  ini.WriteFloat('Difficulty','WallProb',WallProb);
  ini.WriteFloat('Difficulty','UPWallProb',UPWallProb);
  ini.WriteFloat('Difficulty','DownWallProb',DownWallProb);
  ini.WriteFloat('Difficulty','StartSpeed',StartSpeed);
end;

procedure ReadOrigSizes;
var C1:Integer;
begin
  for C1:=Low(OrigSizes) to High(OrigSizes) do
  OrigSizes[C1]:=ini.ReadFloat('Proportions','OS_'+IntToStr(C1),1);

  Form1.BorderStyle:=TFormBorderStyle(Round(OrigSizes[4]));
  Form1.SetBounds(
  Round(OrigSizes[0]),
  Round(OrigSizes[1]),
  Round(OrigSizes[2]),
  Round(OrigSizes[3]));
  Form1.RearrangePanels;
end;
    

procedure ReadMPSet;
begin
  MPServerAddress:=
  ini.ReadString('Multiplayer','MPServerAddress','Localhost');
  MPPort:=
  ini.ReadInteger('Multiplayer','MPPort',10808);
end; 

procedure RewriteMPSet;
begin
  ini.WriteString('Multiplayer','MPServerAddress',MPServerAddress);
  ini.WriteInteger('Multiplayer','MPPort',MPPort);
end;

end.
