mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-10 12:44:53 +00:00
Moved get_pretty_memsize (core.h) to get_pretty_memory_size (mem_utils.h).
This commit is contained in:
parent
81fcdb53a3
commit
a82d721913
@ -12,6 +12,7 @@ COMMON_SOURCES = \
|
|||||||
src/context.cpp \
|
src/context.cpp \
|
||||||
src/gfxmode.cpp \
|
src/gfxmode.cpp \
|
||||||
src/launcher.cpp \
|
src/launcher.cpp \
|
||||||
|
src/mem_utils.cpp \
|
||||||
src/recent_files.cpp \
|
src/recent_files.cpp \
|
||||||
src/ui_context.cpp \
|
src/ui_context.cpp \
|
||||||
src/undoable.cpp \
|
src/undoable.cpp \
|
||||||
|
@ -22,10 +22,9 @@
|
|||||||
|
|
||||||
#include "jinete/jinete.h"
|
#include "jinete/jinete.h"
|
||||||
|
|
||||||
#include "commands/command.h"
|
|
||||||
#include "sprite_wrappers.h"
|
|
||||||
#include "app.h"
|
#include "app.h"
|
||||||
#include "core/core.h"
|
#include "commands/command.h"
|
||||||
|
#include "mem_utils.h"
|
||||||
#include "modules/gui.h"
|
#include "modules/gui.h"
|
||||||
#include "raster/cel.h"
|
#include "raster/cel.h"
|
||||||
#include "raster/image.h"
|
#include "raster/image.h"
|
||||||
@ -33,6 +32,7 @@
|
|||||||
#include "raster/sprite.h"
|
#include "raster/sprite.h"
|
||||||
#include "raster/stock.h"
|
#include "raster/stock.h"
|
||||||
#include "raster/undo.h"
|
#include "raster/undo.h"
|
||||||
|
#include "sprite_wrappers.h"
|
||||||
|
|
||||||
class CelPropertiesCommand : public Command
|
class CelPropertiesCommand : public Command
|
||||||
{
|
{
|
||||||
@ -108,9 +108,9 @@ void CelPropertiesCommand::execute(Context* context)
|
|||||||
usprintf(buf, "%dx%d (",
|
usprintf(buf, "%dx%d (",
|
||||||
sprite->getStock()->image[cel->image]->w,
|
sprite->getStock()->image[cel->image]->w,
|
||||||
sprite->getStock()->image[cel->image]->h);
|
sprite->getStock()->image[cel->image]->h);
|
||||||
get_pretty_memsize(memsize,
|
get_pretty_memory_size(memsize,
|
||||||
buf+ustrsize(buf),
|
buf+ustrsize(buf),
|
||||||
sizeof(buf)-ustrsize(buf));
|
sizeof(buf)-ustrsize(buf));
|
||||||
ustrcat(buf, ")");
|
ustrcat(buf, ")");
|
||||||
|
|
||||||
label_size->setText(buf);
|
label_size->setText(buf);
|
||||||
|
@ -23,14 +23,14 @@
|
|||||||
#include "jinete/jinete.h"
|
#include "jinete/jinete.h"
|
||||||
|
|
||||||
#include "commands/command.h"
|
#include "commands/command.h"
|
||||||
#include "core/core.h"
|
|
||||||
#include "core/color.h"
|
#include "core/color.h"
|
||||||
|
#include "mem_utils.h"
|
||||||
#include "modules/gui.h"
|
#include "modules/gui.h"
|
||||||
#include "raster/image.h"
|
#include "raster/image.h"
|
||||||
#include "raster/sprite.h"
|
|
||||||
#include "raster/palette.h"
|
#include "raster/palette.h"
|
||||||
#include "widgets/colbut.h"
|
#include "raster/sprite.h"
|
||||||
#include "sprite_wrappers.h"
|
#include "sprite_wrappers.h"
|
||||||
|
#include "widgets/colbut.h"
|
||||||
|
|
||||||
/* TODO remove this */
|
/* TODO remove this */
|
||||||
void dialogs_frame_length(const SpriteReader& sprite, int sprite_frpos);
|
void dialogs_frame_length(const SpriteReader& sprite, int sprite_frpos);
|
||||||
@ -106,9 +106,9 @@ void SpritePropertiesCommand::execute(Context* context)
|
|||||||
|
|
||||||
/* sprite size (width and height) */
|
/* sprite size (width and height) */
|
||||||
usprintf(buf, "%dx%d (", sprite->getWidth(), sprite->getHeight());
|
usprintf(buf, "%dx%d (", sprite->getWidth(), sprite->getHeight());
|
||||||
get_pretty_memsize(sprite->getMemSize(),
|
get_pretty_memory_size(sprite->getMemSize(),
|
||||||
buf+ustrsize(buf),
|
buf+ustrsize(buf),
|
||||||
sizeof(buf)-ustrsize(buf));
|
sizeof(buf)-ustrsize(buf));
|
||||||
ustrcat(buf, ")");
|
ustrcat(buf, ")");
|
||||||
size->setText(buf);
|
size->setText(buf);
|
||||||
|
|
||||||
|
@ -118,18 +118,6 @@ bool is_interactive()
|
|||||||
return ase_mode & MODE_GUI ? true: false;
|
return ase_mode & MODE_GUI ? true: false;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *get_pretty_memsize(unsigned int memsize, char *buf, unsigned int bufsize)
|
|
||||||
{
|
|
||||||
if (memsize < 1000)
|
|
||||||
uszprintf(buf, bufsize, "%d bytes", memsize);
|
|
||||||
else if (memsize < 1000*1000)
|
|
||||||
uszprintf(buf, bufsize, "%0.1fK", memsize/1024.0f);
|
|
||||||
else
|
|
||||||
uszprintf(buf, bufsize, "%0.1fM", memsize/(1024.0f*1024.0f));
|
|
||||||
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Like 'strerror' but thread-safe.
|
* Like 'strerror' but thread-safe.
|
||||||
*
|
*
|
||||||
|
@ -39,7 +39,6 @@ public:
|
|||||||
void verbose_printf(const char *format, ...);
|
void verbose_printf(const char *format, ...);
|
||||||
bool is_interactive();
|
bool is_interactive();
|
||||||
|
|
||||||
char *get_pretty_memsize(unsigned int memsize, char *buf, unsigned int bufsize);
|
|
||||||
char *get_errno_string(int errnum, char *buf, int size);
|
char *get_errno_string(int errnum, char *buf, int size);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
33
src/mem_utils.cpp
Normal file
33
src/mem_utils.cpp
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
/* 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 <allegro/unicode.h>
|
||||||
|
|
||||||
|
char *get_pretty_memory_size(unsigned int memsize, char *buf, unsigned int bufsize)
|
||||||
|
{
|
||||||
|
if (memsize < 1000)
|
||||||
|
uszprintf(buf, bufsize, "%d bytes", memsize);
|
||||||
|
else if (memsize < 1000*1000)
|
||||||
|
uszprintf(buf, bufsize, "%0.1fK", memsize/1024.0f);
|
||||||
|
else
|
||||||
|
uszprintf(buf, bufsize, "%0.1fM", memsize/(1024.0f*1024.0f));
|
||||||
|
|
||||||
|
return buf;
|
||||||
|
}
|
25
src/mem_utils.h
Normal file
25
src/mem_utils.h
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
/* 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef MEM_UTILS_H_INCLUDED
|
||||||
|
#define MEM_UTILS_H_INCLUDED
|
||||||
|
|
||||||
|
char* get_pretty_memory_size(unsigned int memsize, char* buf, unsigned int bufsize);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user