1 /* 2 Copyright © 2020, Inochi2D Project 3 Distributed under the 2-Clause BSD License, see LICENSE file. 4 5 Authors: Luna Nielsen 6 */ 7 module creator.windows.about; 8 import creator.widgets.dummy; 9 import creator.widgets.tooltip; 10 import creator.windows; 11 import creator.core; 12 import creator; 13 import std.string; 14 import creator.utils.link; 15 import inochi2d; 16 import i18n; 17 import std.stdio; 18 19 class AboutWindow : Window { 20 private: 21 version (InBranding) { 22 Texture ada; 23 enum ADA_SIZE = 373; 24 enum ADA_SIZE_PARTIAL = ADA_SIZE/6; 25 vec2 ada_float; 26 } 27 28 protected: 29 override 30 void onBeginUpdate() { 31 igSetNextWindowSize(ImVec2(640, 512), ImGuiCond.Appearing); 32 igSetNextWindowSizeConstraints(ImVec2(640, 512), ImVec2(float.max, float.max)); 33 super.onBeginUpdate(); 34 } 35 36 override 37 void onUpdate() { 38 39 // Draw Ada 40 ImVec2 sPos; 41 igGetCursorScreenPos(&sPos); 42 43 44 version (InBranding) { 45 ImVec2 avail = incAvailableSpace(); 46 igSetCursorScreenPos(ImVec2( 47 sPos.x+(avail.x-(ADA_SIZE-ADA_SIZE_PARTIAL)), 48 sPos.y+(avail.y-(ADA_SIZE+28))+(sin(currentTime())*4) 49 )); 50 igImage( 51 cast(void*)ada.getTextureId(), 52 ImVec2(ADA_SIZE, ADA_SIZE), 53 ImVec2(0, 0), 54 ImVec2(1, 1), 55 ImVec4(1, 1, 1, 0.4), ImVec4(0, 0, 0, 0) 56 ); 57 } 58 59 // Draw the actual about dialog 60 igSetCursorScreenPos(sPos); 61 igBeginChild("##LogoArea", ImVec2(0, 92*incGetUIScale())); 62 63 version (InBranding) { 64 igImage( 65 cast(void*)incGetLogo(), 66 ImVec2(64*incGetUIScale(), 64*incGetUIScale()), 67 ImVec2(0, 0), 68 ImVec2(1, 1), 69 ImVec4(1, 1, 1, 1), 70 ImVec4(0, 0, 0, 0) 71 ); 72 } 73 74 igSameLine(0, 8); 75 igSeparatorEx(ImGuiSeparatorFlags.Vertical); 76 igSameLine(0, 8); 77 igBeginChild("##LogoTextArea", ImVec2(0, -24)); 78 79 igText("Inochi Creator"); 80 igText("%s", (INC_VERSION~"\0").ptr); 81 igSeparator(); 82 igTextColored(ImVec4(0.5, 0.5, 0.5, 1), "I2D v. %s", (IN_VERSION~"\0").ptr); 83 igTextColored(ImVec4(0.5, 0.5, 0.5, 1), "imgui v. %s", igGetVersion()); 84 igEndChild(); 85 86 igSpacing(); 87 igText("Credits"); 88 igSeparator(); 89 igEndChild(); 90 91 igBeginChild("##CreditsArea", ImVec2(0, -28*incGetUIScale())); 92 93 igText(import("CONTRIBUTORS.md")); 94 95 igEndChild(); 96 97 igBeginChild("##ButtonArea", ImVec2(0, 0)); 98 ImVec2 space = incAvailableSpace(); 99 incDummy(ImVec2(space.x/2, space.y)); 100 igSameLine(0, 0); 101 102 space = incAvailableSpace(); 103 float spacing = (space.x/3)-8; 104 105 if (igButton("GitHub", ImVec2(8+spacing, 0))) { 106 incOpenLink("https://github.com/Inochi2D/inochi-creator"); 107 } 108 109 igSameLine(0, 8); 110 111 if (igButton("Twitter", ImVec2(spacing, 0))) { 112 incOpenLink("https://twitter.com/Inochi2D"); 113 } 114 115 igSameLine(0, 8); 116 117 if (igButton(__("Donate"), ImVec2(spacing, 0))) { 118 incOpenLink("https://www.patreon.com/clipsey"); 119 } 120 igEndChild(); 121 } 122 123 public: 124 ~this() { 125 version(InBranding) destroy(ada); 126 } 127 128 this() { 129 super(_("About")); 130 this.onlyOne = true; 131 132 // Only load Ada in official builds 133 version(InBranding) { 134 ada_float = vec2(0); 135 auto adaData = ShallowTexture(cast(ubyte[])import("ada-tex.png")); 136 inTexPremultiply(adaData.data); 137 ada = new Texture(adaData); 138 } 139 } 140 }