Subversion Repositories spacemission

Rev

Rev 51 | Rev 61 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 daniel-mar 1
unit Global;
2
 
3
interface
4
 
5
const
28 daniel-mar 6
  ProgramVersion = '1.2';
31 daniel-mar 7
  RasterW = 48;
8
  RasterH = 32;
40 daniel-mar 9
  MaxPossibleEnemyLives = 999;
10
  MaxPossibleLevels = 9999;
47 daniel-mar 11
  RegistrySettingsKey = 'SOFTWARE\ViaThinkSoft\SpaceMission\Settings';
51 daniel-mar 12
  DefaultLevelLength = 1200;
54 daniel-mar 13
  StartLives = 6;
14
  conleicht =  650 div 60; // 10
15
  conmittel = 1000 div 60; // 16
16
  conschwer = 1350 div 60; // 22
17
  conmaster = 2000 div 60; // 33
18
  DEFAULT_ANIMSPEED = 15/1000;
19
  ADDITIONAL_ENEMIES_PER_LEVEL = 75;
2 daniel-mar 20
 
31 daniel-mar 21
type
22
  // DirectX\Music.dxm
23
  TSpaceMissionMusicTrack = (
24
    smmNone,
25
    smmBoss,   // dxmusic.Midis[0]
26
    smmGame,   // dxmusic.Midis[1]
27
    smmScene,  // dxmusic.Midis[2]
28
    smmTitle   // dxmusic.Midis[3]
29
  );
30
 
31
  // DirectX\Graphics.dxg
32
  TSpaceMissionGraphicSprite = (
34 daniel-mar 33
    smgNone,
34
    smgEnemyDisk,         // ImageList.Items.Item[0]
35
    smgEnemyAttacker,     // ImageList.Items.Item[1]
36
    smgEnemyBoss,         // ImageList.Items.Item[2]
37
    smgBounce,            // ImageList.Items.Item[3]
38
    smgMachine,           // ImageList.Items.Item[4]
39
    smgEnemyAttacker2,    // ImageList.Items.Item[5]
40
    smgEnemyAttacker3,    // ImageList.Items.Item[6]
41
    smgEnemyMeteor,       // ImageList.Items.Item[7]
42
    smgBounce2,           // ImageList.Items.Item[8]
43
    smgEnemyDisk2,        // ImageList.Items.Item[9]
44
    smgLogo,              // ImageList.Items.Item[10]
45
    smgExplosion,         // ImageList.Items.Item[11]
46
    smgBackgroundPlanet1, // ImageList.Items.Item[12]
47
    smgMatrix,            // ImageList.Items.Item[13]
48
    smgStar1,             // ImageList.Items.Item[14]
49
    smgStar2,             // ImageList.Items.Item[15]
50
    smgStar3,             // ImageList.Items.Item[16]
51
    smgBackgroundBlue,    // ImageList.Items.Item[17]
52
    smgBackgroundRed,     // ImageList.Items.Item[18]
53
    smgBackgroundYellow,  // ImageList.Items.Item[19]
54
    smgHintergrundRot     // ImageList.Items.Item[20]
31 daniel-mar 55
  );
56
 
57
  // DirectX\Sound.dxw
58
  TSpaceMissionSound = (
59
    smsNone,
60
    smsSceneMov,      // WaveList.Items.Item[0]
61
    smsExplosion,     // WaveList.Items.Item[1]
62
    smsHit,           // WaveList.Items.Item[2]
63
    smsShoot,         // WaveList.Items.Item[3]
64
    smsDanger,        // WaveList.Items.Item[4]
65
    smsEnde,          // WaveList.Items.Item[5]
66
    smsFrage,         // WaveList.Items.Item[6]
67
    smsLevIntro       // WaveList.Items.Item[7]
68
  );
69
 
70
function OwnDirectory: string;
71
 
51 daniel-mar 72
const
73
  FOLDERID_SavedGames: TGuid = '{4C5C32FF-BB9D-43b0-B5B4-2D72E54EAAA4}';
74
 
54 daniel-mar 75
// Useful functions
51 daniel-mar 76
function GetKnownFolderPath(const rfid: TGUID): string;
54 daniel-mar 77
function KillTask(ExeFileName: string): Integer;
51 daniel-mar 78
 
2 daniel-mar 79
implementation
80
 
81
uses
54 daniel-mar 82
  Windows, SysUtils, ActiveX, ShlObj, TlHelp32;
2 daniel-mar 83
 
51 daniel-mar 84
function GetKnownFolderPath(const rfid: TGUID): string;
85
var
86
  OutPath: PWideChar;
87
begin
88
  // https://www.delphipraxis.net/135471-unit-zur-verwendung-von-shgetknownfolderpath.html
89
  if ShGetKnownFolderPath(rfid, 0, 0, OutPath) {>= 0} = S_OK then
90
  begin
91
    Result := OutPath;
92
    // From MSDN
93
    // ppszPath [out]
94
    // Type: PWSTR*
95
    // When this method returns, contains the address of a pointer to a null-terminated Unicode string that specifies the path of the known folder
96
    // The calling process is responsible for freeing this resource once it is no longer needed by calling CoTaskMemFree.
97
    // The returned path does not include a trailing backslash. For example, "C:\Users" is returned rather than "C:\Users\".
98
    CoTaskMemFree(OutPath);
99
  end
100
  else
101
  begin
102
    Result := '';
103
  end;
104
end;
105
 
54 daniel-mar 106
// https://stackoverflow.com/questions/43774320/how-to-kill-a-process-by-name
107
function KillTask(ExeFileName: string): Integer;
108
const
109
  PROCESS_TERMINATE = $0001;
110
var
111
  ContinueLoop: BOOL;
112
  FSnapshotHandle: THandle;
113
  FProcessEntry32: TProcessEntry32;
114
begin
115
  Result := 0;
116
  FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
117
  FProcessEntry32.dwSize := SizeOf(FProcessEntry32);
118
  ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32);
119
 
120
  while Integer(ContinueLoop) <> 0 do
121
  begin
122
    if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile)) =
123
      UpperCase(ExeFileName)) or (UpperCase(FProcessEntry32.szExeFile) =
124
      UpperCase(ExeFileName))) then
125
      Result := Integer(TerminateProcess(
126
                        OpenProcess(PROCESS_TERMINATE,
127
                                    BOOL(0),
128
                                    FProcessEntry32.th32ProcessID),
129
                                    0));
130
     ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32);
131
  end;
132
  CloseHandle(FSnapshotHandle);
133
end;
134
 
31 daniel-mar 135
function OwnDirectory: string;
2 daniel-mar 136
begin
137
  result := extractfilepath(paramstr(0));
138
end;
139
 
140
end.