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     Texture ada;
22     enum ADA_SIZE = 373;
23     enum ADA_SIZE_PARTIAL = ADA_SIZE/6;
24 
25     vec2 ada_float;
26 
27 protected:
28     override
29     void onBeginUpdate() {
30         igSetNextWindowSize(ImVec2(640, 512), ImGuiCond.Appearing);
31         igSetNextWindowSizeConstraints(ImVec2(640, 512), ImVec2(float.max, float.max));
32         super.onBeginUpdate();
33     }
34 
35     override
36     void onUpdate() {
37 
38         // Draw Ada
39         ImVec2 sPos;
40         igGetCursorScreenPos(&sPos);
41 
42         ImVec2 avail = incAvailableSpace();
43         igSetCursorScreenPos(ImVec2(
44             sPos.x+(avail.x-(ADA_SIZE-ADA_SIZE_PARTIAL)), 
45             sPos.y+(avail.y-(ADA_SIZE+28))+(sin(currentTime())*4)
46         ));
47         igImage(
48             cast(void*)ada.getTextureId(),
49             ImVec2(ADA_SIZE, ADA_SIZE),
50             ImVec2(0, 0),
51             ImVec2(1, 1), 
52             ImVec4(1, 1, 1, 0.4), ImVec4(0, 0, 0, 0)
53         );
54 
55         // Draw the actual about dialog
56         igSetCursorScreenPos(sPos);
57         igBeginChild("##LogoArea", ImVec2(0, 92*incGetUIScale()));
58             igImage(
59                 cast(void*)incGetLogo(), 
60                 ImVec2(64*incGetUIScale(), 64*incGetUIScale()), 
61                 ImVec2(0, 0), 
62                 ImVec2(1, 1), 
63                 ImVec4(1, 1, 1, 1), 
64                 ImVec4(0, 0, 0, 0)
65             );
66             
67             igSameLine(0, 8);
68             igSeparatorEx(ImGuiSeparatorFlags.Vertical);
69             igSameLine(0, 8);
70             igBeginChild("##LogoTextArea", ImVec2(0, -24));
71 
72                 igText("Inochi Creator");
73                 igText("%s", (INC_VERSION~"\0").ptr);
74                 igSeparator();
75                 igTextColored(ImVec4(0.5, 0.5, 0.5, 1), "I2D v. %s", (IN_VERSION~"\0").ptr);
76                 igTextColored(ImVec4(0.5, 0.5, 0.5, 1), "imgui v. %s", igGetVersion());
77             igEndChild();
78             
79             igSpacing();
80             igText("Credits");
81             igSeparator();
82         igEndChild();
83 
84         igBeginChild("##CreditsArea", ImVec2(0, -28*incGetUIScale()));
85 
86             igText(import("CONTRIBUTORS.md"));
87 
88         igEndChild();
89 
90         igBeginChild("##ButtonArea", ImVec2(0, 0));
91             ImVec2 space = incAvailableSpace();
92             incDummy(ImVec2(space.x/2, space.y));
93             igSameLine(0, 0);
94 
95             space = incAvailableSpace();
96             float spacing = (space.x/3)-8;
97 
98             if (igButton("GitHub", ImVec2(8+spacing, 0))) {
99                 incOpenLink("https://github.com/Inochi2D/inochi-creator");
100             }
101 
102             igSameLine(0, 8);
103 
104             if (igButton("Twitter", ImVec2(spacing, 0))) {
105                 incOpenLink("https://twitter.com/Inochi2D");
106             }
107 
108             igSameLine(0, 8);
109 
110             if (igButton(__("Donate"), ImVec2(spacing, 0))) {
111                 incOpenLink("https://www.patreon.com/clipsey");
112             }
113         igEndChild();
114     }
115 
116 public:
117     ~this() {
118         destroy(ada);
119     }
120 
121     this() {
122         super(_("About"));
123         this.onlyOne = true;
124         ada_float = vec2(0);
125 
126         auto adaData = ShallowTexture(cast(ubyte[])import("ada-tex.png"));
127         inTexPremultiply(adaData.data);
128         ada = new Texture(adaData);
129     }
130 }