Changeset 596 for trunk


Ignore:
Timestamp:
Aug 11, 2024, 9:39:45 PM (3 months ago)
Author:
chronos
Message:
  • Modified: Remember last selected map between application restarts.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Start.pas

    r589 r596  
    122122    MiniMap: TMiniMap;
    123123    LastGame: string;
     124    LastMap: string;
    124125    procedure DrawAction(Y, IconIndex: Integer; HeaderItem, TextItem: string);
    125126    procedure InitPopup(PlayerIndex: Integer);
     
    403404    if ValueExists('LastGame') then LastGame := Reg.ReadString('LastGame')
    404405       else LastGame := '';
     406    if ValueExists('LastMap') then LastMap := Reg.ReadString('LastMap')
     407       else LastMap := '';
    405408    if ValueExists('NetworkEnabled') then NetworkEnabled := Reg.ReadBool('NetworkEnabled')
    406409       else NetworkEnabled := False;
     
    463466    WriteInteger('StartTab', Integer(ShowTab));
    464467    WriteString('LastGame', LastGame);
     468    WriteString('LastMap', LastMap);
    465469    WriteBool('NetworkEnabled', NetworkEnabled);
    466470  finally
     
    13071311procedure TStartDlg.UpdateMaps;
    13081312var
     1313  I: Integer;
    13091314  F: TSearchRec;
    13101315begin
     
    13171322  Maps.Sort;
    13181323  Maps.Insert(0, Phrases.Lookup('RANMAP'));
    1319   ListIndex[tbMain] := Maps.IndexOf(ExtractFileNameOnly(MapFileName));
     1324  I := Maps.IndexOf(LastMap);
     1325  if I > 0 then begin // Skip random map on index 0
     1326    ListIndex[tbMap] := I;
     1327    MapFileName := GetMapsDir + DirectorySeparator + Maps[I] + CevoMapExt;
     1328  end else ListIndex[tbMap] := Maps.IndexOf(ExtractFileNameOnly(MapFileName));
     1329  if ListIndex[tbMap] < 0 then
     1330    ListIndex[tbMap] := 0;
     1331  ListIndex[tbMain] := ListIndex[tbMap];
    13201332  if ListIndex[tbMain] < 0 then
    13211333    ListIndex[tbMain] := 0;
     
    18011813    LastGame := FormerGames[ListIndex[tbPrevious]]
    18021814    else LastGame := '';
     1815  if (ListIndex[tbMap] >= 0) and (ListIndex[tbMap] < Maps.Count) then
     1816    LastMap := Maps[ListIndex[tbMap]]
     1817    else LastMap := '';
    18031818end;
    18041819
Note: See TracChangeset for help on using the changeset viewer.