📄 term.pas
字号:
skipped:=false; // always show my moves during my turn
idle:=true;
InitTurn(NewPlayer);
DipMem[me].pContact:=-1;
if NatStatDlg.Visible then NatStatDlg.ShowNow;
(* if (me=0) and (MyRO.Alive and (1 shl me)=0)} then
begin
if SimpleQuery(Phrases.Lookup('RESIGN'))=mrIgnore then
Server(sResign,me,0,nil^)
else Server(sBreak,me,0,nil^)
end
else*) Play('TURNSTART');
end
end;
cEditMap:
begin
ClientMode:=cEditMap;
ItsMeAgain(0);
MyData:=nil;
GameBtn.Visible:=true;
StatBtn.Visible:=false;
UnitBtn.Visible:=false;
EOT.Visible:=false;
for i:=0 to ControlCount-1 do if Controls[i] is TButtonC then
Controls[i].visible:=false;
HelpDlg.Difficulty:=0;
BrushType:=fGrass;
BrushLoc:=-1;
UnFocus:=-1;
Tracking:=false;
TurnComplete:=false;
SetTroopLoc(-1);
MapValid:=false;
MainPaint;
idle:=true
end;
scContact:
begin
DipMem[NewPlayer].pContact:=integer(Data);
if Jump[NewPlayer]>0 then DipCall(scReject)
else
begin
ClientMode:=Command;
InitTurn(NewPlayer);
// Play(contact sound!!!);
with MessgExDlg do
begin
MessgText:=Tribe[integer(Data)].TPhrase('FRCONTACT');
Kind:=mkYesNo;
TribeIcon:=integer(Data);
ShowModal;
if ModalResult=mrOK then
begin
NatStatDlg.DialogText[me]:='';
DipMem[me].DeliveredPrices:=[];
DipMem[me].ReceivedPrices:=[];
DipCall(scDipStart)
end
else
begin
DipCall(scReject);
EndNego
end
end
end;
end;
scDipStart..scDipBreak:
begin
ClientMode:=Command;
InitTurn(NewPlayer);
if Command=scDipOffer then ReceivedOffer:=TOffer(Data)
else if Command=scDipAccept then
begin // remember delivered and received prices
for i:=0 to DipMem[me].SentOffer.nDeliver-1 do
include(DipMem[me].DeliveredPrices,DipMem[me].SentOffer.Price[i] shr 24);
for i:=0 to DipMem[me].SentOffer.nCost-1 do
include(DipMem[me].ReceivedPrices,
DipMem[me].SentOffer.Price[DipMem[me].SentOffer.nDeliver+i] shr 24);
end;
if ClientMode<>scDipStart then
NatStatDlg.DialogText[me]:=NatStatDlg.DialogText[me]+'\'
+char(64+DipMem[me].pContact)+Format(Phrases.Lookup('FRSAY'),
[DipCommandToString(DipMem[me].pContact,me, DipMem[me].FormerTreaty,
DipMem[me].SentCommand, ClientMode,
DipMem[me].SentOffer, ReceivedOffer)]);
NatStatDlg.Mode:=mStat;
NatStatDlg.ShowNow;
idle:=true
end;
cShowCancelTreatyByAlliance:
if idle and (NewPlayer=me) then with MessgExDlg do
begin
MessgText:=Tribe[integer(data)].TPhrase('FRENEMYALLIANCE');
Kind:=mkOK;
TribeIcon:=integer(data);
ShowModal;
end;
cShowEndContact: EndNego;
cShowUnitChanged,cShowCityChanged,cShowAfterMove,cShowAfterAttack:
if idle and (NewPlayer=me) or not idle and not skipped then
begin
Application.ProcessMessages;
if idle or mEnMoves.Checked
or (Command=cShowCityChanged) and mEnAttacks.Checked then
begin
if Command=cShowCityChanged then MapValid:=false;
FocusOnLoc(integer(Data),flImmUpdate);
if Command=cShowAfterMove then
PaintLoc(integer(Data),AfterMovePaintRadius) // show discovered areas
else PaintLoc(integer(Data));
if not idle then
if Command=cShowCityChanged then
Sleep(MoveTime*WaitAfterShowMove div 16)
else if (Command=cShowUnitChanged)
and (MyMap[integer(Data)] and fUnit<>0) then
Sleep(MoveTime*WaitAfterShowMove div 32)
end
end;
cShowMoving,cShowCapturing:
if idle and (NewPlayer=me) or not idle and not skipped then
begin
Application.ProcessMessages;
with TShowMove(Data) do
begin
if idle or mEnMoves.Checked
or (not mEnNoMoves.Checked and (Command=cShowCapturing)) then
begin
if not idle and (Tribe[Owner].ModelPicture[mix].HGr=0) then
InitEnemyModel(MyRO.EnemyModel[emix],true);
ToLoc:=dLoc(FromLoc,dx,dy);
if idle then
begin // own unit -- make discovered land visible
assert(Owner=me); // no foreign moves during my turn!
with MyModel[mix] do
if (Kind=mkDiplomat) or (Domain=dAir)
or (Cap[mcRadar]+Cap[mcCarrier]+Cap[mcAcademy]>0)
or (MyMap[ToLoc] and fTerrain=fMountains) then
AfterMovePaintRadius:=2
else AfterMovePaintRadius:=1
end
else if MyRO.Treaty[Owner]=trAlliance then
begin // allied unit -- make discovered land visible
with MyRO.EnemyModel[emix] do
if (Kind=mkDiplomat) or (Domain=dAir) or (ATrans_Fuel>0)
or (Cap and (1 shl (mcRadar-mcFirstNonCap) or 1 shl (mcAcademy-mcFirstNonCap))<>0)
or (MyMap[ToLoc] and fTerrain=fMountains) then
AfterMovePaintRadius:=2
else AfterMovePaintRadius:=1
end
else AfterMovePaintRadius:=0; // enemy unit, nothing discovered
if not idle and not mEnMoves.Checked then
MapValid:=false;
FocusOnLoc(FromLoc,flImmUpdate);
PaintLoc(FromLoc);
if Command=cShowCapturing then
begin
Play('CAPTURE');
MoveOnScreen(TShowMove(Data),1,32,32);
end
else
begin
Play('MOVE_STD');
MoveOnScreen(TShowMove(Data),1,16,16)
end;
end
end
end;
cShowAttacking:
if idle and (NewPlayer=me) or not idle and not skipped then
begin
Application.ProcessMessages;
if idle or not mEnNoMoves.Checked then with TShowMove(Data) do
begin
ToLoc:=dLoc(FromLoc,dx,dy);
if Tribe[Owner].ModelPicture[mix].HGr=0 then
InitEnemyModel(MyRO.EnemyModel[emix],true);
if not idle and not mEnMoves.Checked then
MapValid:=false;
FocusOnLoc(FromLoc,flImmUpdate);
// before combat
MainMap.AttackBegin(TShowMove(Data));
PaintLoc(FromLoc);
Play('ATTACK_STD');
MoveOnScreen(TShowMove(Data),1,9,16);
MoveOnScreen(TShowMove(Data),17,12,32);
MoveOnScreen(TShowMove(Data),7,11,16);
// after combat
MainMap.AttackEffect(TShowMove(Data));
PaintLoc(ToLoc);
if EndHealth>0 then
begin
Health:=EndHealth;
MoveOnScreen(TShowMove(Data),10,0,16);
end
else if not idle then
Sleep(MoveTime div 2);
MainMap.AttackEnd;
end
end;
cShowMissionResult:
if Cardinal(Data)=0 then
SimpleMessage(Phrases.Lookup('NOFOREIGNINFO'),'')
else
begin
s:=Phrases.Lookup('FOREIGNINFO');
for p1:=0 to nPl-1 do if 3 shl (p1*2) and Cardinal(Data)<>0 then
s:=s+'\'+Tribe[p1].TPhrase('SHORTNAME');
SimpleMessage(s,'')
end;
else if Command>=cClientEx then case Command and $FFF0 of
cSetTribe: with TTribeInfo(Data) do
begin
i:=UnusedTribeFiles.Count-1;
while (i>=0) and (AnsiCompareFileName(UnusedTribeFiles[i],FileName)<>0) do
dec(i);
if i>=0 then UnusedTribeFiles.Delete(i);
CreateTribe(trix,FileName,true);
end;
cSetNewModelPicture, cSetModelPicture:
if TribeOriginal[TModelPictureInfo(Data).trix] then
Tribe[TModelPictureInfo(Data).trix].SetModelPicture(
TModelPictureInfo(Data),Command and $FFF0=cSetNewModelPicture);
cSetSlaveIndex and $FFF0:
Tribe[integer(data) shr 16].mixSlaves:=integer(data) and $FFFF;
cSetCityName: with TCityNameInfo(Data) do
if TribeOriginal[ID shr 12] then
Tribe[ID shr 12].SetCityName(ID and $FFF,NewName);
cSetModelName: with TModelNameInfo(Data) do
if TribeOriginal[NewPlayer] then
Tribe[NewPlayer].ModelName[mix]:=NewName;
end
end
end;{<<<client}
{*** main part ***}
procedure TMainScreen.CreateParams (var p: TCreateParams);
var
DefaultOptionChecked: integer;
Reg: TRegistry;
doinit: boolean;
begin
inherited;
// define which menu settings to save
SaveOption[0]:=mFullScreen.Tag;
SaveOption[1]:=mEnMoves.Tag;
SaveOption[2]:=mEnAttacks.Tag;
SaveOption[3]:=mEnNoMoves.Tag;
SaveOption[4]:=mWaitTurn.Tag;
SaveOption[5]:=mTechExt.Tag;
SaveOption[6]:=-1;
SaveOption[7]:=-1;
SaveOption[8]:=-1;
SaveOption[9]:=-1;
SaveOption[10]:=mNames.Tag;
SaveOption[11]:=mRepList.Tag;
SaveOption[12]:=mRepScreens.Tag;
DefaultOptionChecked:= 1 shl 1 + 1 shl 6 + 1 shl 10 + 1 shl 12;
Reg:=TRegistry.Create;
doinit:=true;
if Reg.KeyExists('SOFTWARE\cevo\RegVer5') then
begin
doinit:=false;
Reg.OpenKey('SOFTWARE\cevo\RegVer5',false);
try
OptionChecked:=Reg.ReadInteger('OptionChecked');
MapOptionChecked:=Reg.ReadInteger('MapOptionChecked');
CityRepMask:=Reg.ReadInteger('CityReport');
except
doinit:=true;
end;
Reg.closekey;
end;
Reg.Free;
if doinit then
begin
OptionChecked:=DefaultOptionChecked;
MapOptionChecked:=1 shl moCityNames;
CityRepMask:=not chPopIncrease and not chNoGrowthWarning and not chCaptured;
end;
FullScreen:= 1 shl 0 and OptionChecked=0;
if FullScreen then
begin
p.Style:=$87000000;
BorderStyle:=bsNone;
BorderIcons:=[];
end
end;
procedure TMainScreen.FormCreate(Sender:TObject);
var
i,j: integer;
begin
Screen.Cursors[crImpDrag]:=LoadCursor(HInstance,'DRAG');
for i:=0 to ComponentCount-1 do
if Components[i].Tag and $FF<>0 then
if Components[i] is TMenuItem then
begin
TMenuItem(Components[i]).Caption:=
Phrases.Lookup('CONTROLS',-1+Components[i].Tag and $FF);
for j:=0 to nSaveOption-1 do
if Components[i].Tag and $FF=SaveOption[j] then
TMenuItem(Components[i]).Checked:= 1 shl j and OptionChecked<>0;
end
else if Components[i] is TButtonBase then
begin
TButtonBase(Components[i]).Hint:=
Phrases.Lookup('CONTROLS',-1+Components[i].Tag and $FF);
if Components[i] is TButtonC then
TButtonC(Components[i]).ButtonIndex:=
MapOptionChecked shr (Components[i].Tag shr 8) and 1 +2
end;
for i:=0 to mRep.Count-1 do
begin
j:=mRep[i].Tag shr 8;
mRep[i].Caption:=Phrases.Lookup('CITYEVENTS',j);
mRep[i].Checked:= CityRepMask and (1 shl j)<>0;
end;
mFullScreen.Checked:=not FullScreen;
Mini:=TBitmap.Create;
Mini.PixelFormat:=pf24bit;
Panel:=TBitmap.Create;
if TrueColor=1 then
Panel.PixelFormat:=pf24bit;
Panel.Canvas.Font.Assign(UniFont[ftSmall]);
Panel.Canvas.Brush.Style:=bsClear;
Buffer:=TBitmap.Create;
if TrueColor=1 then
Buffer.PixelFormat:=pf24bit;
Buffer.Width:=2*lxmax;Buffer.Height:=lymax;
Buffer.Canvas.Font.Assign(UniFont[ftSmall]);
InitButtons(self);
end;
procedure TMainScreen.FormDestroy(Sender:TObject);
var
i,j: integer;
Reg: TRegistry;
begin
OptionChecked:=0;
for i:=0 to ComponentCount-1 do if Components[i] is TMenuItem then
for j:=0 to nSaveOption-1 do
if TMenuItem(Components[i]).Checked
and (TMenuItem(Components[i]).Tag=SaveOption[j]) then
inc(OptionChecked,1 shl j);
Reg:=TRegistry.Create;
Reg.OpenKey('SOFTWARE\cevo\RegVer5',true);
Reg.WriteInteger('OptionChecked', OptionChecked);
Reg.WriteInteger('MapOptionChecked', MapOptionChecked);
Reg.WriteInteger('CityReport',CityRepMask);
Reg.closekey;
Reg.Free;
Mini.Free;Buffer.Free;Panel.Free;
end;
procedure TMainScreen.OnEraseBkgnd(var m:TMessage);
begin
end;
procedure TMainScreen.FormResize(Sender:TObject);
begin
MapWidth:=ClientWidth; MapHeight:=ClientHeight-PanelHeight+overlap;
Panel.Width:=ClientWidth; Panel.Height:=PanelHeight;
xMini:=ClientWidth-G.lx*2-11-26; yMini:=PanelHeight div 2-G.ly div 2;
ywmax:=(G.ly-MapHeight div 16+1) and not 1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -