Changeset 292
- Timestamp:
- Mar 28, 2019, 5:34:35 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 10 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UCore.pas
r291 r292 9 9 UGame, UApplicationInfo, UPersistentForm, UScaleDPI, UCoolTranslator, 10 10 URegistry, ULastOpenedList, UTheme, Registry, Menus, UFormClient, UPlayer, 11 UGameServer, UGameClient, fgl, UServerList, UGameSystem, UUnit,Graphics;11 UGameServer, UGameClient, fgl, UServerList, UGameSystem, Graphics; 12 12 13 13 type … … 87 87 procedure UpdateOtherForms; 88 88 procedure FormClientActions; 89 procedure InitGameSystems;89 procedure LoadGameSystems; 90 90 public 91 91 Game: TGame; … … 129 129 uses 130 130 UFormMain, UFormNew, UFormSettings, UFormAbout, UClientAI, UFormKeyShortcuts, 131 UFormHelp, UFormCharts, UFormUnitMoves, UFormPlayersStats, UClientGUI, UMapType, 132 UNation; 131 UFormHelp, UFormCharts, UFormUnitMoves, UFormPlayersStats, UClientGUI; 133 132 134 133 const … … 481 480 begin 482 481 GameSystems := TGameSystems.Create; 483 InitGameSystems;484 482 Server := TServer.Create; 485 483 LocalClients := TClients.Create; 486 484 GameSettings := TGame.Create; 487 GameSettings.GameSystem := GameSystems.First;488 485 Game := TGame.Create; 489 486 Game.OnMoveUpdated := DoMoveUpdated; … … 491 488 Game.OnNewTurn := GameNewTurnExecute; 492 489 Game.OnPlayerChange := DoPlayerChange; 493 Game.GameSystem := GameSystems.First;494 490 Server.Game := Game; 495 491 LocalClients.Game := Game; … … 526 522 begin 527 523 LastOpenedList1.LoadToMenuItem(FormMain.MenuItemLoadRecent, LoadRecentExecute); 528 end;529 530 procedure TCore.InitGameSystems;531 begin532 with GameSystems.AddNew('Custom') do begin533 PreferedMapType := mtNone;534 MaxPlayerCount := 3;535 with TNation(Nations.AddItem('Nation 1')) do begin536 Color := clBlue;537 end;538 with TNation(Nations.AddItem('Nation 2')) do begin539 Color := clRed;540 end;541 with TNation(Nations.AddItem('Nation 3')) do begin542 Color := clGreen;543 end;544 with TNation(Nations.AddItem('Nation 4')) do begin545 Color := clOrange;546 end;547 with TNation(Nations.AddItem('Nation 5')) do begin548 Color := clPurple;549 end;550 with TNation(Nations.AddItem('Nation 6')) do begin551 Color := clMaroon;552 end;553 with TNation(Nations.AddItem('Nation 7')) do begin554 Color := clAqua;555 end;556 with TNation(Nations.AddItem('Nation 8')) do begin557 Color := clFuchsia;558 end;559 with TUnitKind(UnitKinds.AddItem('Unit')) do begin560 Moves := 1;561 Power := 99;562 end;563 end;564 565 with GameSystems.AddNew('HexWars') do begin566 PreferedMapType := mtHexagonVertical;567 UnitsMoveImmediately := False;568 MaxPlayerCount := 8;569 with TNation(Nations.AddItem('Nation 1')) do begin570 Color := clBlue;571 end;572 with TNation(Nations.AddItem('Nation 2')) do begin573 Color := clRed;574 end;575 with TNation(Nations.AddItem('Nation 3')) do begin576 Color := clGreen;577 end;578 with TNation(Nations.AddItem('Nation 4')) do begin579 Color := clOrange;580 end;581 with TNation(Nations.AddItem('Nation 5')) do begin582 Color := clPurple;583 end;584 with TNation(Nations.AddItem('Nation 6')) do begin585 Color := clMaroon;586 end;587 with TNation(Nations.AddItem('Nation 7')) do begin588 Color := clAqua;589 end;590 with TNation(Nations.AddItem('Nation 8')) do begin591 Color := clFuchsia;592 end;593 with TUnitKind(UnitKinds.AddItem('Unit')) do begin594 Moves := 1;595 Power := 99;596 end;597 end;598 599 with GameSystems.AddNew('Civilization I') do begin600 PreferedMapType := mtSquare;601 UnitsMoveImmediately := True;602 MaxPlayerCount := 3;603 with TNation(Nations.AddItem('Americans')) do begin604 Color := clFuchsia;605 end;606 with TUnitKind(UnitKinds.AddItem('Scout')) do begin607 Moves := 1;608 Power := 1;609 end;610 with TUnitKind(UnitKinds.AddItem('Settler')) do begin611 Moves := 1;612 Power := 1;613 end;614 end;615 616 with GameSystems.AddNew('Civilization II') do begin617 PreferedMapType := mtIsometric;618 UnitsMoveImmediately := True;619 MaxPlayerCount := 3;620 with TUnitKind(UnitKinds.AddItem('Scout')) do begin621 Moves := 1;622 Power := 1;623 end;624 with TUnitKind(UnitKinds.AddItem('Settler')) do begin625 Moves := 1;626 Power := 1;627 end;628 end;629 630 with GameSystems.AddNew('Civilization III') do begin631 PreferedMapType := mtIsometric;632 UnitsMoveImmediately := True;633 MaxPlayerCount := 3;634 with TUnitKind(UnitKinds.AddItem('Scout')) do begin635 Moves := 1;636 Power := 1;637 end;638 with TUnitKind(UnitKinds.AddItem('Settler')) do begin639 Moves := 1;640 Power := 1;641 end;642 end;643 644 with GameSystems.AddNew('Civilization IV') do begin645 PreferedMapType := mtIsometric;646 UnitsMoveImmediately := True;647 MaxPlayerCount := 3;648 with TUnitKind(UnitKinds.AddItem('Scout')) do begin649 Moves := 1;650 Power := 1;651 end;652 with TUnitKind(UnitKinds.AddItem('Settler')) do begin653 Moves := 1;654 Power := 1;655 end;656 end;657 658 with GameSystems.AddNew('Civilization V') do begin659 PreferedMapType := mtHexagonHorizontal;660 UnitsMoveImmediately := True;661 MaxPlayerCount := 3;662 with TUnitKind(UnitKinds.AddItem('Scout')) do begin663 Moves := 1;664 Power := 1;665 end;666 with TUnitKind(UnitKinds.AddItem('Settler')) do begin667 Moves := 1;668 Power := 1;669 end;670 end;671 672 with GameSystems.AddNew('Civilization VI') do begin673 PreferedMapType := mtHexagonHorizontal;674 UnitsMoveImmediately := True;675 MaxPlayerCount := 3;676 with TUnitKind(UnitKinds.AddItem('Scout')) do begin677 Moves := 1;678 Power := 1;679 end;680 with TUnitKind(UnitKinds.AddItem('Settler')) do begin681 Moves := 1;682 Power := 1;683 end;684 end;685 686 with GameSystems.AddNew('Dune 2') do begin687 PreferedMapType := mtSquare;688 UnitsMoveImmediately := True;689 MaxPlayerCount := 3;690 with TNation(Nations.AddItem('Attreides')) do begin691 Color := clBlue;692 end;693 with TNation(Nations.AddItem('Harkonen')) do begin694 Color := clRed;695 end;696 with TNation(Nations.AddItem('Ordos')) do begin697 Color := clGreen;698 end;699 with TNation(Nations.AddItem('Fremens')) do begin700 Color := clBrown;701 end;702 with TNation(Nations.AddItem('Sardaukers')) do begin703 Color := clPurple;704 end;705 with TNation(Nations.AddItem('Merceneries')) do begin706 Color := clOrange;707 end;708 with TUnitKind(UnitKinds.AddItem('Light Infantry')) do begin709 Moves := 1;710 end;711 with TUnitKind(UnitKinds.AddItem('Heavy Troopers')) do begin712 Moves := 1;713 end;714 with TUnitKind(UnitKinds.AddItem('Trike')) do begin715 Moves := 1;716 end;717 with TUnitKind(UnitKinds.AddItem('Quad')) do begin718 Moves := 1;719 end;720 end;721 722 with GameSystems.AddNew('Battle Isle 2') do begin723 PreferedMapType := mtHexagonHorizontal;724 UnitsMoveImmediately := True;725 MaxPlayerCount := 8;726 with TUnitKind(UnitKinds.AddItem('Demon 132')) do begin727 Moves := 4;728 Power := 10;729 end;730 with TUnitKind(UnitKinds.AddItem('Troll 142')) do begin731 Moves := 3;732 Power := 10;733 end;734 with TUnitKind(UnitKinds.AddItem('Ranger 132')) do begin735 Moves := 10;736 Power := 10;737 end;738 with TUnitKind(UnitKinds.AddItem('Buggy')) do begin739 Moves := 10;740 Power := 10;741 end;742 end;743 744 with GameSystems.AddNew('Panzer General') do begin745 PreferedMapType := mtHexagonHorizontal;746 UnitsMoveImmediately := True;747 MaxPlayerCount := 2;748 with TNation(Nations.AddItem('Germany')) do begin749 Color := clBlue;750 end;751 with TNation(Nations.AddItem('Russia')) do begin752 Color := clRed;753 end;754 with TNation(Nations.AddItem('Alliance')) do begin755 Color := clGreen;756 end;757 with TUnitKind(UnitKinds.AddItem('Rifle Team')) do begin758 Moves := 1;759 end;760 with TUnitKind(UnitKinds.AddItem('Machine Gun')) do begin761 Moves := 1;762 end;763 with TUnitKind(UnitKinds.AddItem('Heavy Infantry')) do begin764 Moves := 1;765 end;766 with TUnitKind(UnitKinds.AddItem('Granadiers')) do begin767 Moves := 1;768 end;769 end;770 524 end; 771 525 … … 845 599 end; 846 600 601 procedure TCore.LoadGameSystems; 602 var 603 NewItem: TGameSystem; 604 begin 605 if DirectoryExists('Systems') then begin 606 GameSystems.LoadFromDir('Systems'); 607 end else begin 608 NewItem := TGameSystem.Create; 609 NewItem.FileName := 'Custom'; 610 GameSystems.Add(NewItem); 611 end; 612 if GameSystems.Count > 0 then begin 613 GameSettings.GameSystem := GameSystems.First; 614 Game.GameSystem := GameSystems.First; 615 end; 616 end; 617 847 618 procedure TCore.ReopenGameOnInit; 848 619 begin … … 953 724 if not Core.Initialized then begin 954 725 FInitialized := True; 726 LoadGameSystems; 955 727 956 728 // Update translated default player names -
trunk/UGameSystem.pas
r289 r292 7 7 uses 8 8 Classes, SysUtils, fgl, UUnit, DOM, XMLRead, XMLWrite, UXMLUtils, XMLConf, 9 FileUtil, UMapType, UNation, UBuilding;9 FileUtil, LazFileUtils, UMapType, UNation, UBuilding; 10 10 11 11 type … … 42 42 function AddNew(Name: string): TGameSystem; 43 43 function SearchByName(Name: string): TGameSystem; 44 procedure LoadFromDir(Dir: string); 44 45 end; 45 46 … … 73 74 if I < Count then Result := Items[I] 74 75 else Result := nil; 76 end; 77 78 procedure TGameSystems.LoadFromDir(Dir: string); 79 var 80 Files: TStringList; 81 I: Integer; 82 NewItem: TGameSystem; 83 begin 84 Files := TStringList.Create; 85 FindAllFiles(Files, Dir, '*' + GameSystemExt, True, faAnyFile); 86 for I := 0 to Files.Count - 1 do begin 87 NewItem := TGameSystem.Create; 88 NewItem.LoadFromFile(Files[I]); 89 Add(NewItem); 90 end; 91 Files.Free; 75 92 end; 76 93
Note:
See TracChangeset
for help on using the changeset viewer.