[8] | 1 | UNIT Unit1_main;
|
---|
| 2 | INTERFACE
|
---|
| 3 | USES
|
---|
| 4 | Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
---|
| 5 | Dialogs, StdCtrls, StrUtils, Clipbrd, ExtCtrls, ComCtrls, Menus, Grids,
|
---|
| 6 | MPHexEditor, ToolWin, ImgList, Tabs,
|
---|
| 7 | Unit2_functions, Unit3_data, Unit9_data_structures,
|
---|
| 8 | Unit10_leveldb, Unit4_exporters, Unit14_settings,
|
---|
| 9 | Unit5_preview, Unit7_txmpreplace, Unit8_binedit, Unit11_extractor, Unit13_rawedit;
|
---|
| 10 |
|
---|
| 11 | TYPE
|
---|
| 12 | TForm1 = Class(TForm)
|
---|
| 13 | tabs: TTabSet;
|
---|
| 14 | saved: TSaveDialog;
|
---|
| 15 | opend: TOpenDialog;
|
---|
| 16 | statbar: TStatusBar;
|
---|
| 17 | menu: TMainMenu;
|
---|
| 18 | menu_main: TMenuItem;
|
---|
| 19 | menu_loaddat: TMenuItem;
|
---|
| 20 | menu_lvldb: TMenuItem;
|
---|
| 21 | menu_exit: TMenuItem;
|
---|
| 22 | menu_convert: TMenuItem;
|
---|
| 23 | menu_createdb: TMenuItem;
|
---|
| 24 | menu_createlvl: TMenuItem;
|
---|
| 25 | menu_tools: TMenuItem;
|
---|
| 26 | menu_preview: TMenuItem;
|
---|
| 27 | menu_txmpreplace: TMenuItem;
|
---|
| 28 | menu_binedit: TMenuItem;
|
---|
| 29 | menu_extractor: TMenuItem;
|
---|
| 30 | menu_windows: TMenuItem;
|
---|
| 31 | menu_windows_cascade: TMenuItem;
|
---|
| 32 | menu_windows_tile: TMenuItem;
|
---|
| 33 | menu_windows_closeall: TMenuItem;
|
---|
| 34 | menu_windows_next: TMenuItem;
|
---|
| 35 | menu_windows_previous: TMenuItem;
|
---|
| 36 | menu_sep1: TMenuItem;
|
---|
| 37 | menu_sep2: TMenuItem;
|
---|
| 38 | menu_sep3: TMenuItem;
|
---|
| 39 | menu_levelstructedit: TMenuItem;
|
---|
| 40 | menu_rawedit: TMenuItem;
|
---|
| 41 | menu_filecompare: TMenuItem;
|
---|
| 42 | ClosefileDB1: TMenuItem;
|
---|
| 43 | menu_sep4: TMenuItem;
|
---|
| 44 | menu_settings: TMenuItem;
|
---|
| 45 | menu_About: TMenuItem;
|
---|
| 46 | procedure menu_AboutClick(Sender: TObject);
|
---|
| 47 | PROCEDURE menu_settingsClick(Sender: TObject);
|
---|
| 48 | PROCEDURE ClosefileDB1Click(Sender: TObject);
|
---|
| 49 | PROCEDURE menu_filecompareClick(Sender: TObject);
|
---|
| 50 | PROCEDURE menu_raweditClick(Sender: TObject);
|
---|
| 51 | PROCEDURE menu_createlvlClick(Sender: TObject);
|
---|
| 52 | PROCEDURE menu_extractorClick(Sender: TObject);
|
---|
| 53 | PROCEDURE menu_lvldbClick(Sender: TObject);
|
---|
| 54 | PROCEDURE menu_createdbClick(Sender: TObject);
|
---|
| 55 | PROCEDURE SetActiveWindow(window_name:String);
|
---|
| 56 | PROCEDURE tabsChange(Sender: TObject; NewTab: Integer; var AllowChange: Boolean);
|
---|
| 57 | PROCEDURE close_window(window_name:String);
|
---|
| 58 | PROCEDURE menu_windows_previousClick(Sender: TObject);
|
---|
| 59 | PROCEDURE menu_windows_nextClick(Sender: TObject);
|
---|
| 60 | PROCEDURE menu_windows_tileClick(Sender: TObject);
|
---|
| 61 | FUNCTION open_child(window_context:String):Boolean;
|
---|
| 62 | PROCEDURE menu_windows_closeallClick(Sender: TObject);
|
---|
| 63 | PROCEDURE menu_windows_cascadeClick(Sender: TObject);
|
---|
| 64 | PROCEDURE menu_window_entryClick(Sender: TObject);
|
---|
| 65 | PROCEDURE menu_bineditClick(Sender: TObject);
|
---|
| 66 | PROCEDURE menu_loaddatClick(Sender: TObject);
|
---|
| 67 | PROCEDURE menu_txmpreplaceClick(Sender: TObject);
|
---|
| 68 | PROCEDURE menu_exitClick(Sender: TObject);
|
---|
| 69 | PROCEDURE menu_previewClick(Sender: TObject);
|
---|
| 70 | PROCEDURE FormClose(Sender: TObject; var Action: TCloseAction);
|
---|
| 71 | PROCEDURE FormResize(Sender: TObject);
|
---|
| 72 | PROCEDURE FormCreate(Sender: TObject);
|
---|
| 73 | PRIVATE
|
---|
| 74 | PUBLIC
|
---|
| 75 | END;
|
---|
| 76 |
|
---|
| 77 | VAR
|
---|
| 78 | Form1: TForm1;
|
---|
| 79 |
|
---|
| 80 | IMPLEMENTATION
|
---|
| 81 | {$R *.dfm}
|
---|
| 82 | VAR
|
---|
| 83 | tablist:Array OF String;
|
---|
| 84 |
|
---|
| 85 | PROCEDURE TForm1.FormCreate(Sender: TObject);
|
---|
| 86 | BEGIN
|
---|
| 87 | Form1.Caption:='Oni Un/Packer '+version;
|
---|
| 88 | Form1.FormResize(Form1);
|
---|
| 89 |
|
---|
| 90 | IF FileExists(ExtractFilepath(Application.EXEname)+'\oniunpacker.ini') THEN BEGIN
|
---|
| 91 | AssignFile(AppSettingsFile,ExtractFilepath(Application.EXEname)+'\oniunpacker.ini');
|
---|
| 92 | Reset(AppSettingsFile);
|
---|
| 93 | Read(AppSettingsFile,AppSettings);
|
---|
| 94 | CloseFile(AppSettingsFile);
|
---|
| 95 | END ELSE BEGIN
|
---|
| 96 | AppSettings.DatPath:='D:\Spiele\Oni\GameDataFolder';
|
---|
| 97 | AppSettings.ExtractPath:='C:\Dokumente und Einstellungen\Administrator\Desktop';
|
---|
| 98 | END;
|
---|
| 99 |
|
---|
| 100 | IF MidStr(ParamStr(1),1,3)='opf' THEN BEGIN
|
---|
| 101 | ShowMessage('Load OPF-File: '+ParamStr(2));
|
---|
| 102 | END ELSE IF MidStr(ParamStr(1),1,4)='oldb' THEN BEGIN
|
---|
| 103 | OpenDatabase(ParamStr(2));
|
---|
| 104 | IF opened_state=opened_db THEN BEGIN
|
---|
| 105 | menu_tools.Enabled:=True;
|
---|
| 106 | menu_convert.Enabled:=False;
|
---|
| 107 | statbar.Panels.Items[0].Text:='OLDB loaded: '+ParamStr(2);
|
---|
| 108 | statbar.Panels.Items[1].Text:='Files: '+IntToStr(GetFilesCount);
|
---|
| 109 | statbar.Panels.Items[2].Text:='Extensions: '+IntToStr(Length(GetExtensionsList));
|
---|
| 110 | END ELSE BEGIN
|
---|
| 111 | menu_tools.Enabled:=False;
|
---|
| 112 | menu_convert.Enabled:=True;
|
---|
| 113 | END;
|
---|
| 114 | END ELSE IF MidStr(ParamStr(1),1,3)='dat' THEN BEGIN
|
---|
| 115 | IF LoadDatInfos(ParamStr(2)) THEN BEGIN
|
---|
| 116 | Form1.Caption:='Oni Un/Packer '+version+' ('+ExtractFileName(ParamStr(2))+')';
|
---|
| 117 | statbar.Panels.Items[0].Text:='.dat loaded: '+ParamStr(2);
|
---|
| 118 | statbar.Panels.Items[1].Text:='Files: '+IntToStr(dat_header.Files);
|
---|
| 119 | statbar.Panels.Items[2].Text:='Extensions: '+IntToStr(dat_header.Extensions);
|
---|
| 120 | menu_tools.Enabled:=True;
|
---|
| 121 | menu_convert.Enabled:=False;
|
---|
| 122 | END ELSE BEGIN
|
---|
| 123 | menu_convert.Enabled:=True;
|
---|
| 124 | ShowMessage('Error while loading the file:'+CrLf+ParamStr(2)+CrLf+'Perhaps not an Oni-.dat-file?');
|
---|
| 125 | END;
|
---|
| 126 | END;
|
---|
| 127 | END;
|
---|
| 128 |
|
---|
| 129 | PROCEDURE TForm1.FormResize(Sender: TObject);
|
---|
| 130 | CONST
|
---|
| 131 | MinWidth:Integer=750;
|
---|
| 132 | MinHeight:Integer=500;
|
---|
| 133 | BEGIN
|
---|
| 134 | IF Form1.Width<MinWidth THEN Form1.Width:=MinWidth;
|
---|
| 135 | IF Form1.Height<MinHeight THEN Form1.Height:=MinHeight;
|
---|
| 136 | Form1.statbar.Panels.Items[0].Width:=Form1.Width-200;
|
---|
| 137 | END;
|
---|
| 138 |
|
---|
| 139 | PROCEDURE TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
|
---|
| 140 | BEGIN
|
---|
| 141 | AssignFile(AppSettingsFile,ExtractFilepath(Application.EXEname)+'\oniunpacker.ini');
|
---|
| 142 | IF FileExists(ExtractFilepath(Application.EXEname)+'\oniunpacker.ini') THEN
|
---|
| 143 | Reset(AppSettingsFile)
|
---|
| 144 | ELSE
|
---|
| 145 | Rewrite(AppSettingsFile);
|
---|
| 146 | Write(AppSettingsFile,AppSettings);
|
---|
| 147 | CloseFile(AppSettingsFile);
|
---|
| 148 | Action:=caFree;
|
---|
| 149 | END;
|
---|
| 150 |
|
---|
| 151 |
|
---|
| 152 | {#################################}
|
---|
| 153 | {##### Main-Menu-Handlers #####}
|
---|
| 154 | {#################################}
|
---|
| 155 | PROCEDURE TForm1.menu_loaddatClick(Sender: TObject);
|
---|
| 156 | VAR i:LongWord;
|
---|
| 157 | BEGIN
|
---|
| 158 | opend.InitialDir:=AppSettings.DatPath;
|
---|
| 159 | opend.Filter:='Oni-Dat-Files|*.dat';
|
---|
| 160 | IF opend.Execute THEN BEGIN
|
---|
| 161 | menu_windows_closeallClick(Form1);
|
---|
| 162 | IF Length(tablist)=0 THEN BEGIN
|
---|
| 163 | IF opened_state=opened_db THEN CloseDatabase;
|
---|
| 164 | Caption:='Oni Un/Packer '+version;
|
---|
| 165 | statbar.Panels.Items[0].Text:='Nothing loaded';
|
---|
| 166 | statbar.Panels.Items[1].Text:='Files: -';
|
---|
| 167 | statbar.Panels.Items[2].Text:='Extensions: -';
|
---|
| 168 | AppSettings.DatPath:=ExtractFilepath(opend.FileName);
|
---|
| 169 | IF LoadDatInfos(opend.FileName) THEN BEGIN
|
---|
| 170 | Form1.Caption:='Oni Un/Packer '+version+' ('+ExtractFileName(opend.FileName)+')';
|
---|
| 171 | statbar.Panels.Items[0].Text:='.dat loaded: '+dat_FileName;
|
---|
| 172 | statbar.Panels.Items[1].Text:='Files: '+IntToStr(dat_header.Files);
|
---|
| 173 | statbar.Panels.Items[2].Text:='Extensions: '+IntToStr(dat_header.Extensions);
|
---|
| 174 | menu_tools.Enabled:=True;
|
---|
| 175 | menu_convert.Enabled:=False;
|
---|
| 176 | END ELSE BEGIN
|
---|
| 177 | menu_convert.Enabled:=True;
|
---|
| 178 | ShowMessage('Error while loading the file:'+CrLf+opend.FileName+CrLf+'Perhaps not an Oni-.dat-file?');
|
---|
| 179 | END;
|
---|
| 180 | END;
|
---|
| 181 | END;
|
---|
| 182 | END;
|
---|
| 183 | PROCEDURE TForm1.menu_lvldbClick(Sender: TObject);
|
---|
| 184 | BEGIN
|
---|
| 185 | opend.InitialDir:=AppSettings.DatPath;
|
---|
| 186 | opend.Filter:='OUP-Level-DB (*.oldb)|*.oldb';
|
---|
| 187 | IF opend.Execute THEN BEGIN
|
---|
| 188 | menu_windows_closeallClick(Form1);
|
---|
| 189 | IF Length(tablist)=0 THEN BEGIN
|
---|
| 190 | IF opened_state=opened_db THEN CloseDatabase;
|
---|
| 191 | Form1.Caption:='Oni Un/Packer '+version;
|
---|
| 192 | opened_state:=opened_nothing;
|
---|
| 193 | statbar.Panels.Items[0].Text:='Nothing loaded';
|
---|
| 194 | statbar.Panels.Items[1].Text:='Files: -';
|
---|
| 195 | statbar.Panels.Items[2].Text:='Extensions: -';
|
---|
| 196 | OpenDatabase(opend.FileName);
|
---|
| 197 | IF opened_state=opened_db THEN BEGIN
|
---|
| 198 | menu_tools.Enabled:=True;
|
---|
| 199 | menu_convert.Enabled:=False;
|
---|
| 200 | statbar.Panels.Items[0].Text:='OLDB loaded: '+opend.FileName;
|
---|
| 201 | statbar.Panels.Items[1].Text:='Files: '+IntToStr(GetFilesCount);
|
---|
| 202 | statbar.Panels.Items[2].Text:='Extensions: '+IntToStr(Length(GetExtensionsList));
|
---|
| 203 | END ELSE BEGIN
|
---|
| 204 | menu_tools.Enabled:=False;
|
---|
| 205 | menu_convert.Enabled:=True;
|
---|
| 206 | END;
|
---|
| 207 | END;
|
---|
| 208 | END;
|
---|
| 209 | END;
|
---|
| 210 | PROCEDURE TForm1.ClosefileDB1Click(Sender: TObject);
|
---|
| 211 | BEGIN
|
---|
| 212 | menu_windows_closeallClick(Form1);
|
---|
| 213 | IF Length(tablist)=0 THEN BEGIN
|
---|
| 214 | IF opened_state=opened_db THEN CloseDatabase;
|
---|
| 215 | Form1.Caption:='Oni Un/Packer '+version;
|
---|
| 216 | opened_state:=opened_nothing;
|
---|
| 217 | statbar.Panels.Items[0].Text:='Nothing loaded';
|
---|
| 218 | statbar.Panels.Items[1].Text:='Files: -';
|
---|
| 219 | statbar.Panels.Items[2].Text:='Extensions: -';
|
---|
| 220 | menu_tools.Enabled:=False;
|
---|
| 221 | menu_convert.Enabled:=True;
|
---|
| 222 | END;
|
---|
| 223 | END;
|
---|
| 224 | PROCEDURE TForm1.menu_settingsClick(Sender: TObject);
|
---|
| 225 | BEGIN
|
---|
| 226 | Form14.Visible:=True;
|
---|
| 227 | Self.Enabled:=False;
|
---|
| 228 | END;
|
---|
| 229 | PROCEDURE TForm1.menu_exitClick(Sender: TObject);
|
---|
| 230 | BEGIN
|
---|
| 231 | Form1.Close;
|
---|
| 232 | END;
|
---|
| 233 |
|
---|
| 234 | {####################################}
|
---|
| 235 | {##### Converters-Menu-Handlers #####}
|
---|
| 236 | {####################################}
|
---|
| 237 | PROCEDURE TForm1.menu_createdbClick(Sender: TObject);
|
---|
| 238 | BEGIN
|
---|
| 239 | opend.Filter:='Oni-Dat-Files|*.dat';
|
---|
| 240 | saved.Filter:='OUP-Level-DB (*.oldb)|*.oldb';
|
---|
| 241 | saved.DefaultExt:='oldb';
|
---|
| 242 | IF opend.Execute THEN BEGIN
|
---|
| 243 | IF saved.Execute THEN BEGIN
|
---|
| 244 | Form10.CreateDatabase(opend.FileName,saved.FileName);
|
---|
| 245 | END;
|
---|
| 246 | END;
|
---|
| 247 | END;
|
---|
| 248 | PROCEDURE TForm1.menu_createlvlClick(Sender: TObject);
|
---|
| 249 | BEGIN
|
---|
| 250 | opend.Filter:='OUP-Level-DB (*.oldb)|*.oldb';
|
---|
| 251 | saved.Filter:='Oni-Dat-Files|*.dat';
|
---|
| 252 | saved.DefaultExt:='dat';
|
---|
| 253 | IF opend.Execute THEN BEGIN
|
---|
| 254 | IF saved.Execute THEN BEGIN
|
---|
| 255 | Form10.CreateLevel(opend.FileName,saved.FileName);
|
---|
| 256 | END;
|
---|
| 257 | END;
|
---|
| 258 | END;
|
---|
| 259 |
|
---|
| 260 | {#################################}
|
---|
| 261 | {##### Tools-Menu-Handlers #####}
|
---|
| 262 | {#################################}
|
---|
| 263 | PROCEDURE TForm1.menu_previewClick(Sender: TObject);
|
---|
| 264 | BEGIN
|
---|
| 265 | open_child('preview');
|
---|
| 266 | END;
|
---|
| 267 | PROCEDURE TForm1.menu_txmpreplaceClick(Sender: TObject);
|
---|
| 268 | BEGIN
|
---|
| 269 | open_child('txmpreplace');
|
---|
| 270 | END;
|
---|
| 271 | PROCEDURE TForm1.menu_bineditClick(Sender: TObject);
|
---|
| 272 | BEGIN
|
---|
| 273 | open_child('binedit');
|
---|
| 274 | END;
|
---|
| 275 | PROCEDURE TForm1.menu_raweditClick(Sender: TObject);
|
---|
| 276 | BEGIN
|
---|
| 277 | open_child('rawedit');
|
---|
| 278 | END;
|
---|
| 279 |
|
---|
| 280 | PROCEDURE TForm1.menu_extractorClick(Sender: TObject);
|
---|
| 281 | BEGIN
|
---|
| 282 | open_child('extractor');
|
---|
| 283 | END;
|
---|
| 284 | PROCEDURE TForm1.menu_filecompareClick(Sender: TObject);
|
---|
| 285 | BEGIN
|
---|
| 286 | open_child('compare');
|
---|
| 287 | END;
|
---|
| 288 |
|
---|
| 289 |
|
---|
| 290 | {#################################}
|
---|
| 291 | {##### Window-Menu-Handlers #####}
|
---|
| 292 | {#################################}
|
---|
| 293 | PROCEDURE TForm1.menu_windows_cascadeClick(Sender: TObject);
|
---|
| 294 | BEGIN
|
---|
| 295 | Form1.Cascade;
|
---|
| 296 | END;
|
---|
| 297 | PROCEDURE TForm1.menu_windows_tileClick(Sender: TObject);
|
---|
| 298 | BEGIN
|
---|
| 299 | Form1.TileMode:=tbHorizontal;
|
---|
| 300 | Form1.Tile;
|
---|
| 301 | END;
|
---|
| 302 | PROCEDURE TForm1.menu_windows_closeallClick(Sender: TObject);
|
---|
| 303 | VAR
|
---|
| 304 | i:Byte;
|
---|
| 305 | BEGIN
|
---|
| 306 | IF MDIChildCount>0 THEN BEGIN
|
---|
| 307 | FOR i:=0 TO MDIChildCount-1 DO BEGIN
|
---|
| 308 | MDIChildren[i].Close;
|
---|
| 309 | END;
|
---|
| 310 | END;
|
---|
| 311 | tabs.Tabs.Clear;
|
---|
| 312 | END;
|
---|
| 313 | PROCEDURE TForm1.menu_windows_nextClick(Sender: TObject);
|
---|
| 314 | VAR i:Byte;
|
---|
| 315 | first_window:Byte;
|
---|
| 316 | current_focus:String;
|
---|
| 317 | BEGIN
|
---|
| 318 | IF MDIChildCount>1 THEN BEGIN
|
---|
| 319 | FOR i:=0 TO menu_windows.Count-1 DO BEGIN
|
---|
| 320 | IF Pos('menu_window_',menu_windows.Items[i].Name)=1 THEN BEGIN
|
---|
| 321 | first_window:=i;
|
---|
| 322 | Break;
|
---|
| 323 | END;
|
---|
| 324 | END;
|
---|
| 325 | current_focus:=ActiveMDIChild.Name;
|
---|
| 326 | FOR i:=first_window TO menu_windows.Count-1 DO
|
---|
| 327 | IF Pos(current_focus,menu_windows.Items[i].Name)>0 THEN
|
---|
| 328 | Break;
|
---|
| 329 | IF i=menu_windows.Count-1 THEN
|
---|
| 330 | menu_windows.Items[first_window].Click
|
---|
| 331 | ELSE
|
---|
| 332 | menu_windows.Items[i+1].Click;
|
---|
| 333 | FOR i:=0 TO High(tablist) DO BEGIN
|
---|
| 334 | IF tablist[i]=ActiveMDIChild.Name THEN BEGIN
|
---|
| 335 | tabs.TabIndex:=i;
|
---|
| 336 | END;
|
---|
| 337 | END;
|
---|
| 338 | END;
|
---|
| 339 | END;
|
---|
| 340 | PROCEDURE TForm1.menu_windows_previousClick(Sender: TObject);
|
---|
| 341 | VAR i:Byte;
|
---|
| 342 | first_window:Byte;
|
---|
| 343 | current_focus:String;
|
---|
| 344 | BEGIN
|
---|
| 345 | IF MDIChildCount>1 THEN BEGIN
|
---|
| 346 | FOR i:=0 TO menu_windows.Count-1 DO BEGIN
|
---|
| 347 | IF Pos('menu_window_',menu_windows.Items[i].Name)=1 THEN BEGIN
|
---|
| 348 | first_window:=i;
|
---|
| 349 | Break;
|
---|
| 350 | END;
|
---|
| 351 | END;
|
---|
| 352 | current_focus:=ActiveMDIChild.Name;
|
---|
| 353 | FOR i:=first_window TO menu_windows.Count-1 DO
|
---|
| 354 | IF Pos(current_focus,menu_windows.Items[i].Name)>0 THEN
|
---|
| 355 | Break;
|
---|
| 356 | IF i=first_window THEN
|
---|
| 357 | menu_windows.Items[menu_windows.Count-1].Click
|
---|
| 358 | ELSE
|
---|
| 359 | menu_windows.Items[i-1].Click;
|
---|
| 360 | FOR i:=0 TO High(tablist) DO BEGIN
|
---|
| 361 | IF tablist[i]=ActiveMDIChild.Name THEN BEGIN
|
---|
| 362 | tabs.TabIndex:=i;
|
---|
| 363 | END;
|
---|
| 364 | END;
|
---|
| 365 | END;
|
---|
| 366 | END;
|
---|
| 367 |
|
---|
| 368 | PROCEDURE TForm1.menu_window_entryClick(Sender: TObject);
|
---|
| 369 | VAR
|
---|
| 370 | i:Byte;
|
---|
| 371 | window_name:String;
|
---|
| 372 | BEGIN
|
---|
| 373 | window_name:=MidStr(TComponent(Sender).Name,Pos('window_',TComponent(Sender).Name)+7,Length(TComponent(Sender).Name)-Pos('window_',TComponent(Sender).Name)+7+1);
|
---|
| 374 | FOR i:=0 TO MDIChildCount-1 DO BEGIN
|
---|
| 375 | IF MDIChildren[i].Name=window_name THEN BEGIN
|
---|
| 376 | MDIChildren[i].BringToFront;
|
---|
| 377 | END;
|
---|
| 378 | END;
|
---|
| 379 | FOR i:=0 TO High(tablist) DO BEGIN
|
---|
| 380 | IF tablist[i]=ActiveMDIChild.Name THEN BEGIN
|
---|
| 381 | tabs.TabIndex:=i;
|
---|
| 382 | END;
|
---|
| 383 | END;
|
---|
| 384 | END;
|
---|
| 385 |
|
---|
| 386 | procedure TForm1.menu_AboutClick(Sender: TObject);
|
---|
| 387 | begin
|
---|
| 388 | ShowMessage('Will be implemented later ;)');
|
---|
| 389 | end;
|
---|
| 390 |
|
---|
| 391 |
|
---|
| 392 |
|
---|
| 393 |
|
---|
| 394 | FUNCTION TForm1.open_child(window_context:String):Boolean;
|
---|
| 395 | VAR
|
---|
| 396 | rawEdit:TForm13;
|
---|
| 397 | binEdit:TForm8;
|
---|
| 398 | preview:TForm5;
|
---|
| 399 | txmpreplacer:TForm7;
|
---|
| 400 | extractor:TForm11;
|
---|
| 401 | menu_button:TMenuItem;
|
---|
| 402 | used:Array[1..9] OF Boolean;
|
---|
| 403 | i:Byte;
|
---|
| 404 | caption:String;
|
---|
| 405 | name:String;
|
---|
| 406 | BEGIN
|
---|
| 407 | Result:=True;
|
---|
| 408 | FOR i:=1 TO 9 DO used[i]:=False;
|
---|
| 409 | IF MDIChildCount>0 THEN
|
---|
| 410 | FOR i:=0 TO MDIChildCount-1 DO
|
---|
| 411 | IF Pos(window_context,Form1.MDIChildren[i].Name)=1 THEN
|
---|
| 412 | used[StrToInt(RightStr(Form1.MDIChildren[i].Caption,1))]:=True;
|
---|
| 413 | FOR i:=1 TO 10 DO
|
---|
| 414 | IF i=10 THEN
|
---|
| 415 | Break
|
---|
| 416 | ELSE
|
---|
| 417 | IF NOT used[i] THEN Break;
|
---|
| 418 |
|
---|
| 419 | IF i<10 THEN BEGIN
|
---|
| 420 | name:=window_context+IntToStr(i);
|
---|
| 421 | IF window_context='binedit' THEN
|
---|
| 422 | caption:='Binary .dat-Editor '+IntToStr(i);
|
---|
| 423 | IF window_context='rawedit' THEN
|
---|
| 424 | caption:='Binary .raw-Editor '+IntToStr(i);
|
---|
| 425 | IF window_context='preview' THEN
|
---|
| 426 | caption:='Preview-Window '+IntToStr(i);
|
---|
| 427 | IF window_context='txmpreplace' THEN
|
---|
| 428 | caption:='TXMP Replacer '+IntToStr(i);
|
---|
| 429 | IF window_context='extractor' THEN
|
---|
| 430 | caption:='Extractor '+IntToStr(i);
|
---|
| 431 |
|
---|
| 432 | menu_button:=TMenuItem.Create(menu_windows);
|
---|
| 433 | menu_button.Caption:=caption;
|
---|
| 434 | menu_button.Name:='menu_window_'+name;
|
---|
| 435 | menu_button.OnClick:=Form1.menu_window_entryClick;
|
---|
| 436 | menu_windows.Add(menu_button);
|
---|
| 437 |
|
---|
| 438 | SetLength(tablist,Length(tablist)+1);
|
---|
| 439 | tablist[High(tablist)]:=name;
|
---|
| 440 | tabs.Tabs.Add(caption);
|
---|
| 441 |
|
---|
| 442 | IF window_context='binedit' THEN BEGIN
|
---|
| 443 | binEdit:=TForm8.Create(Application);
|
---|
| 444 | binEdit.Name:=name;
|
---|
| 445 | binEdit.Caption:=caption;
|
---|
| 446 | binEdit.Recreatelist;
|
---|
| 447 | END;
|
---|
| 448 | IF window_context='rawedit' THEN BEGIN
|
---|
| 449 | rawEdit:=TForm13.Create(Application);
|
---|
| 450 | rawEdit.Name:=name;
|
---|
| 451 | rawEdit.Caption:=caption;
|
---|
| 452 | rawEdit.Recreatelist;
|
---|
| 453 | END;
|
---|
| 454 | IF window_context='preview' THEN BEGIN
|
---|
| 455 | preview:=TForm5.Create(Application);
|
---|
| 456 | preview.Name:=name;
|
---|
| 457 | preview.Caption:=caption;
|
---|
| 458 | preview.Recreatelist;
|
---|
| 459 | END;
|
---|
| 460 | IF window_context='txmpreplace' THEN BEGIN
|
---|
| 461 | txmpreplacer:=TForm7.Create(Application);
|
---|
| 462 | txmpreplacer.Name:=name;
|
---|
| 463 | txmpreplacer.Caption:=caption;
|
---|
| 464 | txmpreplacer.Recreatelist;
|
---|
| 465 | END;
|
---|
| 466 | IF window_context='extractor' THEN BEGIN
|
---|
| 467 | extractor:=TForm11.Create(Application);
|
---|
| 468 | extractor.Name:=name;
|
---|
| 469 | extractor.Caption:=caption;
|
---|
| 470 | extractor.Recreatelist;
|
---|
| 471 | END;
|
---|
| 472 |
|
---|
| 473 | tabs.TabIndex:=High(tablist);
|
---|
| 474 | IF MDIChildCount=9 THEN menu_tools.Enabled:=False;
|
---|
| 475 | END ELSE BEGIN
|
---|
| 476 | Result:=False;
|
---|
| 477 | END;
|
---|
| 478 | END;
|
---|
| 479 |
|
---|
| 480 |
|
---|
| 481 | PROCEDURE TForm1.close_window(window_name:String);
|
---|
| 482 | VAR
|
---|
| 483 | i,j:Byte;
|
---|
| 484 | BEGIN
|
---|
| 485 | FOR i:=0 TO menu_windows.Count-1 DO BEGIN
|
---|
| 486 | IF menu_windows.Items[i].Name='menu_window_'+window_name THEN BEGIN
|
---|
| 487 | menu_windows.Items[i].Free;
|
---|
| 488 | Break;
|
---|
| 489 | END;
|
---|
| 490 | END;
|
---|
| 491 | FOR i:=0 TO High(tablist) DO BEGIN
|
---|
| 492 | IF tablist[i]=window_name THEN BEGIN
|
---|
| 493 | tabs.Tabs.Delete(i);
|
---|
| 494 | IF High(tablist)>0 THEN
|
---|
| 495 | FOR j:=i TO High(tablist)-1 DO
|
---|
| 496 | tablist[j]:=tablist[j+1];
|
---|
| 497 | SetLength(tablist,Length(tablist)-1);
|
---|
| 498 | Break;
|
---|
| 499 | END;
|
---|
| 500 | END;
|
---|
| 501 | menu_tools.Enabled:=True;
|
---|
| 502 | END;
|
---|
| 503 |
|
---|
| 504 |
|
---|
| 505 | PROCEDURE TForm1.tabsChange(Sender: TObject; NewTab: Integer; var AllowChange: Boolean);
|
---|
| 506 | VAR
|
---|
| 507 | i:Byte;
|
---|
| 508 | BEGIN
|
---|
| 509 | FOR i:=0 TO MDIChildCount-1 DO BEGIN
|
---|
| 510 | IF MDIChildren[i].Name=tablist[NewTab] THEN
|
---|
| 511 | MDIChildren[i].BringToFront;
|
---|
| 512 | END;
|
---|
| 513 | END;
|
---|
| 514 |
|
---|
| 515 | PROCEDURE TForm1.SetActiveWindow(window_name:String);
|
---|
| 516 | VAR
|
---|
| 517 | i:Byte;
|
---|
| 518 | BEGIN
|
---|
| 519 | IF Length(tablist)>0 THEN
|
---|
| 520 | FOR i:=0 TO High(tablist) DO
|
---|
| 521 | IF tablist[i]=window_name THEN
|
---|
| 522 | tabs.TabIndex:=i;
|
---|
| 523 | END;
|
---|
| 524 |
|
---|
| 525 |
|
---|
| 526 | END.
|
---|