Changeset 79 for trunk/UCore.pas


Ignore:
Timestamp:
Nov 4, 2014, 8:57:21 AM (10 years ago)
Author:
chronos
Message:
  • Removed: Useless old method GetCellNeighbors. Cell neigbours can be now accessed directly.
  • Modified: Optimized canvas TextOut to not move pointer after text displaying.
  • Fixed: Computer inner moves were calculated incorrectly multiple times for same cells. This was slowing down calculation in particular for large maps.
  • Added: Used PersistentForm component to keep forms position and size. So far it not supports xmlconfig class.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UCore.pas

    r77 r79  
    77uses
    88  Classes, SysUtils, XMLConf, FileUtil, ActnList, Controls, Dialogs, Forms,
    9   UGame, UApplicationInfo, UCoolTranslator;
     9  UGame, UApplicationInfo, UPersistentForm, UCoolTranslator;
    1010
    1111type
     
    2929    ImageListSmall: TImageList;
    3030    OpenDialog1: TOpenDialog;
     31    PersistentForm: TPersistentForm;
    3132    SaveDialog1: TSaveDialog;
    3233    XMLConfig1: TXMLConfig;
     
    5152    procedure GameNewTurnExecute(Sender: TObject);
    5253    procedure AutoSave;
     54    procedure LoadConfig;
     55    procedure SaveConfig;
    5356  public
    5457    Game: TGame;
     
    143146end;
    144147
     148procedure TCore.LoadConfig;
     149begin
     150  LastMapFileName := XMLConfig1.GetValue('LastMapFileName', '');
     151  DevelMode := XMLConfig1.GetValue('DevelMode', false);
     152  AnimationSpeed := XMLConfig1.GetValue('AnimationSpeed', 50);
     153  AutoSaveEnabled := XMLConfig1.GetValue('AutoSave', True);
     154  CoolTranslator1.Language := CoolTranslator1.Languages.SearchByCode(XMLConfig1.GetValue('Language', ''));
     155end;
     156
     157procedure TCore.SaveConfig;
     158begin
     159  XMLConfig1.SetValue('Language', CoolTranslator1.Language.Code);
     160  XMLConfig1.SetValue('LastMapFileName', LastMapFileName);
     161  XMLConfig1.SetValue('DevelMode', DevelMode);
     162  XMLConfig1.SetValue('AnimationSpeed', AnimationSpeed);
     163  XMLConfig1.SetValue('AutoSave', AutoSaveEnabled);
     164end;
     165
    145166procedure TCore.UpdateActions;
    146167begin
     
    269290begin
    270291  Game.SaveConfig(XMLConfig1, 'Game');
    271   XMLConfig1.SetValue('Language', CoolTranslator1.Language.Code);
    272   XMLConfig1.SetValue('LastMapFileName', LastMapFileName);
    273   XMLConfig1.SetValue('DevelMode', DevelMode);
    274   XMLConfig1.SetValue('AnimationSpeed', AnimationSpeed);
    275   XMLConfig1.SetValue('AutoSave', AutoSaveEnabled);
     292  SaveConfig;
    276293  FreeAndNil(Game);
    277294end;
     
    282299begin
    283300  FInitialized := True;
    284   LastMapFileName := XMLConfig1.GetValue('LastMapFileName', '');
    285   DevelMode := XMLConfig1.GetValue('DevelMode', false);
    286   AnimationSpeed := XMLConfig1.GetValue('AnimationSpeed', 50);
    287   AutoSaveEnabled := XMLConfig1.GetValue('AutoSave', True);
    288   CoolTranslator1.Language := CoolTranslator1.Languages.SearchByCode(XMLConfig1.GetValue('Language', ''));
     301  LoadConfig;
    289302  for I := 0 to Game.Players.Count - 1 do
    290303    TPlayer(Game.Players[I]).View.DestRect := Rect(0, 0, FormMain.PaintBox1.Width,
Note: See TracChangeset for help on using the changeset viewer.