- Timestamp:
- Mar 1, 2014, 5:56:14 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Languages/xtactics.po
r21 r22 2 2 msgstr "Content-Type: text/plain; charset=UTF-8" 3 3 4 #: tformmain.aexit.caption 4 #: tcore.aexit.caption 5 msgctxt "TCORE.AEXIT.CAPTION" 5 6 msgid "Exit" 6 7 msgstr "" 7 8 8 #: tformmain.agameend.caption 9 #: tcore.agameend.caption 10 msgctxt "TCORE.AGAMEEND.CAPTION" 9 11 msgid "End" 10 12 msgstr "" 11 13 12 #: tformmain.agameendturn.caption 14 #: tcore.agameendturn.caption 15 msgctxt "TCORE.AGAMEENDTURN.CAPTION" 13 16 msgid "End turn" 14 17 msgstr "" 15 18 16 #: tformmain.agamenew.caption 19 #: tcore.agamenew.caption 20 msgctxt "TCORE.AGAMENEW.CAPTION" 17 21 msgid "New" 18 22 msgstr "" 19 23 20 #: tformmain.agamerestart.caption 24 #: tcore.agamerestart.caption 25 msgctxt "TCORE.AGAMERESTART.CAPTION" 21 26 msgid "Restart" 22 27 msgstr "" … … 34 39 msgstr "" 35 40 36 #: uformmain.splayerwins 41 #: ucore.splayerwins 42 msgctxt "ucore.splayerwins" 37 43 msgid "Player %s wins" 38 44 msgstr "" 39 45 46 #: uformmain.splayerwins 47 msgctxt "uformmain.splayerwins" 48 msgid "Player %s wins" 49 msgstr "" 50 51 #: ugame.sminimumplayers 52 msgid "You need at least two players" 53 msgstr "" 54 -
trunk/UFormMain.lfm
r20 r22 8 8 ClientWidth = 775 9 9 Menu = MainMenu1 10 OnActivate = FormActivate 10 11 OnCreate = FormCreate 11 12 OnDestroy = FormDestroy … … 34 35 Caption = 'Game' 35 36 object MenuItem2: TMenuItem 36 Action = AGameNew37 Action = Core.AGameNew 37 38 end 38 39 object MenuItem3: TMenuItem 39 Action = AGameEnd40 Action = Core.AGameEnd 40 41 end 41 42 object MenuItem7: TMenuItem 42 Action = AGameRestart43 Action = Core.AGameRestart 43 44 end 44 45 object MenuItem4: TMenuItem 45 Action = AGameEndTurn46 Action = Core.AGameEndTurn 46 47 end 47 48 object MenuItem5: TMenuItem … … 49 50 end 50 51 object MenuItem6: TMenuItem 51 Action = AExit52 Action = Core.AExit 52 53 end 53 end54 end55 object ActionList1: TActionList56 left = 22457 top = 4958 object AGameNew: TAction59 Caption = 'New'60 OnExecute = AGameNewExecute61 ShortCut = 1646262 end63 object AExit: TAction64 Caption = 'Exit'65 OnExecute = AExitExecute66 ShortCut = 3288367 end68 object AGameEnd: TAction69 Caption = 'End'70 OnExecute = AGameEndExecute71 ShortCut = 1645472 end73 object AGameEndTurn: TAction74 Caption = 'End turn'75 OnExecute = AGameEndTurnExecute76 ShortCut = 1646877 end78 object AGameRestart: TAction79 Caption = 'Restart'80 OnExecute = AGameRestartExecute81 ShortCut = 1646682 54 end 83 55 end -
trunk/UFormMain.lrt
r20 r22 2 2 TFORMMAIN.MENUITEM1.CAPTION=Game 3 3 TFORMMAIN.MENUITEM5.CAPTION=- 4 TFORMMAIN.AGAMENEW.CAPTION=New5 TFORMMAIN.AEXIT.CAPTION=Exit6 TFORMMAIN.AGAMEEND.CAPTION=End7 TFORMMAIN.AGAMEENDTURN.CAPTION=End turn8 TFORMMAIN.AGAMERESTART.CAPTION=Restart -
trunk/UFormMain.pas
r21 r22 17 17 18 18 TFormMain = class(TForm) 19 AGameRestart: TAction;20 AGameEndTurn: TAction;21 AGameEnd: TAction;22 AExit: TAction;23 AGameNew: TAction;24 ActionList1: TActionList;25 19 MainMenu1: TMainMenu; 26 20 MenuItem1: TMenuItem; … … 33 27 PaintBox1: TPaintBox; 34 28 Timer1: TTimer; 35 procedure AExitExecute(Sender: TObject); 36 procedure AGameEndExecute(Sender: TObject); 37 procedure AGameEndTurnExecute(Sender: TObject); 38 procedure AGameNewExecute(Sender: TObject); 39 procedure AGameRestartExecute(Sender: TObject); 29 procedure FormActivate(Sender: TObject); 40 30 procedure FormCreate(Sender: TObject); 41 31 procedure FormDestroy(Sender: TObject); … … 61 51 MoveActive: Boolean; 62 52 RedrawPending: Boolean; 63 procedure DoOnMove(CellFrom, CellTo: TCell; var CountOnce, CountRepeat: Integer);64 procedure DoOnWin(Player: TPlayer);65 53 public 66 Game: TGame;67 54 procedure Redraw; 68 55 end; … … 74 61 75 62 uses 76 UFormNew, UFormMove; 77 78 resourcestring 79 SPlayerWins = 'Player %s wins'; 63 UFormNew, UFormMove, UCore; 80 64 81 65 {$R *.lfm} … … 85 69 procedure TFormMain.PaintBox1Paint(Sender: TObject); 86 70 begin 87 if Game.Running then88 with Game.CurrentPlayer do begin71 if Core.Game.Running then 72 with Core.Game.CurrentPlayer do begin 89 73 ViewSize := Point(PaintBox1.Width, PaintBox1.Height); 90 74 Paint(PaintBox1); … … 98 82 procedure TFormMain.PaintBox1Resize(Sender: TObject); 99 83 begin 100 if Assigned( Game.CurrentPlayer) then101 with Game.CurrentPlayer do84 if Assigned(Core.Game.CurrentPlayer) then 85 with Core.Game.CurrentPlayer do 102 86 ViewSize := Point(PaintBox1.Width, PaintBox1.Height); 103 87 Redraw; … … 113 97 114 98 NewCaption := 'xTactics'; 115 if Assigned( Game.CurrentPlayer) then116 NewCaption := Game.CurrentPlayer.Name + ' - turn ' + IntToStr(Game.TurnCounter) + ' - ' + NewCaption;99 if Assigned(Core.Game.CurrentPlayer) then 100 NewCaption := Core.Game.CurrentPlayer.Name + ' - turn ' + IntToStr(Core.Game.TurnCounter) + ' - ' + NewCaption; 117 101 Caption := NewCaption; 118 102 end; 119 end;120 121 procedure TFormMain.DoOnMove(CellFrom, CellTo: TCell; var CountOnce,122 CountRepeat: Integer);123 begin124 FormMove.SpinEditOnce.Value := CountOnce;125 FormMove.SpinEditOnce.MaxValue := CellFrom.GetAvialPower;126 FormMove.SpinEditRepeat.Value := CountRepeat;127 FormMove.SpinEditRepeat.MaxValue := Game.Map.MaxPower;128 if FormMove.ShowModal = mrOk then begin129 CountOnce := FormMove.SpinEditOnce.Value;130 CountRepeat := FormMove.SpinEditRepeat.Value;131 end;132 end;133 134 procedure TFormMain.DoOnWin(Player: TPlayer);135 begin136 ShowMessage(Format(SPlayerWins, [Player.Name]));137 103 end; 138 104 … … 144 110 procedure TFormMain.FormCreate(Sender: TObject); 145 111 begin 146 Game := TGame.Create;147 Game.OnMove := DoOnMove;148 Game.OnWin := DoOnWin;149 112 end; 150 113 151 procedure TFormMain. AExitExecute(Sender: TObject);114 procedure TFormMain.FormActivate(Sender: TObject); 152 115 begin 153 Application.Terminate; 154 end; 155 156 procedure TFormMain.AGameEndExecute(Sender: TObject); 157 begin 158 Game.Running := False; 159 Redraw; 160 end; 161 162 procedure TFormMain.AGameEndTurnExecute(Sender: TObject); 163 begin 164 Game.NextTurn; 165 Redraw; 166 while Game.Running and (Game.CurrentPlayer.Mode <> pmHuman) do begin 167 Game.NextTurn; 168 Redraw; 116 if not Core.Initialized then begin 117 Core.Init; 169 118 end; 170 end;171 172 procedure TFormMain.AGameNewExecute(Sender: TObject);173 begin174 FormNew.Load(Game);175 if FormNew.ShowModal = mrOk then begin176 FormNew.Save(Game);177 Game.New;178 Game.Running := True;179 Redraw;180 end;181 end;182 183 procedure TFormMain.AGameRestartExecute(Sender: TObject);184 begin185 Game.New;186 Game.Running := True;187 Redraw;188 119 end; 189 120 190 121 procedure TFormMain.FormDestroy(Sender: TObject); 191 122 begin 192 FreeAndNil(Game);193 123 end; 194 124 195 125 procedure TFormMain.FormShow(Sender: TObject); 196 var197 I: Integer;198 126 begin 199 for I := 0 to Game.Players.Count - 1 do200 TPlayer(Game.Players[I]).ViewSize := Point(PaintBox1.Canvas.Width, PaintBox1.Canvas.Height);201 Game.New;202 Game.Running := True;203 127 Redraw; 204 128 end; … … 208 132 begin 209 133 if Button = mbLeft then begin 210 if Game.CurrentPlayer.Mode = pmHuman then begin134 if Core.Game.CurrentPlayer.Mode = pmHuman then begin 211 135 StartMousePoint := Point(X, Y); 212 StartViewPoint := Game.CurrentPlayer.CellPos;136 StartViewPoint := Core.Game.CurrentPlayer.CellPos; 213 137 MoveActive := True; 214 138 end; … … 225 149 begin 226 150 if MoveActive then begin 227 if Game.CurrentPlayer.Mode = pmHuman then begin228 Game.CurrentPlayer.CellPos := Point(Trunc(StartViewPoint.X + (StartMousePoint.X - X) /Game.CurrentPlayer.ViewZoom),229 Trunc(StartViewPoint.Y + (StartMousePoint.Y - Y) / Game.CurrentPlayer.ViewZoom));151 if Core.Game.CurrentPlayer.Mode = pmHuman then begin 152 Core.Game.CurrentPlayer.CellPos := Point(Trunc(StartViewPoint.X + (StartMousePoint.X - X) / Core.Game.CurrentPlayer.ViewZoom), 153 Trunc(StartViewPoint.Y + (StartMousePoint.Y - Y) / Core.Game.CurrentPlayer.ViewZoom)); 230 154 Redraw; 231 155 end; … … 237 161 begin 238 162 if (Abs(StartMousePoint.X - X) < 5) and (Abs(StartMousePoint.Y - Y) < 5) then begin 239 if Game.Running and (Game.CurrentPlayer.Mode = pmHuman) then begin240 Game.CurrentPlayer.SelectCell(Point(X, Y));163 if Core.Game.Running and (Core.Game.CurrentPlayer.Mode = pmHuman) then begin 164 Core.Game.CurrentPlayer.SelectCell(Point(X, Y)); 241 165 Redraw; 242 166 end; … … 250 174 D: TPoint; 251 175 begin 252 with Game.CurrentPlayer do begin176 with Core.Game.CurrentPlayer do begin 253 177 //D := Point(Trunc(MousePos.X - View.Left / ViewZoom), 254 178 // Trunc(MousePos.Y - View.Top / ViewZoom)); … … 265 189 MousePos: TPoint; var Handled: Boolean); 266 190 begin 267 with Game.CurrentPlayer do191 with Core.Game.CurrentPlayer do 268 192 ViewZoom := ViewZoom * ZoomFactor; 269 193 Redraw; -
trunk/UGame.pas
r21 r22 144 144 implementation 145 145 146 resourcestring 147 SMinimumPlayers = 'You need at least two players'; 148 146 149 function FloatPoint(AX, AY: Double): TFloatPoint; 147 150 begin … … 379 382 if FRunning = AValue then Exit; 380 383 if AValue then begin 381 if Players.Count < 2 then raise Exception.Create( 'You need at least two players');384 if Players.Count < 2 then raise Exception.Create(SMinimumPlayers); 382 385 FRunning := AValue; 383 386 end else FRunning := AValue; -
trunk/xtactics.lpi
r20 r22 77 77 </Item1> 78 78 </RequiredPackages> 79 <Units Count=" 5">79 <Units Count="6"> 80 80 <Unit0> 81 81 <Filename Value="xtactics.lpr"/> … … 112 112 <UnitName Value="UFormMove"/> 113 113 </Unit4> 114 <Unit5> 115 <Filename Value="UCore.pas"/> 116 <IsPartOfProject Value="True"/> 117 <ComponentName Value="Core"/> 118 <HasResources Value="True"/> 119 <ResourceBaseClass Value="DataModule"/> 120 <UnitName Value="UCore"/> 121 </Unit5> 114 122 </Units> 115 123 </ProjectOptions> … … 136 144 <StackChecks Value="True"/> 137 145 </Checks> 138 <VerifyObjMethodCallValidity Value="True"/>139 146 </CodeGeneration> 140 147 <Linking> -
trunk/xtactics.lpr
r12 r22 8 8 {$ENDIF}{$ENDIF} 9 9 Interfaces, // this includes the LCL widgetset 10 Forms, UFormMain, UGame, UFormNew, UFormMove 10 Forms, UFormMain, UGame, UFormNew, UFormMove, UCore 11 11 { you can add units after this }; 12 12 … … 16 16 RequireDerivedFormResource := True; 17 17 Application.Initialize; 18 Application.CreateForm(TCore, Core); 18 19 Application.CreateForm(TFormMain, FormMain); 19 20 Application.CreateForm(TFormNew, FormNew);
Note:
See TracChangeset
for help on using the changeset viewer.