AboutBox.cs 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using BansheeEngine;
  5. namespace BansheeEditor
  6. {
  7. /// <summary>
  8. /// Displays information about the engine, its creator and licenses.
  9. /// </summary>
  10. public class AboutBox : ModalWindow
  11. {
  12. private GUITextBox emailLabel;
  13. /// <summary>
  14. /// Opens the about box.
  15. /// </summary>
  16. [MenuItem("Help/About", 5000)]
  17. public static void Open()
  18. {
  19. new AboutBox();
  20. }
  21. /// <summary>
  22. /// Constructs the about box.
  23. /// </summary>
  24. protected AboutBox()
  25. : base(true)
  26. {
  27. Title = "About";
  28. Width = 400;
  29. Height = 350;
  30. }
  31. private void OnInitialize()
  32. {
  33. GUILabel title = new GUILabel(new LocEdString("Banshee Engine"), EditorStyles.TitleLabel);
  34. GUILabel subTitle = new GUILabel(new LocEdString("A modern open-source game development toolkit"),
  35. EditorStyles.LabelCentered);
  36. GUILabel license = new GUILabel(new LocEdString(
  37. "This program is licensed under the GNU General Public License V3"), EditorStyles.LabelCentered);
  38. GUILabel copyright = new GUILabel(new LocEdString("Copyright (C) 2015 Marko Pintera. All rights reserved."),
  39. EditorStyles.LabelCentered);
  40. GUILabel emailTitle = new GUILabel(new LocEdString("E-mail"), GUIOption.FixedWidth(150));
  41. emailLabel = new GUITextBox();
  42. GUILabel linkedInTitle = new GUILabel(new LocEdString("LinkedIn"), GUIOption.FixedWidth(150));
  43. GUIButton linkedInBtn = new GUIButton(new LocEdString("Profile"));
  44. GUIToggle contactFoldout = new GUIToggle(new LocEdString("Author contact"), EditorStyles.Foldout);
  45. GUIToggle thirdPartyFoldout = new GUIToggle(new LocEdString("Used third party libraries"), EditorStyles.Foldout);
  46. GUIToggle noticesFoldout = new GUIToggle(new LocEdString("Third party notices"), EditorStyles.Foldout);
  47. GUILabel freeTypeNotice = new GUILabel(new LocEdString(
  48. "Portions of this software are copyright (C) 2015 The FreeType Project (www.freetype.org). " +
  49. "All rights reserved."), EditorStyles.MultiLineLabelCentered,
  50. GUIOption.FlexibleHeight(), GUIOption.FixedWidth(380));
  51. GUILabel fbxSdkNotice = new GUILabel(new LocEdString(
  52. "This software contains Autodesk(R) FBX(R) code developed by Autodesk, Inc. Copyright 2013 Autodesk, Inc. " +
  53. "All rights, reserved. Such code is provided \"as is\" and Autodesk, Inc. disclaims any and all warranties, " +
  54. "whether express or implied, including without limitation the implied warranties of merchantability, " +
  55. "fitness for a particular purpose or non-infringement of third party rights. In no event shall Autodesk, " +
  56. "Inc. be liable for any direct, indirect, incidental, special, exemplary, or consequential damages " +
  57. "(including, but not limited to, procurement of substitute goods or services; loss of use, data, or " +
  58. "profits; or business interruption) however caused and on any theory of liability, whether in contract, " +
  59. "strict liability, or tort (including negligence or otherwise) arising in any way out of such code."),
  60. EditorStyles.MultiLineLabelCentered, GUIOption.FlexibleHeight(), GUIOption.FixedWidth(380));
  61. GUILayoutY mainLayout = GUI.AddLayoutY();
  62. mainLayout.AddSpace(10);
  63. mainLayout.AddElement(title);
  64. mainLayout.AddElement(subTitle);
  65. mainLayout.AddSpace(10);
  66. mainLayout.AddElement(license);
  67. mainLayout.AddElement(copyright);
  68. mainLayout.AddSpace(10);
  69. mainLayout.AddElement(contactFoldout);
  70. GUILayoutY contactLayout = mainLayout.AddLayoutY();
  71. GUILayout emailLayout = contactLayout.AddLayoutX();
  72. emailLayout.AddSpace(10);
  73. emailLayout.AddElement(emailTitle);
  74. emailLayout.AddElement(emailLabel);
  75. emailLayout.AddSpace(10);
  76. GUILayout linkedInLayout = contactLayout.AddLayoutX();
  77. linkedInLayout.AddSpace(10);
  78. linkedInLayout.AddElement(linkedInTitle);
  79. linkedInLayout.AddElement(linkedInBtn);
  80. linkedInLayout.AddSpace(10);
  81. mainLayout.AddSpace(5);
  82. mainLayout.AddElement(thirdPartyFoldout);
  83. GUILayoutY thirdPartyLayout = mainLayout.AddLayoutY();
  84. CreateThirdPartyGUI(thirdPartyLayout, "Autodesk FBX SDK",
  85. "http://usa.autodesk.com/adsk/servlet/pc/item?siteID=123112&id=10775847", "FBX_SDK_License.rtf");
  86. CreateThirdPartyGUI(thirdPartyLayout, "FreeImage", "http://freeimage.sourceforge.net/", "freeimage-license.txt");
  87. CreateThirdPartyGUI(thirdPartyLayout, "FreeType", "http://www.freetype.org/", "FTL.TXT");
  88. CreateThirdPartyGUI(thirdPartyLayout, "Mono", "http://www.mono-project.com/", "Mono.txt");
  89. CreateThirdPartyGUI(thirdPartyLayout, "NVIDIA Texture Tools",
  90. "https://github.com/castano/nvidia-texture-tools", "NVIDIATextureTools.txt");
  91. mainLayout.AddSpace(5);
  92. mainLayout.AddElement(noticesFoldout);
  93. GUILayout noticesLayout = mainLayout.AddLayoutY();
  94. noticesLayout.AddElement(freeTypeNotice);
  95. noticesLayout.AddSpace(10);
  96. noticesLayout.AddElement(fbxSdkNotice);
  97. mainLayout.AddFlexibleSpace();
  98. contactLayout.Active = false;
  99. contactFoldout.OnToggled += x => contactLayout.Active = x;
  100. thirdPartyLayout.Active = false;
  101. thirdPartyFoldout.OnToggled += x => thirdPartyLayout.Active = x;
  102. noticesLayout.Active = false;
  103. noticesFoldout.OnToggled += x => noticesLayout.Active = x;
  104. emailLabel.Text = "[email protected]";
  105. linkedInBtn.OnClick += () => { System.Diagnostics.Process.Start("http://hr.linkedin.com/in/markopintera"); };
  106. }
  107. private void CreateThirdPartyGUI(GUILayoutY layout, string name, string webURL, string licenseFile)
  108. {
  109. GUILabel label = new GUILabel(new LocEdString(name), GUIOption.FixedWidth(150));
  110. GUIButton linkBtn = new GUIButton(new LocEdString("Website"), GUIOption.FixedWidth(50));
  111. GUIButton licenseBtn = new GUIButton(new LocEdString("License"), GUIOption.FixedWidth(50));
  112. string licensePath = "..\\..\\..\\License\\Third Party\\" + licenseFile;
  113. GUILayoutX horzLayout = layout.AddLayoutX();
  114. horzLayout.AddSpace(10);
  115. horzLayout.AddElement(label);
  116. horzLayout.AddSpace(10);
  117. horzLayout.AddElement(linkBtn);
  118. horzLayout.AddSpace(5);
  119. horzLayout.AddElement(licenseBtn);
  120. horzLayout.AddSpace(10);
  121. linkBtn.OnClick += () => { System.Diagnostics.Process.Start(webURL); };
  122. licenseBtn.OnClick += () => { System.Diagnostics.Process.Start(licensePath); };
  123. }
  124. private void OnEditorUpdate()
  125. {
  126. emailLabel.Text = "[email protected]";
  127. }
  128. }
  129. }