Add option to enter Aseprite license key (#2664)

This is an initial version to add an automatic update feature in the
future.
This commit is contained in:
Martín Capello 2021-08-24 11:25:35 -03:00 committed by David Capello
parent faecd682fc
commit fcac48cccb
11 changed files with 131 additions and 0 deletions

View File

@ -65,6 +65,7 @@ option(ENABLE_WEBSOCKET "Compile with websocket support" on)
option(ENABLE_TESTS "Compile unit tests" off) option(ENABLE_TESTS "Compile unit tests" off)
option(ENABLE_BENCHMARKS "Compile benchmarks" off) option(ENABLE_BENCHMARKS "Compile benchmarks" off)
option(ENABLE_TRIAL_MODE "Compile the trial version" off) option(ENABLE_TRIAL_MODE "Compile the trial version" off)
option(ENABLE_DRM "Compile the DRM-enabled version (e.g. for automatic updates)" off)
option(ENABLE_STEAM "Compile with Steam library" off) option(ENABLE_STEAM "Compile with Steam library" off)
option(ENABLE_DEVMODE "Compile vesion for developers" off) option(ENABLE_DEVMODE "Compile vesion for developers" off)
option(ENABLE_UI "Compile UI (turn off to compile CLI-only version)" on) option(ENABLE_UI "Compile UI (turn off to compile CLI-only version)" on)
@ -107,6 +108,10 @@ if(LAF_OS_WITH_GTK)
endif() endif()
endif() endif()
if(ENABLE_DRM AND NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/drm/CMakeLists.txt)
message(FATAL_ERROR "Your Aseprite repository is incomplete, clone the drm repository")
endif()
###################################################################### ######################################################################
# Profile build type # Profile build type
@ -331,6 +336,9 @@ endif()
set(LAF_WITH_TESTS ${ENABLE_TESTS} CACHE BOOL "Enable LAF tests") set(LAF_WITH_TESTS ${ENABLE_TESTS} CACHE BOOL "Enable LAF tests")
set(UNDO_TESTS ${ENABLE_TESTS} CACHE BOOL "Enable undo tests") set(UNDO_TESTS ${ENABLE_TESTS} CACHE BOOL "Enable undo tests")
if(ENABLE_DRM)
add_subdirectory(drm)
endif()
add_subdirectory(laf) add_subdirectory(laf)
# LAF libraries + Aseprite are compiled with config.h # LAF libraries + Aseprite are compiled with config.h

View File

@ -1025,6 +1025,8 @@
<param name="path" value="http://twitter.com/aseprite" /> <param name="path" value="http://twitter.com/aseprite" />
</item> </item>
<separator /> <separator />
<item command="Register" text="@.help_register" group="help_register" />
<separator />
<item command="About" text="@.help_about" group="help_about" /> <item command="About" text="@.help_about" group="help_about" />
</menu> </menu>
</menu> </menu>

View File

@ -422,6 +422,7 @@ PlayAnimation = Play Animation
PlayPreviewAnimation = Play Preview Animation PlayPreviewAnimation = Play Preview Animation
Redo = Redo Redo = Redo
Refresh = Refresh Refresh = Refresh
Register = Register Aseprite
RemoveFrame = Remove Frame RemoveFrame = Remove Frame
RemoveFrameTag = Remove Tag RemoveFrameTag = Remove Tag
RemoveLayer = Remove Layer RemoveLayer = Remove Layer
@ -1043,6 +1044,7 @@ help_documentation = Documentation
help_tutorial = Tutorial help_tutorial = Tutorial
help_release_notes = Release Notes help_release_notes = Release Notes
help_twitter = Twitter help_twitter = Twitter
help_register = &Register Aseprite
help_about = &About help_about = &About
[modify_selection] [modify_selection]
@ -1061,6 +1063,11 @@ name = Name:
tileset = Tileset: tileset = Tileset:
default_new_layer_name = New Layer default_new_layer_name = New Layer
[register]
title = Register Aseprite
default_message = If you need an activation code, go to
activation_code = Activation Code
[tileset_selector] [tileset_selector]
new_tileset = New Tileset new_tileset = New Tileset
grid_width = Grid Width: grid_width = Grid Width:

25
data/widgets/register.xml Normal file
View File

@ -0,0 +1,25 @@
<!-- Aseprite -->
<!-- Copyright (c) 2021 Igara Studio S.A. -->
<gui>
<window id="register" text="@.title" expansive="false">
<box vertical="true">
<hbox>
<label text="@.default_message" />
<link text="https://www.aseprite.org/download/" url="https://www.aseprite.org/download/" />
</hbox>
<separator text="@.activation_code" left="true" horizontal="true" />
<grid columns="4">
<entry id="code1" cell_align="horizontal" magnet="true" maxsize="5" />
<entry id="code2" cell_align="horizontal" maxsize="5" />
<entry id="code3" cell_align="horizontal" maxsize="5" />
</grid>
<box horizontal="true">
<box horizontal="true" expansive="true" />
<box horizontal="true" homogeneous="true">
<button text="@general.ok" closewindow="true" id="ok_button" magnet="true" width="60" />
<button text="@general.cancel" closewindow="true" />
</box>
</box>
</box>
</window>
</gui>

View File

@ -54,6 +54,10 @@ else()
add_definitions(-DENABLE_TRIAL_MODE) add_definitions(-DENABLE_TRIAL_MODE)
endif() endif()
if(ENABLE_DRM)
add_definitions(-DENABLE_DRM)
endif()
if(ENABLE_DEVMODE) if(ENABLE_DEVMODE)
add_definitions(-DENABLE_DEVMODE) add_definitions(-DENABLE_DEVMODE)
endif() endif()

View File

@ -278,6 +278,7 @@ if(ENABLE_UI)
commands/cmd_pixel_perfect_mode.cpp commands/cmd_pixel_perfect_mode.cpp
commands/cmd_play_animation.cpp commands/cmd_play_animation.cpp
commands/cmd_refresh.cpp commands/cmd_refresh.cpp
commands/cmd_register.cpp
commands/cmd_remove_frame.cpp commands/cmd_remove_frame.cpp
commands/cmd_remove_frame_tag.cpp commands/cmd_remove_frame_tag.cpp
commands/cmd_remove_slice.cpp commands/cmd_remove_slice.cpp

View File

@ -0,0 +1,53 @@
// Aseprite
// Copyright (C) 2021 Igara Studio S.A.
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
#include "app/app.h"
#include "app/commands/command.h"
#include "app/context.h"
#include "register.xml.h"
namespace app {
class RegisterCommand : public Command {
public:
RegisterCommand();
protected:
void onExecute(Context* context) override;
};
RegisterCommand::RegisterCommand()
: Command(CommandId::Register(), CmdUIOnlyFlag)
{
}
void RegisterCommand::onExecute(Context* context)
{
// Load the window widget
app::gen::Register window;
window.setSizeable(false);
auto onChange = [] (ui::Entry *entry) {
return [entry]() {
entry->setText(base::string_to_upper(entry->text()));
};
};
window.code1()->Change.connect(onChange(window.code1()));
window.code2()->Change.connect(onChange(window.code2()));
window.code3()->Change.connect(onChange(window.code3()));
// Open the window
window.openWindowInForeground();
}
Command* CommandFactory::createRegisterCommand()
{
return new RegisterCommand;
}
} // namespace app

View File

@ -122,6 +122,7 @@ FOR_EACH_COMMAND(PixelPerfectMode)
FOR_EACH_COMMAND(PlayAnimation) FOR_EACH_COMMAND(PlayAnimation)
FOR_EACH_COMMAND(PlayPreviewAnimation) FOR_EACH_COMMAND(PlayPreviewAnimation)
FOR_EACH_COMMAND(Refresh) FOR_EACH_COMMAND(Refresh)
FOR_EACH_COMMAND(Register)
FOR_EACH_COMMAND(RemoveFrame) FOR_EACH_COMMAND(RemoveFrame)
FOR_EACH_COMMAND(RemoveFrameTag) FOR_EACH_COMMAND(RemoveFrameTag)
FOR_EACH_COMMAND(RemoveSlice) FOR_EACH_COMMAND(RemoveSlice)

17
src/app/drm.h Normal file
View File

@ -0,0 +1,17 @@
// Aseprite
// Copyright (C) 2021 Igara Studio S.A.
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
#ifndef APP_DRM_H_INCLUDED
#define APP_DRM_H_INCLUDED
#pragma once
#ifdef ENABLE_DRM
#include "drm/drm.h"
#else
#define DRM_INVALID if (false)
#endif
#endif

View File

@ -16,6 +16,7 @@
#include "app/console.h" #include "app/console.h"
#include "app/context.h" #include "app/context.h"
#include "app/doc.h" #include "app/doc.h"
#include "app/drm.h"
#include "app/file/file_data.h" #include "app/file/file_data.h"
#include "app/file/file_format.h" #include "app/file/file_format.h"
#include "app/file/file_formats_manager.h" #include "app/file/file_formats_manager.h"
@ -886,6 +887,15 @@ void FileOp::operate(IFileOpProgress* progress)
m_format != NULL && m_format != NULL &&
m_format->support(FILE_SUPPORT_SAVE)) { m_format->support(FILE_SUPPORT_SAVE)) {
#ifdef ENABLE_SAVE #ifdef ENABLE_SAVE
DRM_INVALID {
setError(
fmt::format("Save operation is not supported, activate this Aseprite first.\n"
"Go to {} and get an activation code or get the DRM-FREE full-version.",
get_app_download_url()).c_str());
return;
}
// Save a sequence // Save a sequence
if (isSequence()) { if (isSequence()) {
ASSERT(m_format->support(FILE_SUPPORT_SEQUENCES)); ASSERT(m_format->support(FILE_SUPPORT_SEQUENCES));

View File

@ -9,6 +9,7 @@
#include "config.h" #include "config.h"
#endif #endif
#include "app/drm.h"
#include "app/file/file_format.h" #include "app/file/file_format.h"
#include "app/file/format_options.h" #include "app/file/format_options.h"
@ -48,6 +49,8 @@ bool FileFormat::load(FileOp* fop)
#ifdef ENABLE_SAVE #ifdef ENABLE_SAVE
bool FileFormat::save(FileOp* fop) bool FileFormat::save(FileOp* fop)
{ {
DRM_INVALID return false;
ASSERT(support(FILE_SUPPORT_SAVE)); ASSERT(support(FILE_SUPPORT_SAVE));
return onSave(fop); return onSave(fop);
} }