mirror of
https://github.com/aseprite/aseprite.git
synced 2024-09-02 13:09:27 +00:00
Added Donate command.
This commit is contained in:
parent
3d89a21e2f
commit
449cdd686f
@ -309,6 +309,8 @@
|
||||
<menu text="&Help">
|
||||
<item command="quick_reference" text="Quick &Reference" />
|
||||
<separator />
|
||||
<item command="donate" text="&Donate" />
|
||||
<separator />
|
||||
<item command="about" text="&About" />
|
||||
</menu>
|
||||
</menu>
|
||||
|
@ -31,6 +31,7 @@ COMMON_SOURCES = \
|
||||
src/commands/cmd_crop.cpp \
|
||||
src/commands/cmd_cut.cpp \
|
||||
src/commands/cmd_deselect_mask.cpp \
|
||||
src/commands/cmd_donate.cpp \
|
||||
src/commands/cmd_duplicate_layer.cpp \
|
||||
src/commands/cmd_duplicate_sprite.cpp \
|
||||
src/commands/cmd_exit.cpp \
|
||||
|
59
src/commands/cmd_donate.cpp
Normal file
59
src/commands/cmd_donate.cpp
Normal file
@ -0,0 +1,59 @@
|
||||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2010 David Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "commands/command.h"
|
||||
#include "launcher.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// donate
|
||||
|
||||
class DonateCommand : public Command
|
||||
{
|
||||
public:
|
||||
DonateCommand();
|
||||
Command* clone() const { return new DonateCommand(*this); }
|
||||
|
||||
protected:
|
||||
void execute(Context* context);
|
||||
};
|
||||
|
||||
DonateCommand::DonateCommand()
|
||||
: Command("donate",
|
||||
"Donate",
|
||||
CmdUIOnlyFlag)
|
||||
{
|
||||
}
|
||||
|
||||
void DonateCommand::execute(Context* context)
|
||||
{
|
||||
std::string url;
|
||||
url += WEBSITE;
|
||||
url += "donate/";
|
||||
|
||||
Launcher::openUrl(url);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// CommandFactory
|
||||
|
||||
Command* CommandFactory::create_donate_command()
|
||||
{
|
||||
return new DonateCommand;
|
||||
}
|
@ -38,6 +38,7 @@ FOR_EACH_COMMAND(crop_sprite)
|
||||
FOR_EACH_COMMAND(cut)
|
||||
FOR_EACH_COMMAND(deselect_mask)
|
||||
FOR_EACH_COMMAND(despeckle)
|
||||
FOR_EACH_COMMAND(donate)
|
||||
FOR_EACH_COMMAND(duplicate_layer)
|
||||
FOR_EACH_COMMAND(duplicate_sprite)
|
||||
FOR_EACH_COMMAND(exit)
|
||||
|
@ -29,6 +29,7 @@
|
||||
|
||||
#include "app.h"
|
||||
#include "commands/commands.h"
|
||||
#include "commands/params.h"
|
||||
#include "core/core.h"
|
||||
#include "modules/editors.h"
|
||||
#include "modules/gfx.h"
|
||||
@ -472,16 +473,20 @@ bool StatusBar::msg_proc(JMessage msg)
|
||||
else {
|
||||
int x1 = rc->x2-width;
|
||||
int x2 = rc->x2;
|
||||
bool hot = (0 == m_hot_layer);
|
||||
|
||||
theme->draw_bounds_nw(doublebuffer,
|
||||
x1, rc->y1, x2, rc->y2,
|
||||
PART_TOOLBUTTON_NORMAL_NW,
|
||||
theme->get_button_normal_face_color());
|
||||
hot ? PART_TOOLBUTTON_HOT_NW:
|
||||
PART_TOOLBUTTON_NORMAL_NW,
|
||||
hot ? theme->get_button_hot_face_color():
|
||||
theme->get_button_normal_face_color());
|
||||
|
||||
textout_centre_ex(doublebuffer, this->getFont(), "No Sprite",
|
||||
textout_centre_ex(doublebuffer, this->getFont(), "Donate",
|
||||
(x1+x2)/2,
|
||||
(rc->y1+rc->y2)/2-text_height(this->getFont())/2,
|
||||
theme->get_button_normal_text_color(), -1);
|
||||
hot ? theme->get_button_hot_text_color():
|
||||
theme->get_button_normal_text_color(), -1);
|
||||
}
|
||||
}
|
||||
catch (locked_sprite_exception&) {
|
||||
@ -500,10 +505,10 @@ bool StatusBar::msg_proc(JMessage msg)
|
||||
return true;
|
||||
}
|
||||
|
||||
case JM_MOUSEENTER:
|
||||
if (!jwidget_has_child(this, m_commands_box)) {
|
||||
bool state = (UIContext::instance()->get_current_sprite() != NULL);
|
||||
case JM_MOUSEENTER: {
|
||||
bool state = (UIContext::instance()->get_current_sprite() != NULL);
|
||||
|
||||
if (!jwidget_has_child(this, m_commands_box) && state) {
|
||||
m_b_first->setEnabled(state);
|
||||
m_b_prev->setEnabled(state);
|
||||
m_b_play->setEnabled(state);
|
||||
@ -515,7 +520,13 @@ bool StatusBar::msg_proc(JMessage msg)
|
||||
jwidget_add_child(this, m_commands_box);
|
||||
jwidget_dirty(this);
|
||||
}
|
||||
else {
|
||||
// Status text for donations
|
||||
app_get_statusbar()
|
||||
->setStatusText(0, "Click the \"Donate\" button to support ASE development");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case JM_MOTION: {
|
||||
JRect rc = jwidget_get_rect(this);
|
||||
@ -532,13 +543,15 @@ bool StatusBar::msg_proc(JMessage msg)
|
||||
try {
|
||||
--rc->y2;
|
||||
|
||||
int hot_layer = -1;
|
||||
|
||||
const CurrentSpriteReader sprite(UIContext::instance());
|
||||
// Check which sprite's layer has the mouse over
|
||||
if (sprite) {
|
||||
const LayerFolder* folder = sprite->getFolder();
|
||||
LayerConstIterator it = folder->get_layer_begin();
|
||||
LayerConstIterator end = folder->get_layer_end();
|
||||
int count = folder->get_layers_count();
|
||||
int hot_layer = -1;
|
||||
|
||||
for (int c=0; it != end; ++it, ++c) {
|
||||
int x1 = rc->x2-width + c*width/count;
|
||||
@ -551,12 +564,23 @@ bool StatusBar::msg_proc(JMessage msg)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Check if the "Donate" button has the mouse over
|
||||
else {
|
||||
int x1 = rc->x2-width;
|
||||
int x2 = rc->x2;
|
||||
|
||||
if (m_hot_layer != hot_layer) {
|
||||
m_hot_layer = hot_layer;
|
||||
dirty();
|
||||
if (Rect(Point(x1, rc->y1),
|
||||
Point(x2, rc->y2)).contains(Point(msg->mouse.x,
|
||||
msg->mouse.y))) {
|
||||
hot_layer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_hot_layer != hot_layer) {
|
||||
m_hot_layer = hot_layer;
|
||||
dirty();
|
||||
}
|
||||
}
|
||||
catch (locked_sprite_exception&) {
|
||||
// Do nothing...
|
||||
@ -584,6 +608,14 @@ bool StatusBar::msg_proc(JMessage msg)
|
||||
dirty();
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Call "Donate" command
|
||||
Command* donate = CommandsModule::instance()
|
||||
->get_command_by_name(CommandId::donate);
|
||||
|
||||
Params params;
|
||||
UIContext::instance()->execute_command(donate, ¶ms);
|
||||
}
|
||||
}
|
||||
catch (locked_sprite_exception&) {
|
||||
// Do nothing...
|
||||
|
Loading…
Reference in New Issue
Block a user