mirror of
https://github.com/moparisthebest/Simba
synced 2024-12-24 00:08:52 -05:00
Updated the GUI a bit :-). Now has Loading/Saving + some elementary stuff.
git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@134 3f818213-9676-44b0-a9b4-5e4c4e03d09d
This commit is contained in:
parent
030aac3748
commit
7c2fd48297
File diff suppressed because it is too large
Load Diff
@ -1,23 +1,25 @@
|
||||
object Form1: TForm1
|
||||
Left = 335
|
||||
Left = 207
|
||||
Height = 553
|
||||
Top = 222
|
||||
Top = 196
|
||||
Width = 723
|
||||
ActiveControl = SynEdit1
|
||||
Caption = 'Mufasa v2'
|
||||
ClientHeight = 528
|
||||
ClientHeight = 533
|
||||
ClientWidth = 723
|
||||
Menu = MainMenu1
|
||||
OnClose = FormClose
|
||||
OnCreate = FormCreate
|
||||
OnDestroy = FormDestroy
|
||||
Position = poScreenCenter
|
||||
LCLVersion = '0.9.29'
|
||||
object SynEdit1: TSynEdit
|
||||
Left = 8
|
||||
Height = 328
|
||||
Height = 333
|
||||
Top = 32
|
||||
Width = 704
|
||||
Align = alCustom
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
Font.Height = -13
|
||||
Font.Name = 'Courier New'
|
||||
Font.Pitch = fpFixed
|
||||
@ -25,7 +27,8 @@ object Form1: TForm1
|
||||
ParentColor = False
|
||||
ParentFont = False
|
||||
TabOrder = 0
|
||||
Gutter.Width = 61
|
||||
BookMarkOptions.OnChange = nil
|
||||
Gutter.Width = 57
|
||||
Gutter.MouseActions = <
|
||||
item
|
||||
Shift = []
|
||||
@ -602,12 +605,14 @@ object Form1: TForm1
|
||||
MaxLeftChar = 80
|
||||
ScrollBars = ssAutoBoth
|
||||
BracketHighlightStyle = sbhsBoth
|
||||
OnChange = OnSyneditChange
|
||||
OnProcessCommand = SynEditProcessCommand
|
||||
object TSynGutterPartList
|
||||
object TSynGutterMarks
|
||||
Width = 23
|
||||
end
|
||||
object TSynGutterLineNumber
|
||||
Width = 21
|
||||
Width = 17
|
||||
MouseActions = <>
|
||||
MarkupInfo.Background = clBtnFace
|
||||
MarkupInfo.Foreground = clNone
|
||||
@ -771,8 +776,8 @@ object Form1: TForm1
|
||||
Left = 122
|
||||
Top = 2
|
||||
Caption = 'TB_ClearDebug'
|
||||
Enabled = False
|
||||
ImageIndex = 5
|
||||
OnClick = ClearDebug
|
||||
end
|
||||
object TB_PickColour: TToolButton
|
||||
Left = 145
|
||||
@ -819,20 +824,66 @@ object Form1: TForm1
|
||||
end
|
||||
object Memo1: TMemo
|
||||
Left = 13
|
||||
Height = 134
|
||||
Height = 139
|
||||
Top = 370
|
||||
Width = 694
|
||||
Anchors = [akLeft, akRight, akBottom]
|
||||
ScrollBars = ssAutoBoth
|
||||
TabOrder = 1
|
||||
end
|
||||
object SynFreePascalSyn1: TSynFreePascalSyn
|
||||
Enabled = False
|
||||
CompilerMode = pcmObjFPC
|
||||
NestedComments = True
|
||||
left = 560
|
||||
object StatusBar: TStatusBar
|
||||
Left = 0
|
||||
Height = 23
|
||||
Top = 510
|
||||
Width = 723
|
||||
Panels = <
|
||||
item
|
||||
Text = 'Untitled'
|
||||
Width = 100
|
||||
end
|
||||
item
|
||||
Width = 50
|
||||
end>
|
||||
SimplePanel = False
|
||||
end
|
||||
object MainMenu1: TMainMenu
|
||||
left = 608
|
||||
object MenuFile: TMenuItem
|
||||
Caption = 'File'
|
||||
OnClick = MenuFileClick
|
||||
object MenuItemNew: TMenuItem
|
||||
Caption = 'New'
|
||||
ShortCut = 16462
|
||||
OnClick = MenuItemNewClick
|
||||
end
|
||||
object MenuItemOpen: TMenuItem
|
||||
Caption = 'Open'
|
||||
ShortCut = 16463
|
||||
OnClick = MenuItemOpenClick
|
||||
end
|
||||
object MenuItemSave: TMenuItem
|
||||
Caption = 'Save'
|
||||
ShortCut = 16467
|
||||
OnClick = MenuItemSaveClick
|
||||
end
|
||||
object MenuItemSaveAs: TMenuItem
|
||||
Caption = 'Save as..'
|
||||
OnClick = MenuItemSaveAsClick
|
||||
end
|
||||
end
|
||||
object MenuEdit: TMenuItem
|
||||
Caption = 'Edit'
|
||||
object MenuItemUndo: TMenuItem
|
||||
Caption = 'Undo'
|
||||
ShortCut = 16474
|
||||
OnClick = Undo
|
||||
end
|
||||
object MenuItemRedo: TMenuItem
|
||||
Caption = 'Redo'
|
||||
ShortCut = 24666
|
||||
OnClick = Redo
|
||||
end
|
||||
end
|
||||
object MenuItemScript: TMenuItem
|
||||
Caption = 'Script'
|
||||
object MenuItemRun: TMenuItem
|
||||
@ -1303,4 +1354,18 @@ object Form1: TForm1
|
||||
OnClick = NoTray
|
||||
left = 464
|
||||
end
|
||||
object SynFreePascalSyn1: TSynFreePascalSyn
|
||||
Enabled = False
|
||||
CommentAttri.Foreground = clBlue
|
||||
CommentAttri.Style = [fsBold]
|
||||
IdentifierAttri.Foreground = clDefault
|
||||
NumberAttri.Foreground = clNavy
|
||||
StringAttri.Foreground = clBlue
|
||||
SymbolAttri.Foreground = clRed
|
||||
DirectiveAttri.Foreground = clRed
|
||||
DirectiveAttri.Style = [fsBold]
|
||||
CompilerMode = pcmObjFPC
|
||||
NestedComments = True
|
||||
left = 424
|
||||
end
|
||||
end
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -35,8 +35,9 @@ uses
|
||||
mmlpsthread,
|
||||
window, // for the comp picker and selector
|
||||
colourpicker,
|
||||
windowselector
|
||||
;
|
||||
windowselector,
|
||||
lcltype
|
||||
, SynEditKeyCmds;
|
||||
|
||||
type
|
||||
|
||||
@ -44,10 +45,19 @@ type
|
||||
|
||||
TForm1 = class(TForm)
|
||||
Memo1: TMemo;
|
||||
MenuFile: TMenuItem;
|
||||
MenuEdit: TMenuItem;
|
||||
MenuItemNew: TMenuItem;
|
||||
MenuItemSaveAs: TMenuItem;
|
||||
MenuItemOpen: TMenuItem;
|
||||
MenuItemRedo: TMenuItem;
|
||||
MenuItemUndo: TMenuItem;
|
||||
MenuItemSave: TMenuItem;
|
||||
Mufasa_Image_List: TImageList;
|
||||
MainMenu1: TMainMenu;
|
||||
MenuItemScript: TMenuItem;
|
||||
MenuItemRun: TMenuItem;
|
||||
StatusBar: TStatusBar;
|
||||
SynEdit1: TSynEdit;
|
||||
SynFreePascalSyn1: TSynFreePascalSyn;
|
||||
ToolBar1: TToolBar;
|
||||
@ -67,23 +77,44 @@ type
|
||||
TB_Convert: TToolButton;
|
||||
MTrayIcon: TTrayIcon;
|
||||
procedure Button1Click(Sender: TObject);
|
||||
procedure ClearDebug(Sender: TObject);
|
||||
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure FormDestroy(Sender: TObject);
|
||||
procedure MenuFileClick(Sender: TObject);
|
||||
procedure MenuItemNewClick(Sender: TObject);
|
||||
procedure MenuItemOpenClick(Sender: TObject);
|
||||
procedure MenuItemRunClick(Sender: TObject);
|
||||
procedure MenuItemSaveAsClick(Sender: TObject);
|
||||
procedure MenuItemSaveClick(Sender: TObject);
|
||||
procedure OnSyneditChange(Sender: TObject);
|
||||
procedure PickColorEvent(Sender: TObject);
|
||||
procedure Redo(Sender: TObject);
|
||||
procedure Selector_DOWN(Sender: TObject; Button: TMouseButton;
|
||||
Shift: TShiftState; X, Y: Integer);
|
||||
procedure NoTray(Sender: TObject);
|
||||
procedure SynEditProcessCommand(Sender: TObject;
|
||||
var Command: TSynEditorCommand; var AChar: TUTF8Char; Data: pointer);
|
||||
procedure ToTray(Sender: TObject);
|
||||
procedure Undo(Sender: TObject);
|
||||
private
|
||||
{ private declarations }
|
||||
ScriptPath : string;//The path to the saved/opened file currently in the SynEdit
|
||||
StartText : string;//The text synedit holds upon start/open/save
|
||||
ScriptName : string;//The name of the currently opened/saved file.
|
||||
ScriptDefault : string;//The default script e.g. program new; begin end.
|
||||
ScriptChanged : boolean;//We need this for that little * (edited star).
|
||||
public
|
||||
Window: TMWindow;
|
||||
Picker: TMColorPicker;
|
||||
Selector: TMWindowSelector;
|
||||
{ public declarations }
|
||||
function OpenScript : boolean;
|
||||
function SaveCurrentScript : boolean;
|
||||
function SaveCurrentScriptAs : boolean;
|
||||
function CanExitOrOpen : boolean;
|
||||
function ClearScript : boolean;
|
||||
end;
|
||||
|
||||
const
|
||||
WindowTitle = 'Mufasa v2 - %s';//Title, where %s = the place of the filename.
|
||||
var
|
||||
Form1: TForm1;
|
||||
|
||||
@ -120,12 +151,27 @@ begin;
|
||||
Run;
|
||||
end;
|
||||
|
||||
procedure TForm1.ClearDebug(Sender: TObject);
|
||||
begin
|
||||
Memo1.Clear;
|
||||
end;
|
||||
|
||||
procedure TForm1.FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
||||
begin
|
||||
if not CanExitOrOpen then
|
||||
CloseAction := caNone;
|
||||
end;
|
||||
|
||||
procedure TForm1.FormCreate(Sender: TObject);
|
||||
begin
|
||||
Window := TMWindow.Create;
|
||||
Picker := TMColorPicker.Create(Window);
|
||||
Selector := TMWindowSelector.Create(Window);
|
||||
|
||||
StartText:= SynEdit1.Lines.text;
|
||||
ScriptDefault:= StartText;
|
||||
Caption := Format(WindowTitle,['Untitled']);
|
||||
ScriptName:= 'Untitled';
|
||||
ScriptChanged := false;
|
||||
MainDir:= ExtractFileDir(Application.ExeName);
|
||||
PluginsGlob := TMPlugins.Create;
|
||||
PluginsGlob.PluginDirs.Add(ExpandFileName(MainDir + DS + '..' + DS + '..'+ DS + 'Plugins'+ DS));
|
||||
@ -140,11 +186,45 @@ begin
|
||||
PluginsGlob.Free;
|
||||
end;
|
||||
|
||||
procedure TForm1.MenuFileClick(Sender: TObject);
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
procedure TForm1.MenuItemNewClick(Sender: TObject);
|
||||
begin
|
||||
ClearScript;
|
||||
end;
|
||||
|
||||
procedure TForm1.MenuItemOpenClick(Sender: TObject);
|
||||
begin
|
||||
OpenScript;
|
||||
end;
|
||||
|
||||
procedure TForm1.MenuItemRunClick(Sender: TObject);
|
||||
begin
|
||||
Run;
|
||||
end;
|
||||
|
||||
procedure TForm1.MenuItemSaveAsClick(Sender: TObject);
|
||||
begin
|
||||
SaveCurrentScriptAs;
|
||||
end;
|
||||
|
||||
procedure TForm1.MenuItemSaveClick(Sender: TObject);
|
||||
begin
|
||||
SaveCurrentScript;
|
||||
end;
|
||||
|
||||
procedure TForm1.OnSyneditChange(Sender: TObject);
|
||||
begin
|
||||
if not ScriptChanged then
|
||||
begin;
|
||||
ScriptChanged:= True;
|
||||
Self.Caption:= Format(WindowTitle,[ScriptName + '*']);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TForm1.PickColorEvent(Sender: TObject);
|
||||
var
|
||||
c, x, y: Integer;
|
||||
@ -153,6 +233,17 @@ begin
|
||||
writeln('Picked colour: ' + inttostr(c) + ' at (' + inttostr(x) + ', ' + inttostr(y) + ')');
|
||||
end;
|
||||
|
||||
procedure TForm1.Redo(Sender: TObject);
|
||||
begin
|
||||
SynEdit1.Redo;
|
||||
if ScriptChanged then
|
||||
if SynEdit1.Lines.Text = StartText then
|
||||
begin;
|
||||
Self.Caption:= format(WindowTitle,[ScriptName]);
|
||||
ScriptChanged := false;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TForm1.Selector_DOWN(Sender: TObject; Button: TMouseButton;
|
||||
Shift: TShiftState; X, Y: Integer);
|
||||
begin
|
||||
@ -168,11 +259,138 @@ begin
|
||||
Form1.Hide;
|
||||
end;
|
||||
|
||||
procedure TForm1.SynEditProcessCommand(Sender: TObject;
|
||||
var Command: TSynEditorCommand; var AChar: TUTF8Char; Data: pointer);
|
||||
begin
|
||||
if Command = ecUndo then
|
||||
begin;
|
||||
Command:= ecNone;
|
||||
Undo(Sender);
|
||||
end else
|
||||
if Command = ecRedo then
|
||||
begin;
|
||||
Command := ecNone;
|
||||
Redo(Sender);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TForm1.ToTray(Sender: TObject);
|
||||
begin
|
||||
Form1.Hide;
|
||||
end;
|
||||
|
||||
procedure TForm1.Undo(Sender: TObject);
|
||||
begin
|
||||
SynEdit1.Undo;
|
||||
if ScriptChanged then
|
||||
if SynEdit1.Lines.Text = StartText then
|
||||
begin;
|
||||
Self.Caption:= format(WindowTitle,[ScriptName]);
|
||||
ScriptChanged := false;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TForm1.OpenScript: boolean;
|
||||
begin;
|
||||
Result := False;
|
||||
if CanExitOrOpen = false then
|
||||
Exit;
|
||||
with TOpenDialog.Create(nil) do
|
||||
try
|
||||
Filter:= 'Mufasa Files|*.cogat;*.mufa;*.txt|Any files|*.*';
|
||||
if Execute then
|
||||
if FileExists(FileName) then
|
||||
begin;
|
||||
SynEdit1.Lines.LoadFromFile(FileName);
|
||||
StartText := SynEdit1.Lines.text;
|
||||
ScriptName:= ExtractFileNameOnly(FileName);
|
||||
WriteLn('Script name will be: ' + ScriptName);
|
||||
ScriptPath:= FileName;
|
||||
StatusBar.Panels[0].Text:= ScriptName;
|
||||
StatusBar.Panels[1].text:= ScriptPath;
|
||||
Self.Caption:= Format(WindowTitle,[ScriptName]);
|
||||
ScriptChanged := false;
|
||||
Result := True;
|
||||
end;
|
||||
finally
|
||||
Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TForm1.SaveCurrentScript: boolean;
|
||||
begin
|
||||
Result := (ScriptPath <> '');
|
||||
if Result then
|
||||
begin;
|
||||
ScriptChanged := false;
|
||||
SynEdit1.Lines.SaveToFile(ScriptPath);
|
||||
StartText:= SynEdit1.Lines.Text;
|
||||
end
|
||||
else
|
||||
result := SaveCurrentScriptAs;
|
||||
end;
|
||||
|
||||
function TForm1.SaveCurrentScriptAs: boolean;
|
||||
begin
|
||||
Result := false;
|
||||
with TSaveDialog.Create(nil) do
|
||||
try
|
||||
Filter:= 'Mufasa files|*.cogat;*.mufa;*.pas;*.txt|Any Files|*.*';
|
||||
if Execute then
|
||||
begin;
|
||||
if ExtractFileExt(FileName) = '' then
|
||||
begin;
|
||||
ScriptPath := FileName + '.mufa';
|
||||
end else
|
||||
ScriptPath := FileName;
|
||||
SynEdit1.Lines.SaveToFile(ScriptPath);
|
||||
ScriptName:= ExtractFileNameOnly(ScriptPath);
|
||||
StatusBar.Panels[0].Text:= ScriptName;
|
||||
StatusBar.Panels[1].text := ScriptPath;
|
||||
Self.Caption:= Format(WindowTitle,[ScriptName]);
|
||||
WriteLn('Script name will be: ' + ScriptName);
|
||||
Result := True;
|
||||
end;
|
||||
finally
|
||||
Free;
|
||||
end;
|
||||
if result then
|
||||
begin;
|
||||
Writeln('Succesfully saved: ' + ScriptPath);
|
||||
StartText:= SynEdit1.Lines.Text;
|
||||
SynEdit1.MarkTextAsSaved;
|
||||
ScriptChanged := false;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TForm1.CanExitOrOpen: boolean;
|
||||
var
|
||||
I : integer;
|
||||
begin;
|
||||
Result := True;
|
||||
if StartText <> Synedit1.Lines.text then
|
||||
Case MessageBox(0,pchar('Do you want to save the script?'), Pchar('Script has been modified.'),
|
||||
MB_YESNOCANCEL or MB_ICONQUESTION) of
|
||||
IDCANCEL : Result := False;
|
||||
IDYES : Result := SaveCurrentScript;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TForm1.ClearScript: boolean;
|
||||
begin
|
||||
if CanExitOrOpen then
|
||||
begin;
|
||||
ScriptPath:= '';
|
||||
ScriptName:= 'Untitled';
|
||||
StartText:= ScriptDefault;
|
||||
SynEdit1.Lines.Text:= ScriptDefault;
|
||||
StatusBar.Panels[0].Text:= 'Untitled';
|
||||
StatusBar.Panels[1].Text:= '';
|
||||
Self.Caption := Format(WindowTitle,['Untitled']);
|
||||
ScriptChanged:= false;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
initialization
|
||||
{$I testunit.lrs}
|
||||
|
Loading…
Reference in New Issue
Block a user