Difference between revisions of "Source Code"
(→Visual Studio Express 2012: http://star-trek-supremacy.proboards.com/thread/349/botf2-coding-practice) |
(→Improvement) |
||
(130 intermediate revisions by 3 users not shown) | |||
Line 5: | Line 5: | ||
=== official === | === official === | ||
− | *last source code https://bitbucket.org/mstrobel/supremacy/overview ( | + | * code is now at https://github.com/BotF2/BotF2.git |
− | **Mike's Post: build in [http://www.microsoft.com/downloads/dlx/en-us/ThankYou.aspx?FamilyID=75568AA6-8107-475D-948A-EF22627E57A5 VS2010] with .NET 4.0. You may need the [http://en.csharp-online.net/Download_Free_Microsoft_Visual_CSharp_.NET#Download_Microsoft_Visual_Studio_Async_Community_Technology_Preview_.28CTP.29 C# Async CTP]. http:// | + | |
− | **http:// | + | |
+ | *last source code https://bitbucket.org/mstrobel/supremacy/overview (it's in C#, also named CSharp. [[#Visual Studio]] is used for coding.) | ||
+ | **Mike's Post: build in [http://www.microsoft.com/downloads/dlx/en-us/ThankYou.aspx?FamilyID=75568AA6-8107-475D-948A-EF22627E57A5 VS2010] with .NET 4.0. You may need the [http://en.csharp-online.net/Download_Free_Microsoft_Visual_CSharp_.NET#Download_Microsoft_Visual_Studio_Async_Community_Technology_Preview_.28CTP.29 C# Async CTP]. http://bote2.square7.ch/forum/viewtopic.php?p=70790#p70790 | ||
+ | **http://bote2.square7.ch/forum/viewtopic.php?p=70781#p70781 | ||
+ | *** Supremacy.Game.GameEngine is where you'll find most of the game logic. That's where most of the turn processing happens. | ||
*** The SupremacyCore project is where you'll find the foundation of the game. | *** The SupremacyCore project is where you'll find the foundation of the game. | ||
*** SupremacyService is just the game server (all the important bits it interacts with are in SupremacyCore). | *** SupremacyService is just the game server (all the important bits it interacts with are in SupremacyCore). | ||
Line 17: | Line 21: | ||
*old source code can be taken from here: http://supremacy.codeplex.com/ (last upload from MStrobel at 03.01.2011) | *old source code can be taken from here: http://supremacy.codeplex.com/ (last upload from MStrobel at 03.01.2011) | ||
+ | |||
+ | ==== ClientContext vs AppContext ==== | ||
+ | |||
+ | taken from https://bitbucket.org/kflanagan/supremacydev/commits/0d562ce676425cd5da19cfdbcf1b6c18c7d0d135 | ||
+ | |||
+ | *IClientContext is used by SupremacyCore to interface clients participating on a game, both local and over network. The IClientContext further includes an interface to IGameContext which gives access to the game data itself inside the '''SupremacyClient app''' | ||
+ | *However there should be an option to also include local properties not known to the Core, which is why this is done alternatively another context would have to be introduced for local data, but then still all the client code would have to be updated to make use of it | ||
+ | |||
+ | |||
+ | ==== .XAML files ==== | ||
+ | |||
+ | In Windows Presentation Foundation (WPF), a windows app framework used by Supremacy, XAML forms a user interface markup language to define UI elements, data binding, events, and other features. | ||
+ | |||
+ | Info resources: | ||
+ | |||
+ | *MS Article: [https://msdn.microsoft.com/en-us/library/ms745683(v=vs.110).aspx XAML Styling and Templating] | ||
+ | |||
+ | *Youtube video: [https://www.youtube.com/watch?v=0qE5hyuU9hE Introduction to XAML] (26min) | ||
+ | |||
+ | == Bitbucket == | ||
+ | |||
+ | *https://confluence.atlassian.com/display/BITBUCKET/Maintaining+a+Mercurial+Repository | ||
== Changes == | == Changes == | ||
see [[ChangeLog|here]] or https://bitbucket.org/mstrobel/supremacy/commits/branch/default | see [[ChangeLog|here]] or https://bitbucket.org/mstrobel/supremacy/commits/branch/default | ||
+ | |||
+ | === 2016 === | ||
+ | |||
+ | ==== XAML ==== | ||
+ | |||
+ | *January 2016 [Planned]: Hope to get Major Race specific UI build through use of generic XAML files. | ||
+ | * ClientApp.xaml.cs has the code to direct UI to race specific folders of xaml files in SupremacyClient/themes/{0} | ||
+ | |||
+ | Looking at SystemScreen.xaml, Global.xaml and ClientModules.cs in Themes/SupremacyClient | ||
+ | See also generic.xaml in SupremacyClientComponents/Themes/InfoCard Theme.xaml Default.xaml Icons.xaml ClientApp.xaml.cs SystemScreen.xaml | ||
+ | |||
+ | |||
+ | 1/17/16: Found that Mikes code in ClientApp.xaml.cs will already select for Major race. Need new folders for each major race in SupremacyClient/themes/(major race), edit paths to Resources in the .xaml files found in each races set of .xaml files. File names in SupremacyClient/themes/(major race) are not unique but content in Resources is. Now you can edit files in Resources for unique UI. | ||
+ | |||
+ | 2/13/16: | ||
+ | |||
+ | <Polygon | ||
+ | Points="300,200 400,125 400,275 300,200" | ||
+ | Stroke="Purple" | ||
+ | StrokeThickness="2"> | ||
+ | <Polygon.Fill> | ||
+ | <SolidColorBrush Color="Blue" Opacity="0.4"/> | ||
+ | </Polygon.Fill> | ||
+ | </Polygon> | ||
+ | |||
+ | Makes a left pointing triangle, purple outline and blue body | ||
+ | |||
+ | === 2015 === | ||
+ | |||
+ | *'''Animation.cs''' (animation of opening screen): This is where we can set the number of images, frames, and the rate they play at, currently all images in 30 seconds. We may want that to run faster. The images you will make for the ship de-cloaking will be located in Resources / Images / Animation. | ||
+ | * \supremacyclient\'''ClientModule.cs''': | ||
+ | **Found a place to add the right mouse click instructions for the Panel Access Menu. A thing called the statusWindow held the text "loading" while you wait for a game to load. Added the information there for new players | ||
+ | |||
+ | *FMOD is partly replace by AudioEngine.cs and others - just find it out | ||
+ | |||
+ | === 2014 === | ||
== some code == | == some code == | ||
+ | for Theme and UI see >> '''[[Theme]]''' | ||
+ | |||
+ | === miscellaneous === | ||
+ | |||
+ | *Mainline\SupremacyClient\GameContextMenu.cs | ||
+ | |||
+ | *\Mainline\SupremacyUI\SystemProductionPanel.cs | ||
+ | |||
+ | *\Mainline\SupremacyCore\Orbitals\FleetOrders.cs -> all items inside a sector | ||
+ | |||
+ | *Mainline\SupremacyClient\GameContextMenu.cs (Access Popup Menu - or use F1 to F5) | ||
+ | |||
+ | *\Mainline\SupremacyClientComponents\Controls\InfoCard\InfoCard.cs (-> Tooltips ??) | ||
+ | **\Mainline\SupremacyClient\themes\Federation\InfoCard.xaml -> <Setter Property="Width" Value="500" /> (BEFORE: 250) | ||
+ | |||
+ | |||
+ | *\Mainline\SupremacyClient\Views\ColonyScreen\ColonyPlanetaryBuildQueueView.xaml - Colonies Screen Content | ||
+ | |||
+ | *\Mainline\SupremacyCore\Universe\Colony.cs | ||
+ | *\Mainline\SupremacyClient\Views\ColonyScreen\ColonyStructureListView.xaml | ||
+ | **Size of this area: 720 x 240 | ||
+ | |||
+ | |||
+ | *\Mainline\SupremacyClient\Views\GalaxyScreen\TaskForceListView.xaml | ||
+ | |||
+ | === Version Number === | ||
+ | |||
+ | Look for version number control in AssemblyInfo.cs | ||
+ | |||
+ | your hard disk code folder BotF2\SupremacyClient\Properties\AssemblyInfo.cs | ||
+ | |||
+ | --- | ||
+ | example code: (put in your current star date) | ||
+ | |||
+ | *[assembly: AssemblyVersion("2018.11.20.0")] | ||
+ | *[assembly: AssemblyFileVersion("2018.11.20.0")] | ||
+ | |||
+ | === Ships === | ||
+ | |||
+ | *\Fleets.cs | ||
+ | *\FleetOrder.cs (without a "s" - beware of it) | ||
+ | *\FleetOrders.cs | ||
+ | |||
+ | *\mainline\supremacyclientcomponents\views\galaxyscreen\galaxyscreenpresenter.cs TaskForcesList | ||
+ | |||
+ | |||
+ | ==== Building Ships ==== | ||
+ | |||
+ | *Cancelling -> Breakpoint at Line 185 at OnShipyardBuildProjectsChanged() \Mainline\SupremacyClientComponents\Views\ColonyScreen\ColonyScreenPresentationModel.cs | ||
+ | |||
+ | === Sounds === | ||
+ | |||
+ | *\Mainline\SupremacyClient\AudioEngine.cs (for Music), for Sounds >> SoundPlayerAction is used (search for \Resources\UI\Federation\SoundsButtonClick.wav) | ||
+ | *and in \Mainline\SupremacyClientComponents\Views\SystemAssaultScreen\SystemAssaultScreenViewModel.cs -> Uri is used (e.g. CombatLaser.wav) | ||
+ | |||
+ | |||
+ | === Galaxy Generator === | ||
+ | |||
+ | *\Mainline\SupremacyCore\Universe\GalaxyGenerator.cs | ||
+ | |||
+ | |||
+ | === Values === | ||
+ | *CivID: 0 = Federation... | ||
+ | |||
+ | === TurnPhase === | ||
+ | |||
+ | WaitOnPlayers = 0, | ||
+ | PreTurnOperations, | ||
+ | ResetObjects, | ||
+ | FleetMovement, | ||
+ | Combat, | ||
+ | PopulationGrowth, | ||
+ | PersonnelTraining, | ||
+ | Research, | ||
+ | Scrapping, | ||
+ | Maintenance, | ||
+ | ShipProduction, | ||
+ | Production, | ||
+ | Trade, | ||
+ | Morale, | ||
+ | MapUpdates, | ||
+ | PostTurnOperations, | ||
+ | SendUpdates, | ||
+ | Diplomacy, | ||
+ | WaitOnAIPlayers | ||
+ | |||
+ | === older list === | ||
{|class="wikitable sortable" | {|class="wikitable sortable" | ||
Line 150: | Line 299: | ||
*http://star-trek-supremacy.proboards.com/thread/349/botf2-coding-practice (intern) | *http://star-trek-supremacy.proboards.com/thread/349/botf2-coding-practice (intern) | ||
− | |||
− | + | *prepare: | |
+ | **...we are using SourceTree, provided by bitbucket (another option: TortoiseHg with Mercurial - to access the supremacy code repository http://tortoisehg.bitbucket.org/) | ||
+ | **PuTTYgen - to generate a ssh key to allow using ssh protocol instead of slow https http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html | ||
+ | ***or use C:\Program Files (x86)\Atlassian\SourceTree\tools\putty..puttygen.exe....generate a key (using a phrase is not neccessary) | ||
+ | ***copy the public key (4-5 lines) into your bitbucket account/profile under SSH Keys, label it with any title and CopyPaste | ||
+ | **we are using Visual Studio Community 2013 Update 4 (select the Community Version) https://www.visualstudio.com/en-us/downloads/download-visual-studio-vs.aspx | ||
+ | **we are not(!) using Visual Studio Community 2015 RC - to compile the code (ISO is recommend)....still need to check if Supremacy code compiles with it, so instead we might need to depend on VS2013 http://www.visualstudio.com/downloads/visual-studio-2015-downloads-vs....for VS 2015 we read to create a new project, import Supremacy and go through all the issues | ||
+ | **you also need to have an account on http://bitbucket.org | ||
+ | **and you should have Skype installed to participate in the meetings we have | ||
− | + | *when you attempt to clone by ssh instead of https, check the following tutorial: http://confluence.atlassian.com/display/BITBUCKET/Set+up+SSH+for+Mercurial | |
− | |||
− | + | *here some simple text editors useful to edit stuff like xml files, just pick the one you prefer they all are great: | |
+ | **http://www.sublimetext.com/ | ||
+ | **http://www.contexteditor.org/index.php | ||
+ | **http://notepad-plus-plus.org/ (used by reg atm) | ||
− | + | == SourceTree == | |
− | <img>http://botf2.square7.ch/wiki-files/images/ | + | *Download >> https://www.sourcetreeapp.com/?v=win (or while cloning...use the link below blue Clone Button) |
+ | |||
+ | *Tools: 3rd point: OPTIONS | ||
+ | |||
+ | *SSH Client Configuration: | ||
+ | **SSH Key: c:\....\ReginaldPutty.ppk | ||
+ | **SSH Client: (IMPORTANT) PuTTY/Link (not SSH !!) | ||
+ | **automatically start: yes | ||
+ | |||
+ | == Visual Studio == | ||
+ | |||
+ | It's possible (and standard) to compile the game with Visual Studio. No further stuff of programs is needed, except matching Resources folder. Mention that the compiled exe is then in \Mainline\bin\Debug (or \Release). | ||
+ | |||
+ | === VS2019 === | ||
+ | |||
+ | * meanwhile we are on VS 2019 Community version https://www.visualstudio.com/downloads | ||
+ | |||
+ | * see hints for VS 2017 especially >> Set as Start Project > SupremacyClient (View SolutionExplorer > SupremacyClient > right mouse click ...in the middle) | ||
+ | |||
+ | ==== Improvement ==== | ||
+ | |||
+ | |||
+ | old: var handler = TurnNumberChanged; | ||
+ | if (handler != null) | ||
+ | handler(this, EventArgs.Empty); | ||
+ | New: TurnNumberChanged?.Invoke(this, EventArgs.Empty); | ||
+ | |||
+ | old: if (baseScheduler == null) | ||
+ | throw new ArgumentNullException("baseScheduler"); | ||
+ | new: _baseScheduler = baseScheduler ?? throw new ArgumentNullException("baseScheduler"); | ||
+ | |||
+ | === VS2017 === | ||
+ | |||
+ | In May 2017 we're trying to change to VS 2017 Community version https://www.visualstudio.com/downloads | ||
+ | |||
+ | *you might want to change language at TOOLS > OPTIONS > ENVIROMENT > INTERNATIONAL SETTINGS | ||
+ | |||
+ | * first make a clean !!, maybe for each single project (10 of 10) | ||
+ | |||
+ | * SOLUTION EXPLORER - right mouse click - retarget (in the middle) - select newest versions | ||
+ | |||
+ | * (this should be only needed once and should be uploaded to Repository by one guy) SupremacyClient > Set as start Project | ||
+ | |||
+ | *after cleaning maybe use REBUILD | ||
+ | |||
+ | for more see >> [[#Tools|here]] | ||
+ | |||
+ | |||
+ | |||
+ | === VS2015 === | ||
+ | |||
+ | since April 2016 we're using VS 2015 | ||
+ | |||
+ | *Visual Studio '''Community''' 2015 RC - to compile the code (ISO is recommend) ... still need to check if Supremacy code compiles with it, so instead we might need VS2013. NEW: we try to go to VS 2015 now. | ||
+ | https://www.visualstudio.com/downloads/visual-studio-2015-downloads-vs - you need the "Community" Version, currently (Apr 2016) version "Update 2" | ||
+ | |||
+ | |||
+ | ==== VS 2015 Update 3 ==== | ||
+ | |||
+ | *says it does uninstall Update 2 | ||
+ | *needs update to 33 GB to install (only if every is selected) - seems to need some hours... | ||
+ | |||
+ | === old VS === | ||
+ | |||
+ | this is out of date due to code has changed | ||
+ | |||
+ | ==== Visual C++ Library ==== | ||
+ | |||
+ | IMPORTANT: As Microsoft no longer provides Visual C++ Library as standard installed component ...don't forget to select or install this manually! In VS you can recognize it if \Supremacy Native is unload (sign is greyed out a little bit) | ||
+ | |||
+ | ===== SupremacyNative ===== | ||
+ | |||
+ | SupremacyNative is C++ coded. Sometimes there are some problems with it https://developercommunity.visualstudio.com/content/problem/312852/internal-compiler-error-in-vs158-msc1cpp-line-1518.html | ||
+ | |||
+ | *Visual Studio Community 2013 (Community version is free) http://www.visualstudio.com/downloads/download-visual-studio-vs#d-express-windows-desktop | ||
+ | *Visual Studio Express 2012 (Express version is free) http://www.visualstudio.com/downloads/download-visual-studio-vs#d-express-windows-desktop | ||
+ | *Visual Studio Express 2008 (German) http://www.microsoft.com/de-de/download/details.aspx?id=13276 | ||
+ | |||
+ | === Tools === | ||
+ | |||
+ | *Indent Guides https://visualstudiogallery.msdn.microsoft.com/e792686d-542b-474a-8c55-630980e72c30 Adds vertical lines at each indent level. | ||
+ | |||
+ | * Vertical tabs https://marketplace.visualstudio.com/items?itemName=VisualStudioProductTeam.ProductivityPowerPack2017 | ||
+ | |||
+ | *PowerShell Tools für VS 2015 | ||
+ | |||
+ | === Tips === | ||
+ | *TOOLS > OPTIONS > ENVIRONMENT > Color theme -> Black | ||
+ | |||
+ | *TOOLS > OPTIONS > ENVIRONMENT > DOCUMENTS > Detect when file is changed outside... -> Yes | ||
+ | **TOOLS > OPTIONS > ENVIRONMENT > DOCUMENTS > Reload modified files... -> Yes | ||
+ | |||
+ | *DEBUG > OPTIONS > PROJECTS... > BUILD AND RUN > when code=project is changed="out of date" > "Always Build" (checkbox "only build ...on Run" is marked) | ||
+ | **https://www.vb-paradise.de/index.php/Thread/47935-Code-bei-Klick-auf-Debugging-starten-kompilieren-wenn-er-sich-ge%C3%A4ndert-hat/ | ||
+ | |||
+ | *TOOLS > OPTIONS > TEXT EDITOR > ALL LANGUAGES > Line Number (activate for all) | ||
+ | |||
+ | *DEBUG > SUPREMACY CLIENT PROPERTIES (last) > DEBUG > Start project > Command line arguments: "-aiexplore -SAVEDGAME:auto" (if you save in Supremacy manually a game with name "auto" (independent from game's "(autosave)", this manually saved game can be loaded at startup. | ||
+ | **"-aiexplore" isn't necessary. For more see [[Command line parameter]] | ||
+ | **if working for example on Cardassian UI just save Cardassian as "auto". | ||
+ | **when you want to change to Klingons, just retire and start Klingons. If you want to work steady on Klingons, save a Klingon's game with auto. | ||
+ | **if you want to start a new game steady, just go Command line arguments (see above) and change the filename to an unused one like "-SAVEDGAME:auto123" | ||
+ | |||
+ | *activate Toolbar BUILD by right mouse click on Toolbar line | ||
+ | |||
+ | * Tools -> Options -> Debugging -> Output Window -> Module Load Messages -> Off | ||
+ | |||
+ | ==== Editor ==== | ||
+ | we're using some different editors | ||
+ | *one option is to drag'n'drop files like xml to Visual Studio | ||
+ | *sometimes we use Notepad++ https://notepad-plus-plus.org/download with Extension Compare (PLUGINS > PLUGIN MANAGER > SHOW P-Manager > "Compare" ...install | ||
+ | *for a black style we use Sublime http://www.sublimetext.com/2 | ||
+ | |||
+ | ==== Screenshot ==== | ||
+ | |||
+ | *reg likes Greenshot http://getgreenshot.org/ | ||
+ | **puts an icon into task bar. There: > PREFERENCES | ||
+ | ***PREFERENCES > GENERAL: reg uses for "Capture region" CRTL+PRNT (and no other hotkey) | ||
+ | ***PREFERENCES > OUTPUT: define a folder at "Storage location" and a standard file type (default is *.png) | ||
+ | ***PREFERENCES > DESTINATION: (reg's settings) | ||
+ | ****- turn off "Select destination dymnamically" | ||
+ | ****- open in image editor | ||
+ | ****- copy to clipboard | ||
+ | **Usage: | ||
+ | ***press Hotkey and make Screenshot | ||
+ | ***paste immediately anywhere OR | ||
+ | ***work on it inside Greenshot (give red circles or mark up in any colour), give numbers, obfuscate and more | ||
+ | ***save or save as jpg or print | ||
+ | |||
+ | == Compiling == | ||
+ | |||
+ | if you have an error with "Glyphs.xaml", than make sure you have copied \Resources MANUALLY into the output folders - this was changed in 2015. The output folder depends on compiling method "Debug" or "Release", it is | ||
+ | *for DEBUG _: (YourRepositoryFolder)\Mainline\bin\'''Debug\Resources''' or | ||
+ | *for RELEASE: (YourRepositoryFolder)\Mainline\bin\'''Release\Resources''' | ||
+ | |||
+ | it's creating: | ||
+ | *1> Supremacy.Scripting -> %path_repo%\bin\Debug\lib\Supremacy.Scripting.dll | ||
+ | *2> SupremacyCore -> %path_repo%\bin\Debug\lib\SupremacyCore.dll | ||
+ | *3> Supremacy.Xna -> %path_repo%\bin\Debug\lib\Supremacy.Xna.dll | ||
+ | *4> SupremacyClientComponents -> %path_repo%\bin\Debug\lib\SupremacyClientComponents.dll | ||
+ | *5> SupremacyWPF -> %path_repo%\bin\Debug\lib\SupremacyWPF.dll | ||
+ | *6> SupremacyService -> %path_repo%\bin\Debug\lib\SupremacyService.dll | ||
+ | *7> SupremacyUI -> %path_repo%\bin\Debug\lib\SupremacyUI.dll | ||
+ | |||
+ | == Visual C# == | ||
+ | |||
+ | build in Visual Studio | ||
+ | |||
+ | <img>http://botf2.square7.ch/wiki-files/images/VS2015.jpg</img> | ||
== SunBurn == | == SunBurn == | ||
− | + | SunBurn is on hold for now. Kenneth was working sometimes with SunBurn...this might be a site for this http://channel9.msdn.com/coding4fun/blog/No-need-for-sunscreen-you-want-this-SunBurn-SunBurn-v2-RTMs-including-the-free-SunBurn-Framework-Edi | |
*http://en.wikipedia.org/wiki/List_of_game_engines | *http://en.wikipedia.org/wiki/List_of_game_engines | ||
Line 183: | Line 489: | ||
This suggests the problem is with your XNA installation. The game uses XNA to display the 3D ship models in the shipyard. There's no way to disable the models so XNA wouldn't be needed. So to be able to play the game, i'd advise to uninstall XNA, then install the latest version. | This suggests the problem is with your XNA installation. The game uses XNA to display the 3D ship models in the shipyard. There's no way to disable the models so XNA wouldn't be needed. So to be able to play the game, i'd advise to uninstall XNA, then install the latest version. | ||
− | Download link: http://www.microsoft.com/en-gb/download/details.aspx?id=20914 | + | XNA 3.1 (this one you need in any case): http://www.microsoft.com/en-us/download/details.aspx?id=15163 |
+ | |||
+ | XNA 4.0 Download link: http://www.microsoft.com/en-gb/download/details.aspx?id=20914 | ||
+ | |||
+ | == Try == | ||
+ | |||
+ | (for boolean) | ||
+ | |||
+ | try | ||
+ | { | ||
+ | return true; | ||
+ | } | ||
+ | catch (Exception e) | ||
+ | { | ||
+ | var errors = new System.Collections.Concurrent.ConcurrentStack<Exception>(); | ||
+ | errors.Push(e); | ||
+ | return false; | ||
+ | } | ||
+ | finally | ||
+ | { | ||
+ | xxx; | ||
+ | } | ||
+ | ; | ||
+ | |||
+ | == Contexts == | ||
+ | |||
+ | *AppContext (programm running) | ||
+ | *GameContext.Current (Game started - so after StartScreen) | ||
+ | *PlayerContext.Current | ||
+ | |||
+ | == Text == | ||
+ | === en.txt === | ||
+ | * XAML example: Text="{s:StringResource EMPIRES_HEADER}" | ||
+ | * string _text = String.Format(ResourceManager.GetString("KEY_IN-EN_TXT"),parameter1, parameter2; | ||
+ | |||
+ | == LocalPlayer == | ||
+ | |||
+ | *AppContext.LocalPlayer (just inside XAML-code files ??) | ||
+ | * _appContext.LocalPlayer.Empire | ||
+ | |||
+ | == Civilization == | ||
+ | |||
+ | just the data out of Civilization.xml ... for more see [[#CivilizationManager]] | ||
+ | |||
+ | == CivilizationManager == | ||
+ | |||
+ | CivilizationManager holds all the data like amount of credits, diplomacy, sitreps and more | ||
+ | |||
+ | *GameContext.Current.CivilizationManagers[LocalPlayer.EmpireID] | ||
+ | |||
+ | GameContext.Current.CivilizationManagers[LocalPlayer.EmpireID] | ||
+ | |||
+ | == GameLog == | ||
+ | |||
+ | if not available, try "Quick actions" -> using Supremacy.Utility; | ||
+ | |||
+ | GameLog.Core.GameData.DebugFormat("Turn {0};xx=;{1};xx=;{2};xx={3};xx={4};xx={5};xx={6};xx={7};xx={8};xx={9};" | ||
+ | , GameContext.Current.TurnNumber | ||
+ | , xx | ||
+ | , xx | ||
+ | ); | ||
+ | |||
+ | == Dictionary == | ||
+ | |||
+ | private static Dictionary<string, bool> _acceptRejectDictionary = new Dictionary<string, bool> { { "98", false } }; | ||
+ | |||
+ | == MessageBox (Windows Style) == | ||
+ | |||
+ | MessageBox.Show("Borg turned into Expanded", "WARNING", MessageBoxButton.OK); | ||
+ | |||
+ | == MessageDialog (Supremacy Style) == | ||
+ | |||
+ | var result = MessageDialog.Show("Borg turned into Expanded", MessageDialogButtons.YesNo); | ||
+ | |||
+ | == SoundPlaying == | ||
+ | |||
+ | * _soundPlayer.PlayFile("Resources/SoundFX/ChatMessage.wav"); |
Latest revision as of 13:32, 9 May 2021
Contents
- 1 Source Code
- 2 Bitbucket
- 3 Changes
- 4 some code
- 5 Botf2-coding-practice
- 6 SourceTree
- 7 Visual Studio
- 8 Compiling
- 9 Visual C#
- 10 SunBurn
- 11 .Net
- 12 XNA
- 13 Try
- 14 Contexts
- 15 Text
- 16 LocalPlayer
- 17 Civilization
- 18 CivilizationManager
- 19 GameLog
- 20 Dictionary
- 21 MessageBox (Windows Style)
- 22 MessageDialog (Supremacy Style)
- 23 SoundPlaying
Source Code
http://guganeshan.com/blog/setting-up-git-and-tortoisegit-with-bitbucket-step-by-step.html
official
- code is now at https://github.com/BotF2/BotF2.git
- last source code https://bitbucket.org/mstrobel/supremacy/overview (it's in C#, also named CSharp. #Visual Studio is used for coding.)
- Mike's Post: build in VS2010 with .NET 4.0. You may need the C# Async CTP. http://bote2.square7.ch/forum/viewtopic.php?p=70790#p70790
- http://bote2.square7.ch/forum/viewtopic.php?p=70781#p70781
- Supremacy.Game.GameEngine is where you'll find most of the game logic. That's where most of the turn processing happens.
- The SupremacyCore project is where you'll find the foundation of the game.
- SupremacyService is just the game server (all the important bits it interacts with are in SupremacyCore).
- SupremacyClientComponents is UI infrastructure.
- SupremacyUI and SupremacyWPF are older UI infrastructure stuff, much of which has been phased out and replaced by newer and better stuff in SupremacyClientComponents. The most interesting stuff in SupremacyUI is GalaxyGridPanel, which draws the galactic map. It also has the spinning planet views.
- Supremacy.Xna is where the XNA/3D stuff is located--it's not used heavily yet, but it has some effects for the invasion screen, a newer star renderer, a 3D spinning ship renderer, etc.
- Supremacy.Scripting is an expression language parser/compiler.
- SupremacyClient is the main graphical client and has most of the game screen implementations.
- old source code can be taken from here: http://supremacy.codeplex.com/ (last upload from MStrobel at 03.01.2011)
ClientContext vs AppContext
taken from https://bitbucket.org/kflanagan/supremacydev/commits/0d562ce676425cd5da19cfdbcf1b6c18c7d0d135
- IClientContext is used by SupremacyCore to interface clients participating on a game, both local and over network. The IClientContext further includes an interface to IGameContext which gives access to the game data itself inside the SupremacyClient app
- However there should be an option to also include local properties not known to the Core, which is why this is done alternatively another context would have to be introduced for local data, but then still all the client code would have to be updated to make use of it
.XAML files
In Windows Presentation Foundation (WPF), a windows app framework used by Supremacy, XAML forms a user interface markup language to define UI elements, data binding, events, and other features.
Info resources:
- MS Article: XAML Styling and Templating
- Youtube video: Introduction to XAML (26min)
Bitbucket
Changes
see here or https://bitbucket.org/mstrobel/supremacy/commits/branch/default
2016
XAML
- January 2016 [Planned]: Hope to get Major Race specific UI build through use of generic XAML files.
- ClientApp.xaml.cs has the code to direct UI to race specific folders of xaml files in SupremacyClient/themes/{0}
Looking at SystemScreen.xaml, Global.xaml and ClientModules.cs in Themes/SupremacyClient See also generic.xaml in SupremacyClientComponents/Themes/InfoCard Theme.xaml Default.xaml Icons.xaml ClientApp.xaml.cs SystemScreen.xaml
1/17/16: Found that Mikes code in ClientApp.xaml.cs will already select for Major race. Need new folders for each major race in SupremacyClient/themes/(major race), edit paths to Resources in the .xaml files found in each races set of .xaml files. File names in SupremacyClient/themes/(major race) are not unique but content in Resources is. Now you can edit files in Resources for unique UI.
2/13/16:
<Polygon Points="300,200 400,125 400,275 300,200" Stroke="Purple" StrokeThickness="2"> <Polygon.Fill> <SolidColorBrush Color="Blue" Opacity="0.4"/> </Polygon.Fill> </Polygon>
Makes a left pointing triangle, purple outline and blue body
2015
- Animation.cs (animation of opening screen): This is where we can set the number of images, frames, and the rate they play at, currently all images in 30 seconds. We may want that to run faster. The images you will make for the ship de-cloaking will be located in Resources / Images / Animation.
- \supremacyclient\ClientModule.cs:
- Found a place to add the right mouse click instructions for the Panel Access Menu. A thing called the statusWindow held the text "loading" while you wait for a game to load. Added the information there for new players
- FMOD is partly replace by AudioEngine.cs and others - just find it out
2014
some code
for Theme and UI see >> Theme
miscellaneous
- Mainline\SupremacyClient\GameContextMenu.cs
- \Mainline\SupremacyUI\SystemProductionPanel.cs
- \Mainline\SupremacyCore\Orbitals\FleetOrders.cs -> all items inside a sector
- Mainline\SupremacyClient\GameContextMenu.cs (Access Popup Menu - or use F1 to F5)
- \Mainline\SupremacyClientComponents\Controls\InfoCard\InfoCard.cs (-> Tooltips ??)
- \Mainline\SupremacyClient\themes\Federation\InfoCard.xaml -> <Setter Property="Width" Value="500" /> (BEFORE: 250)
- \Mainline\SupremacyClient\Views\ColonyScreen\ColonyPlanetaryBuildQueueView.xaml - Colonies Screen Content
- \Mainline\SupremacyCore\Universe\Colony.cs
- \Mainline\SupremacyClient\Views\ColonyScreen\ColonyStructureListView.xaml
- Size of this area: 720 x 240
- \Mainline\SupremacyClient\Views\GalaxyScreen\TaskForceListView.xaml
Version Number
Look for version number control in AssemblyInfo.cs
your hard disk code folder BotF2\SupremacyClient\Properties\AssemblyInfo.cs
--- example code: (put in your current star date)
- [assembly: AssemblyVersion("2018.11.20.0")]
- [assembly: AssemblyFileVersion("2018.11.20.0")]
Ships
- \Fleets.cs
- \FleetOrder.cs (without a "s" - beware of it)
- \FleetOrders.cs
- \mainline\supremacyclientcomponents\views\galaxyscreen\galaxyscreenpresenter.cs TaskForcesList
Building Ships
- Cancelling -> Breakpoint at Line 185 at OnShipyardBuildProjectsChanged() \Mainline\SupremacyClientComponents\Views\ColonyScreen\ColonyScreenPresentationModel.cs
Sounds
- \Mainline\SupremacyClient\AudioEngine.cs (for Music), for Sounds >> SoundPlayerAction is used (search for \Resources\UI\Federation\SoundsButtonClick.wav)
- and in \Mainline\SupremacyClientComponents\Views\SystemAssaultScreen\SystemAssaultScreenViewModel.cs -> Uri is used (e.g. CombatLaser.wav)
Galaxy Generator
- \Mainline\SupremacyCore\Universe\GalaxyGenerator.cs
Values
- CivID: 0 = Federation...
TurnPhase
WaitOnPlayers = 0, PreTurnOperations, ResetObjects, FleetMovement, Combat, PopulationGrowth, PersonnelTraining, Research, Scrapping, Maintenance, ShipProduction, Production, Trade, Morale, MapUpdates, PostTurnOperations, SendUpdates, Diplomacy, WaitOnAIPlayers
older list
where | Folder | File | Function | Date | Description | Custom1 | Custom2
|
---|---|---|---|---|---|---|---|
S-Core | Game | GameContext.cs |
initialising game |
||||
S-Core | Game | GameEngine.cs | DoProduction(GameContext game) |
Raw Materials, Deuterium, Dilithium is collected cross over all colonies and used by all colonies |
|||
S-Core | Game | GameEngine.cs | DoShipProduction(GameContext game) | ||||
S-Core | Combat | InvasionArena.cs |
SystemAssault |
||||
S-Core | Orbital | Shipyard.cs | GetBuildOutput(int slot) | 2014-01-15 |
just selects output (active?) and bonus (BonusType.PercentShipBuilding), since 2014-01-15 also case PopulationRatio or IndustryRatio |
||
S-Core | Universe | Colony.cs | GetProductionOutput(ProductionCategory category) |
see last line, too !
float moraleMod = _morale.CurrentValue / (0.5f * MoraleHelper.MaxValue); baseOutput = (int)(moraleMod * baseOutput);
float moraleMod = _morale.CurrentValue / (0.5f * MoraleHelper.MaxValue); baseOutput = (int)(moraleMod * baseOutput);
|
|||
S-Core | Universe | Colony.cs | planet.HasFoodBonus (OutputModifier) |
if (planet.HasFoodBonus) modifier.Efficiency += 0.15f; |
|||
S-Core | Universe | Colony.cs | planet.HasEnergyBonus (OutputModifier) |
if (planet.HasEnergyBonus) modifier.Efficiency += 0.15f; |
|||
S-ClientComp | Views\GalaxyScreen | GalaxyScreenView.cs | GalaxyScreenView() | GalaxyView Hotkeys Definition (see Hotkeys) |
Botf2-coding-practice
- prepare:
- ...we are using SourceTree, provided by bitbucket (another option: TortoiseHg with Mercurial - to access the supremacy code repository http://tortoisehg.bitbucket.org/)
- PuTTYgen - to generate a ssh key to allow using ssh protocol instead of slow https http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
- or use C:\Program Files (x86)\Atlassian\SourceTree\tools\putty..puttygen.exe....generate a key (using a phrase is not neccessary)
- copy the public key (4-5 lines) into your bitbucket account/profile under SSH Keys, label it with any title and CopyPaste
- we are using Visual Studio Community 2013 Update 4 (select the Community Version) https://www.visualstudio.com/en-us/downloads/download-visual-studio-vs.aspx
- we are not(!) using Visual Studio Community 2015 RC - to compile the code (ISO is recommend)....still need to check if Supremacy code compiles with it, so instead we might need to depend on VS2013 http://www.visualstudio.com/downloads/visual-studio-2015-downloads-vs....for VS 2015 we read to create a new project, import Supremacy and go through all the issues
- you also need to have an account on http://bitbucket.org
- and you should have Skype installed to participate in the meetings we have
- when you attempt to clone by ssh instead of https, check the following tutorial: http://confluence.atlassian.com/display/BITBUCKET/Set+up+SSH+for+Mercurial
- here some simple text editors useful to edit stuff like xml files, just pick the one you prefer they all are great:
SourceTree
- Download >> https://www.sourcetreeapp.com/?v=win (or while cloning...use the link below blue Clone Button)
- Tools: 3rd point: OPTIONS
- SSH Client Configuration:
- SSH Key: c:\....\ReginaldPutty.ppk
- SSH Client: (IMPORTANT) PuTTY/Link (not SSH !!)
- automatically start: yes
Visual Studio
It's possible (and standard) to compile the game with Visual Studio. No further stuff of programs is needed, except matching Resources folder. Mention that the compiled exe is then in \Mainline\bin\Debug (or \Release).
VS2019
- meanwhile we are on VS 2019 Community version https://www.visualstudio.com/downloads
- see hints for VS 2017 especially >> Set as Start Project > SupremacyClient (View SolutionExplorer > SupremacyClient > right mouse click ...in the middle)
Improvement
old: var handler = TurnNumberChanged; if (handler != null) handler(this, EventArgs.Empty); New: TurnNumberChanged?.Invoke(this, EventArgs.Empty);
old: if (baseScheduler == null) throw new ArgumentNullException("baseScheduler"); new: _baseScheduler = baseScheduler ?? throw new ArgumentNullException("baseScheduler");
VS2017
In May 2017 we're trying to change to VS 2017 Community version https://www.visualstudio.com/downloads
- you might want to change language at TOOLS > OPTIONS > ENVIROMENT > INTERNATIONAL SETTINGS
- first make a clean !!, maybe for each single project (10 of 10)
- SOLUTION EXPLORER - right mouse click - retarget (in the middle) - select newest versions
- (this should be only needed once and should be uploaded to Repository by one guy) SupremacyClient > Set as start Project
- after cleaning maybe use REBUILD
for more see >> here
VS2015
since April 2016 we're using VS 2015
- Visual Studio Community 2015 RC - to compile the code (ISO is recommend) ... still need to check if Supremacy code compiles with it, so instead we might need VS2013. NEW: we try to go to VS 2015 now.
https://www.visualstudio.com/downloads/visual-studio-2015-downloads-vs - you need the "Community" Version, currently (Apr 2016) version "Update 2"
VS 2015 Update 3
- says it does uninstall Update 2
- needs update to 33 GB to install (only if every is selected) - seems to need some hours...
old VS
this is out of date due to code has changed
Visual C++ Library
IMPORTANT: As Microsoft no longer provides Visual C++ Library as standard installed component ...don't forget to select or install this manually! In VS you can recognize it if \Supremacy Native is unload (sign is greyed out a little bit)
SupremacyNative
SupremacyNative is C++ coded. Sometimes there are some problems with it https://developercommunity.visualstudio.com/content/problem/312852/internal-compiler-error-in-vs158-msc1cpp-line-1518.html
- Visual Studio Community 2013 (Community version is free) http://www.visualstudio.com/downloads/download-visual-studio-vs#d-express-windows-desktop
- Visual Studio Express 2012 (Express version is free) http://www.visualstudio.com/downloads/download-visual-studio-vs#d-express-windows-desktop
- Visual Studio Express 2008 (German) http://www.microsoft.com/de-de/download/details.aspx?id=13276
Tools
- Indent Guides https://visualstudiogallery.msdn.microsoft.com/e792686d-542b-474a-8c55-630980e72c30 Adds vertical lines at each indent level.
- Vertical tabs https://marketplace.visualstudio.com/items?itemName=VisualStudioProductTeam.ProductivityPowerPack2017
- PowerShell Tools für VS 2015
Tips
- TOOLS > OPTIONS > ENVIRONMENT > Color theme -> Black
- TOOLS > OPTIONS > ENVIRONMENT > DOCUMENTS > Detect when file is changed outside... -> Yes
- TOOLS > OPTIONS > ENVIRONMENT > DOCUMENTS > Reload modified files... -> Yes
- DEBUG > OPTIONS > PROJECTS... > BUILD AND RUN > when code=project is changed="out of date" > "Always Build" (checkbox "only build ...on Run" is marked)
- TOOLS > OPTIONS > TEXT EDITOR > ALL LANGUAGES > Line Number (activate for all)
- DEBUG > SUPREMACY CLIENT PROPERTIES (last) > DEBUG > Start project > Command line arguments: "-aiexplore -SAVEDGAME:auto" (if you save in Supremacy manually a game with name "auto" (independent from game's "(autosave)", this manually saved game can be loaded at startup.
- "-aiexplore" isn't necessary. For more see Command line parameter
- if working for example on Cardassian UI just save Cardassian as "auto".
- when you want to change to Klingons, just retire and start Klingons. If you want to work steady on Klingons, save a Klingon's game with auto.
- if you want to start a new game steady, just go Command line arguments (see above) and change the filename to an unused one like "-SAVEDGAME:auto123"
- activate Toolbar BUILD by right mouse click on Toolbar line
- Tools -> Options -> Debugging -> Output Window -> Module Load Messages -> Off
Editor
we're using some different editors
- one option is to drag'n'drop files like xml to Visual Studio
- sometimes we use Notepad++ https://notepad-plus-plus.org/download with Extension Compare (PLUGINS > PLUGIN MANAGER > SHOW P-Manager > "Compare" ...install
- for a black style we use Sublime http://www.sublimetext.com/2
Screenshot
- reg likes Greenshot http://getgreenshot.org/
- puts an icon into task bar. There: > PREFERENCES
- PREFERENCES > GENERAL: reg uses for "Capture region" CRTL+PRNT (and no other hotkey)
- PREFERENCES > OUTPUT: define a folder at "Storage location" and a standard file type (default is *.png)
- PREFERENCES > DESTINATION: (reg's settings)
- - turn off "Select destination dymnamically"
- - open in image editor
- - copy to clipboard
- Usage:
- press Hotkey and make Screenshot
- paste immediately anywhere OR
- work on it inside Greenshot (give red circles or mark up in any colour), give numbers, obfuscate and more
- save or save as jpg or print
- puts an icon into task bar. There: > PREFERENCES
Compiling
if you have an error with "Glyphs.xaml", than make sure you have copied \Resources MANUALLY into the output folders - this was changed in 2015. The output folder depends on compiling method "Debug" or "Release", it is
- for DEBUG _: (YourRepositoryFolder)\Mainline\bin\Debug\Resources or
- for RELEASE: (YourRepositoryFolder)\Mainline\bin\Release\Resources
it's creating:
- 1> Supremacy.Scripting -> %path_repo%\bin\Debug\lib\Supremacy.Scripting.dll
- 2> SupremacyCore -> %path_repo%\bin\Debug\lib\SupremacyCore.dll
- 3> Supremacy.Xna -> %path_repo%\bin\Debug\lib\Supremacy.Xna.dll
- 4> SupremacyClientComponents -> %path_repo%\bin\Debug\lib\SupremacyClientComponents.dll
- 5> SupremacyWPF -> %path_repo%\bin\Debug\lib\SupremacyWPF.dll
- 6> SupremacyService -> %path_repo%\bin\Debug\lib\SupremacyService.dll
- 7> SupremacyUI -> %path_repo%\bin\Debug\lib\SupremacyUI.dll
Visual C#
build in Visual Studio
SunBurn
SunBurn is on hold for now. Kenneth was working sometimes with SunBurn...this might be a site for this http://channel9.msdn.com/coding4fun/blog/No-need-for-sunscreen-you-want-this-SunBurn-SunBurn-v2-RTMs-including-the-free-SunBurn-Framework-Edi
.Net
you should use latest .Net-version (2014: version 4.5.1)
XNA
"Could not load file or assembly 'Microsoft.Xna.Framework.dll' or one of its dependencies. The specified module could not be found."
- suggestion by reg: go to \Resources\Models and rename the "Models"-folder to "Models-SetOffline" or something else (if building a ship no model is shown -as it is to most of the ships- but otherwise the game could work fine)
This suggests the problem is with your XNA installation. The game uses XNA to display the 3D ship models in the shipyard. There's no way to disable the models so XNA wouldn't be needed. So to be able to play the game, i'd advise to uninstall XNA, then install the latest version.
XNA 3.1 (this one you need in any case): http://www.microsoft.com/en-us/download/details.aspx?id=15163
XNA 4.0 Download link: http://www.microsoft.com/en-gb/download/details.aspx?id=20914
Try
(for boolean)
try { return true; } catch (Exception e) { var errors = new System.Collections.Concurrent.ConcurrentStack<Exception>(); errors.Push(e); return false; } finally { xxx; } ;
Contexts
- AppContext (programm running)
- GameContext.Current (Game started - so after StartScreen)
- PlayerContext.Current
Text
en.txt
- XAML example: Text="{s:StringResource EMPIRES_HEADER}"
- string _text = String.Format(ResourceManager.GetString("KEY_IN-EN_TXT"),parameter1, parameter2;
LocalPlayer
- AppContext.LocalPlayer (just inside XAML-code files ??)
- _appContext.LocalPlayer.Empire
Civilization
just the data out of Civilization.xml ... for more see #CivilizationManager
CivilizationManager
CivilizationManager holds all the data like amount of credits, diplomacy, sitreps and more
- GameContext.Current.CivilizationManagers[LocalPlayer.EmpireID]
GameContext.Current.CivilizationManagers[LocalPlayer.EmpireID]
GameLog
if not available, try "Quick actions" -> using Supremacy.Utility;
GameLog.Core.GameData.DebugFormat("Turn {0};xx=;{1};xx=;{2};xx={3};xx={4};xx={5};xx={6};xx={7};xx={8};xx={9};" , GameContext.Current.TurnNumber , xx , xx );
Dictionary
private static Dictionary<string, bool> _acceptRejectDictionary = new Dictionary<string, bool> { { "98", false } };
MessageBox (Windows Style)
MessageBox.Show("Borg turned into Expanded", "WARNING", MessageBoxButton.OK);
MessageDialog (Supremacy Style)
var result = MessageDialog.Show("Borg turned into Expanded", MessageDialogButtons.YesNo);
SoundPlaying
- _soundPlayer.PlayFile("Resources/SoundFX/ChatMessage.wav");