[aseprite] 25/51: Add option to include partial tiles in Import Sprite Sheet (fix #1161)
Tobias Hansen
thansen at moszumanska.debian.org
Mon Jul 11 21:35:16 UTC 2016
This is an automated email from the git hooks/post-receive script.
thansen pushed a commit to branch master
in repository aseprite.
commit 67ce9473f8ef697731b03ef0d126abd50b70869f
Author: David Capello <davidcapello at gmail.com>
Date: Fri Jul 1 10:24:44 2016 -0300
Add option to include partial tiles in Import Sprite Sheet (fix #1161)
---
data/pref.xml | 1 +
data/widgets/import_sprite_sheet.xml | 4 +++-
src/app/commands/cmd_import_sprite_sheet.cpp | 23 ++++++++++++++++++-----
3 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/data/pref.xml b/data/pref.xml
index 88513ab..6dd611e 100644
--- a/data/pref.xml
+++ b/data/pref.xml
@@ -290,6 +290,7 @@
<section id="import_sprite_sheet">
<option id="type" type="app::SpriteSheetType" default="app::SpriteSheetType::Rows" />
<option id="bounds" type="gfx::Rect" default="gfx::Rect(0, 0, 16, 16)" />
+ <option id="partial_tiles" type="bool" default="false" />
</section>
<section id="preview" text="Preview">
<option id="zoom" type="double" default="1.0" />
diff --git a/data/widgets/import_sprite_sheet.xml b/data/widgets/import_sprite_sheet.xml
index a6854e6..5c20cc4 100644
--- a/data/widgets/import_sprite_sheet.xml
+++ b/data/widgets/import_sprite_sheet.xml
@@ -1,5 +1,5 @@
<!-- ASEPRITE -->
-<!-- Copyright (C) 2001-2015 by David Capello -->
+<!-- Copyright (C) 2001-2016 by David Capello -->
<gui>
<window id="import_sprite_sheet" text="Import Sprite Sheet">
<grid columns="4">
@@ -18,6 +18,8 @@
<label text="Height" />
<entry id="height" text="16" maxsize="4" />
+ <check id="partial_tiles" text="Include partial tiles at bottom/right edges" cell_hspan="4" />
+
<hbox cell_hspan="4">
<boxfiller />
<hbox>
diff --git a/src/app/commands/cmd_import_sprite_sheet.cpp b/src/app/commands/cmd_import_sprite_sheet.cpp
index 820b10b..fa77992 100644
--- a/src/app/commands/cmd_import_sprite_sheet.cpp
+++ b/src/app/commands/cmd_import_sprite_sheet.cpp
@@ -1,5 +1,5 @@
// Aseprite
-// Copyright (C) 2001-2015 David Capello
+// Copyright (C) 2001-2016 David Capello
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
@@ -92,6 +92,10 @@ public:
return (app::SpriteSheetType)(sheetType()->getSelectedItemIndex()+1);
}
+ bool partialTilesValue() const {
+ return partialTiles()->isSelected();
+ }
+
bool ok() const {
return closer() == import();
}
@@ -214,6 +218,7 @@ private:
sheetType()->setSelectedItemIndex((int)app::SpriteSheetType::Rows-1);
onChangeRectangle(m_docPref->importSpriteSheet.bounds());
+ partialTiles()->setSelected(m_docPref->importSpriteSheet.partialTiles());
onEntriesChange();
}
}
@@ -305,6 +310,7 @@ void ImportSpriteSheetCommand::onExecute(Context* context)
Document* document = window.document();
DocumentPreferences* docPref = window.docPref();
gfx::Rect frameBounds = window.frameBounds();
+ bool partialTiles = window.partialTilesValue();
auto sheetType = window.sheetTypeValue();
ASSERT(document);
@@ -321,21 +327,27 @@ void ImportSpriteSheetCommand::onExecute(Context* context)
// Each sprite in the sheet
std::vector<gfx::Rect> tileRects;
+ int widthStop = sprite->width();
+ int heightStop = sprite->height();
+ if (partialTiles) {
+ widthStop += frameBounds.w-1;
+ heightStop += frameBounds.h-1;
+ }
switch (sheetType) {
case app::SpriteSheetType::Horizontal:
- for (int x=frameBounds.x; x+frameBounds.w<=sprite->width(); x += frameBounds.w) {
+ for (int x=frameBounds.x; x+frameBounds.w<=widthStop; x += frameBounds.w) {
tileRects.push_back(gfx::Rect(x, frameBounds.y, frameBounds.w, frameBounds.h));
}
break;
case app::SpriteSheetType::Vertical:
- for (int y=frameBounds.y; y+frameBounds.h<=sprite->height(); y += frameBounds.h) {
+ for (int y=frameBounds.y; y+frameBounds.h<=heightStop; y += frameBounds.h) {
tileRects.push_back(gfx::Rect(frameBounds.x, y, frameBounds.w, frameBounds.h));
}
break;
case app::SpriteSheetType::Rows:
- for (int y=frameBounds.y; y+frameBounds.h<=sprite->height(); y += frameBounds.h) {
- for (int x=frameBounds.x; x+frameBounds.w<=sprite->width(); x += frameBounds.w) {
+ for (int y=frameBounds.y; y+frameBounds.h<=heightStop; y += frameBounds.h) {
+ for (int x=frameBounds.x; x+frameBounds.w<=widthStop; x += frameBounds.w) {
tileRects.push_back(gfx::Rect(x, y, frameBounds.w, frameBounds.h));
}
}
@@ -411,6 +423,7 @@ void ImportSpriteSheetCommand::onExecute(Context* context)
if (docPref) {
docPref->importSpriteSheet.type(sheetType);
docPref->importSpriteSheet.bounds(frameBounds);
+ docPref->importSpriteSheet.partialTiles(partialTiles);
}
}
catch (...) {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/aseprite.git
More information about the Pkg-games-commits
mailing list