Changeset 179
- Timestamp:
- Feb 6, 2018, 3:47:23 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormNew.lfm
r155 r179 1 1 object FormNew: TFormNew 2 Left = 11763 Height = 5014 Top = 3315 Width = 6772 Left = 596 3 Height = 617 4 Top = 243 5 Width = 775 6 6 Caption = 'New game' 7 ClientHeight = 5018 ClientWidth = 6777 ClientHeight = 617 8 ClientWidth = 775 9 9 Constraints.MinHeight = 501 10 10 Constraints.MinWidth = 667 11 DesignTimePPI = 120 12 OnClose = FormClose 11 13 OnCreate = FormCreate 12 14 OnDestroy = FormDestroy 13 15 OnShow = FormShow 14 16 Position = poMainFormCenter 15 LCLVersion = '1.8.0.4' 16 object ButtonCancel: TButton 17 Left = 454 18 Height = 25 19 Top = 459 20 Width = 75 21 Anchors = [akRight, akBottom] 22 Caption = 'Cancel' 23 ModalResult = 2 24 TabOrder = 0 25 end 26 object ButtonOk: TButton 27 Left = 558 28 Height = 25 29 Top = 459 30 Width = 75 31 Anchors = [akRight, akBottom] 32 Caption = 'Ok' 33 ModalResult = 1 34 TabOrder = 1 35 end 17 LCLVersion = '1.8.0.6' 36 18 object PageControl1: TPageControl 37 19 Left = 4 38 Height = 43920 Height = 330 39 21 Top = 4 40 Width = 669 41 ActivePage = TabSheet2 42 Align = alTop 43 Anchors = [akTop, akLeft, akRight, akBottom] 22 Width = 767 23 ActivePage = TabSheetMode 24 Align = alClient 44 25 BorderSpacing.Around = 4 45 TabIndex = 1 46 TabOrder = 2 26 TabIndex = 0 27 TabOrder = 0 28 object TabSheetMode: TTabSheet 29 Caption = 'Mode' 30 ClientHeight = 297 31 ClientWidth = 759 32 object RadioButtonModeLocal: TRadioButton 33 Left = 10 34 Height = 24 35 Top = 14 36 Width = 59 37 Caption = 'Local' 38 OnChange = RadioButtonModeLocalChange 39 TabOrder = 0 40 end 41 object RadioButtonModeNetworkServer: TRadioButton 42 Left = 10 43 Height = 24 44 Top = 48 45 Width = 123 46 Caption = 'Network server' 47 OnChange = RadioButtonModeLocalChange 48 TabOrder = 1 49 end 50 object RadioButtonModeNetworkClient: TRadioButton 51 Left = 10 52 Height = 24 53 Top = 152 54 Width = 120 55 Caption = 'Network client' 56 OnChange = RadioButtonModeLocalChange 57 TabOrder = 2 58 end 59 object EditServerAddress: TEdit 60 Left = 24 61 Height = 28 62 Top = 112 63 Width = 220 64 TabOrder = 3 65 end 66 object SpinEditServerPort: TSpinEdit 67 Left = 256 68 Height = 28 69 Top = 112 70 Width = 79 71 MaxValue = 65535 72 TabOrder = 4 73 end 74 object Label11: TLabel 75 Left = 256 76 Height = 20 77 Top = 88 78 Width = 30 79 Caption = 'Port:' 80 ParentColor = False 81 end 82 object Label12: TLabel 83 Left = 24 84 Height = 20 85 Top = 88 86 Width = 56 87 Caption = 'Address:' 88 ParentColor = False 89 end 90 object ListViewServers: TListView 91 Left = 26 92 Height = 97 93 Top = 181 94 Width = 326 95 Anchors = [akTop, akLeft, akBottom] 96 Columns = < 97 item 98 Caption = 'Name' 99 Width = 100 100 end 101 item 102 Caption = 'Address' 103 Width = 200 104 end> 105 TabOrder = 5 106 ViewStyle = vsReport 107 end 108 end 47 109 object TabSheet1: TTabSheet 48 110 Caption = 'Players' 49 ClientHeight = 39550 ClientWidth = 66351 object ListView 1: TListView111 ClientHeight = 297 112 ClientWidth = 759 113 object ListViewPlayers: TListView 52 114 Left = 4 53 Height = 345115 Height = 247 54 116 Top = 4 55 Width = 655117 Width = 751 56 118 Align = alTop 57 119 Anchors = [akTop, akLeft, akRight, akBottom] … … 80 142 TabOrder = 0 81 143 ViewStyle = vsReport 82 OnCustomDrawSubItem = ListView 1CustomDrawSubItem83 OnData = ListView 1Data84 OnDblClick = ListView 1DblClick85 OnKeyPress = ListView 1KeyPress86 OnKeyUp = ListView 1KeyUp87 OnSelectItem = ListView 1SelectItem144 OnCustomDrawSubItem = ListViewPlayersCustomDrawSubItem 145 OnData = ListViewPlayersData 146 OnDblClick = ListViewPlayersDblClick 147 OnKeyPress = ListViewPlayersKeyPress 148 OnKeyUp = ListViewPlayersKeyUp 149 OnSelectItem = ListViewPlayersSelectItem 88 150 end 89 151 object ButtonPlayerRemove: TButton 90 152 Left = 224 91 153 Height = 25 92 Top = 357154 Top = 259 93 155 Width = 83 94 156 Action = APlayerRemove … … 99 161 Left = 16 100 162 Height = 25 101 Top = 357163 Top = 259 102 164 Width = 83 103 165 Action = APlayerAdd … … 108 170 Left = 120 109 171 Height = 25 110 Top = 357172 Top = 259 111 173 Width = 83 112 174 Action = APlayerModify … … 118 180 object TabSheet2: TTabSheet 119 181 Caption = 'Map' 120 ClientHeight = 395121 ClientWidth = 663182 ClientHeight = 297 183 ClientWidth = 759 122 184 object Label1: TLabel 123 185 Left = 8 124 Height = 2 6186 Height = 20 125 187 Top = 9 126 Width = 95188 Width = 74 127 189 Caption = 'Map width:' 128 190 ParentColor = False … … 130 192 object Label2: TLabel 131 193 Left = 8 132 Height = 2 6194 Height = 20 133 195 Top = 57 134 Width = 102196 Width = 79 135 197 Caption = 'Map height:' 136 198 ParentColor = False … … 138 200 object SpinEditMapSizeX: TSpinEdit 139 201 Left = 128 140 Height = 36202 Height = 28 141 203 Top = 4 142 204 Width = 98 … … 148 210 object SpinEditMapSizeY: TSpinEdit 149 211 Left = 128 150 Height = 36212 Height = 28 151 213 Top = 55 152 214 Width = 98 … … 160 222 Height = 47 161 223 Top = 8 162 Width = 412224 Width = 508 163 225 Max = 100 164 226 Min = 2 … … 173 235 Height = 47 174 236 Top = 49 175 Width = 412237 Width = 508 176 238 Max = 100 177 239 Min = 2 … … 184 246 object Label5: TLabel 185 247 Left = 8 186 Height = 2 6248 Height = 20 187 249 Top = 104 188 Width = 83250 Width = 64 189 251 Caption = 'Grid type:' 190 252 ParentColor = False … … 192 254 object ComboBoxGridType: TComboBox 193 255 Left = 146 194 Height = 40256 Height = 28 195 257 Top = 104 196 258 Width = 208 197 ItemHeight = 0259 ItemHeight = 20 198 260 Items.Strings = ( 199 261 'Hexagonal' … … 206 268 object ComboBoxMapShape: TComboBox 207 269 Left = 146 208 Height = 40270 Height = 28 209 271 Top = 144 210 272 Width = 208 211 ItemHeight = 0273 ItemHeight = 20 212 274 Items.Strings = ( 213 275 'Hexagonal' … … 221 283 object Label8: TLabel 222 284 Left = 8 223 Height = 2 6285 Height = 20 224 286 Top = 144 225 Width = 98287 Width = 76 226 288 Caption = 'Map shape:' 227 289 ParentColor = False … … 231 293 Height = 27 232 294 Top = 110 233 Width = 175295 Width = 271 234 296 Anchors = [akTop, akLeft, akRight] 235 297 AutoSize = False … … 239 301 object SpinEditVoidPercent: TSpinEdit 240 302 Left = 216 241 Height = 36303 Height = 28 242 304 Top = 224 243 305 Width = 106 … … 248 310 object CheckBoxVoid: TCheckBox 249 311 Left = 8 250 Height = 30312 Height = 24 251 313 Top = 232 252 Width = 1 87314 Width = 149 253 315 Caption = 'Inaccessible places' 254 316 OnChange = CheckBoxVoidChange … … 257 319 object CheckBoxCity: TCheckBox 258 320 Left = 8 259 Height = 30321 Height = 24 260 322 Top = 272 261 Width = 71323 Width = 60 262 324 Caption = 'Cities' 263 325 OnChange = CheckBoxCityChange … … 266 328 object SpinEditCityPercent: TSpinEdit 267 329 Left = 216 268 Height = 36330 Height = 28 269 331 Top = 272 270 332 Width = 106 … … 275 337 object Label4: TLabel 276 338 Left = 331 277 Height = 2 6339 Height = 20 278 340 Top = 272 279 Width = 1 5341 Width = 12 280 342 Caption = '%' 281 343 ParentColor = False … … 283 345 object Label3: TLabel 284 346 Left = 331 285 Height = 2 6347 Height = 20 286 348 Top = 232 287 Width = 1 5349 Width = 12 288 350 Caption = '%' 289 351 ParentColor = False … … 291 353 object SpinEditNeutralUnits: TSpinEdit 292 354 Left = 408 293 Height = 36355 Height = 28 294 356 Top = 352 295 357 Width = 98 … … 301 363 object Label7: TLabel 302 364 Left = 8 303 Height = 2 6365 Height = 20 304 366 Top = 352 305 Width = 227367 Width = 172 306 368 Caption = 'Max random neutral units:' 307 369 ParentColor = False … … 309 371 object EditImageFile: TEdit 310 372 Left = 144 311 Height = 36373 Height = 28 312 374 Top = 184 313 Width = 396375 Width = 492 314 376 Anchors = [akTop, akLeft, akRight] 315 377 TabOrder = 12 316 378 end 317 379 object ButtonImageBrowse: TButton 318 Left = 548380 Left = 644 319 381 Height = 25 320 382 Top = 192 … … 327 389 object Label9: TLabel 328 390 Left = 8 329 Height = 2 6391 Height = 20 330 392 Top = 184 331 Width = 90393 Width = 70 332 394 Caption = 'Image file:' 333 395 ParentColor = False … … 335 397 object CheckBoxBridges: TCheckBox 336 398 Left = 8 337 Height = 30399 Height = 24 338 400 Top = 310 339 Width = 210401 Width = 168 340 402 Caption = 'Bridges between cells' 341 403 TabOrder = 14 … … 344 406 object TabSheet3: TTabSheet 345 407 Caption = 'Rules' 346 ClientHeight = 395347 ClientWidth = 663408 ClientHeight = 297 409 ClientWidth = 759 348 410 object RadioGroupGrowCells: TRadioGroup 349 411 Left = 15 … … 360 422 ChildSizing.Layout = cclLeftToRightThenTopToBottom 361 423 ChildSizing.ControlsPerLine = 1 362 ClientHeight = 77424 ClientHeight = 80 363 425 ClientWidth = 308 364 426 Items.Strings = ( … … 371 433 object Label6: TLabel 372 434 Left = 8 373 Height = 2 5435 Height = 20 374 436 Top = 248 375 Width = 111437 Width = 94 376 438 Caption = 'Win objective:' 377 439 ParentColor = False … … 379 441 object ComboBoxWinObjective: TComboBox 380 442 Left = 232 381 Height = 33443 Height = 28 382 444 Top = 240 383 445 Width = 328 384 ItemHeight = 0446 ItemHeight = 20 385 447 Items.Strings = ( 386 448 'Defeat all oponents' … … 406 468 ChildSizing.Layout = cclLeftToRightThenTopToBottom 407 469 ChildSizing.ControlsPerLine = 1 408 ClientHeight = 48470 ClientHeight = 51 409 471 ClientWidth = 301 410 472 Items.Strings = ( … … 418 480 Height = 27 419 481 Top = 24 420 Width = 5 03482 Width = 599 421 483 Anchors = [akTop, akLeft, akRight] 422 484 AutoSize = False … … 425 487 end 426 488 end 489 end 490 object PanelButtons: TPanel 491 Left = 0 492 Height = 45 493 Top = 572 494 Width = 775 495 Align = alBottom 496 BevelOuter = bvNone 497 ClientHeight = 45 498 ClientWidth = 775 499 TabOrder = 1 500 object ButtonOk: TButton 501 Left = 587 502 Height = 25 503 Top = 6 504 Width = 75 505 Anchors = [akRight, akBottom] 506 Caption = 'Ok' 507 ModalResult = 1 508 TabOrder = 0 509 end 510 object ButtonCancel: TButton 511 Left = 691 512 Height = 25 513 Top = 6 514 Width = 75 515 Anchors = [akRight, akBottom] 516 Caption = 'Cancel' 517 ModalResult = 2 518 TabOrder = 1 519 end 520 end 521 object PanelChat: TPanel 522 Left = 0 523 Height = 228 524 Top = 344 525 Width = 775 526 Align = alBottom 527 BevelOuter = bvNone 528 TabOrder = 2 529 end 530 object Splitter1: TSplitter 531 Cursor = crVSplit 532 Left = 0 533 Height = 6 534 Top = 338 535 Width = 775 536 Align = alBottom 537 ResizeAnchor = akBottom 427 538 end 428 539 object ActionList1: TActionList -
trunk/Forms/UFormNew.pas
r170 r179 18 18 APlayerModify: TAction; 19 19 ActionList1: TActionList; 20 ButtonCancel: TButton; 20 21 ButtonImageBrowse: TButton; 21 ButtonCancel: TButton;22 22 ButtonOk: TButton; 23 23 ButtonPlayerAdd: TButton; … … 32 32 ComboBoxMapShape: TComboBox; 33 33 ComboBoxWinObjective: TComboBox; 34 EditServerAddress: TEdit; 34 35 EditImageFile: TEdit; 35 36 Label1: TLabel; 37 Label11: TLabel; 38 Label12: TLabel; 36 39 Label2: TLabel; 37 40 Label3: TLabel; … … 42 45 Label8: TLabel; 43 46 Label9: TLabel; 44 ListView1: TListView; 47 ListViewPlayers: TListView; 48 ListViewServers: TListView; 45 49 MenuItem1: TMenuItem; 46 50 MenuItem2: TMenuItem; … … 48 52 OpenPictureDialog1: TOpenPictureDialog; 49 53 PageControl1: TPageControl; 54 PanelButtons: TPanel; 55 PanelChat: TPanel; 50 56 PopupMenu1: TPopupMenu; 57 RadioButtonModeNetworkServer: TRadioButton; 58 RadioButtonModeNetworkClient: TRadioButton; 59 RadioButtonModeLocal: TRadioButton; 51 60 RadioGroupGrowAmount: TRadioGroup; 52 61 RadioGroupGrowCells: TRadioGroup; 62 SpinEditServerPort: TSpinEdit; 53 63 SpinEditCityPercent: TSpinEdit; 54 64 SpinEditMapSizeX: TSpinEdit; … … 56 66 SpinEditNeutralUnits: TSpinEdit; 57 67 SpinEditVoidPercent: TSpinEdit; 68 Splitter1: TSplitter; 58 69 TabSheet1: TTabSheet; 59 70 TabSheet2: TTabSheet; 60 71 TabSheet3: TTabSheet; 72 TabSheetMode: TTabSheet; 61 73 TrackBarSizeX: TTrackBar; 62 74 TrackBarSizeY: TTrackBar; … … 68 80 procedure CheckBoxVoidChange(Sender: TObject); 69 81 procedure ComboBoxMapShapeChange(Sender: TObject); 82 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); 70 83 procedure FormCreate(Sender: TObject); 71 84 procedure FormDestroy(Sender: TObject); 72 85 procedure FormShow(Sender: TObject); 73 procedure ListView 1CustomDrawSubItem(Sender: TCustomListView;86 procedure ListViewPlayersCustomDrawSubItem(Sender: TCustomListView; 74 87 Item: TListItem; SubItem: Integer; State: TCustomDrawState; 75 88 var DefaultDraw: Boolean); 76 procedure ListView 1Data(Sender: TObject; Item: TListItem);77 procedure ListView 1DblClick(Sender: TObject);78 procedure ListView 1KeyPress(Sender: TObject; var Key: char);79 procedure ListView 1KeyUp(Sender: TObject; var Key: Word; Shift: TShiftState89 procedure ListViewPlayersData(Sender: TObject; Item: TListItem); 90 procedure ListViewPlayersDblClick(Sender: TObject); 91 procedure ListViewPlayersKeyPress(Sender: TObject; var Key: char); 92 procedure ListViewPlayersKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState 80 93 ); 81 procedure ListView 1SelectItem(Sender: TObject; Item: TListItem;94 procedure ListViewPlayersSelectItem(Sender: TObject; Item: TListItem; 82 95 Selected: Boolean); 96 procedure RadioButtonModeLocalChange(Sender: TObject); 83 97 procedure SpinEditMapSizeXChange(Sender: TObject); 84 98 procedure SpinEditMapSizeYChange(Sender: TObject); … … 91 105 procedure ReloadView; 92 106 procedure UpdateInterface; 93 procedure Load( Game: TGame);94 procedure Save( Game: TGame);107 procedure Load(Server: TServer); 108 procedure Save(Server: TServer); 95 109 end; 96 110 … … 103 117 104 118 uses 105 UFormPlayer ;119 UFormPlayer, UFormChat, UCore; 106 120 107 121 resourcestring … … 125 139 { TFormNew } 126 140 127 procedure TFormNew.ListView 1Data(Sender: TObject; Item: TListItem);141 procedure TFormNew.ListViewPlayersData(Sender: TObject; Item: TListItem); 128 142 begin 129 143 if (Item.Index >= 0) and (Item.Index < Players.Count) then … … 137 151 end; 138 152 139 procedure TFormNew.ListView 1DblClick(Sender: TObject);153 procedure TFormNew.ListViewPlayersDblClick(Sender: TObject); 140 154 begin 141 155 APlayerModify.Execute; 142 156 end; 143 157 144 procedure TFormNew.ListView 1KeyPress(Sender: TObject; var Key: char);158 procedure TFormNew.ListViewPlayersKeyPress(Sender: TObject; var Key: char); 145 159 begin 146 160 if (Key = #13) then APlayerModify.Execute; 147 161 end; 148 162 149 procedure TFormNew.ListView 1KeyUp(Sender: TObject; var Key: Word;163 procedure TFormNew.ListViewPlayersKeyUp(Sender: TObject; var Key: Word; 150 164 Shift: TShiftState); 151 165 begin … … 154 168 end; 155 169 156 procedure TFormNew.ListView 1SelectItem(Sender: TObject; Item: TListItem;170 procedure TFormNew.ListViewPlayersSelectItem(Sender: TObject; Item: TListItem; 157 171 Selected: Boolean); 158 172 begin 159 173 ReloadView; 174 end; 175 176 procedure TFormNew.RadioButtonModeLocalChange(Sender: TObject); 177 begin 178 UpdateInterface; 160 179 end; 161 180 … … 225 244 ItemIndex := LastIndex; 226 245 end; 246 Core.CoolTranslator1.TranslateComponentRecursive(Self); 227 247 end; 228 248 229 249 procedure TFormNew.ReloadView; 230 250 begin 231 ListView 1.Items.Count := Players.Count;232 ListView 1.Refresh;251 ListViewPlayers.Items.Count := Players.Count; 252 ListViewPlayers.Refresh; 233 253 Translate; 234 254 UpdateInterface; … … 237 257 procedure TFormNew.UpdateInterface; 238 258 begin 239 APlayerRemove.Enabled := Assigned(ListView 1.Selected) and (Players.Count > 2);259 APlayerRemove.Enabled := Assigned(ListViewPlayers.Selected) and (Players.Count > 2); 240 260 APlayerAdd.Enabled := Players.Count < MaxPlayerCount; 241 APlayerModify.Enabled := Assigned(ListView 1.Selected);261 APlayerModify.Enabled := Assigned(ListViewPlayers.Selected); 242 262 EditImageFile.Enabled := ComboBoxMapShape.ItemIndex = Integer(msImage); 243 263 ButtonImageBrowse.Enabled := ComboBoxMapShape.ItemIndex = Integer(msImage); 264 EditServerAddress.Enabled := RadioButtonModeNetworkServer.Checked; 265 SpinEditServerPort.Enabled := RadioButtonModeNetworkServer.Checked; 266 ListViewServers.Enabled := RadioButtonModeNetworkClient.Checked; 244 267 end; 245 268 246 269 procedure TFormNew.FormShow(Sender: TObject); 247 270 begin 271 Core.PersistentForm.Load(Self); 248 272 ReloadView; 249 273 //Height := Trunc(1.5 * Height); … … 251 275 end; 252 276 253 procedure TFormNew.ListView 1CustomDrawSubItem(Sender: TCustomListView;277 procedure TFormNew.ListViewPlayersCustomDrawSubItem(Sender: TCustomListView; 254 278 Item: TListItem; SubItem: Integer; State: TCustomDrawState; 255 279 var DefaultDraw: Boolean); 256 280 begin 257 281 if SubItem = 2 then 258 with ListView 1.Canvas do begin282 with ListViewPlayers.Canvas do begin 259 283 Brush.Color := TPlayer(Item.Data).Color; 260 284 Brush.Style := bsSolid; … … 266 290 begin 267 291 Players := TPlayers.Create; 292 FormChat := TFormChat.Create(nil); 293 FormChat.ManualDock(PanelChat, nil, alClient); 294 FormChat.Align := alClient; 295 FormChat.Show; 296 Translate; 268 297 end; 269 298 … … 283 312 end; 284 313 314 procedure TFormNew.FormClose(Sender: TObject; var CloseAction: TCloseAction); 315 begin 316 Core.PersistentForm.Save(Self); 317 end; 318 285 319 procedure TFormNew.APlayerModifyExecute(Sender: TObject); 286 320 begin 287 if Assigned(ListView 1.Selected) then begin288 FormPlayer.Load(TPlayer(ListView 1.Selected.Data));321 if Assigned(ListViewPlayers.Selected) then begin 322 FormPlayer.Load(TPlayer(ListViewPlayers.Selected.Data)); 289 323 if FormPlayer.ShowModal = mrOk then begin 290 FormPlayer.Save(TPlayer(ListView 1.Selected.Data));324 FormPlayer.Save(TPlayer(ListViewPlayers.Selected.Data)); 291 325 ReloadView; 292 326 end; … … 296 330 procedure TFormNew.APlayerRemoveExecute(Sender: TObject); 297 331 begin 298 if Assigned(ListView 1.Selected) then begin299 Players.Remove(ListView 1.Selected.Data);332 if Assigned(ListViewPlayers.Selected) then begin 333 Players.Remove(ListViewPlayers.Selected.Data); 300 334 ReloadView; 301 335 end; … … 328 362 procedure TFormNew.FormDestroy(Sender: TObject); 329 363 begin 330 Players.Free; 331 end; 332 333 procedure TFormNew.Load(Game: TGame); 334 begin 335 CheckBoxSymetricMap.Checked := Game.SymetricMap; 336 CheckBoxVoid.Checked := Game.VoidEnabled; 337 SpinEditVoidPercent.Value := Game.VoidPercentage; 338 SpinEditVoidPercent.Enabled := Game.VoidEnabled; 339 Players.Assign(Game.PlayersSetting); 340 CheckBoxCity.Checked := Game.CityEnabled; 341 SpinEditCityPercent.Value := Game.CityPercentage; 342 SpinEditMapSizeX.Value := Game.Map.Size.X; 343 SpinEditMapSizeY.Value := Game.Map.Size.Y; 344 TrackBarSizeX.Position := Game.Map.Size.X; 345 TrackBarSizeY.Position := Game.Map.Size.Y; 346 RadioGroupGrowAmount.ItemIndex := Integer(Game.GrowAmount); 347 RadioGroupGrowCells.ItemIndex := Integer(Game.GrowCells); 348 ComboBoxGridType.ItemIndex := Integer(Game.MapType) - 1; 349 ComboBoxWinObjective.ItemIndex := Integer(Game.WinObjective); 350 SpinEditNeutralUnits.Value := Game.MaxNeutralUnits; 351 ComboBoxMapShape.ItemIndex := Integer(Game.Map.Shape); 352 EditImageFile.Text := Game.MapImageFileName; 353 CheckBoxFogOfWar.Checked := Game.FogOfWar; 354 CheckBoxBridges.Checked := Game.BridgeEnabled; 355 end; 356 357 procedure TFormNew.Save(Game: TGame); 358 begin 359 Game.PlayersSetting.Assign(Players); 360 Game.SymetricMap := CheckBoxSymetricMap.Checked; 361 Game.VoidEnabled := CheckBoxVoid.Checked; 362 Game.VoidPercentage := SpinEditVoidPercent.Value; 363 Game.CityEnabled := CheckBoxCity.Checked; 364 Game.CityPercentage := SpinEditCityPercent.Value; 365 Game.Map.Size := TPoint.Create(SpinEditMapSizeX.Value, SpinEditMapSizeY.Value); 366 Game.GrowAmount := TGrowAmount(RadioGroupGrowAmount.ItemIndex); 367 Game.GrowCells := TGrowCells(RadioGroupGrowCells.ItemIndex); 368 Game.MapType := TMapType(ComboBoxGridType.ItemIndex + 1); 369 Game.WinObjective := TWinObjective(ComboBoxWinObjective.ItemIndex); 370 Game.MaxNeutralUnits := SpinEditNeutralUnits.Value; 371 Game.Map.Shape := TMapShape(ComboBoxMapShape.ItemIndex); 372 Game.MapImageFileName := EditImageFile.Text; 373 Game.FogOfWar := CheckBoxFogOfWar.Checked; 374 Game.BridgeEnabled := CheckBoxBridges.Checked; 364 FreeAndNil(Players); 365 FreeAndNil(FormChat); 366 end; 367 368 procedure TFormNew.Load(Server: TServer); 369 begin 370 with Server do begin 371 CheckBoxSymetricMap.Checked := Game.SymetricMap; 372 CheckBoxVoid.Checked := Game.VoidEnabled; 373 SpinEditVoidPercent.Value := Game.VoidPercentage; 374 SpinEditVoidPercent.Enabled := Game.VoidEnabled; 375 Players.Assign(Game.PlayersSetting); 376 CheckBoxCity.Checked := Game.CityEnabled; 377 SpinEditCityPercent.Value := Game.CityPercentage; 378 SpinEditMapSizeX.Value := Game.Map.Size.X; 379 SpinEditMapSizeY.Value := Game.Map.Size.Y; 380 TrackBarSizeX.Position := Game.Map.Size.X; 381 TrackBarSizeY.Position := Game.Map.Size.Y; 382 RadioGroupGrowAmount.ItemIndex := Integer(Game.GrowAmount); 383 RadioGroupGrowCells.ItemIndex := Integer(Game.GrowCells); 384 ComboBoxGridType.ItemIndex := Integer(Game.MapType) - 1; 385 ComboBoxWinObjective.ItemIndex := Integer(Game.WinObjective); 386 SpinEditNeutralUnits.Value := Game.MaxNeutralUnits; 387 ComboBoxMapShape.ItemIndex := Integer(Game.Map.Shape); 388 EditImageFile.Text := Game.MapImageFileName; 389 CheckBoxFogOfWar.Checked := Game.FogOfWar; 390 CheckBoxBridges.Checked := Game.BridgeEnabled; 391 RadioButtonModeLocal.Checked := Mode = smLocal; 392 RadioButtonModeNetworkClient.Checked := Mode = smNetworkClient; 393 RadioButtonModeNetworkServer.Checked := Mode = smNetworkServer; 394 EditServerAddress.Text := LocalNetworkAddress; 395 SpinEditServerPort.Value := LocalNetworkPort; 396 end; 397 end; 398 399 procedure TFormNew.Save(Server: TServer); 400 begin 401 with Server do begin 402 if RadioButtonModeLocal.Checked then Mode := smLocal 403 else if RadioButtonModeNetworkClient.Checked then Mode := smNetworkClient 404 else if RadioButtonModeNetworkServer.Checked then Mode := smNetworkServer; 405 LocalNetworkAddress := EditServerAddress.Text; 406 LocalNetworkPort := SpinEditServerPort.Value; 407 Game.PlayersSetting.Assign(Players); 408 Game.SymetricMap := CheckBoxSymetricMap.Checked; 409 Game.VoidEnabled := CheckBoxVoid.Checked; 410 Game.VoidPercentage := SpinEditVoidPercent.Value; 411 Game.CityEnabled := CheckBoxCity.Checked; 412 Game.CityPercentage := SpinEditCityPercent.Value; 413 Game.Map.Size := TPoint.Create(SpinEditMapSizeX.Value, SpinEditMapSizeY.Value); 414 Game.GrowAmount := TGrowAmount(RadioGroupGrowAmount.ItemIndex); 415 Game.GrowCells := TGrowCells(RadioGroupGrowCells.ItemIndex); 416 Game.MapType := TMapType(ComboBoxGridType.ItemIndex + 1); 417 Game.WinObjective := TWinObjective(ComboBoxWinObjective.ItemIndex); 418 Game.MaxNeutralUnits := SpinEditNeutralUnits.Value; 419 Game.Map.Shape := TMapShape(ComboBoxMapShape.ItemIndex); 420 Game.MapImageFileName := EditImageFile.Text; 421 Game.FogOfWar := CheckBoxFogOfWar.Checked; 422 Game.BridgeEnabled := CheckBoxBridges.Checked; 423 end; 375 424 end; 376 425 -
trunk/Languages/xtactics.cs.po
r178 r179 9 9 "MIME-Version: 1.0\n" 10 10 "Content-Transfer-Encoding: 8bit\n" 11 "X-Generator: Poedit 2.0.4\n"11 "X-Generator: Poedit 1.8.8\n" 12 12 "Language: cs\n" 13 13 … … 131 131 msgid "Occupied cells" 132 132 msgstr "Obsazené buňky" 133 134 #: tformchat.buttonmessagesend.caption 135 msgid "Send" 136 msgstr "Odeslat" 137 138 #: tformchat.caption 139 msgid "Chat" 140 msgstr "Pokec" 141 142 #: tformchat.label1.caption 143 msgid "Chat:" 144 msgstr "Pokec:" 133 145 134 146 #: tformhelp.caption … … 313 325 msgstr "Šířka mapy:" 314 326 327 #: tformnew.label11.caption 328 msgid "Port:" 329 msgstr "Port:" 330 331 #: tformnew.label12.caption 332 msgid "Address:" 333 msgstr "Adresa:" 334 315 335 #: tformnew.label2.caption 316 336 #| msgid "x" … … 348 368 msgstr "Soubor obrázku:" 349 369 350 #: tformnew.listview1.columns[0].caption 370 #: tformnew.listviewplayers.columns[0].caption 371 msgctxt "tformnew.listviewplayers.columns[0].caption" 351 372 msgid "Name" 352 373 msgstr "Jméno" 353 374 354 #: tformnew.listview1.columns[1].caption 375 #: tformnew.listviewplayers.columns[1].caption 376 msgctxt "tformnew.listviewplayers.columns[1].caption" 355 377 msgid "Type" 356 378 msgstr "Typ" 357 379 358 #: tformnew.listview1.columns[2].caption 380 #: tformnew.listviewplayers.columns[2].caption 381 msgctxt "tformnew.listviewplayers.columns[2].caption" 359 382 msgid "Color" 360 383 msgstr "Barva" 361 384 362 #: tformnew.listview1.columns[3].caption 385 #: tformnew.listviewplayers.columns[3].caption 386 msgctxt "tformnew.listviewplayers.columns[3].caption" 363 387 msgid "Start units" 364 388 msgstr "Počátečních jednotek" 389 390 #: tformnew.listviewservers.columns[0].caption 391 msgctxt "tformnew.listviewservers.columns[0].caption" 392 msgid "Name" 393 msgstr "Jméno" 394 395 #: tformnew.listviewservers.columns[1].caption 396 msgctxt "tformnew.listviewservers.columns[1].caption" 397 msgid "Address" 398 msgstr "Adresa" 399 400 #: tformnew.radiobuttonmodelocal.caption 401 msgid "Local" 402 msgstr "Místní" 403 404 #: tformnew.radiobuttonmodenetworkclient.caption 405 msgctxt "tformnew.radiobuttonmodenetworkclient.caption" 406 msgid "Network client" 407 msgstr "Síťový klient" 408 409 #: tformnew.radiobuttonmodenetworkserver.caption 410 msgctxt "tformnew.radiobuttonmodenetworkserver.caption" 411 msgid "Network server" 412 msgstr "Síťový server" 365 413 366 414 #: tformnew.radiogroupgrowamount.caption … … 383 431 msgid "Rules" 384 432 msgstr "Pravidla" 433 434 #: tformnew.tabsheetmode.caption 435 msgid "Mode" 436 msgstr "Režim" 385 437 386 438 #: tformplayer.buttoncancel.caption -
trunk/Languages/xtactics.po
r178 r179 122 122 msgstr "" 123 123 124 #: tformchat.buttonmessagesend.caption 125 msgid "Send" 126 msgstr "" 127 128 #: tformchat.caption 129 msgid "Chat" 130 msgstr "" 131 132 #: tformchat.label1.caption 133 msgid "Chat:" 134 msgstr "" 135 124 136 #: tformhelp.caption 125 137 msgctxt "TFORMHELP.CAPTION" … … 299 311 msgstr "" 300 312 313 #: tformnew.label11.caption 314 msgid "Port:" 315 msgstr "" 316 317 #: tformnew.label12.caption 318 msgid "Address:" 319 msgstr "" 320 301 321 #: tformnew.label2.caption 302 322 msgid "Map height:" … … 333 353 msgstr "" 334 354 335 #: tformnew.listview1.columns[0].caption 355 #: tformnew.listviewplayers.columns[0].caption 356 msgctxt "tformnew.listviewplayers.columns[0].caption" 336 357 msgid "Name" 337 358 msgstr "" 338 359 339 #: tformnew.listview1.columns[1].caption 360 #: tformnew.listviewplayers.columns[1].caption 361 msgctxt "tformnew.listviewplayers.columns[1].caption" 340 362 msgid "Type" 341 363 msgstr "" 342 364 343 #: tformnew.listview1.columns[2].caption 365 #: tformnew.listviewplayers.columns[2].caption 366 msgctxt "tformnew.listviewplayers.columns[2].caption" 344 367 msgid "Color" 345 368 msgstr "" 346 369 347 #: tformnew.listview1.columns[3].caption 370 #: tformnew.listviewplayers.columns[3].caption 371 msgctxt "tformnew.listviewplayers.columns[3].caption" 348 372 msgid "Start units" 373 msgstr "" 374 375 #: tformnew.listviewservers.columns[0].caption 376 msgctxt "tformnew.listviewservers.columns[0].caption" 377 msgid "Name" 378 msgstr "" 379 380 #: tformnew.listviewservers.columns[1].caption 381 msgctxt "tformnew.listviewservers.columns[1].caption" 382 msgid "Address" 383 msgstr "" 384 385 #: tformnew.radiobuttonmodelocal.caption 386 msgid "Local" 387 msgstr "" 388 389 #: tformnew.radiobuttonmodenetworkclient.caption 390 msgctxt "tformnew.radiobuttonmodenetworkclient.caption" 391 msgid "Network client" 392 msgstr "" 393 394 #: tformnew.radiobuttonmodenetworkserver.caption 395 msgctxt "tformnew.radiobuttonmodenetworkserver.caption" 396 msgid "Network server" 349 397 msgstr "" 350 398 … … 367 415 #: tformnew.tabsheet3.caption 368 416 msgid "Rules" 417 msgstr "" 418 419 #: tformnew.tabsheetmode.caption 420 msgid "Mode" 369 421 msgstr "" 370 422 -
trunk/UCore.lfm
r178 r179 3 3 OnDestroy = DataModuleDestroy 4 4 OldCreateOrder = False 5 Height = 678 6 HorizontalOffset = 706 7 VerticalOffset = 352 8 Width = 940 5 Height = 848 6 HorizontalOffset = 695 7 VerticalOffset = 182 8 Width = 1175 9 PPI = 120 9 10 object ActionList1: TActionList 10 11 Images = ImageListSmall 11 left = 90 12 top = 40 12 left = 113 13 top = 50 14 object AExit: TAction 15 Caption = 'Exit' 16 Hint = 'Exit application' 17 ImageIndex = 1 18 OnExecute = AExitExecute 19 ShortCut = 32883 20 end 13 21 object AGameNew: TAction 14 22 Caption = 'New' … … 17 25 OnExecute = AGameNewExecute 18 26 ShortCut = 16462 19 end20 object AExit: TAction21 Caption = 'Exit'22 Hint = 'Exit application'23 ImageIndex = 124 OnExecute = AExitExecute25 ShortCut = 3288326 27 end 27 28 object AGameEnd: TAction … … 84 85 end 85 86 object ImageListSmall: TImageList 86 left = 52487 top = 28087 left = 655 88 top = 350 88 89 Bitmap = { 89 90 4C690C00000010000000100000000000000000000000E3AA4BD6E5B35EFFE3B1 … … 477 478 POFilesFolder = 'Languages' 478 479 OnTranslate = CoolTranslator1Translate 479 left = 91480 top = 290480 left = 114 481 top = 363 481 482 end 482 483 object ImageListLarge: TImageList 483 484 Height = 32 484 485 Width = 32 485 left = 524486 top = 190486 left = 655 487 top = 238 487 488 Bitmap = { 488 489 4C690C0000002000000020000000000000000000000000000000E2AA4B36E2A9 … … 2029 2030 RootName = 'CONFIG' 2030 2031 ReadOnly = False 2031 left = 912032 top = 3702032 left = 114 2033 top = 463 2033 2034 end 2034 2035 object OpenDialog1: TOpenDialog 2035 2036 DefaultExt = '.xtmap' 2036 left = 7502037 top = 1942037 left = 938 2038 top = 243 2038 2039 end 2039 2040 object SaveDialog1: TSaveDialog 2040 2041 DefaultExt = '.xtmap' 2041 left = 7502042 top = 1 102042 left = 938 2043 top = 138 2043 2044 end 2044 2045 object ApplicationInfo: TApplicationInfo … … 2057 2058 RegistryRoot = rrKeyCurrentUser 2058 2059 License = 'CC0' 2059 left = 912060 top = 1 202060 left = 114 2061 top = 150 2061 2062 end 2062 2063 object PersistentForm: TPersistentForm 2063 2064 MinVisiblePart = 50 2064 2065 EntireVisible = False 2065 left = 5202066 top = 4002066 left = 650 2067 top = 500 2067 2068 end 2068 2069 object ScaleDPI1: TScaleDPI 2069 2070 AutoDetect = False 2070 left = 902071 top = 4502071 left = 113 2072 top = 563 2072 2073 end 2073 2074 object LastOpenedList1: TLastOpenedList 2074 2075 MaxCount = 10 2075 2076 OnChange = LastOpenedList1Change 2076 left = 912077 top = 2 002077 left = 114 2078 top = 250 2078 2079 end 2079 2080 end -
trunk/UCore.pas
r178 r179 228 228 if (DesignDPI.X <> DPI.X) or (DesignDPI.Y <> DPI.Y) then begin 229 229 //ApplyToAll(DesignDPI); 230 FormNew.Show;231 FormNew.Hide;232 230 for I := 0 to Screen.FormCount - 1 do 233 231 if (Screen.Forms[I].WindowState = wsNormal) or … … 318 316 procedure TCore.AGameNewExecute(Sender: TObject); 319 317 begin 320 FormNew.Load(Game); 321 if FormNew.ShowModal = mrOk then begin 322 FormNew.Save(Game); 323 StartNewGame; 318 FormNew := TFormNew.Create(nil); 319 try 320 FormNew.Load(Server); 321 if FormNew.ShowModal = mrOk then begin 322 FormNew.Save(Server); 323 StartNewGame; 324 end; 325 finally 326 FormNew.Free; 324 327 end; 325 328 end; … … 361 364 FormSettings.Save; 362 365 Game.SaveConfig(XMLConfig1, 'Game'); 366 Server.SaveConfig(XMLConfig1, 'Server'); 363 367 end; 364 368 finally … … 380 384 begin 381 385 UGame.InitStrings; 382 FormNew.Translate;383 386 FormPlayer.Translate; 384 387 end; … … 404 407 FreeAndNil(StoredDimension); 405 408 Game.SaveConfig(XMLConfig1, 'Game'); 409 Server.SaveConfig(XMLConfig1, 'Server'); 406 410 SaveConfig; 407 411 FreeAndNil(Server); … … 478 482 LoadConfig; 479 483 Game.LoadConfig(XMLConfig1, 'Game'); 484 Server.LoadConfig(XMLConfig1, 'Server'); 480 485 481 486 CommandLineParams; -
trunk/UGame.pas
r176 r179 8 8 Classes, SysUtils, ExtCtrls, Graphics, XMLConf, XMLRead, XMLWrite, 9 9 DOM, Math, LazFileUtils, UXMLUtils, Dialogs, Types, LCLType, LCLIntf, fgl, 10 UGeometry ;10 UGeometry, UGameSocket; 11 11 12 12 const … … 409 409 end; 410 410 411 TCommand = (cmdTextMessage); 412 TReceiveEvent = procedure (Command: TCommand; DataIn, DataOut: Pointer); 413 TCommandTextMessage = record 414 Text: string; 415 end; 416 411 417 { TClient } 412 418 … … 415 421 FGame: TGame; 416 422 FControlPlayer: TPlayer; 423 FOnReceive: TReceiveEvent; 417 424 procedure SetControlPlayer(AValue: TPlayer); 418 425 procedure SetGame(AValue: TGame); … … 420 427 Name: string; 421 428 View: TView; 429 GameSocket: TGameSocket; 430 procedure Send(Command: TCommand; DataOut, DataIn: Pointer); 422 431 constructor Create; 423 432 destructor Destroy; override; 424 433 property ControlPlayer: TPlayer read FControlPlayer write SetControlPlayer; 425 434 property Game: TGame read FGame write SetGame; 435 property OnReceive: TReceiveEvent read FOnReceive write FOnReceive; 426 436 end; 427 437 … … 512 522 end; 513 523 524 TServerMode = (smLocal, smNetworkServer, smNetworkClient); 525 514 526 { TServer } 515 527 516 528 TServer = class 517 529 private 530 FActive: Boolean; 518 531 FGame: TGame; 532 FServerMode: TServerMode; 533 procedure SetActive(AValue: Boolean); 519 534 procedure SetGame(AValue: TGame); 535 procedure SetServerMode(AValue: TServerMode); 520 536 public 521 537 Clients: TClients; 538 LocalNetworkAddress: string; 539 LocalNetworkPort: Word; 540 RemoteNetworkAddress: string; 541 RemoteNetworkPort: Word; 542 GameSocket: TGameSocket; 543 procedure LoadConfig(Config: TXmlConfig; Path: string); 544 procedure SaveConfig(Config: TXmlConfig; Path: string); 522 545 procedure InitClients; 523 546 procedure Clear; … … 525 548 destructor Destroy; override; 526 549 property Game: TGame read FGame write SetGame; 550 property Mode: TServerMode read FServerMode write SetServerMode; 551 property Active: Boolean read FActive write SetActive; 527 552 end; 528 553 … … 648 673 FGame := AValue; 649 674 View.Game := AValue; 675 end; 676 677 procedure TClient.Send(Command: TCommand; DataOut, DataIn: Pointer); 678 begin 650 679 end; 651 680 … … 3131 3160 end; 3132 3161 3162 procedure TServer.SetActive(AValue: Boolean); 3163 begin 3164 if FActive = AValue then Exit; 3165 FActive := AValue; 3166 end; 3167 3168 procedure TServer.SetServerMode(AValue: TServerMode); 3169 var 3170 LastActiveState: Boolean; 3171 begin 3172 if FServerMode = AValue then Exit; 3173 LastActiveState := Active; 3174 Active := False; 3175 FServerMode := AValue; 3176 FreeAndNil(GameSocket); 3177 case FServerMode of 3178 smLocal: GameSocket := TGameSocketDirect.Create; 3179 smNetworkServer: begin 3180 GameSocket := TGameSocketNetworkServer.Create; 3181 TGameSocketNetworkServer(GameSocket).TCPServer.Address := LocalNetworkAddress; 3182 TGameSocketNetworkServer(GameSocket).TCPServer.Port := LocalNetworkPort; 3183 //TODO TGameSocketNetworkServer(GameSocket).TCPServer.Active := True; 3184 end; 3185 smNetworkClient: begin 3186 GameSocket := TGameSocketNetworkClient.Create; 3187 if (LocalNetworkAddress = RemoteNetworkAddress) and 3188 (LocalNetworkPort = RemoteNetworkPort) then begin 3189 // User wants to play on its own server 3190 GameSocket := TGameSocketNetworkServer.Create; 3191 TGameSocketNetworkServer(GameSocket).TCPServer.Address := LocalNetworkAddress; 3192 TGameSocketNetworkServer(GameSocket).TCPServer.Port := LocalNetworkPort; 3193 //TODO TGameSocketNetworkServer(GameSocket).TCPServer.Active := True; 3194 end else 3195 begin 3196 // Do not create socket. User wants to connect elsewhere 3197 end; 3198 end; 3199 end; 3200 Active := LastActiveState; 3201 end; 3202 3203 procedure TServer.LoadConfig(Config: TXmlConfig; Path: string); 3204 begin 3205 with Config do begin 3206 LocalNetworkAddress := string(GetValue(DOMString(Path + '/LocalNetworkAddress'), 'localhost')); 3207 LocalNetworkPort := GetValue(DOMString(Path + '/LocalNetworkPort'), 40009); 3208 RemoteNetworkAddress := string(GetValue(DOMString(Path + '/RemoteNetworkAddress'), 'localhost')); 3209 RemoteNetworkPort := GetValue(DOMString(Path + '/RemoteNetworkPort'), 40009); 3210 Mode := TServerMode(GetValue(DOMString(Path + '/Mode'), Integer(smLocal))); 3211 end; 3212 end; 3213 3214 procedure TServer.SaveConfig(Config: TXmlConfig; Path: string); 3215 begin 3216 with Config do begin 3217 SetValue(DOMString(Path + '/LocalNetworkAddress'), DOMString(LocalNetworkAddress)); 3218 SetValue(DOMString(Path + '/LocalNetworkPort'), LocalNetworkPort); 3219 SetValue(DOMString(Path + '/RemoteNetworkAddress'), DOMString(RemoteNetworkAddress)); 3220 SetValue(DOMString(Path + '/RemoteNetworkPort'), RemoteNetworkPort); 3221 SetValue(DOMString(Path + '/Mode'), Integer(Mode)); 3222 end; 3223 end; 3224 3133 3225 procedure TServer.InitClients; 3134 3226 var -
trunk/xtactics.lpi
r177 r179 100 100 </Item6> 101 101 </RequiredPackages> 102 <Units Count="1 3">102 <Units Count="16"> 103 103 <Unit0> 104 104 <Filename Value="xtactics.lpr"/> … … 183 183 <ResourceBaseClass Value="Form"/> 184 184 </Unit12> 185 <Unit13> 186 <Filename Value="Forms/UFormChat.pas"/> 187 <IsPartOfProject Value="True"/> 188 <ComponentName Value="FormChat"/> 189 <HasResources Value="True"/> 190 <ResourceBaseClass Value="Form"/> 191 </Unit13> 192 <Unit14> 193 <Filename Value="UGameSocket.pas"/> 194 <IsPartOfProject Value="True"/> 195 </Unit14> 196 <Unit15> 197 <Filename Value="UTCP.pas"/> 198 <IsPartOfProject Value="True"/> 199 </Unit15> 185 200 </Units> 186 201 </ProjectOptions> -
trunk/xtactics.lpr
r174 r179 11 11 CoolTranslator, TemplateGenerics, UFormPlayer 12 12 { you can add units after this }, 13 SysUtils, UFormMain, UFormMove, UFormNew, UFormCharts, UFormUnitMoves; 13 SysUtils, UFormMain, UFormMove, UFormNew, UFormCharts, UFormUnitMoves, 14 UFormChat, UGameSocket, UTCP; 14 15 15 16 {$R *.res} … … 32 33 Application.CreateForm(TCore, Core); 33 34 Application.CreateForm(TFormMain, FormMain); 34 Application.CreateForm(TFormNew, FormNew);35 35 Application.CreateForm(TFormMove, FormMove); 36 36 Application.CreateForm(TFormPlayer, FormPlayer);
Note:
See TracChangeset
for help on using the changeset viewer.