mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-27 06:35:16 +00:00
Added the number of colors in "New Sprite" dialog for Indexed sprites.
This commit is contained in:
parent
81bafa3595
commit
0a5746bf3b
@ -1,51 +1,51 @@
|
||||
<!-- ASE - Allegro Sprite Editor -->
|
||||
<!-- Copyright (C) 2001-2010 by David Capello -->
|
||||
<jinete>
|
||||
<window text="New Sprite" name="new_sprite">
|
||||
<box vertical="true">
|
||||
<box horizontal="true">
|
||||
<window text="New Sprite" name="new_sprite">
|
||||
<box vertical="true">
|
||||
|
||||
<box vertical="true" expansive="true">
|
||||
<separator text="Size:" left="true" horizontal="true" />
|
||||
<box vertical="true" expansive="true">
|
||||
<box horizontal="true">
|
||||
<box vertical="true" homogeneous="true">
|
||||
<label text="Width:" />
|
||||
<label text="Height:" />
|
||||
</box>
|
||||
<box vertical="true" homogeneous="true" expansive="true">
|
||||
<entry expansive="true" name="width" maxsize="8" magnetic="true" tooltip="Width of the new sprite (in pixels)" />
|
||||
<entry expansive="true" name="height" maxsize="8" tooltip="Height of the new sprite (in pixels)" />
|
||||
</box>
|
||||
</box>
|
||||
</box>
|
||||
</box>
|
||||
<box vertical="true">
|
||||
<separator text="Color Mode:" left="true" horizontal="true" />
|
||||
<box vertical="true" homogeneous="true">
|
||||
<radio name="radio1" text="&RGB Color" group="1" tooltip="RGBA color mode (32 bits per pixel)" />
|
||||
<radio name="radio2" text="&Grayscale" group="1" tooltip="Value and Alpha (16 bits per pixel)" />
|
||||
<radio name="radio3" text="&Indexed" group="1" tooltip="Using a palette of 256 colors (8 bits per pixel)" />
|
||||
<separator text="Size:" left="true" horizontal="true" />
|
||||
<box vertical="true" expansive="true">
|
||||
<grid columns="2">
|
||||
<label text="Width:" />
|
||||
<entry name="width" maxsize="8" magnetic="true" cell_align="horizontal" tooltip="Width of the new sprite (in pixels)" />
|
||||
<label text="Height:" />
|
||||
<entry name="height" maxsize="8" cell_align="horizontal" tooltip="Height of the new sprite (in pixels)" />
|
||||
</grid>
|
||||
</box>
|
||||
</box>
|
||||
</box>
|
||||
<separator text="Background:" left="true" horizontal="true" />
|
||||
<view maxsize="true" expansive="true">
|
||||
<listbox name="bg_box">
|
||||
<listitem text="Transparent" />
|
||||
<listitem text="Black" />
|
||||
<listitem text="White" />
|
||||
<listitem text="Magenta" />
|
||||
<listitem text="Background Color" />
|
||||
</listbox>
|
||||
</view>
|
||||
|
||||
<box horizontal="true">
|
||||
<box horizontal="true" expansive="true" />
|
||||
<box horizontal="true" homogeneous="true">
|
||||
<button text="&OK" name="ok_button" magnetic="true" width="60" />
|
||||
<button text="&Cancel" />
|
||||
<separator text="Color Mode:" left="true" horizontal="true" />
|
||||
<box vertical="true" homogeneous="true" childspacing="0">
|
||||
<box horizontal="true">
|
||||
<radio name="radio3" text="&Indexed with " group="1" tooltip="Using a palette of 256 colors (8 bits per pixel)" />
|
||||
<entry name="colors" maxsize="8" tooltip="Maximum number of colors (only for Indexed images)" />
|
||||
<label text="Colors" />
|
||||
</box>
|
||||
<radio name="radio1" text="&RGB Color" group="1" tooltip="RGBA color mode (32 bits per pixel)" />
|
||||
<radio name="radio2" text="&Grayscale" group="1" tooltip="Value and Alpha (16 bits per pixel)" />
|
||||
</box>
|
||||
|
||||
<separator text="Background:" left="true" horizontal="true" />
|
||||
<view maxsize="true">
|
||||
<listbox name="bg_box">
|
||||
<listitem text="Transparent" />
|
||||
<listitem text="Black" />
|
||||
<listitem text="White" />
|
||||
<listitem text="Magenta" />
|
||||
<listitem text="Background Color" />
|
||||
</listbox>
|
||||
</view>
|
||||
|
||||
<box horizontal="true">
|
||||
<box horizontal="true" expansive="true" />
|
||||
<box horizontal="true" homogeneous="true">
|
||||
<button text="&OK" name="ok_button" magnetic="true" width="60" />
|
||||
<button text="&Cancel" />
|
||||
</box>
|
||||
</box>
|
||||
|
||||
</box>
|
||||
</box>
|
||||
</window>
|
||||
</window>
|
||||
</jinete>
|
||||
|
@ -68,8 +68,8 @@ NewFileCommand::NewFileCommand()
|
||||
*/
|
||||
void NewFileCommand::execute(Context* context)
|
||||
{
|
||||
JWidget width, height, radio1, radio2, radio3, ok, bg_box;
|
||||
int imgtype, w, h, bg;
|
||||
JWidget width, height, radio1, radio2, radio3, colors, ok, bg_box;
|
||||
int imgtype, w, h, bg, ncolors;
|
||||
char buf[1024];
|
||||
Sprite *sprite;
|
||||
color_t color;
|
||||
@ -80,18 +80,18 @@ void NewFileCommand::execute(Context* context)
|
||||
color_rgb(255, 0, 255),
|
||||
app_get_colorbar()->getBgColor()
|
||||
};
|
||||
int ncolors = 256;
|
||||
|
||||
// Load the window widget
|
||||
FramePtr window(load_widget("new_sprite.xml", "new_sprite"));
|
||||
|
||||
width = jwidget_find_name(window, "width");
|
||||
height = jwidget_find_name(window, "height");
|
||||
radio1 = jwidget_find_name(window, "radio1");
|
||||
radio2 = jwidget_find_name(window, "radio2");
|
||||
radio3 = jwidget_find_name(window, "radio3");
|
||||
ok = jwidget_find_name(window, "ok_button");
|
||||
bg_box = jwidget_find_name(window, "bg_box");
|
||||
get_widgets(window,
|
||||
"width", &width,
|
||||
"height", &height,
|
||||
"radio1", &radio1,
|
||||
"radio2", &radio2,
|
||||
"radio3", &radio3,
|
||||
"colors", &colors,
|
||||
"ok_button", &ok,
|
||||
"bg_box", &bg_box, NULL);
|
||||
|
||||
// Default values: Indexed, 320x240, Background color
|
||||
imgtype = get_config_int("NewSprite", "Type", IMAGE_INDEXED);
|
||||
@ -99,9 +99,11 @@ void NewFileCommand::execute(Context* context)
|
||||
w = get_config_int("NewSprite", "Width", 320);
|
||||
h = get_config_int("NewSprite", "Height", 240);
|
||||
bg = get_config_int("NewSprite", "Background", 4); // Default = Background color
|
||||
ncolors = get_config_int("NewSprite", "Colors", 256);
|
||||
|
||||
width->setTextf("%d", w);
|
||||
height->setTextf("%d", h);
|
||||
width->setTextf("%d", MAX(1, w));
|
||||
height->setTextf("%d", MAX(1, h));
|
||||
colors->setTextf("%d", MID(2, ncolors, 256));
|
||||
|
||||
// Select image-type
|
||||
switch (imgtype) {
|
||||
@ -126,10 +128,12 @@ void NewFileCommand::execute(Context* context)
|
||||
|
||||
w = width->getTextInt();
|
||||
h = height->getTextInt();
|
||||
ncolors = colors->getTextInt();
|
||||
bg = jlistbox_get_selected_index(bg_box);
|
||||
|
||||
w = MID(1, w, 9999);
|
||||
h = MID(1, h, 9999);
|
||||
ncolors = MID(2, ncolors, 256);
|
||||
|
||||
// Select the color
|
||||
color = color_mask();
|
||||
@ -147,7 +151,8 @@ void NewFileCommand::execute(Context* context)
|
||||
set_config_int("NewSprite", "Background", bg);
|
||||
|
||||
// Create the new sprite
|
||||
sprite = new_sprite(UIContext::instance(), imgtype, w, h, ncolors);
|
||||
sprite = new_sprite(UIContext::instance(), imgtype, w, h,
|
||||
imgtype == IMAGE_INDEXED ? ncolors: 256);
|
||||
if (!sprite) {
|
||||
Console console;
|
||||
console.printf("Not enough memory to allocate the sprite\n");
|
||||
|
Loading…
x
Reference in New Issue
Block a user