Ignore:
Timestamp:
Nov 23, 2023, 11:18:42 PM (13 months ago)
Author:
chronos
Message:
  • Modified: Source editor with main menu can't be docked into another form with main menu. Source enditor and Screen have own main menu.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ByteArray/Core.pas

    r57 r58  
    44
    55uses
    6   Classes, SysUtils, Machine, Common.PersistentForm, Common.ApplicationInfo,
    7   Common.RegistryEx, Common.Translator, Common.Theme;
     6  Classes, SysUtils, Machine, ActnList, Forms, Common.PersistentForm,
     7  Common.ApplicationInfo, Common.RegistryEx, Common.Translator, Common.Theme,
     8  FormConsole, FormScreen, FormSourceEditor, FormMemory, FormDisassembler,
     9  FormStorage, FormDebugger;
    810
    911type
     
    1214
    1315  TCore = class(TDataModule)
     16    AAbout: TAction;
     17    AConsole: TAction;
     18    ActionList1: TActionList;
     19    ADebugger: TAction;
     20    ADevices: TAction;
     21    ADisassembler: TAction;
     22    AExit: TAction;
     23    AFullscreen: TAction;
     24    AMemory: TAction;
    1425    ApplicationInfo1: TApplicationInfo;
     26    AScreen: TAction;
     27    ASettings: TAction;
     28    ASourceEditor: TAction;
     29    AStorage: TAction;
    1530    PersistentForm1: TPersistentForm;
    1631    ThemeManager1: TThemeManager;
    1732    Translator1: TTranslator;
     33    procedure AAboutExecute(Sender: TObject);
     34    procedure AConsoleExecute(Sender: TObject);
     35    procedure ADebuggerExecute(Sender: TObject);
     36    procedure ADisassemblerExecute(Sender: TObject);
     37    procedure AExitExecute(Sender: TObject);
     38    procedure AFullscreenExecute(Sender: TObject);
     39    procedure AMemoryExecute(Sender: TObject);
     40    procedure AScreenExecute(Sender: TObject);
     41    procedure ASettingsExecute(Sender: TObject);
     42    procedure ASourceEditorExecute(Sender: TObject);
     43    procedure AStorageExecute(Sender: TObject);
    1844    procedure DataModuleCreate(Sender: TObject);
    1945    procedure DataModuleDestroy(Sender: TObject);
     
    2349    procedure SaveConfig;
    2450  public
     51    MainForm: TForm;
     52    FormScreen: TFormScreen;
     53    FormConsole: TFormConsole;
     54    FormMemory: TFormMemory;
     55    FormSourceEditor: TFormSourceEditor;
     56    FormDisassembler: TFormDisassembler;
     57    FormStorage: TFormStorage;
     58    FormDebugger: TFormDebugger;
    2559    StartUpForm: string;
    2660    AutoStartMachine: Boolean;
     
    3771
    3872uses
    39   BigInt, Cpu, Common.FormEx;
     73  BigInt, Cpu, Common.FormEx, FormSettings, Common.FormAbout;
    4074
    4175{ TCore }
     
    5084  TFormEx.ThemeManager := ThemeManager1;
    5185  TFormEx.PersistentForm := PersistentForm1;
     86
     87  if StartUpForm = 'Screen' then begin
     88    AScreen.Execute;
     89  end;
     90  if StartUpForm = 'Source editor' then begin
     91    ASourceEditor.Execute;
     92  end;
     93  if StartUpForm = 'Debugger' then begin
     94    ADebugger.Execute;
     95  end;
     96  if AutoStartMachine then
     97    Machine.PowerOn;
     98end;
     99
     100procedure TCore.AExitExecute(Sender: TObject);
     101begin
     102  Application.Terminate;
     103end;
     104
     105procedure TCore.ADebuggerExecute(Sender: TObject);
     106begin
     107  if not Assigned(FormDebugger) then begin
     108    FormDebugger := TFormDebugger.Create(nil);
     109  end;
     110  FormDebugger.Show;
     111end;
     112
     113procedure TCore.ADisassemblerExecute(Sender: TObject);
     114begin
     115  if not Assigned(FormDisassembler) then begin
     116    FormDisassembler := TFormDisassembler.Create(nil);
     117    if not Assigned(MainForm) then MainForm := FormDisassembler;
     118  end;
     119  FormDisassembler.Disassembler.Memory := Machine.Memory;
     120  FormDisassembler.Show;
     121end;
     122
     123procedure TCore.AConsoleExecute(Sender: TObject);
     124begin
     125  if not Assigned(FormConsole) then begin
     126    FormConsole := TFormConsole.Create(nil);
     127    Machine.Serial.OnWrite := FormConsole.ConsoleWrite;
     128  end;
     129  FormConsole.Show;
     130end;
     131
     132procedure TCore.AAboutExecute(Sender: TObject);
     133var
     134  FormAbout: TFormAbout;
     135begin
     136  FormAbout := TFormAbout.Create(nil);
     137  try
     138    FormAbout.ApplicationInfo := ApplicationInfo1;
     139    FormAbout.ShowModal;
     140  finally
     141    FreeAndNil(FormAbout);
     142  end;
     143end;
     144
     145procedure TCore.AFullscreenExecute(Sender: TObject);
     146begin
     147  PersistentForm1.SetFullScreen(not PersistentForm1.FormFullScreen);
     148end;
     149
     150procedure TCore.AMemoryExecute(Sender: TObject);
     151begin
     152  if not Assigned(FormMemory) then begin
     153    FormMemory := TFormMemory.Create(nil);
     154    FormMemory.Memory := Machine.Memory;
     155  end;
     156  FormMemory.Show;
     157end;
     158
     159procedure TCore.AScreenExecute(Sender: TObject);
     160begin
     161  if not Assigned(FormScreen) then begin
     162    FormScreen := TFormScreen.Create(nil);
     163    if not Assigned(MainForm) then MainForm := FormScreen;
     164    FormScreen.FrameBuffer := Machine.FrameBuffer;
     165    Machine.FrameBuffer.OnChange := FormScreen.ScreenChange;
     166  end;
     167  FormScreen.Show;
     168end;
     169
     170procedure TCore.ASettingsExecute(Sender: TObject);
     171var
     172  FormSettings: TFormSettings;
     173begin
     174  FormSettings := TFormSettings.Create(nil);
     175  try
     176    FormSettings.ShowModal;
     177  finally
     178    FormSettings.Free;
     179  end;
     180end;
     181
     182procedure TCore.ASourceEditorExecute(Sender: TObject);
     183begin
     184  if not Assigned(FormSourceEditor) then begin
     185    FormSourceEditor := TFormSourceEditor.Create(nil);
     186    if not Assigned(MainForm) then MainForm := FormSourceEditor;
     187    FormSourceEditor.Machine := Machine;
     188  end;
     189  FormSourceEditor.Show;
     190end;
     191
     192procedure TCore.AStorageExecute(Sender: TObject);
     193begin
     194  if not Assigned(FormStorage) then begin
     195    FormStorage := TFormStorage.Create(nil);
     196    FormStorage.Storage := Machine.Storage;
     197  end;
     198  FormStorage.Show;
    52199end;
    53200
     
    55202begin
    56203  SaveConfig;
     204  if Assigned(FormSourceEditor) then FreeAndNil(FormSourceEditor);
     205  if Assigned(FormScreen) then FreeAndNil(FormScreen);
     206  if Assigned(FormConsole) then FreeAndNil(FormConsole);
     207  if Assigned(FormMemory) then FreeAndNil(FormMemory);
     208  if Assigned(FormDisassembler) then FreeAndNil(FormDisassembler);
     209  if Assigned(FormStorage) then FreeAndNil(FormStorage);
     210  if Assigned(FormDebugger) then FreeAndNil(FormDebugger);
     211
    57212  FreeAndNil(Machine);
    58213end;
Note: See TracChangeset for help on using the changeset viewer.