Simba: Some more cleanups.

This commit is contained in:
Merlijn Wajer 2011-04-09 21:33:11 +02:00
parent dfe97bf3a8
commit 6eb7651c27
2 changed files with 25 additions and 4 deletions

View File

@ -32,3 +32,5 @@
//{$DEFINE USE_LAPE} // TODO //{$DEFINE USE_LAPE} // TODO
//{$DEFINE USE_EXTENSIONS} // TODO //{$DEFINE USE_EXTENSIONS} // TODO
//{$DEFINE USE_CODECOMPLETION} // TODO //{$DEFINE USE_CODECOMPLETION} // TODO
//{$DEFINE TERMINALWRITELN} // Only used once. Remove from SimbaUnit?

View File

@ -504,6 +504,7 @@ type
const const
WindowTitle = 'Simba - %s';//Title, where %s = the place of the filename. WindowTitle = 'Simba - %s';//Title, where %s = the place of the filename.
Panel_State = 0; Panel_State = 0;
Panel_Coords = 1; Panel_Coords = 1;
Panel_ScriptName = 2; Panel_ScriptName = 2;
@ -553,7 +554,7 @@ end;
{Global Hotkey Binding } {Global Hotkey Binding }
{$ifdef mswindows} {$IFDEF MSWINDOWS}
{ Used for global callbacks on WINDOWS } { Used for global callbacks on WINDOWS }
function WndCallback(Ahwnd: HWND; uMsg: UINT; wParam: WParam; function WndCallback(Ahwnd: HWND; uMsg: UINT; wParam: WParam;
@ -912,6 +913,7 @@ end;
procedure TSimbaForm.TrayPopupPopup(Sender: TObject); procedure TSimbaForm.TrayPopupPopup(Sender: TObject);
begin begin
{ XXX: What's up with this? }
MenuItemHide.enabled:= SimbaForm.Visible; MenuItemHide.enabled:= SimbaForm.Visible;
{$ifdef MSWindows} {$ifdef MSWindows}
MenuItemShow.Enabled:= not SimbaForm.Visible; MenuItemShow.Enabled:= not SimbaForm.Visible;
@ -963,11 +965,13 @@ begin
ShowMessage('No Updates Available!'); ShowMessage('No Updates Available!');
end; end;
{ Clear te debug memo }
procedure ClearDebug; procedure ClearDebug;
begin begin
{$IFNDEF MSWINDOWS} {$IFNDEF MSWINDOWS} { First write everything we can, then clear }
SimbaForm.ProcessDebugStream(nil); SimbaForm.ProcessDebugStream(nil);
{$ENDIF} {$ENDIF}
TThread.Synchronize(nil,@SimbaForm.Memo1.Clear); TThread.Synchronize(nil,@SimbaForm.Memo1.Clear);
end; end;
@ -1028,7 +1032,7 @@ begin
ScriptThread.Suspended:= True; ScriptThread.Suspended:= True;
ScriptState:= ss_Paused; ScriptState:= ss_Paused;
{$else} {$else}
mDebugLn('Linux users are screwed, no pause button for u!'); mDebugLn('Linux does not yet support suspending threads.');
{$endif} {$endif}
end else if ScriptState = ss_Paused then end else if ScriptState = ss_Paused then
begin; begin;
@ -1066,6 +1070,8 @@ begin
end; end;
end; end;
{ Tab management }
procedure TSimbaForm.AddTab; procedure TSimbaForm.AddTab;
var var
Tab : TMufasaTab; Tab : TMufasaTab;
@ -1143,6 +1149,8 @@ begin
exit; exit;
end; end;
procedure TSimbaForm.SetEditActions; procedure TSimbaForm.SetEditActions;
procedure EditActions(Undo,Redo,Cut,Copy,Paste,Delete : boolean); procedure EditActions(Undo,Redo,Cut,Copy,Paste,Delete : boolean);
begin; begin;
@ -1294,6 +1302,9 @@ begin
RefreshTab; RefreshTab;
end; end;
{ Settings related code }
{ Creates default settings }
procedure TSimbaForm.CreateDefaultEnvironment; procedure TSimbaForm.CreateDefaultEnvironment;
var var
PluginsPath,extensionsPath : string; PluginsPath,extensionsPath : string;
@ -1351,6 +1362,7 @@ begin
UpdateTimer.Interval:=25; UpdateTimer.Interval:=25;
end; end;
{ Load settings }
procedure TSimbaForm.LoadFormSettings; procedure TSimbaForm.LoadFormSettings;
var var
str,str2 : string; str,str2 : string;
@ -1407,6 +1419,7 @@ begin
self.EndFormUpdate; self.EndFormUpdate;
end; end;
{ Save Settings }
procedure TSimbaForm.SaveFormSettings; procedure TSimbaForm.SaveFormSettings;
var var
Data : TStringArray; Data : TStringArray;
@ -1418,7 +1431,7 @@ begin
if Self.WindowState = wsMaximized then if Self.WindowState = wsMaximized then
SetSetting('LastConfig/MainForm/State','maximized') SetSetting('LastConfig/MainForm/State','maximized')
else else
begin; //Only save the form position if its non maximized. begin; //Only save the form position if its not maximized.
SetSetting('LastConfig/MainForm/State','normal'); SetSetting('LastConfig/MainForm/State','normal');
Data := ConvArr([inttostr(Self.left),inttostr(self.top),inttostr(self.width),inttostr(self.height)]); Data := ConvArr([inttostr(Self.left),inttostr(self.top),inttostr(self.width),inttostr(self.height)]);
SetSetting('LastConfig/MainForm/Position', Implode(':',Data )); SetSetting('LastConfig/MainForm/Position', Implode(':',Data ));
@ -1527,6 +1540,9 @@ begin
RecentFileItems[len - 1-i].Caption:= ExtractFileName(RecentFiles[i]); RecentFileItems[len - 1-i].Caption:= ExtractFileName(RecentFiles[i]);
end; end;
{ Loads/Creates the required stuff for a script thread. }
procedure TSimbaForm.InitializeTMThread(out Thread: TMThread); procedure TSimbaForm.InitializeTMThread(out Thread: TMThread);
var var
AppPath : string; AppPath : string;
@ -1558,6 +1574,9 @@ begin
try try
case Interpreter of case Interpreter of
interp_PS : Thread := TPSThread.Create(true,@CurrentSyncInfo,PluginPath); interp_PS : Thread := TPSThread.Create(true,@CurrentSyncInfo,PluginPath);
// XXX: Rutis needs to be completely removed from Simba if it's not defined.
// XXX: Not just print a message that it's not supported now.
interp_RT : {$IFDEF USE_RUTIS}Thread := TRTThread.Create(true,@CurrentSyncInfo,PluginPath){$ELSE}formWriteln('RUTIS NOT SUPPORTED') {$ENDIF}; interp_RT : {$IFDEF USE_RUTIS}Thread := TRTThread.Create(true,@CurrentSyncInfo,PluginPath){$ELSE}formWriteln('RUTIS NOT SUPPORTED') {$ENDIF};
interp_CP : Thread := TCPThread.Create(true,@CurrentSyncInfo,PluginPath); interp_CP : Thread := TCPThread.Create(true,@CurrentSyncInfo,PluginPath);
end; end;