[43] | 1 | unit Main;
|
---|
| 2 |
|
---|
| 3 | interface
|
---|
| 4 |
|
---|
| 5 | uses
|
---|
| 6 | Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
---|
| 7 | Dialogs, StdCtrls, StrUtils, Clipbrd, ExtCtrls, ComCtrls, Menus, Grids,
|
---|
| 8 | MPHexEditor, ToolWin, ImgList, Tabs,
|
---|
[45] | 9 | MDITab, TB2Item, TB2Dock, TB2Toolbar, TB2MDI,
|
---|
[46] | 10 | Data, Functions, DataStructures, OniDataClass, Exporters,
|
---|
| 11 | Helper_LevelDB, Settings, Template,
|
---|
| 12 | BinEdit, Extractor, Preview, RawEdit, TxmpReplace;
|
---|
[43] | 13 |
|
---|
| 14 | type
|
---|
| 15 | TForm_Main = class(TForm)
|
---|
| 16 | saved: TSaveDialog;
|
---|
| 17 | opend: TOpenDialog;
|
---|
| 18 | statbar: TStatusBar;
|
---|
| 19 | MenuImages: TImageList;
|
---|
| 20 | DockTop: TTBDock;
|
---|
| 21 | MainMenu: TTBToolbar;
|
---|
| 22 | menu_main: TTBSubmenuItem;
|
---|
| 23 | menu_loadfile: TTBItem;
|
---|
| 24 | menu_sep1: TTBSeparatorItem;
|
---|
| 25 | menu_settings: TTBItem;
|
---|
| 26 | menu_sep4: TTBSeparatorItem;
|
---|
| 27 | menu_exit: TTBItem;
|
---|
| 28 | menu_convert: TTBSubmenuItem;
|
---|
| 29 | menu_createdb: TTBItem;
|
---|
| 30 | menu_createlvl: TTBItem;
|
---|
| 31 | menu_tools: TTBSubmenuItem;
|
---|
| 32 | menu_preview: TTBItem;
|
---|
| 33 | menu_binedit: TTBItem;
|
---|
| 34 | menu_rawedit: TTBItem;
|
---|
| 35 | menu_txmpreplace: TTBItem;
|
---|
| 36 | menu_extractor: TTBItem;
|
---|
| 37 | menu_filecompare: TTBItem;
|
---|
| 38 | menu_levelstructedit: TTBItem;
|
---|
| 39 | menu_windows: TTBSubmenuItem;
|
---|
| 40 | menu_windows_cascade: TTBItem;
|
---|
| 41 | menu_windows_tile: TTBItem;
|
---|
| 42 | menu_windows_closeall: TTBItem;
|
---|
| 43 | menu_sep3: TTBSeparatorItem;
|
---|
| 44 | menu_windows_next: TTBItem;
|
---|
| 45 | menu_windows_previous: TTBItem;
|
---|
| 46 | menu_sep2: TTBSeparatorItem;
|
---|
| 47 | menu_About: TTBItem;
|
---|
| 48 | Toolbar: TTBToolbar;
|
---|
| 49 | tbOpen: TTBItem;
|
---|
| 50 | DockLeft: TTBDock;
|
---|
| 51 | DockRight: TTBDock;
|
---|
| 52 | DockBottom: TTBDock;
|
---|
| 53 | MDIToolbar: TTBToolbar;
|
---|
| 54 | TBControlItem1: TTBControlItem;
|
---|
| 55 | MDITab: TMDITab;
|
---|
| 56 | menu_view: TTBSubmenuItem;
|
---|
| 57 | menu_view_mdibar: TTBItem;
|
---|
| 58 | menu_view_statusbar: TTBItem;
|
---|
| 59 | menu_view_toolbar: TTBItem;
|
---|
| 60 | tb_separator1: TTBSeparatorItem;
|
---|
| 61 | tb_preview: TTBItem;
|
---|
| 62 | tb_structure: TTBItem;
|
---|
| 63 | tb_compare: TTBItem;
|
---|
| 64 | tb_extractor: TTBItem;
|
---|
| 65 | tb_txmpreplacer: TTBItem;
|
---|
| 66 | tb_rawedit: TTBItem;
|
---|
| 67 | tb_datedit: TTBItem;
|
---|
[46] | 68 | menu_windows_tilevert: TTBItem;
|
---|
[43] | 69 | function TryCloseAll: Boolean;
|
---|
| 70 | procedure menu_AboutClick(Sender: TObject);
|
---|
| 71 | procedure menu_settingsClick(Sender: TObject);
|
---|
| 72 | procedure menu_filecompareClick(Sender: TObject);
|
---|
| 73 | procedure menu_raweditClick(Sender: TObject);
|
---|
| 74 | procedure menu_createlvlClick(Sender: TObject);
|
---|
| 75 | procedure menu_extractorClick(Sender: TObject);
|
---|
| 76 | procedure menu_createdbClick(Sender: TObject);
|
---|
| 77 | procedure menu_windows_previousClick(Sender: TObject);
|
---|
| 78 | procedure menu_windows_nextClick(Sender: TObject);
|
---|
| 79 | procedure menu_windows_tileClick(Sender: TObject);
|
---|
[46] | 80 | function open_child(window_context: String; fileid: Integer): TForm_ToolTemplate;
|
---|
[43] | 81 | procedure menu_windows_closeallClick(Sender: TObject);
|
---|
| 82 | procedure menu_windows_cascadeClick(Sender: TObject);
|
---|
| 83 | procedure menu_bineditClick(Sender: TObject);
|
---|
| 84 | procedure menu_loadfileClick(Sender: TObject);
|
---|
| 85 | procedure menu_txmpreplaceClick(Sender: TObject);
|
---|
| 86 | procedure menu_exitClick(Sender: TObject);
|
---|
| 87 | procedure menu_previewClick(Sender: TObject);
|
---|
| 88 | procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
---|
| 89 | procedure FormResize(Sender: TObject);
|
---|
| 90 | procedure FormCreate(Sender: TObject);
|
---|
| 91 | procedure UpdateStatBar;
|
---|
| 92 | procedure menu_view_mdibarClick(Sender: TObject);
|
---|
| 93 | procedure menu_view_statusbarClick(Sender: TObject);
|
---|
| 94 | procedure menu_view_toolbarClick(Sender: TObject);
|
---|
| 95 | procedure MDITabDrawTab(Control: TCustomTabControl; TabIndex: Integer;
|
---|
| 96 | const Rect: TRect; Active: Boolean);
|
---|
| 97 | procedure ActivateTools(active: Boolean);
|
---|
| 98 | procedure MDITabMouseUp(Sender: TObject; Button: TMouseButton;
|
---|
| 99 | Shift: TShiftState; X, Y: Integer);
|
---|
[46] | 100 | procedure menu_windows_tilevertClick(Sender: TObject);
|
---|
[43] | 101 | private
|
---|
| 102 | public
|
---|
| 103 | end;
|
---|
| 104 |
|
---|
| 105 | var
|
---|
| 106 | Form_Main: TForm_Main;
|
---|
| 107 |
|
---|
| 108 | implementation
|
---|
| 109 |
|
---|
| 110 | {$R *.dfm}
|
---|
| 111 |
|
---|
| 112 |
|
---|
| 113 |
|
---|
| 114 | procedure TForm_Main.FormCreate(Sender: TObject);
|
---|
| 115 | begin
|
---|
| 116 | Self.Caption := 'Oni Un/Packer ' + version;
|
---|
| 117 | Self.FormResize(Self);
|
---|
| 118 |
|
---|
| 119 | if FileExists(ExtractFilepath(Application.EXEname) + '\oniunpacker.ini') then
|
---|
| 120 | begin
|
---|
| 121 | AssignFile(AppSettingsFile, ExtractFilepath(Application.EXEname) +
|
---|
| 122 | '\oniunpacker.ini');
|
---|
| 123 | Reset(AppSettingsFile);
|
---|
| 124 | Read(AppSettingsFile, AppSettings);
|
---|
| 125 | CloseFile(AppSettingsFile);
|
---|
| 126 | end
|
---|
| 127 | else
|
---|
| 128 | begin
|
---|
| 129 | AppSettings.DatPath := 'D:\Spiele\Oni\GameDataFolder';
|
---|
| 130 | AppSettings.ExtractPath := 'C:\Dokumente und Einstellungen\Administrator\Desktop';
|
---|
| 131 | AppSettings.FilenumbersAsHex := False;
|
---|
| 132 | AppSettings.CharSet := DEFAULT_CHARSET;
|
---|
| 133 | AppSettings.HideUnusedData := False;
|
---|
| 134 | end;
|
---|
| 135 |
|
---|
| 136 | if MidStr(ParamStr(1), 1, 3) = 'opf' then
|
---|
| 137 | begin
|
---|
| 138 | ShowMessage('Load OPF-File: ' + ParamStr(2));
|
---|
| 139 | end
|
---|
| 140 | else if MidStr(ParamStr(1), 1, 4) = 'oldb' then
|
---|
| 141 | begin
|
---|
| 142 | if not CreateDataConnection(ParamStr(2), ODB_ADB) then
|
---|
| 143 | ShowMessage('Error while loading the file:' + CrLf + ParamStr(
|
---|
| 144 | 2) + CrLf + 'Perhaps not an OniUnPacker-LevelDatabase-file?');
|
---|
| 145 | end
|
---|
| 146 | else if MidStr(ParamStr(1), 1, 3) = 'dat' then
|
---|
| 147 | begin
|
---|
| 148 | if not CreateDataConnection(ParamStr(2), ODB_Dat) then
|
---|
| 149 | ShowMessage('Error while loading the file:' + CrLf + ParamStr(
|
---|
| 150 | 2) + CrLf + 'Perhaps not an Oni-.dat-file?');
|
---|
| 151 | end;
|
---|
| 152 | UpdateStatBar;
|
---|
| 153 | end;
|
---|
| 154 |
|
---|
| 155 |
|
---|
| 156 |
|
---|
| 157 |
|
---|
| 158 | procedure TForm_Main.FormResize(Sender: TObject);
|
---|
| 159 | const
|
---|
| 160 | MinWidth: Integer = 750;
|
---|
| 161 | MinHeight: Integer = 500;
|
---|
| 162 | begin
|
---|
| 163 | if Self.Width < MinWidth then
|
---|
| 164 | Self.Width := MinWidth;
|
---|
| 165 | if Self.Height < MinHeight then
|
---|
| 166 | Self.Height := MinHeight;
|
---|
| 167 | statbar.Panels.Items[0].Width := Self.Width - 200;
|
---|
| 168 | MDITab.Width := Self.Width - 20;
|
---|
| 169 | end;
|
---|
| 170 |
|
---|
| 171 |
|
---|
| 172 |
|
---|
| 173 |
|
---|
| 174 | procedure TForm_Main.MDITabDrawTab(Control: TCustomTabControl;
|
---|
| 175 | TabIndex: Integer; const Rect: TRect; Active: Boolean);
|
---|
| 176 | var
|
---|
| 177 | x, y: Integer;
|
---|
| 178 | iconindex: Integer;
|
---|
| 179 | caption: String;
|
---|
| 180 | begin
|
---|
| 181 | iconindex := TMDITab(Control).Glyphs[TabIndex];
|
---|
| 182 | caption := TMDITab(Control).Captions[TabIndex];
|
---|
| 183 | if active then
|
---|
| 184 | begin
|
---|
| 185 | Control.Canvas.Font.Style := Control.Canvas.Font.Style + [fsItalic];
|
---|
| 186 | y := Rect.Top + 1;
|
---|
| 187 | end else
|
---|
| 188 | y := Rect.Top;
|
---|
| 189 | if iconindex >= 0 then
|
---|
| 190 | begin
|
---|
| 191 | TMDITab(Control).Images.Draw(Control.Canvas, Rect.Left + 4, y, iconindex);
|
---|
| 192 | x := Rect.Left + 26;
|
---|
| 193 | end else
|
---|
| 194 | x := Rect.Left + 4;
|
---|
| 195 | Control.Canvas.TextOut(x, y + 2, caption);
|
---|
| 196 | end;
|
---|
| 197 |
|
---|
| 198 |
|
---|
| 199 |
|
---|
| 200 |
|
---|
| 201 |
|
---|
| 202 |
|
---|
| 203 | procedure TForm_Main.MDITabMouseUp(Sender: TObject; Button: TMouseButton;
|
---|
| 204 | Shift: TShiftState; X, Y: Integer);
|
---|
| 205 | var
|
---|
| 206 | pt: TPoint;
|
---|
| 207 | index: Integer;
|
---|
| 208 | begin
|
---|
| 209 | pt.X := X;
|
---|
| 210 | pt.Y := Y;
|
---|
| 211 | index := MDITab.GetTabAtPos(pt);
|
---|
| 212 | if (Button = mbRight) and (index >= 0) then
|
---|
| 213 | MDITab.MDIChildren[index].Close;
|
---|
| 214 | end;
|
---|
| 215 |
|
---|
| 216 | procedure TForm_Main.FormClose(Sender: TObject; var Action: TCloseAction);
|
---|
| 217 | begin
|
---|
| 218 | AssignFile(AppSettingsFile, ExtractFilepath(Application.EXEname) + '\oniunpacker.ini');
|
---|
| 219 | if FileExists(ExtractFilepath(Application.EXEname) + '\oniunpacker.ini') then
|
---|
| 220 | Reset(AppSettingsFile)
|
---|
| 221 | else
|
---|
| 222 | Rewrite(AppSettingsFile);
|
---|
| 223 | Write(AppSettingsFile, AppSettings);
|
---|
| 224 | CloseFile(AppSettingsFile);
|
---|
| 225 | Action := caFree;
|
---|
| 226 | end;
|
---|
| 227 |
|
---|
| 228 |
|
---|
| 229 |
|
---|
| 230 | procedure TForm_Main.ActivateTools(active: Boolean);
|
---|
| 231 | begin
|
---|
| 232 | menu_tools.Enabled := active;
|
---|
| 233 | tb_preview.Enabled := active;
|
---|
| 234 | tb_datedit.Enabled := active;
|
---|
| 235 | tb_rawedit.Enabled := active;
|
---|
| 236 | tb_txmpreplacer.Enabled := active;
|
---|
| 237 | tb_extractor.Enabled := active;
|
---|
| 238 | // tb_compare.Enabled := active;
|
---|
| 239 | // tb_structure.Enabled := active;
|
---|
| 240 | end;
|
---|
| 241 |
|
---|
| 242 | procedure TForm_Main.UpdateStatBar;
|
---|
| 243 | begin
|
---|
| 244 | if Assigned(OniDataConnection) then
|
---|
| 245 | begin
|
---|
| 246 | Self.Caption := 'Oni Un/Packer ' + version + ' (' + ExtractFileName(
|
---|
| 247 | OniDataConnection.FileName) + ')';
|
---|
| 248 | ActivateTools(True);
|
---|
| 249 | statbar.Panels.Items[1].Text := 'Files: ' + IntToStr(OniDataConnection.GetFilesCount);
|
---|
| 250 | statbar.Panels.Items[2].Text :=
|
---|
| 251 | 'Extensions: ' + IntToStr(Length(OniDataConnection.GetExtensionsList));
|
---|
| 252 | case OniDataConnection.Backend of
|
---|
| 253 | ODB_Dat:
|
---|
| 254 | begin
|
---|
| 255 | statbar.Panels.Items[0].Text := '.dat loaded: ' + OniDataConnection.FileName;
|
---|
| 256 | end;
|
---|
| 257 | ODB_ADB:
|
---|
| 258 | begin
|
---|
| 259 | statbar.Panels.Items[0].Text := 'OLDB loaded: ' + OniDataConnection.FileName;
|
---|
| 260 | end;
|
---|
| 261 | else
|
---|
| 262 | Self.Caption := 'Oni Un/Packer ' + version;
|
---|
| 263 | statbar.Panels.Items[0].Text := 'Nothing loaded';
|
---|
| 264 | statbar.Panels.Items[1].Text := 'Files: -';
|
---|
| 265 | statbar.Panels.Items[2].Text := 'Extensions: -';
|
---|
| 266 | ActivateTools(False);
|
---|
| 267 | end;
|
---|
| 268 | end
|
---|
| 269 | else
|
---|
| 270 | begin
|
---|
| 271 | Self.Caption := 'Oni Un/Packer ' + version;
|
---|
| 272 | statbar.Panels.Items[0].Text := 'Nothing loaded';
|
---|
| 273 | statbar.Panels.Items[1].Text := 'Files: -';
|
---|
| 274 | statbar.Panels.Items[2].Text := 'Extensions: -';
|
---|
| 275 | ActivateTools(False);
|
---|
| 276 | end;
|
---|
| 277 | end;
|
---|
| 278 |
|
---|
| 279 |
|
---|
| 280 |
|
---|
| 281 |
|
---|
| 282 | function TForm_Main.TryCloseAll: Boolean;
|
---|
| 283 | begin
|
---|
| 284 | menu_windows_closeallClick(Self);
|
---|
| 285 | Application.ProcessMessages;
|
---|
| 286 | if MDITab.MDIChildCount = 0 then
|
---|
| 287 | Result := True
|
---|
| 288 | else
|
---|
| 289 | Result := False;
|
---|
| 290 | end;
|
---|
| 291 |
|
---|
| 292 |
|
---|
| 293 | {#################################}
|
---|
| 294 | {##### Main-Menu-Handlers #####}
|
---|
| 295 | {#################################}
|
---|
| 296 | procedure TForm_Main.menu_loadfileClick(Sender: TObject);
|
---|
| 297 | var
|
---|
| 298 | ext: String;
|
---|
| 299 | begin
|
---|
| 300 | if TryCloseAll then
|
---|
| 301 | begin
|
---|
| 302 | CloseDataConnection;
|
---|
| 303 | opend.InitialDir := AppSettings.DatPath;
|
---|
| 304 | opend.Filter := 'Compatible level files|*.dat;*.oldb|Oni level (*.dat)|*.dat|OUP level database (*.oldb)|*.oldb|Any (*.*)|*';
|
---|
| 305 | if opend.Execute then
|
---|
| 306 | begin
|
---|
| 307 | ext := ExtractFileExt(opend.FileName);
|
---|
| 308 | if ext = '.dat' then
|
---|
[45] | 309 | begin
|
---|
[43] | 310 | if not CreateDataConnection(opend.FileName, ODB_Dat) then
|
---|
| 311 | ShowMessage('Error while loading the file:' + CrLf + opend.FileName +
|
---|
[45] | 312 | CrLf + 'Perhaps not an Oni-.dat-file?');
|
---|
| 313 | end else if ext = '.oldb' then
|
---|
| 314 | begin
|
---|
[43] | 315 | if not CreateDataConnection(opend.FileName, ODB_ADB) then
|
---|
| 316 | ShowMessage('Error while loading the file:' + CrLf + opend.FileName +
|
---|
[45] | 317 | CrLf + 'Perhaps not an OniUnPacker-LevelDatabase-file?');
|
---|
| 318 | end else
|
---|
[43] | 319 | ShowMessage('Incompatible file');
|
---|
| 320 | AppSettings.DatPath := ExtractFilepath(opend.FileName);
|
---|
| 321 | end;
|
---|
| 322 | end;
|
---|
| 323 | UpdateStatBar;
|
---|
| 324 | end;
|
---|
| 325 |
|
---|
| 326 |
|
---|
| 327 |
|
---|
| 328 |
|
---|
| 329 | procedure TForm_Main.menu_settingsClick(Sender: TObject);
|
---|
| 330 | begin
|
---|
| 331 | Form_Settings.Visible := True;
|
---|
| 332 | Self.Enabled := False;
|
---|
| 333 | end;
|
---|
| 334 |
|
---|
| 335 |
|
---|
| 336 |
|
---|
| 337 |
|
---|
| 338 | procedure TForm_Main.menu_exitClick(Sender: TObject);
|
---|
| 339 | begin
|
---|
| 340 | Self.Close;
|
---|
| 341 | end;
|
---|
| 342 |
|
---|
| 343 | {####################################}
|
---|
| 344 | {##### Converters-Menu-Handlers #####}
|
---|
| 345 | {####################################}
|
---|
| 346 | procedure TForm_Main.menu_createdbClick(Sender: TObject);
|
---|
| 347 | begin
|
---|
| 348 | if Assigned(OniDataConnection) then
|
---|
| 349 | if MessageBox(Self.Handle, PChar('You have currently opened a level-file. ' +
|
---|
| 350 | 'Do you want to close it to continue?'), PChar('Close file?'),
|
---|
| 351 | MB_YESNO + MB_ICONQUESTION) = ID_NO then
|
---|
| 352 | Exit
|
---|
| 353 | else begin
|
---|
| 354 | if TryCloseAll then
|
---|
| 355 | begin
|
---|
| 356 | CloseDataConnection;
|
---|
| 357 | UpdateStatBar;
|
---|
| 358 | end else
|
---|
| 359 | Exit;
|
---|
| 360 | end;
|
---|
| 361 | opend.Filter := 'Oni-Dat-Files|*.dat';
|
---|
| 362 | saved.Filter := 'OUP-Level-DB (*.oldb)|*.oldb';
|
---|
| 363 | saved.DefaultExt := 'oldb';
|
---|
| 364 | if opend.Execute then
|
---|
| 365 | if saved.Execute then
|
---|
| 366 | Form_LevelDB.CreateDatabase(opend.FileName, saved.FileName);
|
---|
| 367 | end;
|
---|
| 368 |
|
---|
| 369 |
|
---|
| 370 |
|
---|
| 371 |
|
---|
| 372 | procedure TForm_Main.menu_createlvlClick(Sender: TObject);
|
---|
| 373 | begin
|
---|
| 374 | if Assigned(OniDataConnection) then
|
---|
| 375 | if MessageBox(Self.Handle, PChar('You have currently opened a level-file. ' +
|
---|
| 376 | 'Do you want to close it to continue?'), PChar('Close file?'),
|
---|
| 377 | MB_YESNO + MB_ICONQUESTION) = ID_NO then
|
---|
| 378 | Exit
|
---|
| 379 | else begin
|
---|
| 380 | if TryCloseAll then
|
---|
| 381 | begin
|
---|
| 382 | CloseDataConnection;
|
---|
| 383 | UpdateStatBar;
|
---|
| 384 | end else
|
---|
| 385 | Exit;
|
---|
| 386 | end;
|
---|
| 387 | opend.Filter := 'OUP-Level-DB (*.oldb)|*.oldb';
|
---|
| 388 | saved.Filter := 'Oni-Dat-Files|*.dat';
|
---|
| 389 | saved.DefaultExt := 'dat';
|
---|
| 390 | if opend.Execute then
|
---|
| 391 | if saved.Execute then
|
---|
| 392 | Form_LevelDB.CreateLevel(opend.FileName, saved.FileName);
|
---|
| 393 | end;
|
---|
| 394 |
|
---|
| 395 | {#################################}
|
---|
| 396 | {##### Tools-Menu-Handlers #####}
|
---|
| 397 | {#################################}
|
---|
| 398 | procedure TForm_Main.menu_previewClick(Sender: TObject);
|
---|
| 399 | begin
|
---|
[45] | 400 | open_child('preview', -1);
|
---|
[43] | 401 | end;
|
---|
| 402 |
|
---|
| 403 |
|
---|
| 404 | procedure TForm_Main.menu_txmpreplaceClick(Sender: TObject);
|
---|
| 405 | begin
|
---|
[45] | 406 | open_child('txmpreplace', -1);
|
---|
[43] | 407 | end;
|
---|
| 408 |
|
---|
| 409 |
|
---|
| 410 | procedure TForm_Main.menu_bineditClick(Sender: TObject);
|
---|
| 411 | begin
|
---|
[45] | 412 | open_child('binedit', -1);
|
---|
[43] | 413 | end;
|
---|
| 414 |
|
---|
| 415 |
|
---|
| 416 | procedure TForm_Main.menu_raweditClick(Sender: TObject);
|
---|
| 417 | begin
|
---|
[45] | 418 | open_child('rawedit', -1);
|
---|
[43] | 419 | end;
|
---|
| 420 |
|
---|
| 421 |
|
---|
| 422 | procedure TForm_Main.menu_extractorClick(Sender: TObject);
|
---|
| 423 | begin
|
---|
[45] | 424 | open_child('extractor', -1);
|
---|
[43] | 425 | end;
|
---|
| 426 |
|
---|
| 427 |
|
---|
| 428 | procedure TForm_Main.menu_filecompareClick(Sender: TObject);
|
---|
| 429 | begin
|
---|
[45] | 430 | open_child('compare', -1);
|
---|
[43] | 431 | end;
|
---|
| 432 |
|
---|
| 433 |
|
---|
| 434 | {#################################}
|
---|
| 435 | {##### View-Menu-Handlers #####}
|
---|
| 436 | {#################################}
|
---|
| 437 | procedure TForm_Main.menu_view_mdibarClick(Sender: TObject);
|
---|
| 438 | begin
|
---|
| 439 | menu_view_mdibar.Checked := not menu_view_mdibar.Checked;
|
---|
| 440 | mditoolbar.Visible := menu_view_mdibar.Checked;
|
---|
| 441 | end;
|
---|
| 442 |
|
---|
| 443 |
|
---|
| 444 |
|
---|
| 445 |
|
---|
| 446 | procedure TForm_Main.menu_view_statusbarClick(Sender: TObject);
|
---|
| 447 | begin
|
---|
| 448 | menu_view_statusbar.Checked := not menu_view_statusbar.Checked;
|
---|
| 449 | statbar.Visible := menu_view_statusbar.Checked;
|
---|
| 450 | end;
|
---|
| 451 |
|
---|
| 452 |
|
---|
| 453 |
|
---|
| 454 |
|
---|
| 455 | procedure TForm_Main.menu_view_toolbarClick(Sender: TObject);
|
---|
| 456 | begin
|
---|
| 457 | menu_view_toolbar.Checked := not menu_view_toolbar.Checked;
|
---|
| 458 | Toolbar.Visible := menu_view_toolbar.Checked;
|
---|
| 459 | end;
|
---|
| 460 |
|
---|
| 461 |
|
---|
| 462 |
|
---|
| 463 | {#################################}
|
---|
| 464 | {##### Window-Menu-Handlers #####}
|
---|
| 465 | {#################################}
|
---|
| 466 | procedure TForm_Main.menu_windows_cascadeClick(Sender: TObject);
|
---|
| 467 | begin
|
---|
| 468 | Self.Cascade;
|
---|
| 469 | end;
|
---|
| 470 |
|
---|
| 471 |
|
---|
| 472 |
|
---|
| 473 | procedure TForm_Main.menu_windows_tileClick(Sender: TObject);
|
---|
| 474 | begin
|
---|
| 475 | Self.TileMode := tbHorizontal;
|
---|
| 476 | Self.Tile;
|
---|
| 477 | end;
|
---|
| 478 |
|
---|
[46] | 479 | procedure TForm_Main.menu_windows_tilevertClick(Sender: TObject);
|
---|
| 480 | begin
|
---|
| 481 | Self.TileMode := tbVertical;
|
---|
| 482 | Self.Tile;
|
---|
| 483 | end;
|
---|
[43] | 484 |
|
---|
| 485 |
|
---|
| 486 | procedure TForm_Main.menu_windows_closeallClick(Sender: TObject);
|
---|
| 487 | begin
|
---|
| 488 | MDITab.CloseAll;
|
---|
| 489 | end;
|
---|
| 490 |
|
---|
| 491 |
|
---|
| 492 |
|
---|
| 493 | procedure TForm_Main.menu_windows_nextClick(Sender: TObject);
|
---|
| 494 | begin
|
---|
| 495 | if MDIChildCount > 1 then
|
---|
| 496 | if MDITab.TabIndex = MDITab.MDIChildCount - 1 then
|
---|
| 497 | MDITab.MDIChildren[0].BringToFront
|
---|
| 498 | else
|
---|
| 499 | MDITab.MDIChildren[MDITab.TabIndex + 1].BringToFront;
|
---|
| 500 | end;
|
---|
| 501 |
|
---|
| 502 |
|
---|
| 503 |
|
---|
| 504 | procedure TForm_Main.menu_windows_previousClick(Sender: TObject);
|
---|
| 505 | begin
|
---|
| 506 | if MDIChildCount > 1 then
|
---|
| 507 | if MDITab.TabIndex = 0 then
|
---|
| 508 | MDITab.MDIChildren[MDITab.MDIChildCount - 1].BringToFront
|
---|
| 509 | else
|
---|
| 510 | MDITab.MDIChildren[MDITab.TabIndex - 1].BringToFront;
|
---|
| 511 | end;
|
---|
| 512 |
|
---|
| 513 |
|
---|
| 514 |
|
---|
| 515 |
|
---|
| 516 |
|
---|
| 517 |
|
---|
| 518 | procedure TForm_Main.menu_AboutClick(Sender: TObject);
|
---|
| 519 | begin
|
---|
| 520 | ShowMessage('Will be implemented later ;)');
|
---|
| 521 | end;
|
---|
| 522 |
|
---|
| 523 |
|
---|
| 524 |
|
---|
| 525 |
|
---|
[46] | 526 | function TForm_Main.open_child(window_context: String; fileid: Integer): TForm_ToolTemplate;
|
---|
[43] | 527 | var
|
---|
[45] | 528 | toolform: TForm_ToolTemplate;
|
---|
[43] | 529 | i: Integer;
|
---|
| 530 | tag: Integer;
|
---|
| 531 | iconindex: Integer;
|
---|
| 532 | begin
|
---|
[46] | 533 | Result := nil;
|
---|
[43] | 534 |
|
---|
| 535 | tag := 1;
|
---|
| 536 | if MDIChildCount > 0 then
|
---|
| 537 | for i := 0 to MDIChildCount - 1 do
|
---|
| 538 | if MDIChildren[i].Tag >= tag then
|
---|
| 539 | tag := MDIChildren[i].Tag + 1;
|
---|
| 540 |
|
---|
| 541 | iconindex := -1;
|
---|
| 542 |
|
---|
| 543 | if window_context = 'binedit' then
|
---|
| 544 | begin
|
---|
[45] | 545 | toolform := TForm_BinEdit.Create(Self);
|
---|
| 546 | toolform.Caption := 'Binary .dat-Editor ' + IntToStr(tag);
|
---|
[46] | 547 | iconindex := 4;
|
---|
[43] | 548 | end;
|
---|
[45] | 549 | if window_context = 'extractor' then
|
---|
[43] | 550 | begin
|
---|
[45] | 551 | toolform := TForm_Extractor.Create(Self);
|
---|
| 552 | toolform.Caption := 'Extractor ' + IntToStr(tag);
|
---|
[46] | 553 | iconindex := 7;
|
---|
[43] | 554 | end;
|
---|
| 555 | if window_context = 'preview' then
|
---|
| 556 | begin
|
---|
[45] | 557 | toolform := TForm_Preview.Create(Self);
|
---|
| 558 | toolform.Caption := 'Preview-Window ' + IntToStr(tag);
|
---|
[46] | 559 | iconindex := 3;
|
---|
[43] | 560 | end;
|
---|
[45] | 561 | if window_context = 'rawedit' then
|
---|
| 562 | begin
|
---|
| 563 | toolform := TForm_RawEdit.Create(Self);
|
---|
| 564 | toolform.Caption := 'Binary .raw-Editor ' + IntToStr(tag);
|
---|
[46] | 565 | iconindex := 5;
|
---|
[45] | 566 | end;
|
---|
[43] | 567 | if window_context = 'txmpreplace' then
|
---|
| 568 | begin
|
---|
[45] | 569 | toolform := TForm_TxmpReplace.Create(Application);
|
---|
| 570 | toolform.Caption := 'TXMP Replacer ' + IntToStr(tag);
|
---|
[46] | 571 | iconindex := 6;
|
---|
[43] | 572 | end;
|
---|
[45] | 573 |
|
---|
| 574 | if Assigned(toolform) then
|
---|
[43] | 575 | begin
|
---|
[45] | 576 | toolform.Name := window_context + IntToStr(tag);
|
---|
| 577 | toolform.Tag := tag;
|
---|
| 578 | MDITab.AddTab(TForm(toolform), iconindex);
|
---|
| 579 | if fileid > -1 then
|
---|
| 580 | toolform.SelectFileID(fileid);
|
---|
[46] | 581 | Result := toolform;
|
---|
[43] | 582 | end;
|
---|
| 583 | end;
|
---|
| 584 |
|
---|
| 585 | end.
|
---|