Ignore:
Timestamp:
Sep 14, 2024, 11:02:08 AM (5 days ago)
Author:
chronos
Message:
  • Added: Allow to rename city with mouse right click on city caption in City screen.
  • Fixed: Do not overflow city name text in City screen.
  • Fixed: Repaint main screen after city and unit rename.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LocalPlayer/CityScreen.pas

    r592 r613  
    144144  hZoomMap = 124;
    145145  wZoomEnvironment = 68;
     146  CaptionX = 42;
     147  CaptionY = 7;
    146148
    147149  ImpPosition: array [28 .. nImp - 1] of Integer = (
     
    408410    begin
    409411      Assert(cix < 0);
    410       Exit
     412      Exit;
    411413    end;
    412414    Total := TileInfo.Food + TileInfo.Prod + TileInfo.Trade;
     
    444446  end;
    445447var
    446   Line, MessageCount: Integer;
     448  Line: Integer;
     449  MessageCount: Integer;
    447450
    448451  procedure CheckMessage(Flag: Integer);
     
    472475
    473476      S := CityEventName(I);
    474       { if Flag=chNoGrowthWarning then
    475         if C.Built[imAqueduct]=0 then
    476         S:=Format(S,[Phrases.Lookup('IMPROVEMENTS',imAqueduct)])
    477         else S:=Format(S,[Phrases.Lookup('IMPROVEMENTS',imSewer)]); }
     477      { if Flag = chNoGrowthWarning then
     478        if C.Built[imAqueduct] = 0 then
     479        S := Format(S, [Phrases.Lookup('IMPROVEMENTS', imAqueduct)])
     480        else S := Format(S, [Phrases.Lookup('IMPROVEMENTS', imSewer)]); }
    478481      RisedTextOut(Offscreen.Canvas, xmOpt + 40, ymOpt - 1 - 8 * MessageCount +
    479482        16 * Line, S);
     
    528531  BitBltBitmap(Offscreen, 0, 0, 640, 480, Back, 0, 0);
    529532
     533  // Show city size and name
    530534  Offscreen.Canvas.Font.Assign(UniFont[ftCaption]);
    531   RisedTextOut(Offscreen.Canvas, 42, 7, Caption);
    532   with Offscreen.Canvas do
    533   begin // city size
     535
     536  S := Caption;
     537  J := Offscreen.Canvas.TextWidth('...');
     538  if (Length(S) > 1) and (Offscreen.Canvas.TextWidth(S) > PrevCityBtn.Left - CaptionX) then begin
     539    while (Length(S) > 1) and (Offscreen.Canvas.TextWidth(S) > PrevCityBtn.Left - CaptionX - J) do
     540      SetLength(S, Length(S) - 1);
     541    S := S + '...';
     542  end;
     543
     544  RisedTextOut(Offscreen.Canvas, CaptionX, CaptionY, S);
     545  with Offscreen.Canvas do begin // city size
    534546    Brush.Color := $000000;
    535547    FillRect(Rect(8 + 1, 7 + 1, 36 + 1, 32 + 1));
     
    11611173    Exit; // Not an own city
    11621174
     1175  if (ssRight in Shift) then begin
     1176    // Allow to rename city with right mouse click
     1177    if (X >= CaptionX) and (Y >= CaptionY) and (X <= PrevCityBtn.Left) and
     1178    (Y <= NextCityBtn.Top + NextCityBtn.Height) then
     1179    if Term.MainScreen.ListDlg.RenameCity(cix) then begin
     1180      SmartUpdateContent;
     1181      Term.MainScreen.RepaintAll;
     1182    end;
     1183  end else
    11631184  if (ssLeft in Shift) then
    11641185    if (ClientMode < scContact) and (X >= xView) and (Y >= yView) and
     
    12491270                    ShowModal;
    12501271                    if ModalResult <> mrOK then
    1251                       iix := -1
     1272                      iix := -1;
    12521273                  end
    12531274                  else
     
    12701291                    ShowModal;
    12711292                    if ModalResult <> mrOK then
    1272                       iix := -1
     1293                      iix := -1;
    12731294                  end;
    12741295                  if iix >= 0 then
Note: See TracChangeset for help on using the changeset viewer.