Changeset 613


Ignore:
Timestamp:
Sep 14, 2024, 11:02:08 AM (2 months 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.
Location:
trunk/LocalPlayer
Files:
4 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
  • trunk/LocalPlayer/Diplomacy.pas

    r468 r613  
    2929        Result := Tribe[P].TPhrase('PRICE_MAP');
    3030      opTreaty:
    31         { if Price-opTreaty<Treaty then
     31        { if Price - opTreaty < Treaty then
    3232          case Treaty of
    33           trPeace: Result:=Phrases.Lookup('FRENDTREATY_PEACE');
    34           trFriendlyContact: Result:=Phrases.Lookup('FRENDTREATY_FRIENDLY');
    35           trAlliance: Result:=Phrases.Lookup('FRENDTREATY_ALLIANCE');
     33            trPeace: Result := Phrases.Lookup('FRENDTREATY_PEACE');
     34            trFriendlyContact: Result := Phrases.Lookup('FRENDTREATY_FRIENDLY');
     35            trAlliance: Result := Phrases.Lookup('FRENDTREATY_ALLIANCE');
    3636          end
    3737          else } Result := Phrases.Lookup('TREATY', Price - opTreaty);
     
    6161        Result := Tribe[P].TPhrase('PRICE_ALLMODEL');
    6262      { opCity:
    63         Result:=Format(TPhrase('PRICE_CITY',P),[CityName(Price-opCity)]); }
    64     end
     63        Result := Format(TPhrase('PRICE_CITY', P), [CityName(Price - opCity)]); }
     64    end;
    6565  end;
    6666
     
    9292          (Integer(OppOffer.Price[0] - opTreaty) > Treaty) then
    9393        // simple treaty offer
    94           { if OppOffer.Price[0]-opTreaty=trCeaseFire then
    95             Result:=Tribe[pTarget].TPhrase('FRACCEPTCEASEFIRE')
     94          { if OppOffer.Price[0] - opTreaty = trCeaseFire then
     95            Result := Tribe[pTarget].TPhrase('FRACCEPTCEASEFIRE')
    9696            else } Result := Tribe[pTarget].TPhrase('FRACCEPTTREATY')
    9797        else if OppOffer.nDeliver = 0 then
     
    132132            sDeliver := sAdd
    133133          else
    134             sDeliver := Format(Phrases.Lookup('PRICE_CONCAT'), [sDeliver, sAdd])
     134            sDeliver := Format(Phrases.Lookup('PRICE_CONCAT'), [sDeliver, sAdd]);
    135135        end;
    136136        sCost := '';
     
    141141            sCost := sAdd
    142142          else
    143             sCost := Format(Phrases.Lookup('PRICE_CONCAT'), [sCost, sAdd])
     143            sCost := Format(Phrases.Lookup('PRICE_CONCAT'), [sCost, sAdd]);
    144144        end;
    145145
     
    167167            end;
    168168            Result := Result + Phrases.Lookup('FRDONE');
    169             DoIntro := False
    170           end
     169            DoIntro := False;
     170          end;
    171171        end
    172172        else if (Offer.nDeliver + Offer.nCost = 1) and
     
    183183            trAlliance:
    184184              Result := Result + Tribe[pTarget].TPhrase('FRALLIANCE');
    185           end
     185          end;
    186186        end
    187187        else if Offer.nDeliver = 0 then // demand
     
    196196            Result := Result +
    197197              Format(Tribe[pTarget].TPhrase('FRDEMAND_STRONG'), [sCost]);
    198             DoIntro := False
    199           end
     198            DoIntro := False;
     199          end;
    200200        end
    201201        else if Offer.nCost = 0 then // present
     
    216216      Result := Tribe[pSender].TPhrase('FRSTART_NOTREATY') + ' ' + Result
    217217    else
    218       Result := Tribe[pSender].TPhrase('FRSTART_PEACE') + ' ' + Result
     218      Result := Tribe[pSender].TPhrase('FRSTART_PEACE') + ' ' + Result;
    219219end;
    220220
  • trunk/LocalPlayer/Select.pas

    r558 r613  
    6969    procedure InitLines;
    7070    procedure Line(ca: TCanvas; L: Integer; NonText, lit: Boolean);
    71     function RenameCity(cix: Integer): Boolean;
    7271    function RenameModel(mix: Integer): Boolean;
    7372    procedure OnScroll(var Msg: TMessage); message WM_VSCROLL;
     
    7574  public
    7675    Result: Integer;
     76    function RenameCity(cix: Integer): Boolean;
    7777    function OnlyChoice(TestKind: TListKind): Integer;
    7878    // -2=empty, -1=ambiguous, other=only choice
     
    248248  if ScrollBar.Position + L >= FirstShrinkedLine[Layer] then
    249249    ofs := (ScrollBar.Position + L - FirstShrinkedLine[Layer]) and 1 * 33
    250   else { if FirstShrinkedLine[Layer]<Lines[Layer] then }
     250  else { if FirstShrinkedLine[Layer] < Lines[Layer] then }
    251251    ofs := 33;
    252252
     
    973973      case Kind of
    974974        kCities, kCityEvents:
    975           if RenameCity(lix) then
     975          if RenameCity(lix) then begin
    976976            SmartUpdateContent;
     977            Term.MainScreen.RepaintAll;
     978          end;
    977979        kModels:
    978           if RenameModel(lix) then
     980          if RenameModel(lix) then begin
    979981            SmartUpdateContent;
     982            Term.MainScreen.RepaintAll;
     983          end;
    980984      end;
    981985  end;
  • trunk/LocalPlayer/Term.pas

    r612 r613  
    442442    procedure UpdateViews(UpdateCityScreen: Boolean = False);
    443443    function ContactRefused(P: Integer; Item: String): Boolean;
     444    procedure RepaintAll;
    444445    // Forms
    445446    property WondersDlg: TWondersDlg read GetWondersDlg;
     
    44064407                MessgText := Format(Phrases.Lookup(MsgItem), [CityName(ID)]);
    44074408                Kind := mkYesNo;
    4408                 // BigIcon:=29;
     4409                // BigIcon := 29;
    44094410                ShowModal;
    44104411                Zoom := ModalResult <> mrOK;
     
    47874788  MiniMapPaint;
    47884789  PanelPaint;
     4790end;
     4791
     4792procedure TMainScreen.RepaintAll;
     4793begin
     4794  RectInvalidate(0, TopBarHeight, Width, TopBarHeight + MapHeight);
     4795  MapValid := False;
     4796  PaintAll;
    47894797end;
    47904798
     
    83788386  ManagementArea.Top := TopBarHeight + MapHeight - Overlap + yPalace;
    83798387  ArrangeMidPanel;
    8380   if RepaintOnResize then begin
    8381     RectInvalidate(0, TopBarHeight, Width, TopBarHeight + MapHeight);
    8382     MapValid := False;
    8383     PaintAll;
    8384   end;
     8388  if RepaintOnResize then RepaintAll;
    83858389end;
    83868390
Note: See TracChangeset for help on using the changeset viewer.