Move PACKAGE/VERSION, etc. to new ver-lib

* As we moved the VERSION macro to a .c file, we don't have to
  recompile the whole project when we change the version number.
* Removed the version number from gui.xml
* Removed the invalid first menu item that might appear in the root
  menu when the gui.xml version is outdated in debug mode.
This commit is contained in:
David Capello 2020-03-16 10:29:58 -03:00
parent 23d41e7340
commit a0882ba443
38 changed files with 218 additions and 148 deletions

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- Aseprite --> <!-- Aseprite -->
<!-- Copyright (C) 2018-2019 Igara Studio S.A. --> <!-- Copyright (C) 2018-2020 Igara Studio S.A. -->
<!-- Copyright (C) 2001-2018 David Capello --> <!-- Copyright (C) 2001-2018 David Capello -->
<gui version="1.3-dev"> <gui>
<!-- Keyboard shortcuts --> <!-- Keyboard shortcuts -->
<keyboard version="1"> <keyboard version="1">

2
laf

@ -1 +1 @@
Subproject commit 287e30976e201f99e20884afea1f4a3a1d78cbdb Subproject commit e48a236a9fa56dffc11749ebac7a2eb75699efe7

View File

@ -37,13 +37,6 @@ if(WIN32)
include_directories(..) include_directories(..)
endif() endif()
######################################################################
# Custom Aseprite website (for testing server-side)
if(NOT "${CUSTOM_WEBSITE_URL}" STREQUAL "")
add_definitions(-DCUSTOM_WEBSITE_URL="${CUSTOM_WEBSITE_URL}")
endif()
###################################################################### ######################################################################
# With static libcurl # With static libcurl
@ -106,6 +99,7 @@ add_subdirectory(flic)
add_subdirectory(render) add_subdirectory(render)
add_subdirectory(dio) add_subdirectory(dio)
add_subdirectory(ui) add_subdirectory(ui)
add_subdirectory(ver)
if(REQUIRE_CURL) if(REQUIRE_CURL)
add_subdirectory(net) add_subdirectory(net)

View File

@ -615,6 +615,10 @@ add_library(app-lib
${scripting_files} ${scripting_files}
${generated_files}) ${generated_files})
if(TARGET generated_version)
add_dependencies(app-lib generated_version)
endif()
target_link_libraries(app-lib target_link_libraries(app-lib
laf-base laf-base
cfg-lib cfg-lib
@ -629,6 +633,7 @@ target_link_libraries(app-lib
laf-ft laf-ft
laf-os laf-os
ui-lib ui-lib
ver-lib
undo undo
${CMARK_LIBRARIES} ${CMARK_LIBRARIES}
${TINYXML_LIBRARY} ${TINYXML_LIBRARY}

View File

@ -67,6 +67,7 @@
#include "render/render.h" #include "render/render.h"
#include "ui/intern.h" #include "ui/intern.h"
#include "ui/ui.h" #include "ui/ui.h"
#include "ver/info.h"
#include <iostream> #include <iostream>
#include <memory> #include <memory>
@ -514,7 +515,7 @@ App::~App()
// no re-throw // no re-throw
} }
catch (...) { catch (...) {
os::error_message("Error closing " PACKAGE ".\n(uncaught exception)"); os::error_message("Error closing the program.\n(uncaught exception)");
// no re-throw // no re-throw
} }
@ -626,7 +627,7 @@ void App::showBackupNotification(bool state)
void App::updateDisplayTitleBar() void App::updateDisplayTitleBar()
{ {
std::string defaultTitle = PACKAGE " v" VERSION; std::string defaultTitle = fmt::format("{} v{}", get_app_name(), get_app_version());
std::string title; std::string title;
DocView* docView = UIContext::instance()->activeView(); DocView* docView = UIContext::instance()->activeView();

View File

@ -1,5 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2019 Igara Studio S.A. // Copyright (C) 2019-2020 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello // Copyright (C) 2001-2018 David Capello
// //
// This program is distributed under the terms of // This program is distributed under the terms of
@ -29,9 +29,11 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/fs.h" #include "base/fs.h"
#include "base/string.h" #include "base/string.h"
#include "fmt/format.h"
#include "os/menus.h" #include "os/menus.h"
#include "os/system.h" #include "os/system.h"
#include "ui/ui.h" #include "ui/ui.h"
#include "ver/info.h"
#include "tinyxml.h" #include "tinyxml.h"
@ -329,12 +331,6 @@ void AppMenus::reload()
m_rootMenu.reset(loadMenuById(handle, "main_menu")); m_rootMenu.reset(loadMenuById(handle, "main_menu"));
#if _DEBUG
// Add a warning element because the user is not using the last well-known gui.xml file.
if (GuiXml::instance()->version() != VERSION)
m_rootMenu->insertChild(0, createInvalidVersionMenuitem());
#endif
LOG("MENU: Main menu loaded.\n"); LOG("MENU: Main menu loaded.\n");
m_tabPopupMenu.reset(loadMenuById(handle, "tab_popup_menu")); m_tabPopupMenu.reset(loadMenuById(handle, "tab_popup_menu"));
@ -625,20 +621,6 @@ Widget* AppMenus::convertXmlelemToMenuitem(TiXmlElement* elem)
return menuitem; return menuitem;
} }
Widget* AppMenus::createInvalidVersionMenuitem()
{
AppMenuItem* menuitem = new AppMenuItem("WARNING!");
Menu* subMenu = new Menu();
subMenu->addChild(new AppMenuItem(PACKAGE " is using a customized gui.xml (maybe from your HOME directory)."));
subMenu->addChild(new AppMenuItem("You should update your customized gui.xml file to the new version to get"));
subMenu->addChild(new AppMenuItem("the latest commands available."));
subMenu->addChild(new MenuSeparator);
subMenu->addChild(new AppMenuItem("You can bypass this validation adding the correct version"));
subMenu->addChild(new AppMenuItem("number in <gui version=\"" VERSION "\"> element."));
menuitem->setSubmenu(subMenu);
return menuitem;
}
void AppMenus::applyShortcutToMenuitemsWithCommand(Command* command, void AppMenus::applyShortcutToMenuitemsWithCommand(Command* command,
const Params& params, const Params& params,
const KeyPtr& key) const KeyPtr& key)
@ -724,7 +706,7 @@ void AppMenus::createNativeMenus()
#ifdef __APPLE__ // Create default macOS app menus (App ... Window) #ifdef __APPLE__ // Create default macOS app menus (App ... Window)
{ {
os::MenuItemInfo about("About " PACKAGE); os::MenuItemInfo about(fmt::format("About {}", get_app_name()));
auto native = get_native_shortcut_for_command(CommandId::About()); auto native = get_native_shortcut_for_command(CommandId::About());
about.shortcut = native.shortcut; about.shortcut = native.shortcut;
about.execute = [native]{ about.execute = [native]{
@ -750,10 +732,10 @@ void AppMenus::createNativeMenus()
item->setEnabled(can_call_global_shortcut(&native)); item->setEnabled(can_call_global_shortcut(&native));
}; };
os::MenuItemInfo hide("Hide " PACKAGE, os::MenuItemInfo::Hide); os::MenuItemInfo hide(fmt::format("Hide {}", get_app_name()), os::MenuItemInfo::Hide);
hide.shortcut = os::Shortcut('h', os::kKeyCmdModifier); hide.shortcut = os::Shortcut('h', os::kKeyCmdModifier);
os::MenuItemInfo quit("Quit " PACKAGE, os::MenuItemInfo::Quit); os::MenuItemInfo quit(fmt::format("Quit {}", get_app_name()), os::MenuItemInfo::Quit);
quit.shortcut = os::Shortcut('q', os::kKeyCmdModifier); quit.shortcut = os::Shortcut('q', os::kKeyCmdModifier);
os::Menu* appMenu = menus->createMenu(); os::Menu* appMenu = menus->createMenu();

View File

@ -1,5 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2019 Igara Studio S.A. // Copyright (C) 2019-2020 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello // Copyright (C) 2001-2018 David Capello
// //
// This program is distributed under the terms of // This program is distributed under the terms of
@ -69,7 +69,6 @@ namespace app {
Menu* loadMenuById(TiXmlHandle& handle, const char *id); Menu* loadMenuById(TiXmlHandle& handle, const char *id);
Menu* convertXmlelemToMenu(TiXmlElement* elem); Menu* convertXmlelemToMenu(TiXmlElement* elem);
Widget* convertXmlelemToMenuitem(TiXmlElement* elem); Widget* convertXmlelemToMenuitem(TiXmlElement* elem);
Widget* createInvalidVersionMenuitem();
void applyShortcutToMenuitemsWithCommand(Menu* menu, Command* command, const Params& params, void applyShortcutToMenuitemsWithCommand(Menu* menu, Command* command, const Params& params,
const KeyPtr& key); const KeyPtr& key);
void syncNativeMenuItemKeyShortcuts(Menu* menu); void syncNativeMenuItemKeyShortcuts(Menu* menu);

View File

@ -1,4 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2020 Igara Studio S.A.
// Copyright (C) 2001-2017 David Capello // Copyright (C) 2001-2017 David Capello
// //
// This program is distributed under the terms of // This program is distributed under the terms of
@ -19,6 +20,7 @@
#include "base/launcher.h" #include "base/launcher.h"
#include "base/replace_string.h" #include "base/replace_string.h"
#include "base/version.h" #include "base/version.h"
#include "ver/info.h"
#include <ctime> #include <ctime>
#include <sstream> #include <sstream>
@ -202,7 +204,7 @@ void CheckUpdateThreadLauncher::checkForUpdates()
void CheckUpdateThreadLauncher::showUI() void CheckUpdateThreadLauncher::showUI()
{ {
std::string localVersionStr = VERSION; std::string localVersionStr = get_app_version();
base::replace_string(localVersionStr, "-x64", ""); base::replace_string(localVersionStr, "-x64", "");
bool newVer = false; bool newVer = false;

View File

@ -1,5 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2018-2019 Igara Studio S.A. // Copyright (C) 2018-2020 Igara Studio S.A.
// Copyright (C) 2016-2018 David Capello // Copyright (C) 2016-2018 David Capello
// //
// This program is distributed under the terms of // This program is distributed under the terms of
@ -26,6 +26,7 @@
#include "doc/slice.h" #include "doc/slice.h"
#include "doc/sprite.h" #include "doc/sprite.h"
#include "doc/tag.h" #include "doc/tag.h"
#include "ver/info.h"
#ifdef ENABLE_SCRIPTING #ifdef ENABLE_SCRIPTING
#include "app/app.h" #include "app/app.h"
@ -40,18 +41,20 @@ namespace app {
void DefaultCliDelegate::showHelp(const AppOptions& options) void DefaultCliDelegate::showHelp(const AppOptions& options)
{ {
std::cout std::cout
<< PACKAGE << " v" << VERSION << " | A pixel art program\n" << COPYRIGHT << get_app_name() << " v" << get_app_version()
<< " | A pixel art program\n"
<< get_app_copyright()
<< "\n\nUsage:\n" << "\n\nUsage:\n"
<< " " << options.exeName() << " [OPTIONS] [FILES]...\n\n" << " " << options.exeName() << " [OPTIONS] [FILES]...\n\n"
<< "Options:\n" << "Options:\n"
<< options.programOptions() << options.programOptions()
<< "\nFind more information in " << PACKAGE << "\nFind more information in " << get_app_name()
<< " web site: " << WEBSITE << "\n\n"; << " web site: " << get_app_url() << "\n\n";
} }
void DefaultCliDelegate::showVersion() void DefaultCliDelegate::showVersion()
{ {
std::cout << PACKAGE << ' ' << VERSION << '\n'; std::cout << get_app_name() << ' ' << get_app_version() << '\n';
} }
void DefaultCliDelegate::afterOpenFile(const CliOpenFile& cof) void DefaultCliDelegate::afterOpenFile(const CliOpenFile& cof)

View File

@ -1,5 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2018-2019 Igara Studio S.A. // Copyright (C) 2018-2020 Igara Studio S.A.
// Copyright (C) 2016-2018 David Capello // Copyright (C) 2016-2018 David Capello
// //
// This program is distributed under the terms of // This program is distributed under the terms of
@ -19,6 +19,8 @@
#include "base/fs.h" #include "base/fs.h"
#include "doc/layer.h" #include "doc/layer.h"
#include "doc/sprite.h" #include "doc/sprite.h"
#include "fmt/format.h"
#include "ver/info.h"
#include <iostream> #include <iostream>
#include <memory> #include <memory>
@ -27,12 +29,12 @@ namespace app {
void PreviewCliDelegate::showHelp(const AppOptions& options) void PreviewCliDelegate::showHelp(const AppOptions& options)
{ {
std::cout << "- Show " PACKAGE " CLI usage\n"; std::cout << fmt::format("- Show {} CLI usage\n", get_app_name());
} }
void PreviewCliDelegate::showVersion() void PreviewCliDelegate::showVersion()
{ {
std::cout << "- Show " PACKAGE " version\n"; std::cout << fmt::format("- Show {} version\n", get_app_name());
} }
void PreviewCliDelegate::uiMode() void PreviewCliDelegate::uiMode()

View File

@ -1,4 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2020 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello // Copyright (C) 2001-2018 David Capello
// //
// This program is distributed under the terms of // This program is distributed under the terms of
@ -13,6 +14,8 @@
#include "app/modules/gui.h" #include "app/modules/gui.h"
#include "app/ui/main_window.h" #include "app/ui/main_window.h"
#include "base/bind.h" #include "base/bind.h"
#include "fmt/format.h"
#include "ver/info.h"
#include "about.xml.h" #include "about.xml.h"
@ -36,7 +39,7 @@ AboutCommand::AboutCommand()
void AboutCommand::onExecute(Context* context) void AboutCommand::onExecute(Context* context)
{ {
gen::About window; gen::About window;
window.title()->setText(PACKAGE " v" VERSION); window.title()->setText(fmt::format("{} v{}", get_app_name(), get_app_version()));
window.licenses()->Click.connect( window.licenses()->Click.connect(
[&window]{ [&window]{
window.closeWindow(nullptr); window.closeWindow(nullptr);

View File

@ -1,4 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2020 Igara Studio S.A.
// Copyright (C) 2001-2017 David Capello // Copyright (C) 2001-2017 David Capello
// //
// This program is distributed under the terms of // This program is distributed under the terms of
@ -12,6 +13,7 @@
#include "app/commands/params.h" #include "app/commands/params.h"
#include "app/launcher.h" #include "app/launcher.h"
#include "base/fs.h" #include "base/fs.h"
#include "ver/info.h"
namespace app { namespace app {
@ -42,7 +44,7 @@ void LaunchCommand::onLoadParams(const Params& params)
m_path = params.get("path"); m_path = params.get("path");
if (m_type == Url && !m_path.empty() && m_path[0] == '/') { if (m_type == Url && !m_path.empty() && m_path[0] == '/') {
m_path = WEBSITE + m_path.substr(1); m_path = std::string(get_app_url()) + m_path.substr(1);
} }
} }

View File

@ -1,5 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2019 Igara Studio S.A. // Copyright (C) 2019-2020 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello // Copyright (C) 2001-2018 David Capello
// //
// This program is distributed under the terms of // This program is distributed under the terms of
@ -31,6 +31,7 @@
#include "base/time.h" #include "base/time.h"
#include "doc/cancel_io.h" #include "doc/cancel_io.h"
#include "fmt/format.h" #include "fmt/format.h"
#include "ver/info.h"
namespace app { namespace app {
namespace crash { namespace crash {
@ -170,7 +171,7 @@ void Session::create(base::pid pid)
std::ofstream verf(FSTREAM_PATH(verFilename())); std::ofstream verf(FSTREAM_PATH(verFilename()));
pidf << m_pid; pidf << m_pid;
verf << VERSION; verf << get_app_version();
} }
void Session::close() void Session::close()

View File

@ -44,6 +44,7 @@
#include "render/dithering.h" #include "render/dithering.h"
#include "render/ordered_dither.h" #include "render/ordered_dither.h"
#include "render/render.h" #include "render/render.h"
#include "ver/info.h"
#include <cstdio> #include <cstdio>
#include <fstream> #include <fstream>
@ -1299,8 +1300,8 @@ void DocExporter::createDataFile(const Samples& samples,
// "meta" property // "meta" property
os << ",\n" os << ",\n"
<< " \"meta\": {\n" << " \"meta\": {\n"
<< " \"app\": \"" << WEBSITE << "\",\n" << " \"app\": \"" << get_app_url() << "\",\n"
<< " \"version\": \"" << VERSION << "\",\n"; << " \"version\": \"" << get_app_version() << "\",\n";
if (!m_textureFilename.empty()) if (!m_textureFilename.empty())
os << " \"image\": \"" os << " \"image\": \""

View File

@ -1,5 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2018-2019 Igara Studio S.A. // Copyright (C) 2018-2020 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello // Copyright (C) 2001-2018 David Capello
// //
// This program is distributed under the terms of // This program is distributed under the terms of
@ -27,6 +27,7 @@
#include "fixmath/fixmath.h" #include "fixmath/fixmath.h"
#include "fmt/format.h" #include "fmt/format.h"
#include "ui/alert.h" #include "ui/alert.h"
#include "ver/info.h"
#include "zlib.h" #include "zlib.h"
#include <cstdio> #include <cstdio>
@ -223,7 +224,7 @@ bool AseFormat::onPostLoad(FileOp* fop)
// Forward Compatibility: In 1.1 we convert a file with layer groups // Forward Compatibility: In 1.1 we convert a file with layer groups
// (saved with 1.2) as top level layers // (saved with 1.2) as top level layers
std::string ver = VERSION; std::string ver = get_app_version();
bool flat = (ver[0] == '1' && bool flat = (ver[0] == '1' &&
ver[1] == '.' && ver[1] == '.' &&
ver[2] == '1'); ver[2] == '1');
@ -240,7 +241,7 @@ bool AseFormat::onPostLoad(FileOp* fop)
"<<Note: Layers inside groups will be converted to top level layers." "<<Note: Layers inside groups will be converted to top level layers."
"||&Yes||&No", "||&Yes||&No",
base::get_file_name(fop->filename()), base::get_file_name(fop->filename()),
PACKAGE, ver)) != 1) { get_app_name(), ver)) != 1) {
return false; return false;
} }
ase_ungroup_all(group); ase_ungroup_all(group);

View File

@ -1,5 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2018-2019 Igara Studio S.A. // Copyright (C) 2018-2020 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello // Copyright (C) 2001-2018 David Capello
// //
// This program is distributed under the terms of // This program is distributed under the terms of
@ -41,6 +41,7 @@
#include "ui/alert.h" #include "ui/alert.h"
#include "ui/listitem.h" #include "ui/listitem.h"
#include "ui/system.h" #include "ui/system.h"
#include "ver/info.h"
#include "ask_for_color_profile.xml.h" #include "ask_for_color_profile.xml.h"
#include "open_sequence.xml.h" #include "open_sequence.xml.h"
@ -200,7 +201,7 @@ FileOp* FileOp::createLoadDocumentOperation(Context* context,
dio::detect_format(filename)); dio::detect_format(filename));
if (!fop->m_format || if (!fop->m_format ||
!fop->m_format->support(FILE_SUPPORT_LOAD)) { !fop->m_format->support(FILE_SUPPORT_LOAD)) {
fop->setError("%s can't load \"%s\" file (\"%s\")\n", PACKAGE, fop->setError("%s can't load \"%s\" file (\"%s\")\n", get_app_name(),
filename.c_str(), base::get_file_extension(filename).c_str()); filename.c_str(), base::get_file_extension(filename).c_str());
goto done; goto done;
} }
@ -354,7 +355,7 @@ FileOp* FileOp::createSaveDocumentOperation(const Context* context,
dio::detect_format_by_file_extension(filename)); dio::detect_format_by_file_extension(filename));
if (!fop->m_format || if (!fop->m_format ||
!fop->m_format->support(FILE_SUPPORT_SAVE)) { !fop->m_format->support(FILE_SUPPORT_SAVE)) {
fop->setError("%s can't save \"%s\" file (\"%s\")\n", PACKAGE, fop->setError("%s can't save \"%s\" file (\"%s\")\n", get_app_name(),
filename.c_str(), base::get_file_extension(filename).c_str()); filename.c_str(), base::get_file_extension(filename).c_str());
return fop.release(); return fop.release();
} }
@ -834,8 +835,9 @@ void FileOp::operate(IFileOpProgress* progress)
} }
#else #else
setError( setError(
"Save operation is not supported in trial version.\n" fmt::format("Save operation is not supported in trial version.\n"
"Go to " WEBSITE_DOWNLOAD " and get the full-version."); "Go to {} and get the full-version.",
get_app_download_url()));
#endif #endif
} }

View File

@ -1,4 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2020 Igara Studio S.A.
// Copyright (C) 2001-2016 David Capello // Copyright (C) 2001-2016 David Capello
// //
// This program is distributed under the terms of // This program is distributed under the terms of
@ -40,17 +41,4 @@ GuiXml::GuiXml()
m_doc = app::open_xml(rf.filename()); m_doc = app::open_xml(rf.filename());
} }
std::string GuiXml::version()
{
TiXmlHandle handle(m_doc.get());
TiXmlElement* xmlKey = handle.FirstChild("gui").ToElement();
if (xmlKey && xmlKey->Attribute("version")) {
const char* guixml_version = xmlKey->Attribute("version");
return guixml_version;
}
else
return "";
}
} // namespace app } // namespace app

View File

@ -1,4 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2020 Igara Studio S.A.
// Copyright (C) 2001-2015 David Capello // Copyright (C) 2001-2015 David Capello
// //
// This program is distributed under the terms of // This program is distributed under the terms of
@ -32,8 +33,6 @@ namespace app {
return m_doc->Value(); return m_doc->Value();
} }
std::string version();
private: private:
GuiXml(); GuiXml();

View File

@ -1,4 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2020 Igara Studio S.A.
// Copyright (C) 2001-2016 David Capello // Copyright (C) 2001-2016 David Capello
// //
// This program is distributed under the terms of // This program is distributed under the terms of
@ -13,6 +14,8 @@
#include "app/app.h" #include "app/app.h"
#include "app/resource_finder.h" #include "app/resource_finder.h"
#include "base/log.h" #include "base/log.h"
#include "fmt/format.h"
#include "ver/info.h"
namespace app { namespace app {
@ -20,10 +23,14 @@ LoggerModule::LoggerModule(bool createLogInDesktop)
{ {
app::ResourceFinder rf(false); app::ResourceFinder rf(false);
if (createLogInDesktop) if (createLogInDesktop) {
rf.includeDesktopDir(PACKAGE "-v" VERSION "-DebugOutput.txt"); rf.includeDesktopDir(fmt::format("{}-v{}-DebugOutput.txt",
else get_app_name(),
rf.includeUserDir("aseprite.log"); get_app_version()).c_str());
}
else {
rf.includeUserDir(fmt::format("{}.log", get_app_name()).c_str());
}
auto filename = rf.defaultFilename(); auto filename = rf.defaultFilename();
base::set_log_filename(filename.c_str()); base::set_log_filename(filename.c_str());

View File

@ -1,4 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2020 Igara Studio S.A.
// Copyright (C) 2001-2016 David Capello // Copyright (C) 2001-2016 David Capello
// //
// This program is distributed under the terms of // This program is distributed under the terms of
@ -18,6 +19,7 @@
#include "base/string.h" #include "base/string.h"
#include "net/http_request.h" #include "net/http_request.h"
#include "net/http_response.h" #include "net/http_response.h"
#include "ver/info.h"
#include <fstream> #include <fstream>
@ -49,7 +51,7 @@ void HttpLoader::threadHttpRequest()
LOG("HTTP: Sending http request to %s\n", m_url.c_str()); LOG("HTTP: Sending http request to %s\n", m_url.c_str());
std::string dir = base::join_path(base::get_temp_path(), PACKAGE); std::string dir = base::join_path(base::get_temp_path(), get_app_name());
base::make_all_directories(dir); base::make_all_directories(dir);
std::string fn = m_url; std::string fn = m_url;

View File

@ -1,5 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2019 Igara Studio S.A. // Copyright (C) 2019-2020 Igara Studio S.A.
// Copyright (C) 2001-2016 David Capello // Copyright (C) 2001-2016 David Capello
// //
// This program is distributed under the terms of // This program is distributed under the terms of
@ -14,6 +14,7 @@
#include "app/app.h" #include "app/app.h"
#include "base/fs.h" #include "base/fs.h"
#include "base/string.h" #include "base/string.h"
#include "ver/info.h"
#include <cstdio> #include <cstdio>
#include <cstdlib> #include <cstdlib>
@ -178,7 +179,7 @@ void ResourceFinder::includeUserDir(const char* filename)
// $HOME/Library/Application Support/Aseprite/filename // $HOME/Library/Application Support/Aseprite/filename
addPath( addPath(
base::join_path( base::join_path(
base::join_path(base::get_lib_app_support_path(), PACKAGE), base::join_path(base::get_lib_app_support_path(), get_app_name()),
filename).c_str()); filename).c_str());
#else // !__APPLE__ #else // !__APPLE__

View File

@ -44,6 +44,7 @@
#include "doc/tag.h" #include "doc/tag.h"
#include "render/render.h" #include "render/render.h"
#include "ui/alert.h" #include "ui/alert.h"
#include "ver/info.h"
#include <iostream> #include <iostream>
@ -483,7 +484,7 @@ int App_get_isUIAvailable(lua_State* L)
int App_get_version(lua_State* L) int App_get_version(lua_State* L)
{ {
std::string ver = VERSION; std::string ver = get_app_version();
base::replace_string(ver, "-x64", ""); // Remove "-x64" suffix base::replace_string(ver, "-x64", ""); // Remove "-x64" suffix
push_version(L, base::Version(ver)); push_version(L, base::Version(ver));
return 1; return 1;

View File

@ -19,8 +19,10 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/fs.h" #include "base/fs.h"
#include "base/launcher.h" #include "base/launcher.h"
#include "fmt/format.h"
#include "ui/alert.h" #include "ui/alert.h"
#include "ui/system.h" #include "ui/system.h"
#include "ver/info.h"
#include "send_crash.xml.h" #include "send_crash.xml.h"
@ -30,9 +32,11 @@ namespace app {
std::string SendCrash::DefaultMemoryDumpFilename() std::string SendCrash::DefaultMemoryDumpFilename()
{ {
#ifdef _WIN32 #ifdef _WIN32
const char* kDefaultCrashName = PACKAGE "-crash-" VERSION ".dmp"; std::string kDefaultCrashName = fmt::format("{}-crash-{}.dmp",
get_app_name(),
get_app_version());
ResourceFinder rf; ResourceFinder rf;
rf.includeUserDir(kDefaultCrashName); rf.includeUserDir(kDefaultCrashName.c_str());
return rf.getFirstOrCreateDefault(); return rf.getFirstOrCreateDefault();
#else #else
return std::string(); return std::string();
@ -76,13 +80,13 @@ void SendCrash::search()
std::string dir = rf.defaultFilename(); std::string dir = rf.defaultFilename();
if (base::is_directory(dir)) { if (base::is_directory(dir)) {
std::vector<std::string> candidates; std::vector<std::string> candidates;
int n = std::strlen(PACKAGE); int n = std::strlen(get_app_name());
for (const auto& fn : base::list_files(dir)) { for (const auto& fn : base::list_files(dir)) {
// Cancel everything // Cancel everything
if (m_task.canceled()) if (m_task.canceled())
return; return;
if (base::utf8_icmp(PACKAGE, fn, n) == 0) { if (base::utf8_icmp(get_app_name(), fn, n) == 0) {
candidates.push_back(fn); candidates.push_back(fn);
} }
} }
@ -125,13 +129,13 @@ void SendCrash::notificationClick()
app::gen::SendCrash dlg; app::gen::SendCrash dlg;
#if _WIN32 #if _WIN32
// Only on Windows, if the current version is a "development" // Only on Windows, if the current version is a development version
// version (i.e. the VERSION macro contains the "dev" word), the // (i.e. the get_app_version() contains "-dev"), the .dmp
// .dmp file is useless for us. This is because we need the .exe + // file is useless for us. This is because we need the .exe + .pdb +
// .pdb + source code used in the compilation process to make some // source code used in the compilation process to make some sense of
// sense of the .dmp file. // the .dmp file.
bool isDev = (std::string(VERSION).find("dev") != std::string::npos); bool isDev = (std::string(get_app_version()).find("-dev") != std::string::npos);
if (isDev) { if (isDev) {
dlg.official()->setVisible(false); dlg.official()->setVisible(false);
dlg.devFilename()->setText(m_dumpFilename); dlg.devFilename()->setText(m_dumpFilename);
@ -139,8 +143,8 @@ void SendCrash::notificationClick()
} }
else else
#endif // On other platforms the crash file might be useful even in #endif // On other platforms the crash file might be useful even in
// the -dev version (e.g. on macOS it's a text file with stack // the "-dev" version (e.g. on macOS it's a text file with
// traces). // stack traces).
{ {
dlg.dev()->setVisible(false); dlg.dev()->setVisible(false);
dlg.filename()->setText(m_dumpFilename); dlg.filename()->setText(m_dumpFilename);

View File

@ -1,4 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2020 Igara Studio S.A.
// Copyright (C) 2001-2016 David Capello // Copyright (C) 2001-2016 David Capello
// //
// This program is distributed under the terms of // This program is distributed under the terms of
@ -14,7 +15,9 @@
#include "app/shell.h" #include "app/shell.h"
#include "fmt/format.h"
#include "script/engine.h" #include "script/engine.h"
#include "ver/info.h"
#include <iostream> #include <iostream>
#include <string> #include <string>
@ -31,7 +34,8 @@ Shell::~Shell()
void Shell::run(script::Engine& engine) void Shell::run(script::Engine& engine)
{ {
std::cout << "Welcome to " PACKAGE " v" VERSION " Interactive Console" << std::endl; std::cout << fmt::format("Welcome to {} v{} Interactive Console",
get_app_name(), get_app_version()) << std::endl;
std::string line; std::string line;
while (std::getline(std::cin, line)) { while (std::getline(std::cin, line)) {
engine.evalCode(line); engine.evalCode(line);

View File

@ -1,5 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2019 Igara Studio S.A. // Copyright (C) 2019-2020 Igara Studio S.A.
// Copyright (C) 2001-2017 David Capello // Copyright (C) 2001-2017 David Capello
// //
// This program is distributed under the terms of // This program is distributed under the terms of
@ -40,6 +40,7 @@
#include "ui/size_hint_event.h" #include "ui/size_hint_event.h"
#include "ui/system.h" #include "ui/system.h"
#include "ui/view.h" #include "ui/view.h"
#include "ver/info.h"
#include <algorithm> #include <algorithm>
@ -314,7 +315,7 @@ void DataRecoveryView::fillListWith(const bool crashes)
} }
std::string title = session->name(); std::string title = session->name();
if (session->version() != VERSION) if (session->version() != get_app_version())
title = title =
fmt::format(Strings::recover_files_incompatible(), fmt::format(Strings::recover_files_incompatible(),
title, session->version()); title, session->version());

View File

@ -1,4 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2020 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello // Copyright (C) 2001-2018 David Capello
// //
// This program is distributed under the terms of // This program is distributed under the terms of
@ -18,11 +19,13 @@
#include "app/app_menus.h" #include "app/app_menus.h"
#include "app/ui/skin/skin_theme.h" #include "app/ui/skin/skin_theme.h"
#include "app/ui/workspace.h" #include "app/ui/workspace.h"
#include "fmt/format.h"
#include "ui/entry.h" #include "ui/entry.h"
#include "ui/message.h" #include "ui/message.h"
#include "ui/system.h" #include "ui/system.h"
#include "ui/textbox.h" #include "ui/textbox.h"
#include "ui/view.h" #include "ui/view.h"
#include "ver/info.h"
namespace app { namespace app {
@ -64,7 +67,8 @@ protected:
DevConsoleView::DevConsoleView() DevConsoleView::DevConsoleView()
: Box(VERTICAL) : Box(VERTICAL)
, m_textBox("Welcome to " PACKAGE " v" VERSION " Console\n(Experimental)", LEFT) , m_textBox(fmt::format("Welcome to {} v{} Console\n(Experimental)",
get_app_name(), get_app_version()), LEFT)
, m_label(">") , m_label(">")
, m_entry(new CommmandEntry) , m_entry(new CommmandEntry)
, m_engine(App::instance()->scriptEngine()) , m_engine(App::instance()->scriptEngine())

View File

@ -1,5 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2019 Igara Studio S.A. // Copyright (C) 2019-2020 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello // Copyright (C) 2001-2018 David Capello
// //
// This program is distributed under the terms of // This program is distributed under the terms of
@ -33,6 +33,7 @@
#include "ui/system.h" #include "ui/system.h"
#include "ui/textbox.h" #include "ui/textbox.h"
#include "ui/view.h" #include "ui/view.h"
#include "ver/info.h"
#ifdef ENABLE_NEWS #ifdef ENABLE_NEWS
#include "app/ui/news_listbox.h" #include "app/ui/news_listbox.h"
@ -177,7 +178,7 @@ void HomeView::onCheckingUpdates()
void HomeView::onUpToDate() void HomeView::onUpToDate()
{ {
checkUpdate()->setText( checkUpdate()->setText(
fmt::format(Strings::home_view_is_up_to_date(), PACKAGE)); fmt::format(Strings::home_view_is_up_to_date(), get_app_name()));
checkUpdate()->setVisible(true); checkUpdate()->setVisible(true);
layout(); layout();
@ -186,7 +187,8 @@ void HomeView::onUpToDate()
void HomeView::onNewUpdate(const std::string& url, const std::string& version) void HomeView::onNewUpdate(const std::string& url, const std::string& version)
{ {
checkUpdate()->setText( checkUpdate()->setText(
fmt::format(Strings::home_view_new_version_available(), PACKAGE, version)); fmt::format(Strings::home_view_new_version_available(),
get_app_name(), version));
checkUpdate()->setUrl(url); checkUpdate()->setUrl(url);
checkUpdate()->setVisible(true); checkUpdate()->setVisible(true);
checkUpdate()->InitTheme.connect( checkUpdate()->InitTheme.connect(

View File

@ -1,4 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2020 Igara Studio S.A.
// Copyright (C) 2001-2017 David Capello // Copyright (C) 2001-2017 David Capello
// //
// This program is distributed under the terms of // This program is distributed under the terms of
@ -23,6 +24,7 @@
#include "ui/paint_event.h" #include "ui/paint_event.h"
#include "ui/size_hint_event.h" #include "ui/size_hint_event.h"
#include "ui/view.h" #include "ui/view.h"
#include "ver/info.h"
#include "tinyxml.h" #include "tinyxml.h"
@ -209,7 +211,7 @@ void NewsListBox::reload()
if (view) if (view)
view->updateView(); view->updateView();
m_loader = new HttpLoader(WEBSITE_NEWS_RSS); m_loader = new HttpLoader(get_app_news_rss_url());
m_timer.start(); m_timer.start();
} }

View File

@ -1,5 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2018-2019 Igara Studio S.A. // Copyright (C) 2018-2020 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello // Copyright (C) 2001-2018 David Capello
// //
// This program is distributed under the terms of // This program is distributed under the terms of
@ -46,6 +46,7 @@
#include "os/font.h" #include "os/font.h"
#include "os/surface.h" #include "os/surface.h"
#include "ui/ui.h" #include "ui/ui.h"
#include "ver/info.h"
#include <algorithm> #include <algorithm>
#include <cstdarg> #include <cstdarg>
@ -621,7 +622,7 @@ void StatusBar::showDefaultText()
} }
else if (App::instance()->mainWindow()->isHomeSelected()) { else if (App::instance()->mainWindow()->isHomeSelected()) {
setStatusText(0, "-- %s %s by David & Gaspar Capello -- Igara Studio --", setStatusText(0, "-- %s %s by David & Gaspar Capello -- Igara Studio --",
PACKAGE, VERSION); get_app_name(), get_app_version());
} }
else { else {
clearText(); clearText();

View File

@ -1,15 +1,15 @@
// Aseprite // Aseprite
// Copyright (C) 2018-2019 Igara Studio S.A. // Copyright (C) 2018-2020 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello // Copyright (C) 2001-2018 David Capello
// //
// This program is distributed under the terms of // This program is distributed under the terms of
// the End-User License Agreement for Aseprite. // the End-User License Agreement for Aseprite.
#ifdef __ASE_CONFIG_H #ifdef __ASEPRITE_CONFIG_H
#error You cannot use config.h two times #error You cannot use config.h two times
#endif #endif
#define __ASE_CONFIG_H #define __ASEPRITE_CONFIG_H
// In MSVC // In MSVC
#ifdef _MSC_VER #ifdef _MSC_VER
@ -26,21 +26,6 @@
#pragma warning(disable:4710) #pragma warning(disable:4710)
#endif #endif
// General information
#define PACKAGE "Aseprite"
#define VERSION "1.3-dev"
#ifdef CUSTOM_WEBSITE_URL
#define WEBSITE CUSTOM_WEBSITE_URL // To test web server
#else
#define WEBSITE "http://www.aseprite.org/"
#endif
#define WEBSITE_DOWNLOAD WEBSITE "download/"
#define WEBSITE_CONTRIBUTORS WEBSITE "contributors/"
#define WEBSITE_NEWS_RSS "http://blog.aseprite.org/rss"
#define UPDATE_URL WEBSITE "update/?xml=1"
#define COPYRIGHT "Copyright (C) 2001-2019 Igara Studio S.A."
#include "base/base.h" #include "base/base.h"
#include "base/debug.h" #include "base/debug.h"
#include "base/log.h" #include "base/log.h"

View File

@ -1,5 +1,5 @@
// Aseprite UI Library // Aseprite UI Library
// Copyright (C) 2018-2019 Igara Studio S.A. // Copyright (C) 2018-2020 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello // Copyright (C) 2001-2018 David Capello
// //
// This file is released under the terms of the MIT license. // This file is released under the terms of the MIT license.
@ -302,10 +302,11 @@ Widget* Menu::findItemById(const char* id)
return result; return result;
for (auto child : children()) { for (auto child : children()) {
if (child->type() == kMenuItemWidget) { if (child->type() == kMenuItemWidget) {
result = static_cast<MenuItem*>(child) if (Menu* submenu = static_cast<MenuItem*>(child)->getSubmenu()) {
->getSubmenu()->findItemById(id); result = submenu->findItemById(id);
if (result) if (result)
return result; return result;
}
} }
} }
return nullptr; return nullptr;

View File

@ -1,4 +1,5 @@
# ASEPRITE # ASEPRITE
# Copyright (C) 2020 Igara Studio S.A.
# Copyright (C) 2001-2017 David Capello # Copyright (C) 2001-2017 David Capello
set(UPDATER_LIB_SOURCES set(UPDATER_LIB_SOURCES
@ -16,4 +17,5 @@ add_library(updater-lib ${UPDATER_LIB_SOURCES})
target_link_libraries(updater-lib target_link_libraries(updater-lib
net-lib net-lib
cfg-lib cfg-lib
ver-lib
${TINYXML_LIBRARY}) ${TINYXML_LIBRARY})

View File

@ -1,4 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2020 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello // Copyright (C) 2001-2018 David Capello
// //
// This program is distributed under the terms of // This program is distributed under the terms of
@ -18,6 +19,7 @@
#include "net/http_response.h" #include "net/http_response.h"
#include "tinyxml.h" #include "tinyxml.h"
#include "updater/user_agent.h" #include "updater/user_agent.h"
#include "ver/info.h"
#include <iostream> #include <iostream>
#include <memory> #include <memory>
@ -97,12 +99,7 @@ public:
bool checkNewVersion(const Uuid& uuid, const std::string& extraParams, CheckUpdateDelegate* delegate) bool checkNewVersion(const Uuid& uuid, const std::string& extraParams, CheckUpdateDelegate* delegate)
{ {
#ifndef UPDATE_URL std::string url = get_app_update_url();
#define UPDATE_URL ""
#pragma message("warning: Define UPDATE_URL macro")
#endif
std::string url = UPDATE_URL;
if (!uuid.empty()) { if (!uuid.empty()) {
url += "&uuid="; url += "&uuid=";
url += uuid; url += uuid;

View File

@ -1,5 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2019 Igara Studio S.A. // Copyright (C) 2019-2020 Igara Studio S.A.
// Copyright (C) 2001-2017 David Capello // Copyright (C) 2001-2017 David Capello
// //
// This program is distributed under the terms of // This program is distributed under the terms of
@ -9,6 +9,9 @@
#include "config.h" #include "config.h"
#endif #endif
#include "updater/user_agent.h"
#include "ver/info.h"
#include <string> #include <string>
#include <sstream> #include <sstream>
@ -39,18 +42,7 @@ std::string getUserAgent()
std::stringstream userAgent; std::stringstream userAgent;
// App name and version // App name and version
userAgent << get_app_name() << "/" << get_app_version() << " (";
#ifndef PACKAGE
#define PACKAGE ""
#pragma message("warning: Define PACKAGE macro")
#endif
#ifndef VERSION
#define VERSION ""
#pragma message("warning: Define VERSION macro")
#endif
userAgent << PACKAGE << "/" << VERSION << " (";
#if _WIN32 #if _WIN32

18
src/ver/CMakeLists.txt Normal file
View File

@ -0,0 +1,18 @@
# ASEPRITE
# Copyright (C) 2020 Igara Studio S.A.
# Version of Aseprite
set(VERSION "1.x-dev")
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/generated_version.h.in"
"${CMAKE_CURRENT_BINARY_DIR}/generated_version.h")
# Custom Aseprite website (for testing server-side)
if(NOT "${CUSTOM_WEBSITE_URL}" STREQUAL "")
add_definitions(-DCUSTOM_WEBSITE_URL="${CUSTOM_WEBSITE_URL}")
endif()
add_library(ver-lib info.c ${gen_ver_fn})
add_dependencies(ver-lib generated_version_h)
target_include_directories(ver-lib PRIVATE "${CMAKE_CURRENT_BINARY_DIR}")

View File

@ -0,0 +1 @@
#cmakedefine VERSION "@VERSION@"

31
src/ver/info.c Normal file
View File

@ -0,0 +1,31 @@
/* Aseprite
Copyright (C) 2020 Igara Studio S.A.
This program is distributed under the terms of
the End-User License Agreement for Aseprite. */
#include "ver/info.h"
#include "generated_version.h" /* It defines the VERSION macro */
#define PACKAGE "Aseprite"
#define COPYRIGHT "Copyright (C) 2001-2020 Igara Studio S.A."
#ifdef CUSTOM_WEBSITE_URL
#define WEBSITE CUSTOM_WEBSITE_URL /* To test web server */
#else
#define WEBSITE "http://www.aseprite.org/"
#endif
#define WEBSITE_DOWNLOAD WEBSITE "download/"
#define WEBSITE_CONTRIBUTORS WEBSITE "contributors/"
#define WEBSITE_NEWS_RSS "http://blog.aseprite.org/rss"
#define WEBSITE_UPDATE WEBSITE "update/?xml=1"
const char* get_app_name() { return PACKAGE; }
const char* get_app_version() { return VERSION; }
const char* get_app_copyright() { return COPYRIGHT; }
const char* get_app_url() { return WEBSITE; }
const char* get_app_download_url() { return WEBSITE_DOWNLOAD; }
const char* get_app_contributors_url() { return WEBSITE_CONTRIBUTORS; }
const char* get_app_news_rss_url() { return WEBSITE_NEWS_RSS; }
const char* get_app_update_url() { return WEBSITE_UPDATE; }

29
src/ver/info.h Normal file
View File

@ -0,0 +1,29 @@
/* Aseprite
Copyright (C) 2020 Igara Studio S.A.
This program is distributed under the terms of
the End-User License Agreement for Aseprite. */
#ifndef VER_INFO_H_INCLUDED
#define VER_INFO_H_INCLUDED
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
const char* get_app_name();
const char* get_app_version();
const char* get_app_copyright();
const char* get_app_url();
const char* get_app_download_url();
const char* get_app_contributors_url();
const char* get_app_news_rss_url();
const char* get_app_update_url();
#ifdef __cplusplus
}
#endif
#endif /* VER_INFO_H_INCLUDED */