| 1 | //============================================================================ | 
|---|
| 2 | // | 
|---|
| 3 | //   SSSS    tt          lll  lll | 
|---|
| 4 | //  SS  SS   tt           ll   ll | 
|---|
| 5 | //  SS     tttttt  eeee   ll   ll   aaaa | 
|---|
| 6 | //   SSSS    tt   ee  ee  ll   ll      aa | 
|---|
| 7 | //      SS   tt   eeeeee  ll   ll   aaaaa  --  "An Atari 2600 VCS Emulator" | 
|---|
| 8 | //  SS  SS   tt   ee      ll   ll  aa  aa | 
|---|
| 9 | //   SSSS     ttt  eeeee llll llll  aaaaa | 
|---|
| 10 | // | 
|---|
| 11 | // Copyright (c) 1995-2019 by Bradford W. Mott, Stephen Anthony | 
|---|
| 12 | // and the Stella Team | 
|---|
| 13 | // | 
|---|
| 14 | // See the file "License.txt" for information on usage and redistribution of | 
|---|
| 15 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. | 
|---|
| 16 | //============================================================================ | 
|---|
| 17 |  | 
|---|
| 18 | #include "Dialog.hxx" | 
|---|
| 19 | #include "OSystem.hxx" | 
|---|
| 20 | #include "Version.hxx" | 
|---|
| 21 | #include "Widget.hxx" | 
|---|
| 22 | #include "Font.hxx" | 
|---|
| 23 | #include "AboutDialog.hxx" | 
|---|
| 24 |  | 
|---|
| 25 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 
|---|
| 26 | AboutDialog::AboutDialog(OSystem& osystem, DialogContainer& parent, | 
|---|
| 27 | const GUI::Font& font) | 
|---|
| 28 | : Dialog(osystem, parent, font, "About Stella"), | 
|---|
| 29 | myPage(1), | 
|---|
| 30 | myNumPages(4), | 
|---|
| 31 | myLinesPerPage(13) | 
|---|
| 32 | { | 
|---|
| 33 | const int lineHeight   = font.getLineHeight(), | 
|---|
| 34 | fontWidth    = font.getMaxCharWidth(), | 
|---|
| 35 | fontHeight   = font.getFontHeight(), | 
|---|
| 36 | buttonWidth  = font.getStringWidth( "Defaults") + 20, | 
|---|
| 37 | buttonHeight = font.getLineHeight() + 4; | 
|---|
| 38 | int xpos, ypos; | 
|---|
| 39 | WidgetArray wid; | 
|---|
| 40 |  | 
|---|
| 41 | // Set real dimensions | 
|---|
| 42 | _w = 55 * fontWidth + 8; | 
|---|
| 43 | _h = 15 * lineHeight + 20 + _th; | 
|---|
| 44 |  | 
|---|
| 45 | // Add Previous, Next and Close buttons | 
|---|
| 46 | xpos = 10;  ypos = _h - buttonHeight - 10; | 
|---|
| 47 | myPrevButton = | 
|---|
| 48 | new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight, | 
|---|
| 49 | "Previous", GuiObject::kPrevCmd); | 
|---|
| 50 | myPrevButton->clearFlags(Widget::FLAG_ENABLED); | 
|---|
| 51 | wid.push_back(myPrevButton); | 
|---|
| 52 |  | 
|---|
| 53 | xpos += buttonWidth + 8; | 
|---|
| 54 | myNextButton = | 
|---|
| 55 | new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight, | 
|---|
| 56 | "Next", GuiObject::kNextCmd); | 
|---|
| 57 | wid.push_back(myNextButton); | 
|---|
| 58 |  | 
|---|
| 59 | xpos = _w - buttonWidth - 10; | 
|---|
| 60 | ButtonWidget* b = | 
|---|
| 61 | new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight, | 
|---|
| 62 | "Close", GuiObject::kCloseCmd); | 
|---|
| 63 | wid.push_back(b); | 
|---|
| 64 | addCancelWidget(b); | 
|---|
| 65 |  | 
|---|
| 66 | xpos = 5;  ypos = 5 + _th; | 
|---|
| 67 | myTitle = new StaticTextWidget(this, font, xpos, ypos, _w - xpos * 2, fontHeight, | 
|---|
| 68 | "", TextAlign::Center); | 
|---|
| 69 | myTitle->setTextColor(kTextColorEm); | 
|---|
| 70 |  | 
|---|
| 71 | xpos = 16;  ypos += lineHeight + 4; | 
|---|
| 72 | for(int i = 0; i < myLinesPerPage; i++) | 
|---|
| 73 | { | 
|---|
| 74 | myDesc.push_back(new StaticTextWidget(this, font, xpos, ypos, _w - xpos * 2, | 
|---|
| 75 | fontHeight, "", TextAlign::Left)); | 
|---|
| 76 | myDescStr.push_back( ""); | 
|---|
| 77 | ypos += fontHeight; | 
|---|
| 78 | } | 
|---|
| 79 |  | 
|---|
| 80 | addToFocusList(wid); | 
|---|
| 81 | } | 
|---|
| 82 |  | 
|---|
| 83 | // The following commands can be put at the start of a line (all subject to change): | 
|---|
| 84 | //   \C, \L, \R  -- set center/left/right alignment | 
|---|
| 85 | //   \c0 - \c5   -- set a custom color: | 
|---|
| 86 | //                  0 normal text (green) | 
|---|
| 87 | //                  1 highlighted text (light green) | 
|---|
| 88 | //                  2 light border (light gray) | 
|---|
| 89 | //                  3 dark border (dark gray) | 
|---|
| 90 | //                  4 background (black) | 
|---|
| 91 | //                  5 emphasized text (red) | 
|---|
| 92 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 
|---|
| 93 | void AboutDialog::updateStrings(int page, int lines, string& title) | 
|---|
| 94 | { | 
|---|
| 95 | int i = 0; | 
|---|
| 96 | auto ADD_ATEXT = [&](const string& d) { myDescStr[i] = d; i++; }; | 
|---|
| 97 | auto ADD_ALINE = [&]() { ADD_ATEXT( ""); }; | 
|---|
| 98 |  | 
|---|
| 99 | switch(page) | 
|---|
| 100 | { | 
|---|
| 101 | case 1: | 
|---|
| 102 | title = string( "Stella ") + STELLA_VERSION; | 
|---|
| 103 | ADD_ATEXT( "\\CA multi-platform Atari 2600 VCS emulator"); | 
|---|
| 104 | ADD_ATEXT(string( "\\C\\c2Features: ") + instance().features()); | 
|---|
| 105 | ADD_ATEXT(string( "\\C\\c2") + instance().buildInfo()); | 
|---|
| 106 | ADD_ALINE(); | 
|---|
| 107 | ADD_ATEXT( "\\CCopyright (c) 1995-2019 The Stella Team"); | 
|---|
| 108 | ADD_ATEXT( "\\C(https://stella-emu.github.io)"); | 
|---|
| 109 | ADD_ALINE(); | 
|---|
| 110 | ADD_ATEXT( "\\CStella is now DonationWare!"); | 
|---|
| 111 | ADD_ATEXT( "\\C(https://stella-emu.github.io/donations.html)"); | 
|---|
| 112 | ADD_ALINE(); | 
|---|
| 113 | ADD_ATEXT( "\\CStella is free software released under the GNU GPL."); | 
|---|
| 114 | ADD_ATEXT( "\\CSee manual for further details."); | 
|---|
| 115 | break; | 
|---|
| 116 |  | 
|---|
| 117 | case 2: | 
|---|
| 118 | title = "The Stella Team"; | 
|---|
| 119 | ADD_ATEXT( "\\L\\c0" "Stephen Anthony"); | 
|---|
| 120 | ADD_ATEXT( "\\L\\c2" "  Lead developer, current maintainer for the"); | 
|---|
| 121 | ADD_ATEXT( "\\L\\c2" "  Linux, macOS and Windows ports "); | 
|---|
| 122 | ADD_ATEXT( "\\L\\c0" "Christian Speckner"); | 
|---|
| 123 | ADD_ATEXT( "\\L\\c2" "  Emulation core development, TIA core"); | 
|---|
| 124 | ADD_ATEXT( "\\L\\c0" "Eckhard Stolberg"); | 
|---|
| 125 | ADD_ATEXT( "\\L\\c2" "  Emulation core development"); | 
|---|
| 126 | ADD_ATEXT( "\\L\\c0" "Thomas Jentzsch"); | 
|---|
| 127 | ADD_ATEXT( "\\L\\c2" "  Emulation core development, jack-of-all-trades"); | 
|---|
| 128 | ADD_ATEXT( "\\L\\c0" "Brian Watson"); | 
|---|
| 129 | ADD_ATEXT( "\\L\\c2" "  Emulation core enhancement, debugger support"); | 
|---|
| 130 | ADD_ATEXT( "\\L\\c0" "Bradford W. Mott"); | 
|---|
| 131 | ADD_ATEXT( "\\L\\c2" "  Original author of Stella"); | 
|---|
| 132 | break; | 
|---|
| 133 |  | 
|---|
| 134 | case 3: | 
|---|
| 135 | title = "Contributors"; | 
|---|
| 136 | ADD_ATEXT( "\\L\\c0" "See https://stella-emu.github.io/credits.html for"); | 
|---|
| 137 | ADD_ATEXT( "\\L\\c0" "people that have contributed to Stella."); | 
|---|
| 138 | ADD_ALINE(); | 
|---|
| 139 | ADD_ATEXT( "\\L\\c0" "Thanks to the ScummVM project for the GUI code."); | 
|---|
| 140 | ADD_ALINE(); | 
|---|
| 141 | ADD_ATEXT( "\\L\\c0" "Thanks to Ian Bogost and the Georgia Tech Atari Team"); | 
|---|
| 142 | ADD_ATEXT( "\\L\\c0" "for the CRT Simulation effects."); | 
|---|
| 143 | break; | 
|---|
| 144 |  | 
|---|
| 145 | case 4: | 
|---|
| 146 | title = "Cast of thousands"; | 
|---|
| 147 | ADD_ATEXT( "\\L\\c0" "Special thanks to AtariAge for introducing the"); | 
|---|
| 148 | ADD_ATEXT( "\\L\\c0" "Atari 2600 to a whole new generation."); | 
|---|
| 149 | ADD_ATEXT( "\\L\\c2" "  http://www.atariage.com"); | 
|---|
| 150 | ADD_ALINE(); | 
|---|
| 151 | ADD_ATEXT( "\\L\\c0" "Finally, a huge thanks to the original Atari 2600"); | 
|---|
| 152 | ADD_ATEXT( "\\L\\c0" "VCS team for giving us the magic, and to the"); | 
|---|
| 153 | ADD_ATEXT( "\\L\\c0" "homebrew developers for keeping the magic alive."); | 
|---|
| 154 | break; | 
|---|
| 155 | } | 
|---|
| 156 |  | 
|---|
| 157 | while(i < lines) | 
|---|
| 158 | ADD_ALINE(); | 
|---|
| 159 | } | 
|---|
| 160 |  | 
|---|
| 161 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 
|---|
| 162 | void AboutDialog::displayInfo() | 
|---|
| 163 | { | 
|---|
| 164 | string titleStr; | 
|---|
| 165 | updateStrings(myPage, myLinesPerPage, titleStr); | 
|---|
| 166 |  | 
|---|
| 167 | myTitle->setLabel(titleStr); | 
|---|
| 168 | for(int i = 0; i < myLinesPerPage; i++) | 
|---|
| 169 | { | 
|---|
| 170 | const char* str = myDescStr[i].c_str(); | 
|---|
| 171 | TextAlign align = TextAlign::Center; | 
|---|
| 172 | ColorId color  = kTextColor; | 
|---|
| 173 |  | 
|---|
| 174 | while (str[0] == '\\') | 
|---|
| 175 | { | 
|---|
| 176 | switch (str[1]) | 
|---|
| 177 | { | 
|---|
| 178 | case 'C': | 
|---|
| 179 | align = TextAlign::Center; | 
|---|
| 180 | break; | 
|---|
| 181 |  | 
|---|
| 182 | case 'L': | 
|---|
| 183 | align = TextAlign::Left; | 
|---|
| 184 | break; | 
|---|
| 185 |  | 
|---|
| 186 | case 'R': | 
|---|
| 187 | align = TextAlign::Right; | 
|---|
| 188 | break; | 
|---|
| 189 |  | 
|---|
| 190 | case 'c': | 
|---|
| 191 | switch (str[2]) | 
|---|
| 192 | { | 
|---|
| 193 | case '0': | 
|---|
| 194 | color = kTextColor; | 
|---|
| 195 | break; | 
|---|
| 196 | case '1': | 
|---|
| 197 | color = kTextColorHi; | 
|---|
| 198 | break; | 
|---|
| 199 | case '2': | 
|---|
| 200 | color = kColor; | 
|---|
| 201 | break; | 
|---|
| 202 | case '3': | 
|---|
| 203 | color = kShadowColor; | 
|---|
| 204 | break; | 
|---|
| 205 | case '4': | 
|---|
| 206 | color = kBGColor; | 
|---|
| 207 | break; | 
|---|
| 208 | case '5': | 
|---|
| 209 | color = kTextColorEm; | 
|---|
| 210 | break; | 
|---|
| 211 | default: | 
|---|
| 212 | break; | 
|---|
| 213 | } | 
|---|
| 214 | str++; | 
|---|
| 215 | break; | 
|---|
| 216 |  | 
|---|
| 217 | default: | 
|---|
| 218 | break; | 
|---|
| 219 | } | 
|---|
| 220 | str += 2; | 
|---|
| 221 | } | 
|---|
| 222 |  | 
|---|
| 223 | myDesc[i]->setAlign(align); | 
|---|
| 224 | myDesc[i]->setTextColor(color); | 
|---|
| 225 | myDesc[i]->setLabel(str); | 
|---|
| 226 | } | 
|---|
| 227 |  | 
|---|
| 228 | // Redraw entire dialog | 
|---|
| 229 | setDirty(); | 
|---|
| 230 | } | 
|---|
| 231 |  | 
|---|
| 232 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 
|---|
| 233 | void AboutDialog::handleCommand(CommandSender* sender, int cmd, int data, int id) | 
|---|
| 234 | { | 
|---|
| 235 | switch(cmd) | 
|---|
| 236 | { | 
|---|
| 237 | case GuiObject::kNextCmd: | 
|---|
| 238 | myPage++; | 
|---|
| 239 | if(myPage >= myNumPages) | 
|---|
| 240 | myNextButton->clearFlags(Widget::FLAG_ENABLED); | 
|---|
| 241 | if(myPage >= 2) | 
|---|
| 242 | myPrevButton->setFlags(Widget::FLAG_ENABLED); | 
|---|
| 243 |  | 
|---|
| 244 | displayInfo(); | 
|---|
| 245 | break; | 
|---|
| 246 |  | 
|---|
| 247 | case GuiObject::kPrevCmd: | 
|---|
| 248 | myPage--; | 
|---|
| 249 | if(myPage <= myNumPages) | 
|---|
| 250 | myNextButton->setFlags(Widget::FLAG_ENABLED); | 
|---|
| 251 | if(myPage <= 1) | 
|---|
| 252 | myPrevButton->clearFlags(Widget::FLAG_ENABLED); | 
|---|
| 253 |  | 
|---|
| 254 | displayInfo(); | 
|---|
| 255 | break; | 
|---|
| 256 |  | 
|---|
| 257 | default: | 
|---|
| 258 | Dialog::handleCommand(sender, cmd, data, 0); | 
|---|
| 259 | } | 
|---|
| 260 | } | 
|---|
| 261 |  | 
|---|