📄 select.pas
字号:
else
begin
s:=Phrases.Lookup('IMPROVEMENTS',lix and cpIndex);
if (Imp[lix and cpIndex].Kind in [ikNatLocal,ikNatGlobal])
and (MyRO.NatBuilt[lix and cpIndex]>0) then
s:=Format(Phrases.Lookup('NATEXISTS'),[s]);
end;
if NonText then DisplayProject(8+ofs,y0-15,lix);
end;
kAdvance, kFarAdvance, kScience, kChooseTech, kChooseETech, kStealTech:
begin
if lix=adNone then s:=Phrases.Lookup('NOFARTECH')
else if lix=adMilitary then s:=Phrases.Lookup('INITUNIT')
else
begin
s:=Phrases.Lookup('ADVANCES',lix);
if (Kind=kAdvance) and (lix in FutureTech) then
if MyRO.Tech[lix]<tsApplicable then s:=s+' 1'
else s:=s+' '+IntToStr(MyRO.Tech[lix]+1);
end;
if NonText and (lix<>adNone) then
begin // show tech icon
if lix=adMilitary then
begin
Frame(offscreen.Canvas,ofs+(8+16-1),y0-1,ofs+(8+16+36),
y0+20,InnerTex.clBevelLight,InnerTex.clBevelShade);
Dump(offscreen,HGrSystem,ofs+(8+16),y0,36,20,38,295)
end
else
begin
Frame(offscreen.Canvas,ofs+(8+16-1),y0-1,ofs+(8+16+xSizeSmall),
y0+ySizeSmall,InnerTex.clBevelLight,InnerTex.clBevelShade);
if AdvIcon[lix]<84 then
BitBlt(offscreen.Canvas.Handle,ofs+(8+16),y0,xSizeSmall,ySizeSmall,
SmallImp.Canvas.Handle,AdvIcon[lix] mod 7*xSizeSmall,
(AdvIcon[lix]+SystemIconLines*7) div 7*ySizeSmall,SRCCOPY)
else Dump(offscreen,HGrSystem,ofs+(8+16),y0,36,20,
1+(AdvIcon[lix]-84) mod 8*37,295+(AdvIcon[lix]-84) div 8*21);
j:=AdvValue[lix] div 1000;
BitBlt(Handle,ofs+(8+16-4),y0+2,14,14,
GrExt[HGrSystem].Mask.Canvas.Handle,127+j*15,85,SRCAND);
Sprite(offscreen,HGrSystem,ofs+(8+16-5),y0+1,14,14,
127+j*15,85);
end;
end;
if NonText and (Kind in [kAdvance, kFarAdvance, kScience]) then
begin // show research state
for j:=0 to nColumn-1 do
begin
if j=0 then // own science
if lix=MyRO.ResearchTech then
begin
Server(sGetTechCost,me,0,icon);
icon:=4+MyRO.Research*4 div icon;
if icon>4+3 then icon:=4+3
end
else if (Kind=kAdvance)
and ((lix=adMilitary) or (lix in FutureTech)) then icon:=3
else if (lix=adMilitary) or (lix in FutureTech) or (lix=adNone) then
icon:=-1
else if MyRO.Tech[lix]=tsSeen then icon:=1
else if (Kind=kAdvance) and (code[1,sb.si.npos+l]>0) then icon:=3
else if MyRO.Tech[lix]>=tsApplicable then icon:=2
else icon:=-1
else with MyRO.EnemyReport[Column[j]]^ do // enemy science
if (TurnOfCivilReport>=0) and (lix=ResearchTech)
and ((lix=adMilitary) or (lix in FutureTech)
or (Tech[lix]<tsApplicable)) then
icon:=4+ResearchDone div 25
else if (lix=adMilitary) or (lix in FutureTech) then
icon:=-1
else if Tech[lix]>=tsApplicable then
icon:=2
else if Tech[lix]=tsSeen then
icon:=1
else icon:=-1;
if icon>=0 then
Sprite(offscreen,HGrSystem,104+15+3+TechNameSpace+24*j,y0+3,
14,14,67+icon*15,85);
end
end;
end; // kAdvance, kScience
kTribe:
s:=TribeNames[lix];
kDeliver,kCost:
begin
case lix of
opChoose: s:=Phrases.Lookup('PRICECAT_CHOOSE');
opCivilReport: s:=Phrases.Lookup('PRICECAT_CIVIL');
opMilReport: s:=Phrases.Lookup('PRICECAT_MIL');
opMap: s:=Phrases.Lookup('PRICECAT_MAP');
opShipParts+0 shl 16: s:=Phrases.Lookup('PRICECAT_SHIPCOMP');
opShipParts+1 shl 16: s:=Phrases.Lookup('PRICECAT_SHIPPOW');
opShipParts+2 shl 16: s:=Phrases.Lookup('PRICECAT_SHIPHAB');
opMoney: s:=Phrases.Lookup('PRICECAT_MONEY');
opTribute: s:=Phrases.Lookup('PRICECAT_TRIBUTE');
opTech: s:=Phrases.Lookup('PRICECAT_TECH');
opAllTech: s:=Phrases.Lookup('PRICECAT_ALLTECH');
opModel: s:=Phrases.Lookup('PRICECAT_MODEL');
opAllModel: s:=Phrases.Lookup('PRICECAT_ALLMODEL');
// opCity: s:=Phrases.Lookup('PRICECAT_CITY');
opTreaty..opTreaty+trAlliance:
if lix-opTreaty=MyRO.Treaty[DipMem[me].pContact]-1 then
s:=Format(Phrases.Lookup('PRICECAT_ENDTREATY'),
[Phrases.Lookup('TREATY',MyRO.Treaty[DipMem[me].pContact])])
else s:=Phrases.Lookup('TREATY',lix-opTreaty)
end;
end;
kGov:
s:=Phrases.Lookup('GOVERNMENT',lix);
kMission:
s:=Phrases.Lookup('SPYMISSION',lix);
end;
if Kind in [kTribe,kDeliver,kCost,kGov,kMission] then // center text
x:=InnerWidth div 2-ca.TextWidth(s) div 2
else if Kind=kAllEModels then x:=104
else x:=104+15;
y:=y0;
if ca=Canvas then
begin x:=x+SideFrame; y:=y+WideFrame end;
if lit then TextColor:=InnerTex.clLitText
else TextColor:=-1;
{ if Kind=kTribe then ReplaceText_Tribe(x,y,TextColor,
integer(TribeNames.Objects[lix]),s)
else} ReplaceText(x,y,TextColor,s);
end
end;
procedure TSelectDlg.OffscreenPaint;
var
i,j: integer;
begin
case Kind of
kCities: Caption:=Tribe[me].TPhrase('TITLE_CITIES');
kCityEvents: Caption:=Format(Phrases.Lookup('TITLE_EVENTS'),[TurnToString(MyRO.Turn)]);
end;
inherited;
offscreen.Canvas.Font.Assign(UniFont[ftNormal]);
Fill(offscreen.Canvas,0,0,InnerWidth,InnerHeight,0,sb.si.npos*24,InnerTex);
with offscreen.Canvas do
begin
if Kind=kScience then
for i:=1 to nColumn-1 do
begin // colored player columns
Pen.Color:=$000000;
MoveTo(104+15+TechNameSpace+24*i,0);
LineTo(104+15+TechNameSpace+24*i,InnerHeight);
MoveTo(104+15+TechNameSpace+9*2+24*i,0);
LineTo(104+15+TechNameSpace+9*2+24*i,InnerHeight);
Pen.Color:=Tribe[Column[i]].Color;
for j:=1 to 8 do
begin
MoveTo(104+15+TechNameSpace+24*i+j*2,0);
LineTo(104+15+TechNameSpace+24*i+j*2,InnerHeight);
end
end;
for i:=-1 to DispLines do if (i+sb.si.npos>=0) and (i+sb.si.npos<Lines[Layer]) then
line(offscreen.Canvas,i,true,false)
end;
MarkUsedOffscreen(InnerWidth,8+48+DispLines*24);
end;
procedure TSelectDlg.PaintBox1MouseMove(Sender:TObject;
Shift:TShiftState;x,y:integer);
var
i0,Sel0:integer;
begin
y:=y-WideFrame;
i0:=sb.si.npos;
Sel0:=Sel;
if (x>=SideFrame) and (x<SideFrame+InnerWidth) and (y>=0) and (y<InnerHeight)
and (y mod 24>=4) and (y mod 24<20) then
Sel:=y div 24-1
else Sel:=-2;
if (Sel<-1) or (Sel>DispLines) or (Sel+i0<0) or (Sel+i0>=Lines[Layer]) then
Sel:=-2;
if Sel<>Sel0 then with Canvas do
begin
if Sel0<>-2 then line(Canvas,Sel0,false,false);
if Sel<>-2 then line(Canvas,Sel,false,true)
end
end;
function TSelectDlg.RenameCity(cix: integer): boolean;
var
CityNameInfo: TCityNameInfo;
begin
InputDlg.Caption:=Phrases.Lookup('TITLE_CITYNAME');
InputDlg.EInput.Text:=CityName(MyCity[cix].ID);
InputDlg.ShowModal;
if (InputDlg.ModalResult=mrOK) and (InputDlg.EInput.Text<>'')
and (InputDlg.EInput.Text<>CityName(MyCity[cix].ID)) then
begin
CityNameInfo.ID:=MyCity[cix].ID;
CityNameInfo.NewName:=InputDlg.EInput.Text;
Server(cSetCityName+(Length(CityNameInfo.NewName)+8) div 4,me,0,CityNameInfo);
result:=true
end
else result:=false
end;
function TSelectDlg.RenameModel(mix: integer): boolean;
var
ModelNameInfo: TModelNameInfo;
begin
InputDlg.Caption:=Phrases.Lookup('TITLE_MODELNAME');
InputDlg.EInput.Text:=Tribe[me].ModelName[mix];
InputDlg.ShowModal;
if (InputDlg.ModalResult=mrOK) and (InputDlg.EInput.Text<>'')
and (InputDlg.EInput.Text<>Tribe[me].ModelName[mix]) then
begin
ModelNameInfo.mix:=mix;
ModelNameInfo.NewName:=InputDlg.EInput.Text;
Server(cSetModelName+(Length(ModelNameInfo.NewName)+1+4+3) div 4,
me,0,ModelNameInfo);
result:=true
end
else result:=false
end;
procedure TSelectDlg.PaintBox1MouseDown(Sender:TObject;Button:TMouseButton;
Shift:TShiftState;x,y:integer);
var
lix: integer;
begin
if sb.si.npos+Sel>=0 then lix:=code[Layer,sb.si.npos+Sel];
if Kind in [kScience,kCities,kCityEvents,kModels,kEModels,kAllEModels] then
include(Shift, ssShift); // don't close list window
if (ssLeft in Shift) and not(ssShift in Shift) then
begin
if Sel<>-2 then
begin result:=lix; Closable:=true; Close end
end
else if (ssLeft in Shift) and (ssShift in Shift) then
begin // show help/info popup
if Sel<>-2 then
case Kind of
kCities:
begin
MainScreen.CityOpened(MyCity[lix].Loc);
MainScreen.Update;
CityDlg.cix:=lix;
CityDlg.ProdHint:=false;
CityDlg.Happened:=0;
CityDlg.ShowNow;
end;
kCityEvents:
begin
MainScreen.CityOpened(MyCity[lix].Loc);
MainScreen.Update;
CityDlg.cix:=lix;
CityDlg.ProdHint:= (MyCity[lix].Flags and CityRepMask
and (chProduction or chFounded)<>0)
and (MyCity[lix].Project and (cpImp+cpIndex)=cpImp+imTrGoods);
CityDlg.Happened:=MyCity[lix].Flags and CityRepMask;
CityDlg.ShowNow;
end;
kModels:
begin
UnitStatDlg.mix:=lix;
UnitStatDlg.Kind:=dkInfo;
UnitStatDlg.ShowNow;
end;
kEModels:
begin
UnitStatDlg.mox:=@MyRO.EnemyModel[code[1,sb.si.npos+Sel]];
UnitStatDlg.Kind:=dkEnemy;
UnitStatDlg.ShowNow;
end;
kAllEModels:
begin
UnitStatDlg.mox:=@MyRO.EnemyModel[lix];
UnitStatDlg.Kind:=dkEnemy;
UnitStatDlg.ShowNow;
end;
kAdvance,kFarAdvance,kScience:
if lix=adMilitary then HelpDlg.ShowPage(hkText,HelpDlg.TextIndex('MILRES'))
else if lix<>adNone then HelpDlg.ShowPage(hkAdv,lix);
kProject:
if lix=cpImp+imTrGoods then
HelpDlg.ShowPage(hkText,HelpDlg.TextIndex('TRADINGGOODS'))
else if lix and (cpImp+cpType)=0 then
begin
UnitStatDlg.mix:=lix and cpIndex;
UnitStatDlg.Kind:=dkInfo;
UnitStatDlg.ShowNow;
end
else if (lix and cpType=0) and (lix<>cpImp+imTrGoods) then
HelpDlg.ShowPage(hkImp,lix and cpIndex);
kWonders:
HelpDlg.ShowPage(hkImp,lix);
kGov:
HelpDlg.ShowPage(hkMisc,miscGovList);
end
end
else if ssRight in Shift then
begin
if Sel<>-2 then
case Kind of
kCities, kCityEvents:
if RenameCity(lix) then begin OffscreenPaint; SmartInvalidate; end;
kModels:
if RenameModel(lix) then begin OffscreenPaint; SmartInvalidate; end;
end
end
end;
procedure TSelectDlg.InitLines;
procedure TryAddImpLine(Layer,Project: integer);
begin
if Server(sSetCityProject-sExecute,me,cix,Project)>=rExecuted then
begin code[Layer,Lines[Layer]]:=Project; inc(Lines[Layer]); end;
end;
procedure SortTechs;
var
i,j,swap: integer;
begin // sort by advancedness
for i:=0 to Lines[0]-2 do if code[0,i]<>adNone then
for j:=i+1 to Lines[0]-1 do
if AdvValue[code[0,i]]*nAdv+code[0,i]<AdvValue[code[0,j]]*nAdv+code[0,j] then
begin swap:=code[0,i]; code[0,i]:=code[0,j]; code[0,j]:=swap end;
end;
var
Loc1,i,j,p1,dx,dy,mix,emix:integer;
mi: TModelInfo;
PPicture, PTestPicture: ^TModelPicture;
ModelOk: array[0..4095] of boolean;
Exchanged: ^TPriceSet;
ok, ShowTech, ShowModel: boolean;
begin
for i:=0 to MaxLayer-1 do
begin Lines[i]:=0; FirstShrinkedLine[i]:=MaxInt end;
case Kind of
kProject:
begin
// improvements
code[0,0]:=cpImp+imTrGoods;
Lines[0]:=1;
for i:=28 to nImp-1 do
if Imp[i].Kind=ikCommon then
TryAddImpLine(0,i+cpImp);
for i:=0 to nCityType-1 do if MyData.ImpOrder[i,0]>=0 then
begin code[0,Lines[0]]:=cpType+i; inc(Lines[0]); end;
// nat. projects + wonders
for i:=28 to nImp-1 do
if not (Imp[i].Kind in [ikCommon,ikTrGoods])
and ((MyRO.NatBuilt[i]=0) or (Imp[i].Kind=ikNatLocal)) then
TryAddImpLine(1,i+cpImp);
for i:=0 to 27 do
TryAddImpLine(1,i+cpImp);
// units
for i:=0 to MyRO.nModel-1 do
begin
{ if MyModel[i].Kind=mkSlaves then
ok:= MyRO.Wonder[woPyramids].EffectiveOwner=me
else} if MyModel[i].Domain=dSea then
begin
ok:=false;
for dx:=-2 to 2 do for dy:=-2 to 2 do if abs(dx)+abs(dy)=2 then
begin
Loc1:=dLoc(MyCity[cix].Loc,dx,dy);
if (Loc1>=0) and (Loc1<G.lx*G.ly)
and ((MyMap[Loc1] and fTerrain=fShore) or (MyMap[Loc1] and fCanal>0)) then
ok:=true;
end
end
else ok:=true;
if ok then
begin
if MyModel[i].Status and msObsolete=0 then
begin code[2,Lines[2]]:=i; inc(Lines[2]) end;
if MyModel[i].Status and msAllowConscripts<>0 then
begin code[2,Lines[2]]:=i+cpConscripts; inc(Lines[2]) end;
end;
end;
FirstShrinkedLine[2]:=0;
end;
kWonders:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -