library Game;

uses
  ShareMem,
  Windows,
  uGame in 'uGame.pas',
  uPlayer in 'uPlayer.pas',
  uMap in 'uMap.pas',
  uWeapon in 'uWeapon.pas',
  uObjects in 'uObjects.pas',
  uGlobal in '..\uGlobal.pas',
  uMaterials in 'uMaterials.pas';

type
  TCallState = (onGetProcsList, onInit, onDeInit, onProgress);
  TStringArray = array of string;

procedure Add(var SA: TStringArray; Name: string);
begin
  SetLength(SA,length(SA)+1);
  SA[length(SA)-1]:=Name;
end;

function MainProc(State: TCallState): TStringArray; stdcall;
begin
  case State of
    onGetProcsList:
      begin
        Add(Result,'GameInit');
        Add(Result,'GameProcess');
        Add(Result,'onbuttondown');

        Add(Result,'GameOnKeyDown');
        Add(Result,'GameOnKeyUp');
        Add(Result,'GameOnMouseDown');
        Add(Result,'GameOnMouseUp');
        Add(Result,'GameOnMouseMove');

        Add(Result,'building_dialog_ok');
      end;
    onInit:
      begin
        call('glInit',[]);
        call('glWndSize', [WndSize[0], WndSize[1]]);
        //call('glMotionBlur', [true, 0.65]);

        //Create Camera
        Camera:=call('glCameraAdd',[]);
        call('glCameraActivate',[Camera]);
        call('glTranslate', [Camera, -14, 10, 0]);

        //Add Lignt Source
        Light:=call('glLightAdd',[]);
        call('glTranslate', [Light, -5000, 5000, 5000]);
        call('glDirection', [Light, 1, -1, 0]);
        call('glLightColor', [Light, mcDiffuse, 1,1,1,1]);
        call('glLightAttenuation', [Light, 0.9, 0, 0]);

        //Init Gui
        call('glGUIStyleLoad', ['Data\GUI\skin\Default.layout']);
        Font:=call('glFontAdd',[]);
        call('glFontName', [Font, 'Courier New']);
        call('glGUIStyleFont', [Font]);
        Skin:=call('glMaterialAdd',['gui']);
        call('glMaterialTextureLoad',[Skin, 'Data\GUI\skin\Default.bmp']);
        call('glMaterialTextureEnable',[Skin, true]);
        call('glGUIStyleMaterial', [Skin]);
        //call('glMaterialBlendingMode', [Skin, bmTransparency]);
        call('glMaterialTextureAlpha', [Skin, tiaSuperBlackTransparent]);

        call('glStart',[]);
      end;
    onDeInit:
      begin
        ShowCursor(true);
      end;
  end;
end;

procedure SendHandles(Procs: array of pointer); stdcall;
begin
  Call:=Procs[0];
  PluginLoad:=Procs[1];
  PluginLoaded:=Procs[2];
end;

exports
  MainProc,
  SendHandles,

  GameInit,
  GameProcess,

  GameOnKeyDown,
  GameOnKeyUp,
  GameOnMouseDown,
  GameOnMouseUp,
  GameOnMouseMove,

  building_dialog_ok;

begin
end.
