diff --git a/Checkbox.as b/Checkbox.as deleted file mode 100644 index c5aaba2..0000000 --- a/Checkbox.as +++ /dev/null @@ -1,42 +0,0 @@ -package { - - import flash.display.MovieClip; - import flash.events.MouseEvent; - - public class Checkbox extends MovieClip - { - public var Enabled:Boolean = true; - public function Checkbox() - { - checkbox.gotoAndStop(1); - checkbox.addEventListener(MouseEvent.CLICK, Clicked); - } - - protected function Clicked(event) - { - if (!Enabled) return; - Toggle(); - if (OnClick != null) OnClick(OnClickParam); - } - - protected var checked = false; - public function set Checked(value) { checked = value; checkbox.gotoAndStop(checked ? 2 : 1); } - public function get Checked() { return checked; } - - public function set Text(value) { text.text = value; } - - public var OnClickParam; - public var OnClick; - - - public function Toggle() - { - checked = !checked; - checkbox.gotoAndStop(checked ? 2 : 1); - - - } - - } - -} diff --git a/Checkbox.as b/Checkbox.as deleted file mode 100644 index c5aaba2..0000000 --- a/Checkbox.as +++ /dev/null @@ -1,42 +0,0 @@ -package { - - import flash.display.MovieClip; - import flash.events.MouseEvent; - - public class Checkbox extends MovieClip - { - public var Enabled:Boolean = true; - public function Checkbox() - { - checkbox.gotoAndStop(1); - checkbox.addEventListener(MouseEvent.CLICK, Clicked); - } - - protected function Clicked(event) - { - if (!Enabled) return; - Toggle(); - if (OnClick != null) OnClick(OnClickParam); - } - - protected var checked = false; - public function set Checked(value) { checked = value; checkbox.gotoAndStop(checked ? 2 : 1); } - public function get Checked() { return checked; } - - public function set Text(value) { text.text = value; } - - public var OnClickParam; - public var OnClick; - - - public function Toggle() - { - checked = !checked; - checkbox.gotoAndStop(checked ? 2 : 1); - - - } - - } - -} diff --git a/Exporter-app.xml b/Exporter-app.xml index dbb9ba7..7deb7c5 100755 --- a/Exporter-app.xml +++ b/Exporter-app.xml @@ -16,7 +16,7 @@ Japanese App name goes here --> - + Exporter 1.0 Exporter diff --git a/Checkbox.as b/Checkbox.as deleted file mode 100644 index c5aaba2..0000000 --- a/Checkbox.as +++ /dev/null @@ -1,42 +0,0 @@ -package { - - import flash.display.MovieClip; - import flash.events.MouseEvent; - - public class Checkbox extends MovieClip - { - public var Enabled:Boolean = true; - public function Checkbox() - { - checkbox.gotoAndStop(1); - checkbox.addEventListener(MouseEvent.CLICK, Clicked); - } - - protected function Clicked(event) - { - if (!Enabled) return; - Toggle(); - if (OnClick != null) OnClick(OnClickParam); - } - - protected var checked = false; - public function set Checked(value) { checked = value; checkbox.gotoAndStop(checked ? 2 : 1); } - public function get Checked() { return checked; } - - public function set Text(value) { text.text = value; } - - public var OnClickParam; - public var OnClick; - - - public function Toggle() - { - checked = !checked; - checkbox.gotoAndStop(checked ? 2 : 1); - - - } - - } - -} diff --git a/Exporter-app.xml b/Exporter-app.xml index dbb9ba7..7deb7c5 100755 --- a/Exporter-app.xml +++ b/Exporter-app.xml @@ -16,7 +16,7 @@ Japanese App name goes here --> - + Exporter 1.0 Exporter diff --git a/Exporter.exe b/Exporter.exe index aa5d57e..7833fe5 100755 --- a/Exporter.exe +++ b/Exporter.exe Binary files differ diff --git a/Checkbox.as b/Checkbox.as deleted file mode 100644 index c5aaba2..0000000 --- a/Checkbox.as +++ /dev/null @@ -1,42 +0,0 @@ -package { - - import flash.display.MovieClip; - import flash.events.MouseEvent; - - public class Checkbox extends MovieClip - { - public var Enabled:Boolean = true; - public function Checkbox() - { - checkbox.gotoAndStop(1); - checkbox.addEventListener(MouseEvent.CLICK, Clicked); - } - - protected function Clicked(event) - { - if (!Enabled) return; - Toggle(); - if (OnClick != null) OnClick(OnClickParam); - } - - protected var checked = false; - public function set Checked(value) { checked = value; checkbox.gotoAndStop(checked ? 2 : 1); } - public function get Checked() { return checked; } - - public function set Text(value) { text.text = value; } - - public var OnClickParam; - public var OnClick; - - - public function Toggle() - { - checked = !checked; - checkbox.gotoAndStop(checked ? 2 : 1); - - - } - - } - -} diff --git a/Exporter-app.xml b/Exporter-app.xml index dbb9ba7..7deb7c5 100755 --- a/Exporter-app.xml +++ b/Exporter-app.xml @@ -16,7 +16,7 @@ Japanese App name goes here --> - + Exporter 1.0 Exporter diff --git a/Exporter.exe b/Exporter.exe index aa5d57e..7833fe5 100755 --- a/Exporter.exe +++ b/Exporter.exe Binary files differ diff --git a/Exporter.swf b/Exporter.swf index 484f56c..9c7464a 100644 --- a/Exporter.swf +++ b/Exporter.swf Binary files differ diff --git a/Checkbox.as b/Checkbox.as deleted file mode 100644 index c5aaba2..0000000 --- a/Checkbox.as +++ /dev/null @@ -1,42 +0,0 @@ -package { - - import flash.display.MovieClip; - import flash.events.MouseEvent; - - public class Checkbox extends MovieClip - { - public var Enabled:Boolean = true; - public function Checkbox() - { - checkbox.gotoAndStop(1); - checkbox.addEventListener(MouseEvent.CLICK, Clicked); - } - - protected function Clicked(event) - { - if (!Enabled) return; - Toggle(); - if (OnClick != null) OnClick(OnClickParam); - } - - protected var checked = false; - public function set Checked(value) { checked = value; checkbox.gotoAndStop(checked ? 2 : 1); } - public function get Checked() { return checked; } - - public function set Text(value) { text.text = value; } - - public var OnClickParam; - public var OnClick; - - - public function Toggle() - { - checked = !checked; - checkbox.gotoAndStop(checked ? 2 : 1); - - - } - - } - -} diff --git a/Exporter-app.xml b/Exporter-app.xml index dbb9ba7..7deb7c5 100755 --- a/Exporter-app.xml +++ b/Exporter-app.xml @@ -16,7 +16,7 @@ Japanese App name goes here --> - + Exporter 1.0 Exporter diff --git a/Exporter.exe b/Exporter.exe index aa5d57e..7833fe5 100755 --- a/Exporter.exe +++ b/Exporter.exe Binary files differ diff --git a/Exporter.swf b/Exporter.swf index 484f56c..9c7464a 100644 --- a/Exporter.swf +++ b/Exporter.swf Binary files differ diff --git a/GraphicExport-app.xml b/GraphicExport-app.xml deleted file mode 100755 index 5144634..0000000 --- a/GraphicExport-app.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - GraphicExport - 1.0 - GraphicExport - - GraphicExport - - - GraphicExport.swf - standard - false - true - false - portrait - auto - true - true - true - - - false - false - desktop extendedDesktop diff --git a/Checkbox.as b/Checkbox.as deleted file mode 100644 index c5aaba2..0000000 --- a/Checkbox.as +++ /dev/null @@ -1,42 +0,0 @@ -package { - - import flash.display.MovieClip; - import flash.events.MouseEvent; - - public class Checkbox extends MovieClip - { - public var Enabled:Boolean = true; - public function Checkbox() - { - checkbox.gotoAndStop(1); - checkbox.addEventListener(MouseEvent.CLICK, Clicked); - } - - protected function Clicked(event) - { - if (!Enabled) return; - Toggle(); - if (OnClick != null) OnClick(OnClickParam); - } - - protected var checked = false; - public function set Checked(value) { checked = value; checkbox.gotoAndStop(checked ? 2 : 1); } - public function get Checked() { return checked; } - - public function set Text(value) { text.text = value; } - - public var OnClickParam; - public var OnClick; - - - public function Toggle() - { - checked = !checked; - checkbox.gotoAndStop(checked ? 2 : 1); - - - } - - } - -} diff --git a/Exporter-app.xml b/Exporter-app.xml index dbb9ba7..7deb7c5 100755 --- a/Exporter-app.xml +++ b/Exporter-app.xml @@ -16,7 +16,7 @@ Japanese App name goes here --> - + Exporter 1.0 Exporter diff --git a/Exporter.exe b/Exporter.exe index aa5d57e..7833fe5 100755 --- a/Exporter.exe +++ b/Exporter.exe Binary files differ diff --git a/Exporter.swf b/Exporter.swf index 484f56c..9c7464a 100644 --- a/Exporter.swf +++ b/Exporter.swf Binary files differ diff --git a/GraphicExport-app.xml b/GraphicExport-app.xml deleted file mode 100755 index 5144634..0000000 --- a/GraphicExport-app.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - GraphicExport - 1.0 - GraphicExport - - GraphicExport - - - GraphicExport.swf - standard - false - true - false - portrait - auto - true - true - true - - - false - false - desktop extendedDesktop diff --git a/GraphicExport.exe b/GraphicExport.exe deleted file mode 100755 index 56315aa..0000000 --- a/GraphicExport.exe +++ /dev/null Binary files differ diff --git a/Checkbox.as b/Checkbox.as deleted file mode 100644 index c5aaba2..0000000 --- a/Checkbox.as +++ /dev/null @@ -1,42 +0,0 @@ -package { - - import flash.display.MovieClip; - import flash.events.MouseEvent; - - public class Checkbox extends MovieClip - { - public var Enabled:Boolean = true; - public function Checkbox() - { - checkbox.gotoAndStop(1); - checkbox.addEventListener(MouseEvent.CLICK, Clicked); - } - - protected function Clicked(event) - { - if (!Enabled) return; - Toggle(); - if (OnClick != null) OnClick(OnClickParam); - } - - protected var checked = false; - public function set Checked(value) { checked = value; checkbox.gotoAndStop(checked ? 2 : 1); } - public function get Checked() { return checked; } - - public function set Text(value) { text.text = value; } - - public var OnClickParam; - public var OnClick; - - - public function Toggle() - { - checked = !checked; - checkbox.gotoAndStop(checked ? 2 : 1); - - - } - - } - -} diff --git a/Exporter-app.xml b/Exporter-app.xml index dbb9ba7..7deb7c5 100755 --- a/Exporter-app.xml +++ b/Exporter-app.xml @@ -16,7 +16,7 @@ Japanese App name goes here --> - + Exporter 1.0 Exporter diff --git a/Exporter.exe b/Exporter.exe index aa5d57e..7833fe5 100755 --- a/Exporter.exe +++ b/Exporter.exe Binary files differ diff --git a/Exporter.swf b/Exporter.swf index 484f56c..9c7464a 100644 --- a/Exporter.swf +++ b/Exporter.swf Binary files differ diff --git a/GraphicExport-app.xml b/GraphicExport-app.xml deleted file mode 100755 index 5144634..0000000 --- a/GraphicExport-app.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - GraphicExport - 1.0 - GraphicExport - - GraphicExport - - - GraphicExport.swf - standard - false - true - false - portrait - auto - true - true - true - - - false - false - desktop extendedDesktop diff --git a/GraphicExport.exe b/GraphicExport.exe deleted file mode 100755 index 56315aa..0000000 --- a/GraphicExport.exe +++ /dev/null Binary files differ diff --git a/GraphicExport.fla b/GraphicExport.fla deleted file mode 100755 index 0b78ed7..0000000 --- a/GraphicExport.fla +++ /dev/null Binary files differ diff --git a/Checkbox.as b/Checkbox.as deleted file mode 100644 index c5aaba2..0000000 --- a/Checkbox.as +++ /dev/null @@ -1,42 +0,0 @@ -package { - - import flash.display.MovieClip; - import flash.events.MouseEvent; - - public class Checkbox extends MovieClip - { - public var Enabled:Boolean = true; - public function Checkbox() - { - checkbox.gotoAndStop(1); - checkbox.addEventListener(MouseEvent.CLICK, Clicked); - } - - protected function Clicked(event) - { - if (!Enabled) return; - Toggle(); - if (OnClick != null) OnClick(OnClickParam); - } - - protected var checked = false; - public function set Checked(value) { checked = value; checkbox.gotoAndStop(checked ? 2 : 1); } - public function get Checked() { return checked; } - - public function set Text(value) { text.text = value; } - - public var OnClickParam; - public var OnClick; - - - public function Toggle() - { - checked = !checked; - checkbox.gotoAndStop(checked ? 2 : 1); - - - } - - } - -} diff --git a/Exporter-app.xml b/Exporter-app.xml index dbb9ba7..7deb7c5 100755 --- a/Exporter-app.xml +++ b/Exporter-app.xml @@ -16,7 +16,7 @@ Japanese App name goes here --> - + Exporter 1.0 Exporter diff --git a/Exporter.exe b/Exporter.exe index aa5d57e..7833fe5 100755 --- a/Exporter.exe +++ b/Exporter.exe Binary files differ diff --git a/Exporter.swf b/Exporter.swf index 484f56c..9c7464a 100644 --- a/Exporter.swf +++ b/Exporter.swf Binary files differ diff --git a/GraphicExport-app.xml b/GraphicExport-app.xml deleted file mode 100755 index 5144634..0000000 --- a/GraphicExport-app.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - GraphicExport - 1.0 - GraphicExport - - GraphicExport - - - GraphicExport.swf - standard - false - true - false - portrait - auto - true - true - true - - - false - false - desktop extendedDesktop diff --git a/GraphicExport.exe b/GraphicExport.exe deleted file mode 100755 index 56315aa..0000000 --- a/GraphicExport.exe +++ /dev/null Binary files differ diff --git a/GraphicExport.fla b/GraphicExport.fla deleted file mode 100755 index 0b78ed7..0000000 --- a/GraphicExport.fla +++ /dev/null Binary files differ diff --git a/GraphicExport.swf b/GraphicExport.swf deleted file mode 100644 index 542db97..0000000 --- a/GraphicExport.swf +++ /dev/null Binary files differ diff --git a/Checkbox.as b/Checkbox.as deleted file mode 100644 index c5aaba2..0000000 --- a/Checkbox.as +++ /dev/null @@ -1,42 +0,0 @@ -package { - - import flash.display.MovieClip; - import flash.events.MouseEvent; - - public class Checkbox extends MovieClip - { - public var Enabled:Boolean = true; - public function Checkbox() - { - checkbox.gotoAndStop(1); - checkbox.addEventListener(MouseEvent.CLICK, Clicked); - } - - protected function Clicked(event) - { - if (!Enabled) return; - Toggle(); - if (OnClick != null) OnClick(OnClickParam); - } - - protected var checked = false; - public function set Checked(value) { checked = value; checkbox.gotoAndStop(checked ? 2 : 1); } - public function get Checked() { return checked; } - - public function set Text(value) { text.text = value; } - - public var OnClickParam; - public var OnClick; - - - public function Toggle() - { - checked = !checked; - checkbox.gotoAndStop(checked ? 2 : 1); - - - } - - } - -} diff --git a/Exporter-app.xml b/Exporter-app.xml index dbb9ba7..7deb7c5 100755 --- a/Exporter-app.xml +++ b/Exporter-app.xml @@ -16,7 +16,7 @@ Japanese App name goes here --> - + Exporter 1.0 Exporter diff --git a/Exporter.exe b/Exporter.exe index aa5d57e..7833fe5 100755 --- a/Exporter.exe +++ b/Exporter.exe Binary files differ diff --git a/Exporter.swf b/Exporter.swf index 484f56c..9c7464a 100644 --- a/Exporter.swf +++ b/Exporter.swf Binary files differ diff --git a/GraphicExport-app.xml b/GraphicExport-app.xml deleted file mode 100755 index 5144634..0000000 --- a/GraphicExport-app.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - GraphicExport - 1.0 - GraphicExport - - GraphicExport - - - GraphicExport.swf - standard - false - true - false - portrait - auto - true - true - true - - - false - false - desktop extendedDesktop diff --git a/GraphicExport.exe b/GraphicExport.exe deleted file mode 100755 index 56315aa..0000000 --- a/GraphicExport.exe +++ /dev/null Binary files differ diff --git a/GraphicExport.fla b/GraphicExport.fla deleted file mode 100755 index 0b78ed7..0000000 --- a/GraphicExport.fla +++ /dev/null Binary files differ diff --git a/GraphicExport.swf b/GraphicExport.swf deleted file mode 100644 index 542db97..0000000 --- a/GraphicExport.swf +++ /dev/null Binary files differ diff --git a/NewGraphicDialog.as b/NewGraphicDialog.as deleted file mode 100644 index 152011c..0000000 --- a/NewGraphicDialog.as +++ /dev/null @@ -1,224 +0,0 @@ -package { - - import flash.display.MovieClip; - import flash.events.MouseEvent; - import flash.events.*; - import flash.filesystem.File; - import flash.net.FileFilter; - import Defs.GraphicDef; - import flash.text.engine.GraphicElement; - - public class NewGraphicDialog extends MovieClip - { - - public function NewGraphicDialog() - { - // constructor code - Init(); - } - - var typeButtons:Array = new Array(); - - public function Init() - { - graphicPath.text = "Path to Graphic Here"; - - this.removeChild(browseButton); - - var newBrowseButton = new UI_GenericBlueButton(); - newBrowseButton.Text = "Browse"; - newBrowseButton.OnClick = BrowseForFile; - newBrowseButton.x = browseButton.x + (newBrowseButton.width / 2); - newBrowseButton.y = browseButton.y + (newBrowseButton.height / 2); - addChild(newBrowseButton); - - var newTestButton = new UI_GenericBlueButton(); - newTestButton.Text = "Export"; - newTestButton.OnClick = TestFile; - newTestButton.x = testButton.x + (newTestButton.width / 2); - newTestButton.y = testButton.y + (newTestButton.height / 2); - addChild(newTestButton); - - this.removeChild(typePlaceholderButton); - - var typeX = typePlaceholderButton.x; - var typeY = typePlaceholderButton.y + (typePlaceholderButton.height / 2); - - - var typeButton = new UI_GenericBlueButton(); - typeButton.Text = "Graphic (1)"; - typeButton.OnClick = function(){ SetType(1); } - typeButton.x = typeX + (typeButton.width / 2); - typeButton.y = typeY; - typeButtons.push(typeButton); - addChild(typeButton); - - typeX += typeButton.width + 5; - - typeButton = new UI_GenericBlueButton(); - typeButton.Text = "Skeletal (3)"; - typeButton.OnClick = function(){ SetType(3); } - typeButton.x = typeX + (typeButton.width / 2); - typeButton.y = typeY; - typeButtons.push(typeButton); - addChild(typeButton); - - typeX += typeButton.width + 5; - - typeButton = new UI_GenericBlueButton(); - typeButton.Text = "Scene (6)"; - typeButton.OnClick = function(){ SetType(6); } - typeButton.x = typeX + (typeButton.width / 2); - typeButton.y = typeY; - typeButtons.push(typeButton); - addChild(typeButton); - - animationCheckbox.Checked = true; - //browseButton - //typePlaceholderButton - //usesInput - //usesText.text = "" - } - - var usesInputDefaultText = "Comma Seperated List of Uses Here"; - - public static var fakeID = 9999999; - public function TestFile() - { - fakeID++; - var graphicName = graphicPath.text; - var graphicData = {id:fakeID,graphic:graphicPath.text,v:1,fs:0,p:0,type:selectedType}; - - //"export_params":{"uses":["background"],"available_sizes":["default"],"compress":false}} - - var graphicDef = new GraphicDef(graphicData); - - this.Hide(); - graphicExport.ExportItem(graphicDef); - } - - var selectedType = 1; - public function SetType(type:Number) - { - selectedType = type; - - for(var i = 0; i < typeButtons.length; i++) - { - typeButtons[i].Enabled = true; - } - - animationCheckbox.visible = false; - - switch(type) - { - case 1: { - typeButtons[0].Enabled = false; - animationCheckbox.visible = true; - break; - } - case 3: typeButtons[1].Enabled = false; break; - case 6: typeButtons[2].Enabled = false; break; - } - } - - var graphicExport:GraphicExport; - public function Show(parentClip) - { - this.graphicExport = parentClip; - - parentClip.addChild(this); - - SetType(selectedType); - - var graphicList = GameData.Instance().GraphicDefines; - - var usesString:String = ""; - var uniqueUseTypes:Array = new Array(); - for (var i = 0; i < graphicList.length; i++) - { - var graphicDef:GraphicDef = graphicList[i]; - var uses = graphicDef.ExportParams['uses']; - for (var usage in uses) - { - if (uniqueUseTypes[uses[usage]] == null) - { - uniqueUseTypes[uses[usage]] = uses[usage]; - usesString += uses[usage] + ", "; - } - } - } - - graphicPath.text = ""; - - } - - public function CloseClicked(event) - { - Hide(); - } - - public function Hide() - { - if (this.parent != null) this.parent.removeChild(this); - } - - public function BrowseForFile() - { - var file:File = new File(); - var swfTypeFilter:FileFilter = new FileFilter("SWF Files","*.swf"); - file.addEventListener(Event.SELECT, openFile); - file.browse([swfTypeFilter]); - } - - private function openFile(event:Event):void - { - _strace(event.target.nativePath); - var path:String = event.target.nativePath; - var pathParts:Array = path.split("Graphics\\"); - if (pathParts.length == 2) - { - var fileRemainder:String = pathParts[1]; - var withoutExtension:String = fileRemainder.split(".")[0]; - var pattern:RegExp = /\\/g; - withoutExtension = withoutExtension.replace(pattern, "/"); - _strace(withoutExtension); - graphicPath.text = withoutExtension; - - if (withoutExtension.indexOf("Backgrounds") > -1) - { - SetType(6); - } - - if (withoutExtension.indexOf("Monsters") > -1) - { - SetType(3); - } - - if (withoutExtension.indexOf("Characters") > -1) - { - SetType(3); - } - - if (withoutExtension.indexOf("Portraits") > -1) - { - SetType(1); - } - - if (withoutExtension.indexOf("Quest") > -1) - { - SetType(1); - } - - if (withoutExtension.indexOf("Equipment") > -1) - { - SetType(1); - } - - - } - } - - - } - -} diff --git a/Checkbox.as b/Checkbox.as deleted file mode 100644 index c5aaba2..0000000 --- a/Checkbox.as +++ /dev/null @@ -1,42 +0,0 @@ -package { - - import flash.display.MovieClip; - import flash.events.MouseEvent; - - public class Checkbox extends MovieClip - { - public var Enabled:Boolean = true; - public function Checkbox() - { - checkbox.gotoAndStop(1); - checkbox.addEventListener(MouseEvent.CLICK, Clicked); - } - - protected function Clicked(event) - { - if (!Enabled) return; - Toggle(); - if (OnClick != null) OnClick(OnClickParam); - } - - protected var checked = false; - public function set Checked(value) { checked = value; checkbox.gotoAndStop(checked ? 2 : 1); } - public function get Checked() { return checked; } - - public function set Text(value) { text.text = value; } - - public var OnClickParam; - public var OnClick; - - - public function Toggle() - { - checked = !checked; - checkbox.gotoAndStop(checked ? 2 : 1); - - - } - - } - -} diff --git a/Exporter-app.xml b/Exporter-app.xml index dbb9ba7..7deb7c5 100755 --- a/Exporter-app.xml +++ b/Exporter-app.xml @@ -16,7 +16,7 @@ Japanese App name goes here --> - + Exporter 1.0 Exporter diff --git a/Exporter.exe b/Exporter.exe index aa5d57e..7833fe5 100755 --- a/Exporter.exe +++ b/Exporter.exe Binary files differ diff --git a/Exporter.swf b/Exporter.swf index 484f56c..9c7464a 100644 --- a/Exporter.swf +++ b/Exporter.swf Binary files differ diff --git a/GraphicExport-app.xml b/GraphicExport-app.xml deleted file mode 100755 index 5144634..0000000 --- a/GraphicExport-app.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - GraphicExport - 1.0 - GraphicExport - - GraphicExport - - - GraphicExport.swf - standard - false - true - false - portrait - auto - true - true - true - - - false - false - desktop extendedDesktop diff --git a/GraphicExport.exe b/GraphicExport.exe deleted file mode 100755 index 56315aa..0000000 --- a/GraphicExport.exe +++ /dev/null Binary files differ diff --git a/GraphicExport.fla b/GraphicExport.fla deleted file mode 100755 index 0b78ed7..0000000 --- a/GraphicExport.fla +++ /dev/null Binary files differ diff --git a/GraphicExport.swf b/GraphicExport.swf deleted file mode 100644 index 542db97..0000000 --- a/GraphicExport.swf +++ /dev/null Binary files differ diff --git a/NewGraphicDialog.as b/NewGraphicDialog.as deleted file mode 100644 index 152011c..0000000 --- a/NewGraphicDialog.as +++ /dev/null @@ -1,224 +0,0 @@ -package { - - import flash.display.MovieClip; - import flash.events.MouseEvent; - import flash.events.*; - import flash.filesystem.File; - import flash.net.FileFilter; - import Defs.GraphicDef; - import flash.text.engine.GraphicElement; - - public class NewGraphicDialog extends MovieClip - { - - public function NewGraphicDialog() - { - // constructor code - Init(); - } - - var typeButtons:Array = new Array(); - - public function Init() - { - graphicPath.text = "Path to Graphic Here"; - - this.removeChild(browseButton); - - var newBrowseButton = new UI_GenericBlueButton(); - newBrowseButton.Text = "Browse"; - newBrowseButton.OnClick = BrowseForFile; - newBrowseButton.x = browseButton.x + (newBrowseButton.width / 2); - newBrowseButton.y = browseButton.y + (newBrowseButton.height / 2); - addChild(newBrowseButton); - - var newTestButton = new UI_GenericBlueButton(); - newTestButton.Text = "Export"; - newTestButton.OnClick = TestFile; - newTestButton.x = testButton.x + (newTestButton.width / 2); - newTestButton.y = testButton.y + (newTestButton.height / 2); - addChild(newTestButton); - - this.removeChild(typePlaceholderButton); - - var typeX = typePlaceholderButton.x; - var typeY = typePlaceholderButton.y + (typePlaceholderButton.height / 2); - - - var typeButton = new UI_GenericBlueButton(); - typeButton.Text = "Graphic (1)"; - typeButton.OnClick = function(){ SetType(1); } - typeButton.x = typeX + (typeButton.width / 2); - typeButton.y = typeY; - typeButtons.push(typeButton); - addChild(typeButton); - - typeX += typeButton.width + 5; - - typeButton = new UI_GenericBlueButton(); - typeButton.Text = "Skeletal (3)"; - typeButton.OnClick = function(){ SetType(3); } - typeButton.x = typeX + (typeButton.width / 2); - typeButton.y = typeY; - typeButtons.push(typeButton); - addChild(typeButton); - - typeX += typeButton.width + 5; - - typeButton = new UI_GenericBlueButton(); - typeButton.Text = "Scene (6)"; - typeButton.OnClick = function(){ SetType(6); } - typeButton.x = typeX + (typeButton.width / 2); - typeButton.y = typeY; - typeButtons.push(typeButton); - addChild(typeButton); - - animationCheckbox.Checked = true; - //browseButton - //typePlaceholderButton - //usesInput - //usesText.text = "" - } - - var usesInputDefaultText = "Comma Seperated List of Uses Here"; - - public static var fakeID = 9999999; - public function TestFile() - { - fakeID++; - var graphicName = graphicPath.text; - var graphicData = {id:fakeID,graphic:graphicPath.text,v:1,fs:0,p:0,type:selectedType}; - - //"export_params":{"uses":["background"],"available_sizes":["default"],"compress":false}} - - var graphicDef = new GraphicDef(graphicData); - - this.Hide(); - graphicExport.ExportItem(graphicDef); - } - - var selectedType = 1; - public function SetType(type:Number) - { - selectedType = type; - - for(var i = 0; i < typeButtons.length; i++) - { - typeButtons[i].Enabled = true; - } - - animationCheckbox.visible = false; - - switch(type) - { - case 1: { - typeButtons[0].Enabled = false; - animationCheckbox.visible = true; - break; - } - case 3: typeButtons[1].Enabled = false; break; - case 6: typeButtons[2].Enabled = false; break; - } - } - - var graphicExport:GraphicExport; - public function Show(parentClip) - { - this.graphicExport = parentClip; - - parentClip.addChild(this); - - SetType(selectedType); - - var graphicList = GameData.Instance().GraphicDefines; - - var usesString:String = ""; - var uniqueUseTypes:Array = new Array(); - for (var i = 0; i < graphicList.length; i++) - { - var graphicDef:GraphicDef = graphicList[i]; - var uses = graphicDef.ExportParams['uses']; - for (var usage in uses) - { - if (uniqueUseTypes[uses[usage]] == null) - { - uniqueUseTypes[uses[usage]] = uses[usage]; - usesString += uses[usage] + ", "; - } - } - } - - graphicPath.text = ""; - - } - - public function CloseClicked(event) - { - Hide(); - } - - public function Hide() - { - if (this.parent != null) this.parent.removeChild(this); - } - - public function BrowseForFile() - { - var file:File = new File(); - var swfTypeFilter:FileFilter = new FileFilter("SWF Files","*.swf"); - file.addEventListener(Event.SELECT, openFile); - file.browse([swfTypeFilter]); - } - - private function openFile(event:Event):void - { - _strace(event.target.nativePath); - var path:String = event.target.nativePath; - var pathParts:Array = path.split("Graphics\\"); - if (pathParts.length == 2) - { - var fileRemainder:String = pathParts[1]; - var withoutExtension:String = fileRemainder.split(".")[0]; - var pattern:RegExp = /\\/g; - withoutExtension = withoutExtension.replace(pattern, "/"); - _strace(withoutExtension); - graphicPath.text = withoutExtension; - - if (withoutExtension.indexOf("Backgrounds") > -1) - { - SetType(6); - } - - if (withoutExtension.indexOf("Monsters") > -1) - { - SetType(3); - } - - if (withoutExtension.indexOf("Characters") > -1) - { - SetType(3); - } - - if (withoutExtension.indexOf("Portraits") > -1) - { - SetType(1); - } - - if (withoutExtension.indexOf("Quest") > -1) - { - SetType(1); - } - - if (withoutExtension.indexOf("Equipment") > -1) - { - SetType(1); - } - - - } - } - - - } - -} diff --git a/PNGExportHelper.as b/PNGExportHelper.as deleted file mode 100644 index f8c4c9d..0000000 --- a/PNGExportHelper.as +++ /dev/null @@ -1,253 +0,0 @@ -package -{ - import flash.display.*; - import com.adobe.images.*; - import flash.utils.*; - import flash.net.*; - import flash.geom.Matrix; - import flash.geom.Rectangle; - import flash.geom.Point; - - public class PNGExportHelper - { - public static var UseExpandedBitmaps = false; - public static var AlphaThreshold = 5; - - private static function ExpandBitmapBorders(bd:BitmapData, bgColor = 0x0, passes = 1):BitmapData - { - /* - var thresh:BitmapData = new BitmapData(bd.width, bd.height, true, bgColor); - thresh.threshold(bd, bd.rect, new Point(), "<", (20 << 24), bgColor, 0xFF000000, true); - */ - var sampled:BitmapData = new BitmapData(bd.width, bd.height, true, bgColor); - bd.lock(); - sampled.lock(); - - for (var y = 0; y < bd.height; y++) - { - for (var x = 0; x < bd.width; x++) - { - var oldVal:uint = bd.getPixel32(x, y); - var a:uint = (oldVal & 0xFF000000) >>> 24; - var rgb:uint = (oldVal & 0xFFFFFF); - if (a > AlphaThreshold) - { - sampled.setPixel32(x, y, (0xFF << 24) | rgb); - } - else - { - sampled.setPixel32(x, y, bgColor); - } - } - } - sampled.unlock(); - bd.unlock(); - - return ExpandBitmapBordersInternal(sampled, bgColor, passes); - } - - private static function ExpandBitmapBordersInternal(bd:BitmapData, bgColor, passes):BitmapData - { - var output:BitmapData = new BitmapData(bd.width, bd.height, true, bgColor); - - var scale = 16; - var scaled:BitmapData = new BitmapData(bd.width/scale, bd.height/scale, true, bgColor); - var mat:Matrix = new Matrix(); - mat.scale(1/scale, 1/scale); - scaled.draw(bd, mat, null, null, null, true); - - output.lock(); - - var colors:Array = new Array(); - var weights:Array = new Array(); - - for (var oy = 0; oy < scaled.height; oy++) - { - - for (var ox = 0; ox < scaled.width; ox++) - { - - var scaledVal:uint = scaled.getPixel32(ox, oy); - var scaleda:uint = (scaledVal & 0xFF000000) >>> 24; - if (scaleda == 0 || scaleda == 255) - { - output.copyPixels(bd, new Rectangle(ox * scale, oy * scale, scale, scale), new Point(ox * scale, oy * scale)); - continue; - } else { - //_strace(scaleda+""); - } - - - for (var y = oy * scale; y < oy * scale + scale; y++) - { - for (var x = ox * scale; x < ox * scale + scale; x++) - { - var oldVal:uint = bd.getPixel32(x, y); - var a:uint = (oldVal & 0xFF000000) >>> 24; - var rgb:uint = (oldVal & 0xFFFFFF); - - if (a == 0 && rgb == bgColor) - { - colors.length = 0; - weights.length = 0; - - for (var y1 = y - 2; y1 <= y + 2; y1++) - { - for (var x1 = x - 2; x1 <= x + 2; x1++) - { - var dist = Math.abs(x1 - x) + Math.abs(y1 - y); - if (dist >= 3) continue; - - if (x1 >= 0 && x1 < bd.width && y1 >= 0 && y1 < bd.height) - { - colors.push(bd.getPixel(x1, y1)); - weights.push(1 - dist * 0.2); - } - } - } - - var newVal = AveragePixels(colors, weights, bgColor); - if (newVal == null) - { - newVal = oldVal; - } - else - { - var newR:uint = (newVal & 0xFF0000) >> 16; - var newG:uint = (newVal & 0xFF00) >> 8; - var newB:uint = (newVal & 0xFF); - - if (newVal != 0 && colors.length >= 4) - { - var bp = true; - } - - var sorted = colors.sort(function(a, b) - { - var aR:uint = (a & 0xFF0000) >> 16; - var aG:uint = (a & 0xFF00) >> 8; - var aB:uint = (a & 0xFF); - - var bR:uint = (b & 0xFF0000) >> 16; - var bG:uint = (b & 0xFF00) >> 8; - var bB:uint = (b & 0xFF); - - var diffA = Math.abs(aR - newR) + Math.abs(aG - newG) + Math.abs(aB - newB); - var diffB = Math.abs(bR - newR) + Math.abs(bG - newG) + Math.abs(bB - newB); - - return diffA - diffB; - - }, Array.RETURNINDEXEDARRAY | Array.DESCENDING); - - var toRemove = Math.min(2, colors.length - 4); - var removed = 0; - for (var i = 0; i < colors.length; i++) - { - var index = sorted.indexOf(i + removed); - if (index < toRemove) - { - colors.splice(i, 1); - weights.splice(i, 1); - removed++; - i--; - if (removed == toRemove) break; - } - } - - var fixOutliersVal = AveragePixels(colors, weights, bgColor); - if (fixOutliersVal == null) newVal = (0xFF << 24) | newVal; - - newVal = (0xFF << 24) | fixOutliersVal; - } - - output.setPixel32(x, y, newVal); - } - else - { - output.setPixel32(x, y, oldVal); - } - } - } - }//end outer scaled x - }//End outer scaled y - - bd.unlock(); - output.unlock(); - - passes--; - if (passes > 0) - { - return ExpandBitmapBordersInternal(output, bgColor, passes); - } - else - { - return output; - } - } - - private static function AveragePixels(colors:Array, weights:Array, bgColor:uint):uint - { - var rTotal = 0; - var gTotal = 0; - var bTotal = 0; - - var wTotal = 0; - - for (var i = 0; i < colors.length; i++) - { - var color:uint = colors[i]; - var a:uint = (color & 0xFF000000) >>> 24; - var rgb:uint = (color & 0xFFFFFF); - - if (a == 0 && rgb == bgColor) - { - colors.splice(i, 1); - weights.splice(i, 1); - i--; - continue; - } - - var r:uint = (rgb & 0xFF0000) >>> 16; - var g:uint = (rgb & 0xFF00) >>> 8; - var b:uint = (rgb & 0xFF); - var w = weights[i]; - - rTotal += w * r; - gTotal += w * g; - bTotal += w * b; - - wTotal += w; - } - - if (wTotal == 0) - { - return null; - } - - rTotal /= wTotal; - gTotal /= wTotal; - bTotal /= wTotal; - - var rFinal = Math.max(0, Math.min(255, Math.round(rTotal))); - var gFinal = Math.max(0, Math.min(255, Math.round(gTotal))); - var bFinal = Math.max(0, Math.min(255, Math.round(bTotal))); - - return (uint(rFinal) << 16) | (uint(gFinal) << 8) | (uint(bFinal)); - } - - - - public static function GetExportPNG(bd:BitmapData):ByteArray - { - if (!UseExpandedBitmaps) return PNGEncoder.encode(bd); - - var expanded:BitmapData = ExpandBitmapBorders(bd, 0x0, 2); - - //var fr:FileReference = new FileReference(); - //fr.save(PNGEncoder.encode(expanded), "output.png"); - - return PNGEncoderWithAlpha.encode(expanded, bd); - } - - } -} \ No newline at end of file diff --git a/Checkbox.as b/Checkbox.as deleted file mode 100644 index c5aaba2..0000000 --- a/Checkbox.as +++ /dev/null @@ -1,42 +0,0 @@ -package { - - import flash.display.MovieClip; - import flash.events.MouseEvent; - - public class Checkbox extends MovieClip - { - public var Enabled:Boolean = true; - public function Checkbox() - { - checkbox.gotoAndStop(1); - checkbox.addEventListener(MouseEvent.CLICK, Clicked); - } - - protected function Clicked(event) - { - if (!Enabled) return; - Toggle(); - if (OnClick != null) OnClick(OnClickParam); - } - - protected var checked = false; - public function set Checked(value) { checked = value; checkbox.gotoAndStop(checked ? 2 : 1); } - public function get Checked() { return checked; } - - public function set Text(value) { text.text = value; } - - public var OnClickParam; - public var OnClick; - - - public function Toggle() - { - checked = !checked; - checkbox.gotoAndStop(checked ? 2 : 1); - - - } - - } - -} diff --git a/Exporter-app.xml b/Exporter-app.xml index dbb9ba7..7deb7c5 100755 --- a/Exporter-app.xml +++ b/Exporter-app.xml @@ -16,7 +16,7 @@ Japanese App name goes here --> - + Exporter 1.0 Exporter diff --git a/Exporter.exe b/Exporter.exe index aa5d57e..7833fe5 100755 --- a/Exporter.exe +++ b/Exporter.exe Binary files differ diff --git a/Exporter.swf b/Exporter.swf index 484f56c..9c7464a 100644 --- a/Exporter.swf +++ b/Exporter.swf Binary files differ diff --git a/GraphicExport-app.xml b/GraphicExport-app.xml deleted file mode 100755 index 5144634..0000000 --- a/GraphicExport-app.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - GraphicExport - 1.0 - GraphicExport - - GraphicExport - - - GraphicExport.swf - standard - false - true - false - portrait - auto - true - true - true - - - false - false - desktop extendedDesktop diff --git a/GraphicExport.exe b/GraphicExport.exe deleted file mode 100755 index 56315aa..0000000 --- a/GraphicExport.exe +++ /dev/null Binary files differ diff --git a/GraphicExport.fla b/GraphicExport.fla deleted file mode 100755 index 0b78ed7..0000000 --- a/GraphicExport.fla +++ /dev/null Binary files differ diff --git a/GraphicExport.swf b/GraphicExport.swf deleted file mode 100644 index 542db97..0000000 --- a/GraphicExport.swf +++ /dev/null Binary files differ diff --git a/NewGraphicDialog.as b/NewGraphicDialog.as deleted file mode 100644 index 152011c..0000000 --- a/NewGraphicDialog.as +++ /dev/null @@ -1,224 +0,0 @@ -package { - - import flash.display.MovieClip; - import flash.events.MouseEvent; - import flash.events.*; - import flash.filesystem.File; - import flash.net.FileFilter; - import Defs.GraphicDef; - import flash.text.engine.GraphicElement; - - public class NewGraphicDialog extends MovieClip - { - - public function NewGraphicDialog() - { - // constructor code - Init(); - } - - var typeButtons:Array = new Array(); - - public function Init() - { - graphicPath.text = "Path to Graphic Here"; - - this.removeChild(browseButton); - - var newBrowseButton = new UI_GenericBlueButton(); - newBrowseButton.Text = "Browse"; - newBrowseButton.OnClick = BrowseForFile; - newBrowseButton.x = browseButton.x + (newBrowseButton.width / 2); - newBrowseButton.y = browseButton.y + (newBrowseButton.height / 2); - addChild(newBrowseButton); - - var newTestButton = new UI_GenericBlueButton(); - newTestButton.Text = "Export"; - newTestButton.OnClick = TestFile; - newTestButton.x = testButton.x + (newTestButton.width / 2); - newTestButton.y = testButton.y + (newTestButton.height / 2); - addChild(newTestButton); - - this.removeChild(typePlaceholderButton); - - var typeX = typePlaceholderButton.x; - var typeY = typePlaceholderButton.y + (typePlaceholderButton.height / 2); - - - var typeButton = new UI_GenericBlueButton(); - typeButton.Text = "Graphic (1)"; - typeButton.OnClick = function(){ SetType(1); } - typeButton.x = typeX + (typeButton.width / 2); - typeButton.y = typeY; - typeButtons.push(typeButton); - addChild(typeButton); - - typeX += typeButton.width + 5; - - typeButton = new UI_GenericBlueButton(); - typeButton.Text = "Skeletal (3)"; - typeButton.OnClick = function(){ SetType(3); } - typeButton.x = typeX + (typeButton.width / 2); - typeButton.y = typeY; - typeButtons.push(typeButton); - addChild(typeButton); - - typeX += typeButton.width + 5; - - typeButton = new UI_GenericBlueButton(); - typeButton.Text = "Scene (6)"; - typeButton.OnClick = function(){ SetType(6); } - typeButton.x = typeX + (typeButton.width / 2); - typeButton.y = typeY; - typeButtons.push(typeButton); - addChild(typeButton); - - animationCheckbox.Checked = true; - //browseButton - //typePlaceholderButton - //usesInput - //usesText.text = "" - } - - var usesInputDefaultText = "Comma Seperated List of Uses Here"; - - public static var fakeID = 9999999; - public function TestFile() - { - fakeID++; - var graphicName = graphicPath.text; - var graphicData = {id:fakeID,graphic:graphicPath.text,v:1,fs:0,p:0,type:selectedType}; - - //"export_params":{"uses":["background"],"available_sizes":["default"],"compress":false}} - - var graphicDef = new GraphicDef(graphicData); - - this.Hide(); - graphicExport.ExportItem(graphicDef); - } - - var selectedType = 1; - public function SetType(type:Number) - { - selectedType = type; - - for(var i = 0; i < typeButtons.length; i++) - { - typeButtons[i].Enabled = true; - } - - animationCheckbox.visible = false; - - switch(type) - { - case 1: { - typeButtons[0].Enabled = false; - animationCheckbox.visible = true; - break; - } - case 3: typeButtons[1].Enabled = false; break; - case 6: typeButtons[2].Enabled = false; break; - } - } - - var graphicExport:GraphicExport; - public function Show(parentClip) - { - this.graphicExport = parentClip; - - parentClip.addChild(this); - - SetType(selectedType); - - var graphicList = GameData.Instance().GraphicDefines; - - var usesString:String = ""; - var uniqueUseTypes:Array = new Array(); - for (var i = 0; i < graphicList.length; i++) - { - var graphicDef:GraphicDef = graphicList[i]; - var uses = graphicDef.ExportParams['uses']; - for (var usage in uses) - { - if (uniqueUseTypes[uses[usage]] == null) - { - uniqueUseTypes[uses[usage]] = uses[usage]; - usesString += uses[usage] + ", "; - } - } - } - - graphicPath.text = ""; - - } - - public function CloseClicked(event) - { - Hide(); - } - - public function Hide() - { - if (this.parent != null) this.parent.removeChild(this); - } - - public function BrowseForFile() - { - var file:File = new File(); - var swfTypeFilter:FileFilter = new FileFilter("SWF Files","*.swf"); - file.addEventListener(Event.SELECT, openFile); - file.browse([swfTypeFilter]); - } - - private function openFile(event:Event):void - { - _strace(event.target.nativePath); - var path:String = event.target.nativePath; - var pathParts:Array = path.split("Graphics\\"); - if (pathParts.length == 2) - { - var fileRemainder:String = pathParts[1]; - var withoutExtension:String = fileRemainder.split(".")[0]; - var pattern:RegExp = /\\/g; - withoutExtension = withoutExtension.replace(pattern, "/"); - _strace(withoutExtension); - graphicPath.text = withoutExtension; - - if (withoutExtension.indexOf("Backgrounds") > -1) - { - SetType(6); - } - - if (withoutExtension.indexOf("Monsters") > -1) - { - SetType(3); - } - - if (withoutExtension.indexOf("Characters") > -1) - { - SetType(3); - } - - if (withoutExtension.indexOf("Portraits") > -1) - { - SetType(1); - } - - if (withoutExtension.indexOf("Quest") > -1) - { - SetType(1); - } - - if (withoutExtension.indexOf("Equipment") > -1) - { - SetType(1); - } - - - } - } - - - } - -} diff --git a/PNGExportHelper.as b/PNGExportHelper.as deleted file mode 100644 index f8c4c9d..0000000 --- a/PNGExportHelper.as +++ /dev/null @@ -1,253 +0,0 @@ -package -{ - import flash.display.*; - import com.adobe.images.*; - import flash.utils.*; - import flash.net.*; - import flash.geom.Matrix; - import flash.geom.Rectangle; - import flash.geom.Point; - - public class PNGExportHelper - { - public static var UseExpandedBitmaps = false; - public static var AlphaThreshold = 5; - - private static function ExpandBitmapBorders(bd:BitmapData, bgColor = 0x0, passes = 1):BitmapData - { - /* - var thresh:BitmapData = new BitmapData(bd.width, bd.height, true, bgColor); - thresh.threshold(bd, bd.rect, new Point(), "<", (20 << 24), bgColor, 0xFF000000, true); - */ - var sampled:BitmapData = new BitmapData(bd.width, bd.height, true, bgColor); - bd.lock(); - sampled.lock(); - - for (var y = 0; y < bd.height; y++) - { - for (var x = 0; x < bd.width; x++) - { - var oldVal:uint = bd.getPixel32(x, y); - var a:uint = (oldVal & 0xFF000000) >>> 24; - var rgb:uint = (oldVal & 0xFFFFFF); - if (a > AlphaThreshold) - { - sampled.setPixel32(x, y, (0xFF << 24) | rgb); - } - else - { - sampled.setPixel32(x, y, bgColor); - } - } - } - sampled.unlock(); - bd.unlock(); - - return ExpandBitmapBordersInternal(sampled, bgColor, passes); - } - - private static function ExpandBitmapBordersInternal(bd:BitmapData, bgColor, passes):BitmapData - { - var output:BitmapData = new BitmapData(bd.width, bd.height, true, bgColor); - - var scale = 16; - var scaled:BitmapData = new BitmapData(bd.width/scale, bd.height/scale, true, bgColor); - var mat:Matrix = new Matrix(); - mat.scale(1/scale, 1/scale); - scaled.draw(bd, mat, null, null, null, true); - - output.lock(); - - var colors:Array = new Array(); - var weights:Array = new Array(); - - for (var oy = 0; oy < scaled.height; oy++) - { - - for (var ox = 0; ox < scaled.width; ox++) - { - - var scaledVal:uint = scaled.getPixel32(ox, oy); - var scaleda:uint = (scaledVal & 0xFF000000) >>> 24; - if (scaleda == 0 || scaleda == 255) - { - output.copyPixels(bd, new Rectangle(ox * scale, oy * scale, scale, scale), new Point(ox * scale, oy * scale)); - continue; - } else { - //_strace(scaleda+""); - } - - - for (var y = oy * scale; y < oy * scale + scale; y++) - { - for (var x = ox * scale; x < ox * scale + scale; x++) - { - var oldVal:uint = bd.getPixel32(x, y); - var a:uint = (oldVal & 0xFF000000) >>> 24; - var rgb:uint = (oldVal & 0xFFFFFF); - - if (a == 0 && rgb == bgColor) - { - colors.length = 0; - weights.length = 0; - - for (var y1 = y - 2; y1 <= y + 2; y1++) - { - for (var x1 = x - 2; x1 <= x + 2; x1++) - { - var dist = Math.abs(x1 - x) + Math.abs(y1 - y); - if (dist >= 3) continue; - - if (x1 >= 0 && x1 < bd.width && y1 >= 0 && y1 < bd.height) - { - colors.push(bd.getPixel(x1, y1)); - weights.push(1 - dist * 0.2); - } - } - } - - var newVal = AveragePixels(colors, weights, bgColor); - if (newVal == null) - { - newVal = oldVal; - } - else - { - var newR:uint = (newVal & 0xFF0000) >> 16; - var newG:uint = (newVal & 0xFF00) >> 8; - var newB:uint = (newVal & 0xFF); - - if (newVal != 0 && colors.length >= 4) - { - var bp = true; - } - - var sorted = colors.sort(function(a, b) - { - var aR:uint = (a & 0xFF0000) >> 16; - var aG:uint = (a & 0xFF00) >> 8; - var aB:uint = (a & 0xFF); - - var bR:uint = (b & 0xFF0000) >> 16; - var bG:uint = (b & 0xFF00) >> 8; - var bB:uint = (b & 0xFF); - - var diffA = Math.abs(aR - newR) + Math.abs(aG - newG) + Math.abs(aB - newB); - var diffB = Math.abs(bR - newR) + Math.abs(bG - newG) + Math.abs(bB - newB); - - return diffA - diffB; - - }, Array.RETURNINDEXEDARRAY | Array.DESCENDING); - - var toRemove = Math.min(2, colors.length - 4); - var removed = 0; - for (var i = 0; i < colors.length; i++) - { - var index = sorted.indexOf(i + removed); - if (index < toRemove) - { - colors.splice(i, 1); - weights.splice(i, 1); - removed++; - i--; - if (removed == toRemove) break; - } - } - - var fixOutliersVal = AveragePixels(colors, weights, bgColor); - if (fixOutliersVal == null) newVal = (0xFF << 24) | newVal; - - newVal = (0xFF << 24) | fixOutliersVal; - } - - output.setPixel32(x, y, newVal); - } - else - { - output.setPixel32(x, y, oldVal); - } - } - } - }//end outer scaled x - }//End outer scaled y - - bd.unlock(); - output.unlock(); - - passes--; - if (passes > 0) - { - return ExpandBitmapBordersInternal(output, bgColor, passes); - } - else - { - return output; - } - } - - private static function AveragePixels(colors:Array, weights:Array, bgColor:uint):uint - { - var rTotal = 0; - var gTotal = 0; - var bTotal = 0; - - var wTotal = 0; - - for (var i = 0; i < colors.length; i++) - { - var color:uint = colors[i]; - var a:uint = (color & 0xFF000000) >>> 24; - var rgb:uint = (color & 0xFFFFFF); - - if (a == 0 && rgb == bgColor) - { - colors.splice(i, 1); - weights.splice(i, 1); - i--; - continue; - } - - var r:uint = (rgb & 0xFF0000) >>> 16; - var g:uint = (rgb & 0xFF00) >>> 8; - var b:uint = (rgb & 0xFF); - var w = weights[i]; - - rTotal += w * r; - gTotal += w * g; - bTotal += w * b; - - wTotal += w; - } - - if (wTotal == 0) - { - return null; - } - - rTotal /= wTotal; - gTotal /= wTotal; - bTotal /= wTotal; - - var rFinal = Math.max(0, Math.min(255, Math.round(rTotal))); - var gFinal = Math.max(0, Math.min(255, Math.round(gTotal))); - var bFinal = Math.max(0, Math.min(255, Math.round(bTotal))); - - return (uint(rFinal) << 16) | (uint(gFinal) << 8) | (uint(bFinal)); - } - - - - public static function GetExportPNG(bd:BitmapData):ByteArray - { - if (!UseExpandedBitmaps) return PNGEncoder.encode(bd); - - var expanded:BitmapData = ExpandBitmapBorders(bd, 0x0, 2); - - //var fr:FileReference = new FileReference(); - //fr.save(PNGEncoder.encode(expanded), "output.png"); - - return PNGEncoderWithAlpha.encode(expanded, bd); - } - - } -} \ No newline at end of file diff --git a/PreviewHolder.as b/PreviewHolder.as deleted file mode 100644 index 587bf68..0000000 --- a/PreviewHolder.as +++ /dev/null @@ -1,57 +0,0 @@ -package { - import flash.display.MovieClip; - - public class PreviewHolder extends MovieClip - { - - var startingWidth = 1024; - var startingHeight = 1024; - - public function PreviewHolder() - { - startingWidth = this.width; - startingHeight = this.height; - } - - var clips:Array = new Array(); - public function AddClip(clip) - { - clips.push(clip); - this.addChild(clip); - ArrangeClips(); - } - - public function ArrangeClips() - { - var numCols = Math.ceil(Math.sqrt(clips.length)); - var maxY = 0; - var maxX = 0; - var clipIndex = 0; - for (var row = 0; row < numCols; row++) - { - var clipX = 0; - var clipY = maxY; - for (var col = 0; col < numCols; col++) - { - if (clipIndex == clips.length) break; - clips[clipIndex].x = clipX; - clips[clipIndex].y = clipY; - clipX += clips[clipIndex].width; - var clipBottom = clips[clipIndex].y + clips[clipIndex].height; - if (clipBottom > maxY) maxY = clipBottom; - - var clipRight = clips[clipIndex].x + clips[clipIndex].width; - if (clipRight > maxX) maxX = clipRight; - clipIndex++; - } - } - - var scale = Math.min(startingWidth / maxX, startingHeight / maxY); - if (scale > 1) scale = 1; - - this.scaleX = this.scaleY = scale; - } - - } - -} diff --git a/Checkbox.as b/Checkbox.as deleted file mode 100644 index c5aaba2..0000000 --- a/Checkbox.as +++ /dev/null @@ -1,42 +0,0 @@ -package { - - import flash.display.MovieClip; - import flash.events.MouseEvent; - - public class Checkbox extends MovieClip - { - public var Enabled:Boolean = true; - public function Checkbox() - { - checkbox.gotoAndStop(1); - checkbox.addEventListener(MouseEvent.CLICK, Clicked); - } - - protected function Clicked(event) - { - if (!Enabled) return; - Toggle(); - if (OnClick != null) OnClick(OnClickParam); - } - - protected var checked = false; - public function set Checked(value) { checked = value; checkbox.gotoAndStop(checked ? 2 : 1); } - public function get Checked() { return checked; } - - public function set Text(value) { text.text = value; } - - public var OnClickParam; - public var OnClick; - - - public function Toggle() - { - checked = !checked; - checkbox.gotoAndStop(checked ? 2 : 1); - - - } - - } - -} diff --git a/Exporter-app.xml b/Exporter-app.xml index dbb9ba7..7deb7c5 100755 --- a/Exporter-app.xml +++ b/Exporter-app.xml @@ -16,7 +16,7 @@ Japanese App name goes here --> - + Exporter 1.0 Exporter diff --git a/Exporter.exe b/Exporter.exe index aa5d57e..7833fe5 100755 --- a/Exporter.exe +++ b/Exporter.exe Binary files differ diff --git a/Exporter.swf b/Exporter.swf index 484f56c..9c7464a 100644 --- a/Exporter.swf +++ b/Exporter.swf Binary files differ diff --git a/GraphicExport-app.xml b/GraphicExport-app.xml deleted file mode 100755 index 5144634..0000000 --- a/GraphicExport-app.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - GraphicExport - 1.0 - GraphicExport - - GraphicExport - - - GraphicExport.swf - standard - false - true - false - portrait - auto - true - true - true - - - false - false - desktop extendedDesktop diff --git a/GraphicExport.exe b/GraphicExport.exe deleted file mode 100755 index 56315aa..0000000 --- a/GraphicExport.exe +++ /dev/null Binary files differ diff --git a/GraphicExport.fla b/GraphicExport.fla deleted file mode 100755 index 0b78ed7..0000000 --- a/GraphicExport.fla +++ /dev/null Binary files differ diff --git a/GraphicExport.swf b/GraphicExport.swf deleted file mode 100644 index 542db97..0000000 --- a/GraphicExport.swf +++ /dev/null Binary files differ diff --git a/NewGraphicDialog.as b/NewGraphicDialog.as deleted file mode 100644 index 152011c..0000000 --- a/NewGraphicDialog.as +++ /dev/null @@ -1,224 +0,0 @@ -package { - - import flash.display.MovieClip; - import flash.events.MouseEvent; - import flash.events.*; - import flash.filesystem.File; - import flash.net.FileFilter; - import Defs.GraphicDef; - import flash.text.engine.GraphicElement; - - public class NewGraphicDialog extends MovieClip - { - - public function NewGraphicDialog() - { - // constructor code - Init(); - } - - var typeButtons:Array = new Array(); - - public function Init() - { - graphicPath.text = "Path to Graphic Here"; - - this.removeChild(browseButton); - - var newBrowseButton = new UI_GenericBlueButton(); - newBrowseButton.Text = "Browse"; - newBrowseButton.OnClick = BrowseForFile; - newBrowseButton.x = browseButton.x + (newBrowseButton.width / 2); - newBrowseButton.y = browseButton.y + (newBrowseButton.height / 2); - addChild(newBrowseButton); - - var newTestButton = new UI_GenericBlueButton(); - newTestButton.Text = "Export"; - newTestButton.OnClick = TestFile; - newTestButton.x = testButton.x + (newTestButton.width / 2); - newTestButton.y = testButton.y + (newTestButton.height / 2); - addChild(newTestButton); - - this.removeChild(typePlaceholderButton); - - var typeX = typePlaceholderButton.x; - var typeY = typePlaceholderButton.y + (typePlaceholderButton.height / 2); - - - var typeButton = new UI_GenericBlueButton(); - typeButton.Text = "Graphic (1)"; - typeButton.OnClick = function(){ SetType(1); } - typeButton.x = typeX + (typeButton.width / 2); - typeButton.y = typeY; - typeButtons.push(typeButton); - addChild(typeButton); - - typeX += typeButton.width + 5; - - typeButton = new UI_GenericBlueButton(); - typeButton.Text = "Skeletal (3)"; - typeButton.OnClick = function(){ SetType(3); } - typeButton.x = typeX + (typeButton.width / 2); - typeButton.y = typeY; - typeButtons.push(typeButton); - addChild(typeButton); - - typeX += typeButton.width + 5; - - typeButton = new UI_GenericBlueButton(); - typeButton.Text = "Scene (6)"; - typeButton.OnClick = function(){ SetType(6); } - typeButton.x = typeX + (typeButton.width / 2); - typeButton.y = typeY; - typeButtons.push(typeButton); - addChild(typeButton); - - animationCheckbox.Checked = true; - //browseButton - //typePlaceholderButton - //usesInput - //usesText.text = "" - } - - var usesInputDefaultText = "Comma Seperated List of Uses Here"; - - public static var fakeID = 9999999; - public function TestFile() - { - fakeID++; - var graphicName = graphicPath.text; - var graphicData = {id:fakeID,graphic:graphicPath.text,v:1,fs:0,p:0,type:selectedType}; - - //"export_params":{"uses":["background"],"available_sizes":["default"],"compress":false}} - - var graphicDef = new GraphicDef(graphicData); - - this.Hide(); - graphicExport.ExportItem(graphicDef); - } - - var selectedType = 1; - public function SetType(type:Number) - { - selectedType = type; - - for(var i = 0; i < typeButtons.length; i++) - { - typeButtons[i].Enabled = true; - } - - animationCheckbox.visible = false; - - switch(type) - { - case 1: { - typeButtons[0].Enabled = false; - animationCheckbox.visible = true; - break; - } - case 3: typeButtons[1].Enabled = false; break; - case 6: typeButtons[2].Enabled = false; break; - } - } - - var graphicExport:GraphicExport; - public function Show(parentClip) - { - this.graphicExport = parentClip; - - parentClip.addChild(this); - - SetType(selectedType); - - var graphicList = GameData.Instance().GraphicDefines; - - var usesString:String = ""; - var uniqueUseTypes:Array = new Array(); - for (var i = 0; i < graphicList.length; i++) - { - var graphicDef:GraphicDef = graphicList[i]; - var uses = graphicDef.ExportParams['uses']; - for (var usage in uses) - { - if (uniqueUseTypes[uses[usage]] == null) - { - uniqueUseTypes[uses[usage]] = uses[usage]; - usesString += uses[usage] + ", "; - } - } - } - - graphicPath.text = ""; - - } - - public function CloseClicked(event) - { - Hide(); - } - - public function Hide() - { - if (this.parent != null) this.parent.removeChild(this); - } - - public function BrowseForFile() - { - var file:File = new File(); - var swfTypeFilter:FileFilter = new FileFilter("SWF Files","*.swf"); - file.addEventListener(Event.SELECT, openFile); - file.browse([swfTypeFilter]); - } - - private function openFile(event:Event):void - { - _strace(event.target.nativePath); - var path:String = event.target.nativePath; - var pathParts:Array = path.split("Graphics\\"); - if (pathParts.length == 2) - { - var fileRemainder:String = pathParts[1]; - var withoutExtension:String = fileRemainder.split(".")[0]; - var pattern:RegExp = /\\/g; - withoutExtension = withoutExtension.replace(pattern, "/"); - _strace(withoutExtension); - graphicPath.text = withoutExtension; - - if (withoutExtension.indexOf("Backgrounds") > -1) - { - SetType(6); - } - - if (withoutExtension.indexOf("Monsters") > -1) - { - SetType(3); - } - - if (withoutExtension.indexOf("Characters") > -1) - { - SetType(3); - } - - if (withoutExtension.indexOf("Portraits") > -1) - { - SetType(1); - } - - if (withoutExtension.indexOf("Quest") > -1) - { - SetType(1); - } - - if (withoutExtension.indexOf("Equipment") > -1) - { - SetType(1); - } - - - } - } - - - } - -} diff --git a/PNGExportHelper.as b/PNGExportHelper.as deleted file mode 100644 index f8c4c9d..0000000 --- a/PNGExportHelper.as +++ /dev/null @@ -1,253 +0,0 @@ -package -{ - import flash.display.*; - import com.adobe.images.*; - import flash.utils.*; - import flash.net.*; - import flash.geom.Matrix; - import flash.geom.Rectangle; - import flash.geom.Point; - - public class PNGExportHelper - { - public static var UseExpandedBitmaps = false; - public static var AlphaThreshold = 5; - - private static function ExpandBitmapBorders(bd:BitmapData, bgColor = 0x0, passes = 1):BitmapData - { - /* - var thresh:BitmapData = new BitmapData(bd.width, bd.height, true, bgColor); - thresh.threshold(bd, bd.rect, new Point(), "<", (20 << 24), bgColor, 0xFF000000, true); - */ - var sampled:BitmapData = new BitmapData(bd.width, bd.height, true, bgColor); - bd.lock(); - sampled.lock(); - - for (var y = 0; y < bd.height; y++) - { - for (var x = 0; x < bd.width; x++) - { - var oldVal:uint = bd.getPixel32(x, y); - var a:uint = (oldVal & 0xFF000000) >>> 24; - var rgb:uint = (oldVal & 0xFFFFFF); - if (a > AlphaThreshold) - { - sampled.setPixel32(x, y, (0xFF << 24) | rgb); - } - else - { - sampled.setPixel32(x, y, bgColor); - } - } - } - sampled.unlock(); - bd.unlock(); - - return ExpandBitmapBordersInternal(sampled, bgColor, passes); - } - - private static function ExpandBitmapBordersInternal(bd:BitmapData, bgColor, passes):BitmapData - { - var output:BitmapData = new BitmapData(bd.width, bd.height, true, bgColor); - - var scale = 16; - var scaled:BitmapData = new BitmapData(bd.width/scale, bd.height/scale, true, bgColor); - var mat:Matrix = new Matrix(); - mat.scale(1/scale, 1/scale); - scaled.draw(bd, mat, null, null, null, true); - - output.lock(); - - var colors:Array = new Array(); - var weights:Array = new Array(); - - for (var oy = 0; oy < scaled.height; oy++) - { - - for (var ox = 0; ox < scaled.width; ox++) - { - - var scaledVal:uint = scaled.getPixel32(ox, oy); - var scaleda:uint = (scaledVal & 0xFF000000) >>> 24; - if (scaleda == 0 || scaleda == 255) - { - output.copyPixels(bd, new Rectangle(ox * scale, oy * scale, scale, scale), new Point(ox * scale, oy * scale)); - continue; - } else { - //_strace(scaleda+""); - } - - - for (var y = oy * scale; y < oy * scale + scale; y++) - { - for (var x = ox * scale; x < ox * scale + scale; x++) - { - var oldVal:uint = bd.getPixel32(x, y); - var a:uint = (oldVal & 0xFF000000) >>> 24; - var rgb:uint = (oldVal & 0xFFFFFF); - - if (a == 0 && rgb == bgColor) - { - colors.length = 0; - weights.length = 0; - - for (var y1 = y - 2; y1 <= y + 2; y1++) - { - for (var x1 = x - 2; x1 <= x + 2; x1++) - { - var dist = Math.abs(x1 - x) + Math.abs(y1 - y); - if (dist >= 3) continue; - - if (x1 >= 0 && x1 < bd.width && y1 >= 0 && y1 < bd.height) - { - colors.push(bd.getPixel(x1, y1)); - weights.push(1 - dist * 0.2); - } - } - } - - var newVal = AveragePixels(colors, weights, bgColor); - if (newVal == null) - { - newVal = oldVal; - } - else - { - var newR:uint = (newVal & 0xFF0000) >> 16; - var newG:uint = (newVal & 0xFF00) >> 8; - var newB:uint = (newVal & 0xFF); - - if (newVal != 0 && colors.length >= 4) - { - var bp = true; - } - - var sorted = colors.sort(function(a, b) - { - var aR:uint = (a & 0xFF0000) >> 16; - var aG:uint = (a & 0xFF00) >> 8; - var aB:uint = (a & 0xFF); - - var bR:uint = (b & 0xFF0000) >> 16; - var bG:uint = (b & 0xFF00) >> 8; - var bB:uint = (b & 0xFF); - - var diffA = Math.abs(aR - newR) + Math.abs(aG - newG) + Math.abs(aB - newB); - var diffB = Math.abs(bR - newR) + Math.abs(bG - newG) + Math.abs(bB - newB); - - return diffA - diffB; - - }, Array.RETURNINDEXEDARRAY | Array.DESCENDING); - - var toRemove = Math.min(2, colors.length - 4); - var removed = 0; - for (var i = 0; i < colors.length; i++) - { - var index = sorted.indexOf(i + removed); - if (index < toRemove) - { - colors.splice(i, 1); - weights.splice(i, 1); - removed++; - i--; - if (removed == toRemove) break; - } - } - - var fixOutliersVal = AveragePixels(colors, weights, bgColor); - if (fixOutliersVal == null) newVal = (0xFF << 24) | newVal; - - newVal = (0xFF << 24) | fixOutliersVal; - } - - output.setPixel32(x, y, newVal); - } - else - { - output.setPixel32(x, y, oldVal); - } - } - } - }//end outer scaled x - }//End outer scaled y - - bd.unlock(); - output.unlock(); - - passes--; - if (passes > 0) - { - return ExpandBitmapBordersInternal(output, bgColor, passes); - } - else - { - return output; - } - } - - private static function AveragePixels(colors:Array, weights:Array, bgColor:uint):uint - { - var rTotal = 0; - var gTotal = 0; - var bTotal = 0; - - var wTotal = 0; - - for (var i = 0; i < colors.length; i++) - { - var color:uint = colors[i]; - var a:uint = (color & 0xFF000000) >>> 24; - var rgb:uint = (color & 0xFFFFFF); - - if (a == 0 && rgb == bgColor) - { - colors.splice(i, 1); - weights.splice(i, 1); - i--; - continue; - } - - var r:uint = (rgb & 0xFF0000) >>> 16; - var g:uint = (rgb & 0xFF00) >>> 8; - var b:uint = (rgb & 0xFF); - var w = weights[i]; - - rTotal += w * r; - gTotal += w * g; - bTotal += w * b; - - wTotal += w; - } - - if (wTotal == 0) - { - return null; - } - - rTotal /= wTotal; - gTotal /= wTotal; - bTotal /= wTotal; - - var rFinal = Math.max(0, Math.min(255, Math.round(rTotal))); - var gFinal = Math.max(0, Math.min(255, Math.round(gTotal))); - var bFinal = Math.max(0, Math.min(255, Math.round(bTotal))); - - return (uint(rFinal) << 16) | (uint(gFinal) << 8) | (uint(bFinal)); - } - - - - public static function GetExportPNG(bd:BitmapData):ByteArray - { - if (!UseExpandedBitmaps) return PNGEncoder.encode(bd); - - var expanded:BitmapData = ExpandBitmapBorders(bd, 0x0, 2); - - //var fr:FileReference = new FileReference(); - //fr.save(PNGEncoder.encode(expanded), "output.png"); - - return PNGEncoderWithAlpha.encode(expanded, bd); - } - - } -} \ No newline at end of file diff --git a/PreviewHolder.as b/PreviewHolder.as deleted file mode 100644 index 587bf68..0000000 --- a/PreviewHolder.as +++ /dev/null @@ -1,57 +0,0 @@ -package { - import flash.display.MovieClip; - - public class PreviewHolder extends MovieClip - { - - var startingWidth = 1024; - var startingHeight = 1024; - - public function PreviewHolder() - { - startingWidth = this.width; - startingHeight = this.height; - } - - var clips:Array = new Array(); - public function AddClip(clip) - { - clips.push(clip); - this.addChild(clip); - ArrangeClips(); - } - - public function ArrangeClips() - { - var numCols = Math.ceil(Math.sqrt(clips.length)); - var maxY = 0; - var maxX = 0; - var clipIndex = 0; - for (var row = 0; row < numCols; row++) - { - var clipX = 0; - var clipY = maxY; - for (var col = 0; col < numCols; col++) - { - if (clipIndex == clips.length) break; - clips[clipIndex].x = clipX; - clips[clipIndex].y = clipY; - clipX += clips[clipIndex].width; - var clipBottom = clips[clipIndex].y + clips[clipIndex].height; - if (clipBottom > maxY) maxY = clipBottom; - - var clipRight = clips[clipIndex].x + clips[clipIndex].width; - if (clipRight > maxX) maxX = clipRight; - clipIndex++; - } - } - - var scale = Math.min(startingWidth / maxX, startingHeight / maxY); - if (scale > 1) scale = 1; - - this.scaleX = this.scaleY = scale; - } - - } - -} diff --git a/old/Checkbox.as b/old/Checkbox.as new file mode 100644 index 0000000..c5aaba2 --- /dev/null +++ b/old/Checkbox.as @@ -0,0 +1,42 @@ +package { + + import flash.display.MovieClip; + import flash.events.MouseEvent; + + public class Checkbox extends MovieClip + { + public var Enabled:Boolean = true; + public function Checkbox() + { + checkbox.gotoAndStop(1); + checkbox.addEventListener(MouseEvent.CLICK, Clicked); + } + + protected function Clicked(event) + { + if (!Enabled) return; + Toggle(); + if (OnClick != null) OnClick(OnClickParam); + } + + protected var checked = false; + public function set Checked(value) { checked = value; checkbox.gotoAndStop(checked ? 2 : 1); } + public function get Checked() { return checked; } + + public function set Text(value) { text.text = value; } + + public var OnClickParam; + public var OnClick; + + + public function Toggle() + { + checked = !checked; + checkbox.gotoAndStop(checked ? 2 : 1); + + + } + + } + +} diff --git a/Checkbox.as b/Checkbox.as deleted file mode 100644 index c5aaba2..0000000 --- a/Checkbox.as +++ /dev/null @@ -1,42 +0,0 @@ -package { - - import flash.display.MovieClip; - import flash.events.MouseEvent; - - public class Checkbox extends MovieClip - { - public var Enabled:Boolean = true; - public function Checkbox() - { - checkbox.gotoAndStop(1); - checkbox.addEventListener(MouseEvent.CLICK, Clicked); - } - - protected function Clicked(event) - { - if (!Enabled) return; - Toggle(); - if (OnClick != null) OnClick(OnClickParam); - } - - protected var checked = false; - public function set Checked(value) { checked = value; checkbox.gotoAndStop(checked ? 2 : 1); } - public function get Checked() { return checked; } - - public function set Text(value) { text.text = value; } - - public var OnClickParam; - public var OnClick; - - - public function Toggle() - { - checked = !checked; - checkbox.gotoAndStop(checked ? 2 : 1); - - - } - - } - -} diff --git a/Exporter-app.xml b/Exporter-app.xml index dbb9ba7..7deb7c5 100755 --- a/Exporter-app.xml +++ b/Exporter-app.xml @@ -16,7 +16,7 @@ Japanese App name goes here --> - + Exporter 1.0 Exporter diff --git a/Exporter.exe b/Exporter.exe index aa5d57e..7833fe5 100755 --- a/Exporter.exe +++ b/Exporter.exe Binary files differ diff --git a/Exporter.swf b/Exporter.swf index 484f56c..9c7464a 100644 --- a/Exporter.swf +++ b/Exporter.swf Binary files differ diff --git a/GraphicExport-app.xml b/GraphicExport-app.xml deleted file mode 100755 index 5144634..0000000 --- a/GraphicExport-app.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - GraphicExport - 1.0 - GraphicExport - - GraphicExport - - - GraphicExport.swf - standard - false - true - false - portrait - auto - true - true - true - - - false - false - desktop extendedDesktop diff --git a/GraphicExport.exe b/GraphicExport.exe deleted file mode 100755 index 56315aa..0000000 --- a/GraphicExport.exe +++ /dev/null Binary files differ diff --git a/GraphicExport.fla b/GraphicExport.fla deleted file mode 100755 index 0b78ed7..0000000 --- a/GraphicExport.fla +++ /dev/null Binary files differ diff --git a/GraphicExport.swf b/GraphicExport.swf deleted file mode 100644 index 542db97..0000000 --- a/GraphicExport.swf +++ /dev/null Binary files differ diff --git a/NewGraphicDialog.as b/NewGraphicDialog.as deleted file mode 100644 index 152011c..0000000 --- a/NewGraphicDialog.as +++ /dev/null @@ -1,224 +0,0 @@ -package { - - import flash.display.MovieClip; - import flash.events.MouseEvent; - import flash.events.*; - import flash.filesystem.File; - import flash.net.FileFilter; - import Defs.GraphicDef; - import flash.text.engine.GraphicElement; - - public class NewGraphicDialog extends MovieClip - { - - public function NewGraphicDialog() - { - // constructor code - Init(); - } - - var typeButtons:Array = new Array(); - - public function Init() - { - graphicPath.text = "Path to Graphic Here"; - - this.removeChild(browseButton); - - var newBrowseButton = new UI_GenericBlueButton(); - newBrowseButton.Text = "Browse"; - newBrowseButton.OnClick = BrowseForFile; - newBrowseButton.x = browseButton.x + (newBrowseButton.width / 2); - newBrowseButton.y = browseButton.y + (newBrowseButton.height / 2); - addChild(newBrowseButton); - - var newTestButton = new UI_GenericBlueButton(); - newTestButton.Text = "Export"; - newTestButton.OnClick = TestFile; - newTestButton.x = testButton.x + (newTestButton.width / 2); - newTestButton.y = testButton.y + (newTestButton.height / 2); - addChild(newTestButton); - - this.removeChild(typePlaceholderButton); - - var typeX = typePlaceholderButton.x; - var typeY = typePlaceholderButton.y + (typePlaceholderButton.height / 2); - - - var typeButton = new UI_GenericBlueButton(); - typeButton.Text = "Graphic (1)"; - typeButton.OnClick = function(){ SetType(1); } - typeButton.x = typeX + (typeButton.width / 2); - typeButton.y = typeY; - typeButtons.push(typeButton); - addChild(typeButton); - - typeX += typeButton.width + 5; - - typeButton = new UI_GenericBlueButton(); - typeButton.Text = "Skeletal (3)"; - typeButton.OnClick = function(){ SetType(3); } - typeButton.x = typeX + (typeButton.width / 2); - typeButton.y = typeY; - typeButtons.push(typeButton); - addChild(typeButton); - - typeX += typeButton.width + 5; - - typeButton = new UI_GenericBlueButton(); - typeButton.Text = "Scene (6)"; - typeButton.OnClick = function(){ SetType(6); } - typeButton.x = typeX + (typeButton.width / 2); - typeButton.y = typeY; - typeButtons.push(typeButton); - addChild(typeButton); - - animationCheckbox.Checked = true; - //browseButton - //typePlaceholderButton - //usesInput - //usesText.text = "" - } - - var usesInputDefaultText = "Comma Seperated List of Uses Here"; - - public static var fakeID = 9999999; - public function TestFile() - { - fakeID++; - var graphicName = graphicPath.text; - var graphicData = {id:fakeID,graphic:graphicPath.text,v:1,fs:0,p:0,type:selectedType}; - - //"export_params":{"uses":["background"],"available_sizes":["default"],"compress":false}} - - var graphicDef = new GraphicDef(graphicData); - - this.Hide(); - graphicExport.ExportItem(graphicDef); - } - - var selectedType = 1; - public function SetType(type:Number) - { - selectedType = type; - - for(var i = 0; i < typeButtons.length; i++) - { - typeButtons[i].Enabled = true; - } - - animationCheckbox.visible = false; - - switch(type) - { - case 1: { - typeButtons[0].Enabled = false; - animationCheckbox.visible = true; - break; - } - case 3: typeButtons[1].Enabled = false; break; - case 6: typeButtons[2].Enabled = false; break; - } - } - - var graphicExport:GraphicExport; - public function Show(parentClip) - { - this.graphicExport = parentClip; - - parentClip.addChild(this); - - SetType(selectedType); - - var graphicList = GameData.Instance().GraphicDefines; - - var usesString:String = ""; - var uniqueUseTypes:Array = new Array(); - for (var i = 0; i < graphicList.length; i++) - { - var graphicDef:GraphicDef = graphicList[i]; - var uses = graphicDef.ExportParams['uses']; - for (var usage in uses) - { - if (uniqueUseTypes[uses[usage]] == null) - { - uniqueUseTypes[uses[usage]] = uses[usage]; - usesString += uses[usage] + ", "; - } - } - } - - graphicPath.text = ""; - - } - - public function CloseClicked(event) - { - Hide(); - } - - public function Hide() - { - if (this.parent != null) this.parent.removeChild(this); - } - - public function BrowseForFile() - { - var file:File = new File(); - var swfTypeFilter:FileFilter = new FileFilter("SWF Files","*.swf"); - file.addEventListener(Event.SELECT, openFile); - file.browse([swfTypeFilter]); - } - - private function openFile(event:Event):void - { - _strace(event.target.nativePath); - var path:String = event.target.nativePath; - var pathParts:Array = path.split("Graphics\\"); - if (pathParts.length == 2) - { - var fileRemainder:String = pathParts[1]; - var withoutExtension:String = fileRemainder.split(".")[0]; - var pattern:RegExp = /\\/g; - withoutExtension = withoutExtension.replace(pattern, "/"); - _strace(withoutExtension); - graphicPath.text = withoutExtension; - - if (withoutExtension.indexOf("Backgrounds") > -1) - { - SetType(6); - } - - if (withoutExtension.indexOf("Monsters") > -1) - { - SetType(3); - } - - if (withoutExtension.indexOf("Characters") > -1) - { - SetType(3); - } - - if (withoutExtension.indexOf("Portraits") > -1) - { - SetType(1); - } - - if (withoutExtension.indexOf("Quest") > -1) - { - SetType(1); - } - - if (withoutExtension.indexOf("Equipment") > -1) - { - SetType(1); - } - - - } - } - - - } - -} diff --git a/PNGExportHelper.as b/PNGExportHelper.as deleted file mode 100644 index f8c4c9d..0000000 --- a/PNGExportHelper.as +++ /dev/null @@ -1,253 +0,0 @@ -package -{ - import flash.display.*; - import com.adobe.images.*; - import flash.utils.*; - import flash.net.*; - import flash.geom.Matrix; - import flash.geom.Rectangle; - import flash.geom.Point; - - public class PNGExportHelper - { - public static var UseExpandedBitmaps = false; - public static var AlphaThreshold = 5; - - private static function ExpandBitmapBorders(bd:BitmapData, bgColor = 0x0, passes = 1):BitmapData - { - /* - var thresh:BitmapData = new BitmapData(bd.width, bd.height, true, bgColor); - thresh.threshold(bd, bd.rect, new Point(), "<", (20 << 24), bgColor, 0xFF000000, true); - */ - var sampled:BitmapData = new BitmapData(bd.width, bd.height, true, bgColor); - bd.lock(); - sampled.lock(); - - for (var y = 0; y < bd.height; y++) - { - for (var x = 0; x < bd.width; x++) - { - var oldVal:uint = bd.getPixel32(x, y); - var a:uint = (oldVal & 0xFF000000) >>> 24; - var rgb:uint = (oldVal & 0xFFFFFF); - if (a > AlphaThreshold) - { - sampled.setPixel32(x, y, (0xFF << 24) | rgb); - } - else - { - sampled.setPixel32(x, y, bgColor); - } - } - } - sampled.unlock(); - bd.unlock(); - - return ExpandBitmapBordersInternal(sampled, bgColor, passes); - } - - private static function ExpandBitmapBordersInternal(bd:BitmapData, bgColor, passes):BitmapData - { - var output:BitmapData = new BitmapData(bd.width, bd.height, true, bgColor); - - var scale = 16; - var scaled:BitmapData = new BitmapData(bd.width/scale, bd.height/scale, true, bgColor); - var mat:Matrix = new Matrix(); - mat.scale(1/scale, 1/scale); - scaled.draw(bd, mat, null, null, null, true); - - output.lock(); - - var colors:Array = new Array(); - var weights:Array = new Array(); - - for (var oy = 0; oy < scaled.height; oy++) - { - - for (var ox = 0; ox < scaled.width; ox++) - { - - var scaledVal:uint = scaled.getPixel32(ox, oy); - var scaleda:uint = (scaledVal & 0xFF000000) >>> 24; - if (scaleda == 0 || scaleda == 255) - { - output.copyPixels(bd, new Rectangle(ox * scale, oy * scale, scale, scale), new Point(ox * scale, oy * scale)); - continue; - } else { - //_strace(scaleda+""); - } - - - for (var y = oy * scale; y < oy * scale + scale; y++) - { - for (var x = ox * scale; x < ox * scale + scale; x++) - { - var oldVal:uint = bd.getPixel32(x, y); - var a:uint = (oldVal & 0xFF000000) >>> 24; - var rgb:uint = (oldVal & 0xFFFFFF); - - if (a == 0 && rgb == bgColor) - { - colors.length = 0; - weights.length = 0; - - for (var y1 = y - 2; y1 <= y + 2; y1++) - { - for (var x1 = x - 2; x1 <= x + 2; x1++) - { - var dist = Math.abs(x1 - x) + Math.abs(y1 - y); - if (dist >= 3) continue; - - if (x1 >= 0 && x1 < bd.width && y1 >= 0 && y1 < bd.height) - { - colors.push(bd.getPixel(x1, y1)); - weights.push(1 - dist * 0.2); - } - } - } - - var newVal = AveragePixels(colors, weights, bgColor); - if (newVal == null) - { - newVal = oldVal; - } - else - { - var newR:uint = (newVal & 0xFF0000) >> 16; - var newG:uint = (newVal & 0xFF00) >> 8; - var newB:uint = (newVal & 0xFF); - - if (newVal != 0 && colors.length >= 4) - { - var bp = true; - } - - var sorted = colors.sort(function(a, b) - { - var aR:uint = (a & 0xFF0000) >> 16; - var aG:uint = (a & 0xFF00) >> 8; - var aB:uint = (a & 0xFF); - - var bR:uint = (b & 0xFF0000) >> 16; - var bG:uint = (b & 0xFF00) >> 8; - var bB:uint = (b & 0xFF); - - var diffA = Math.abs(aR - newR) + Math.abs(aG - newG) + Math.abs(aB - newB); - var diffB = Math.abs(bR - newR) + Math.abs(bG - newG) + Math.abs(bB - newB); - - return diffA - diffB; - - }, Array.RETURNINDEXEDARRAY | Array.DESCENDING); - - var toRemove = Math.min(2, colors.length - 4); - var removed = 0; - for (var i = 0; i < colors.length; i++) - { - var index = sorted.indexOf(i + removed); - if (index < toRemove) - { - colors.splice(i, 1); - weights.splice(i, 1); - removed++; - i--; - if (removed == toRemove) break; - } - } - - var fixOutliersVal = AveragePixels(colors, weights, bgColor); - if (fixOutliersVal == null) newVal = (0xFF << 24) | newVal; - - newVal = (0xFF << 24) | fixOutliersVal; - } - - output.setPixel32(x, y, newVal); - } - else - { - output.setPixel32(x, y, oldVal); - } - } - } - }//end outer scaled x - }//End outer scaled y - - bd.unlock(); - output.unlock(); - - passes--; - if (passes > 0) - { - return ExpandBitmapBordersInternal(output, bgColor, passes); - } - else - { - return output; - } - } - - private static function AveragePixels(colors:Array, weights:Array, bgColor:uint):uint - { - var rTotal = 0; - var gTotal = 0; - var bTotal = 0; - - var wTotal = 0; - - for (var i = 0; i < colors.length; i++) - { - var color:uint = colors[i]; - var a:uint = (color & 0xFF000000) >>> 24; - var rgb:uint = (color & 0xFFFFFF); - - if (a == 0 && rgb == bgColor) - { - colors.splice(i, 1); - weights.splice(i, 1); - i--; - continue; - } - - var r:uint = (rgb & 0xFF0000) >>> 16; - var g:uint = (rgb & 0xFF00) >>> 8; - var b:uint = (rgb & 0xFF); - var w = weights[i]; - - rTotal += w * r; - gTotal += w * g; - bTotal += w * b; - - wTotal += w; - } - - if (wTotal == 0) - { - return null; - } - - rTotal /= wTotal; - gTotal /= wTotal; - bTotal /= wTotal; - - var rFinal = Math.max(0, Math.min(255, Math.round(rTotal))); - var gFinal = Math.max(0, Math.min(255, Math.round(gTotal))); - var bFinal = Math.max(0, Math.min(255, Math.round(bTotal))); - - return (uint(rFinal) << 16) | (uint(gFinal) << 8) | (uint(bFinal)); - } - - - - public static function GetExportPNG(bd:BitmapData):ByteArray - { - if (!UseExpandedBitmaps) return PNGEncoder.encode(bd); - - var expanded:BitmapData = ExpandBitmapBorders(bd, 0x0, 2); - - //var fr:FileReference = new FileReference(); - //fr.save(PNGEncoder.encode(expanded), "output.png"); - - return PNGEncoderWithAlpha.encode(expanded, bd); - } - - } -} \ No newline at end of file diff --git a/PreviewHolder.as b/PreviewHolder.as deleted file mode 100644 index 587bf68..0000000 --- a/PreviewHolder.as +++ /dev/null @@ -1,57 +0,0 @@ -package { - import flash.display.MovieClip; - - public class PreviewHolder extends MovieClip - { - - var startingWidth = 1024; - var startingHeight = 1024; - - public function PreviewHolder() - { - startingWidth = this.width; - startingHeight = this.height; - } - - var clips:Array = new Array(); - public function AddClip(clip) - { - clips.push(clip); - this.addChild(clip); - ArrangeClips(); - } - - public function ArrangeClips() - { - var numCols = Math.ceil(Math.sqrt(clips.length)); - var maxY = 0; - var maxX = 0; - var clipIndex = 0; - for (var row = 0; row < numCols; row++) - { - var clipX = 0; - var clipY = maxY; - for (var col = 0; col < numCols; col++) - { - if (clipIndex == clips.length) break; - clips[clipIndex].x = clipX; - clips[clipIndex].y = clipY; - clipX += clips[clipIndex].width; - var clipBottom = clips[clipIndex].y + clips[clipIndex].height; - if (clipBottom > maxY) maxY = clipBottom; - - var clipRight = clips[clipIndex].x + clips[clipIndex].width; - if (clipRight > maxX) maxX = clipRight; - clipIndex++; - } - } - - var scale = Math.min(startingWidth / maxX, startingHeight / maxY); - if (scale > 1) scale = 1; - - this.scaleX = this.scaleY = scale; - } - - } - -} diff --git a/old/Checkbox.as b/old/Checkbox.as new file mode 100644 index 0000000..c5aaba2 --- /dev/null +++ b/old/Checkbox.as @@ -0,0 +1,42 @@ +package { + + import flash.display.MovieClip; + import flash.events.MouseEvent; + + public class Checkbox extends MovieClip + { + public var Enabled:Boolean = true; + public function Checkbox() + { + checkbox.gotoAndStop(1); + checkbox.addEventListener(MouseEvent.CLICK, Clicked); + } + + protected function Clicked(event) + { + if (!Enabled) return; + Toggle(); + if (OnClick != null) OnClick(OnClickParam); + } + + protected var checked = false; + public function set Checked(value) { checked = value; checkbox.gotoAndStop(checked ? 2 : 1); } + public function get Checked() { return checked; } + + public function set Text(value) { text.text = value; } + + public var OnClickParam; + public var OnClick; + + + public function Toggle() + { + checked = !checked; + checkbox.gotoAndStop(checked ? 2 : 1); + + + } + + } + +} diff --git a/old/GraphicExport-app.xml b/old/GraphicExport-app.xml new file mode 100644 index 0000000..5144634 --- /dev/null +++ b/old/GraphicExport-app.xml @@ -0,0 +1,41 @@ + + + + GraphicExport + 1.0 + GraphicExport + + GraphicExport + + + GraphicExport.swf + standard + false + true + false + portrait + auto + true + true + true + + + false + false + desktop extendedDesktop diff --git a/Checkbox.as b/Checkbox.as deleted file mode 100644 index c5aaba2..0000000 --- a/Checkbox.as +++ /dev/null @@ -1,42 +0,0 @@ -package { - - import flash.display.MovieClip; - import flash.events.MouseEvent; - - public class Checkbox extends MovieClip - { - public var Enabled:Boolean = true; - public function Checkbox() - { - checkbox.gotoAndStop(1); - checkbox.addEventListener(MouseEvent.CLICK, Clicked); - } - - protected function Clicked(event) - { - if (!Enabled) return; - Toggle(); - if (OnClick != null) OnClick(OnClickParam); - } - - protected var checked = false; - public function set Checked(value) { checked = value; checkbox.gotoAndStop(checked ? 2 : 1); } - public function get Checked() { return checked; } - - public function set Text(value) { text.text = value; } - - public var OnClickParam; - public var OnClick; - - - public function Toggle() - { - checked = !checked; - checkbox.gotoAndStop(checked ? 2 : 1); - - - } - - } - -} diff --git a/Exporter-app.xml b/Exporter-app.xml index dbb9ba7..7deb7c5 100755 --- a/Exporter-app.xml +++ b/Exporter-app.xml @@ -16,7 +16,7 @@ Japanese App name goes here --> - + Exporter 1.0 Exporter diff --git a/Exporter.exe b/Exporter.exe index aa5d57e..7833fe5 100755 --- a/Exporter.exe +++ b/Exporter.exe Binary files differ diff --git a/Exporter.swf b/Exporter.swf index 484f56c..9c7464a 100644 --- a/Exporter.swf +++ b/Exporter.swf Binary files differ diff --git a/GraphicExport-app.xml b/GraphicExport-app.xml deleted file mode 100755 index 5144634..0000000 --- a/GraphicExport-app.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - GraphicExport - 1.0 - GraphicExport - - GraphicExport - - - GraphicExport.swf - standard - false - true - false - portrait - auto - true - true - true - - - false - false - desktop extendedDesktop diff --git a/GraphicExport.exe b/GraphicExport.exe deleted file mode 100755 index 56315aa..0000000 --- a/GraphicExport.exe +++ /dev/null Binary files differ diff --git a/GraphicExport.fla b/GraphicExport.fla deleted file mode 100755 index 0b78ed7..0000000 --- a/GraphicExport.fla +++ /dev/null Binary files differ diff --git a/GraphicExport.swf b/GraphicExport.swf deleted file mode 100644 index 542db97..0000000 --- a/GraphicExport.swf +++ /dev/null Binary files differ diff --git a/NewGraphicDialog.as b/NewGraphicDialog.as deleted file mode 100644 index 152011c..0000000 --- a/NewGraphicDialog.as +++ /dev/null @@ -1,224 +0,0 @@ -package { - - import flash.display.MovieClip; - import flash.events.MouseEvent; - import flash.events.*; - import flash.filesystem.File; - import flash.net.FileFilter; - import Defs.GraphicDef; - import flash.text.engine.GraphicElement; - - public class NewGraphicDialog extends MovieClip - { - - public function NewGraphicDialog() - { - // constructor code - Init(); - } - - var typeButtons:Array = new Array(); - - public function Init() - { - graphicPath.text = "Path to Graphic Here"; - - this.removeChild(browseButton); - - var newBrowseButton = new UI_GenericBlueButton(); - newBrowseButton.Text = "Browse"; - newBrowseButton.OnClick = BrowseForFile; - newBrowseButton.x = browseButton.x + (newBrowseButton.width / 2); - newBrowseButton.y = browseButton.y + (newBrowseButton.height / 2); - addChild(newBrowseButton); - - var newTestButton = new UI_GenericBlueButton(); - newTestButton.Text = "Export"; - newTestButton.OnClick = TestFile; - newTestButton.x = testButton.x + (newTestButton.width / 2); - newTestButton.y = testButton.y + (newTestButton.height / 2); - addChild(newTestButton); - - this.removeChild(typePlaceholderButton); - - var typeX = typePlaceholderButton.x; - var typeY = typePlaceholderButton.y + (typePlaceholderButton.height / 2); - - - var typeButton = new UI_GenericBlueButton(); - typeButton.Text = "Graphic (1)"; - typeButton.OnClick = function(){ SetType(1); } - typeButton.x = typeX + (typeButton.width / 2); - typeButton.y = typeY; - typeButtons.push(typeButton); - addChild(typeButton); - - typeX += typeButton.width + 5; - - typeButton = new UI_GenericBlueButton(); - typeButton.Text = "Skeletal (3)"; - typeButton.OnClick = function(){ SetType(3); } - typeButton.x = typeX + (typeButton.width / 2); - typeButton.y = typeY; - typeButtons.push(typeButton); - addChild(typeButton); - - typeX += typeButton.width + 5; - - typeButton = new UI_GenericBlueButton(); - typeButton.Text = "Scene (6)"; - typeButton.OnClick = function(){ SetType(6); } - typeButton.x = typeX + (typeButton.width / 2); - typeButton.y = typeY; - typeButtons.push(typeButton); - addChild(typeButton); - - animationCheckbox.Checked = true; - //browseButton - //typePlaceholderButton - //usesInput - //usesText.text = "" - } - - var usesInputDefaultText = "Comma Seperated List of Uses Here"; - - public static var fakeID = 9999999; - public function TestFile() - { - fakeID++; - var graphicName = graphicPath.text; - var graphicData = {id:fakeID,graphic:graphicPath.text,v:1,fs:0,p:0,type:selectedType}; - - //"export_params":{"uses":["background"],"available_sizes":["default"],"compress":false}} - - var graphicDef = new GraphicDef(graphicData); - - this.Hide(); - graphicExport.ExportItem(graphicDef); - } - - var selectedType = 1; - public function SetType(type:Number) - { - selectedType = type; - - for(var i = 0; i < typeButtons.length; i++) - { - typeButtons[i].Enabled = true; - } - - animationCheckbox.visible = false; - - switch(type) - { - case 1: { - typeButtons[0].Enabled = false; - animationCheckbox.visible = true; - break; - } - case 3: typeButtons[1].Enabled = false; break; - case 6: typeButtons[2].Enabled = false; break; - } - } - - var graphicExport:GraphicExport; - public function Show(parentClip) - { - this.graphicExport = parentClip; - - parentClip.addChild(this); - - SetType(selectedType); - - var graphicList = GameData.Instance().GraphicDefines; - - var usesString:String = ""; - var uniqueUseTypes:Array = new Array(); - for (var i = 0; i < graphicList.length; i++) - { - var graphicDef:GraphicDef = graphicList[i]; - var uses = graphicDef.ExportParams['uses']; - for (var usage in uses) - { - if (uniqueUseTypes[uses[usage]] == null) - { - uniqueUseTypes[uses[usage]] = uses[usage]; - usesString += uses[usage] + ", "; - } - } - } - - graphicPath.text = ""; - - } - - public function CloseClicked(event) - { - Hide(); - } - - public function Hide() - { - if (this.parent != null) this.parent.removeChild(this); - } - - public function BrowseForFile() - { - var file:File = new File(); - var swfTypeFilter:FileFilter = new FileFilter("SWF Files","*.swf"); - file.addEventListener(Event.SELECT, openFile); - file.browse([swfTypeFilter]); - } - - private function openFile(event:Event):void - { - _strace(event.target.nativePath); - var path:String = event.target.nativePath; - var pathParts:Array = path.split("Graphics\\"); - if (pathParts.length == 2) - { - var fileRemainder:String = pathParts[1]; - var withoutExtension:String = fileRemainder.split(".")[0]; - var pattern:RegExp = /\\/g; - withoutExtension = withoutExtension.replace(pattern, "/"); - _strace(withoutExtension); - graphicPath.text = withoutExtension; - - if (withoutExtension.indexOf("Backgrounds") > -1) - { - SetType(6); - } - - if (withoutExtension.indexOf("Monsters") > -1) - { - SetType(3); - } - - if (withoutExtension.indexOf("Characters") > -1) - { - SetType(3); - } - - if (withoutExtension.indexOf("Portraits") > -1) - { - SetType(1); - } - - if (withoutExtension.indexOf("Quest") > -1) - { - SetType(1); - } - - if (withoutExtension.indexOf("Equipment") > -1) - { - SetType(1); - } - - - } - } - - - } - -} diff --git a/PNGExportHelper.as b/PNGExportHelper.as deleted file mode 100644 index f8c4c9d..0000000 --- a/PNGExportHelper.as +++ /dev/null @@ -1,253 +0,0 @@ -package -{ - import flash.display.*; - import com.adobe.images.*; - import flash.utils.*; - import flash.net.*; - import flash.geom.Matrix; - import flash.geom.Rectangle; - import flash.geom.Point; - - public class PNGExportHelper - { - public static var UseExpandedBitmaps = false; - public static var AlphaThreshold = 5; - - private static function ExpandBitmapBorders(bd:BitmapData, bgColor = 0x0, passes = 1):BitmapData - { - /* - var thresh:BitmapData = new BitmapData(bd.width, bd.height, true, bgColor); - thresh.threshold(bd, bd.rect, new Point(), "<", (20 << 24), bgColor, 0xFF000000, true); - */ - var sampled:BitmapData = new BitmapData(bd.width, bd.height, true, bgColor); - bd.lock(); - sampled.lock(); - - for (var y = 0; y < bd.height; y++) - { - for (var x = 0; x < bd.width; x++) - { - var oldVal:uint = bd.getPixel32(x, y); - var a:uint = (oldVal & 0xFF000000) >>> 24; - var rgb:uint = (oldVal & 0xFFFFFF); - if (a > AlphaThreshold) - { - sampled.setPixel32(x, y, (0xFF << 24) | rgb); - } - else - { - sampled.setPixel32(x, y, bgColor); - } - } - } - sampled.unlock(); - bd.unlock(); - - return ExpandBitmapBordersInternal(sampled, bgColor, passes); - } - - private static function ExpandBitmapBordersInternal(bd:BitmapData, bgColor, passes):BitmapData - { - var output:BitmapData = new BitmapData(bd.width, bd.height, true, bgColor); - - var scale = 16; - var scaled:BitmapData = new BitmapData(bd.width/scale, bd.height/scale, true, bgColor); - var mat:Matrix = new Matrix(); - mat.scale(1/scale, 1/scale); - scaled.draw(bd, mat, null, null, null, true); - - output.lock(); - - var colors:Array = new Array(); - var weights:Array = new Array(); - - for (var oy = 0; oy < scaled.height; oy++) - { - - for (var ox = 0; ox < scaled.width; ox++) - { - - var scaledVal:uint = scaled.getPixel32(ox, oy); - var scaleda:uint = (scaledVal & 0xFF000000) >>> 24; - if (scaleda == 0 || scaleda == 255) - { - output.copyPixels(bd, new Rectangle(ox * scale, oy * scale, scale, scale), new Point(ox * scale, oy * scale)); - continue; - } else { - //_strace(scaleda+""); - } - - - for (var y = oy * scale; y < oy * scale + scale; y++) - { - for (var x = ox * scale; x < ox * scale + scale; x++) - { - var oldVal:uint = bd.getPixel32(x, y); - var a:uint = (oldVal & 0xFF000000) >>> 24; - var rgb:uint = (oldVal & 0xFFFFFF); - - if (a == 0 && rgb == bgColor) - { - colors.length = 0; - weights.length = 0; - - for (var y1 = y - 2; y1 <= y + 2; y1++) - { - for (var x1 = x - 2; x1 <= x + 2; x1++) - { - var dist = Math.abs(x1 - x) + Math.abs(y1 - y); - if (dist >= 3) continue; - - if (x1 >= 0 && x1 < bd.width && y1 >= 0 && y1 < bd.height) - { - colors.push(bd.getPixel(x1, y1)); - weights.push(1 - dist * 0.2); - } - } - } - - var newVal = AveragePixels(colors, weights, bgColor); - if (newVal == null) - { - newVal = oldVal; - } - else - { - var newR:uint = (newVal & 0xFF0000) >> 16; - var newG:uint = (newVal & 0xFF00) >> 8; - var newB:uint = (newVal & 0xFF); - - if (newVal != 0 && colors.length >= 4) - { - var bp = true; - } - - var sorted = colors.sort(function(a, b) - { - var aR:uint = (a & 0xFF0000) >> 16; - var aG:uint = (a & 0xFF00) >> 8; - var aB:uint = (a & 0xFF); - - var bR:uint = (b & 0xFF0000) >> 16; - var bG:uint = (b & 0xFF00) >> 8; - var bB:uint = (b & 0xFF); - - var diffA = Math.abs(aR - newR) + Math.abs(aG - newG) + Math.abs(aB - newB); - var diffB = Math.abs(bR - newR) + Math.abs(bG - newG) + Math.abs(bB - newB); - - return diffA - diffB; - - }, Array.RETURNINDEXEDARRAY | Array.DESCENDING); - - var toRemove = Math.min(2, colors.length - 4); - var removed = 0; - for (var i = 0; i < colors.length; i++) - { - var index = sorted.indexOf(i + removed); - if (index < toRemove) - { - colors.splice(i, 1); - weights.splice(i, 1); - removed++; - i--; - if (removed == toRemove) break; - } - } - - var fixOutliersVal = AveragePixels(colors, weights, bgColor); - if (fixOutliersVal == null) newVal = (0xFF << 24) | newVal; - - newVal = (0xFF << 24) | fixOutliersVal; - } - - output.setPixel32(x, y, newVal); - } - else - { - output.setPixel32(x, y, oldVal); - } - } - } - }//end outer scaled x - }//End outer scaled y - - bd.unlock(); - output.unlock(); - - passes--; - if (passes > 0) - { - return ExpandBitmapBordersInternal(output, bgColor, passes); - } - else - { - return output; - } - } - - private static function AveragePixels(colors:Array, weights:Array, bgColor:uint):uint - { - var rTotal = 0; - var gTotal = 0; - var bTotal = 0; - - var wTotal = 0; - - for (var i = 0; i < colors.length; i++) - { - var color:uint = colors[i]; - var a:uint = (color & 0xFF000000) >>> 24; - var rgb:uint = (color & 0xFFFFFF); - - if (a == 0 && rgb == bgColor) - { - colors.splice(i, 1); - weights.splice(i, 1); - i--; - continue; - } - - var r:uint = (rgb & 0xFF0000) >>> 16; - var g:uint = (rgb & 0xFF00) >>> 8; - var b:uint = (rgb & 0xFF); - var w = weights[i]; - - rTotal += w * r; - gTotal += w * g; - bTotal += w * b; - - wTotal += w; - } - - if (wTotal == 0) - { - return null; - } - - rTotal /= wTotal; - gTotal /= wTotal; - bTotal /= wTotal; - - var rFinal = Math.max(0, Math.min(255, Math.round(rTotal))); - var gFinal = Math.max(0, Math.min(255, Math.round(gTotal))); - var bFinal = Math.max(0, Math.min(255, Math.round(bTotal))); - - return (uint(rFinal) << 16) | (uint(gFinal) << 8) | (uint(bFinal)); - } - - - - public static function GetExportPNG(bd:BitmapData):ByteArray - { - if (!UseExpandedBitmaps) return PNGEncoder.encode(bd); - - var expanded:BitmapData = ExpandBitmapBorders(bd, 0x0, 2); - - //var fr:FileReference = new FileReference(); - //fr.save(PNGEncoder.encode(expanded), "output.png"); - - return PNGEncoderWithAlpha.encode(expanded, bd); - } - - } -} \ No newline at end of file diff --git a/PreviewHolder.as b/PreviewHolder.as deleted file mode 100644 index 587bf68..0000000 --- a/PreviewHolder.as +++ /dev/null @@ -1,57 +0,0 @@ -package { - import flash.display.MovieClip; - - public class PreviewHolder extends MovieClip - { - - var startingWidth = 1024; - var startingHeight = 1024; - - public function PreviewHolder() - { - startingWidth = this.width; - startingHeight = this.height; - } - - var clips:Array = new Array(); - public function AddClip(clip) - { - clips.push(clip); - this.addChild(clip); - ArrangeClips(); - } - - public function ArrangeClips() - { - var numCols = Math.ceil(Math.sqrt(clips.length)); - var maxY = 0; - var maxX = 0; - var clipIndex = 0; - for (var row = 0; row < numCols; row++) - { - var clipX = 0; - var clipY = maxY; - for (var col = 0; col < numCols; col++) - { - if (clipIndex == clips.length) break; - clips[clipIndex].x = clipX; - clips[clipIndex].y = clipY; - clipX += clips[clipIndex].width; - var clipBottom = clips[clipIndex].y + clips[clipIndex].height; - if (clipBottom > maxY) maxY = clipBottom; - - var clipRight = clips[clipIndex].x + clips[clipIndex].width; - if (clipRight > maxX) maxX = clipRight; - clipIndex++; - } - } - - var scale = Math.min(startingWidth / maxX, startingHeight / maxY); - if (scale > 1) scale = 1; - - this.scaleX = this.scaleY = scale; - } - - } - -} diff --git a/old/Checkbox.as b/old/Checkbox.as new file mode 100644 index 0000000..c5aaba2 --- /dev/null +++ b/old/Checkbox.as @@ -0,0 +1,42 @@ +package { + + import flash.display.MovieClip; + import flash.events.MouseEvent; + + public class Checkbox extends MovieClip + { + public var Enabled:Boolean = true; + public function Checkbox() + { + checkbox.gotoAndStop(1); + checkbox.addEventListener(MouseEvent.CLICK, Clicked); + } + + protected function Clicked(event) + { + if (!Enabled) return; + Toggle(); + if (OnClick != null) OnClick(OnClickParam); + } + + protected var checked = false; + public function set Checked(value) { checked = value; checkbox.gotoAndStop(checked ? 2 : 1); } + public function get Checked() { return checked; } + + public function set Text(value) { text.text = value; } + + public var OnClickParam; + public var OnClick; + + + public function Toggle() + { + checked = !checked; + checkbox.gotoAndStop(checked ? 2 : 1); + + + } + + } + +} diff --git a/old/GraphicExport-app.xml b/old/GraphicExport-app.xml new file mode 100644 index 0000000..5144634 --- /dev/null +++ b/old/GraphicExport-app.xml @@ -0,0 +1,41 @@ + + + + GraphicExport + 1.0 + GraphicExport + + GraphicExport + + + GraphicExport.swf + standard + false + true + false + portrait + auto + true + true + true + + + false + false + desktop extendedDesktop diff --git a/old/GraphicExport.exe b/old/GraphicExport.exe new file mode 100644 index 0000000..56315aa --- /dev/null +++ b/old/GraphicExport.exe Binary files differ diff --git a/Checkbox.as b/Checkbox.as deleted file mode 100644 index c5aaba2..0000000 --- a/Checkbox.as +++ /dev/null @@ -1,42 +0,0 @@ -package { - - import flash.display.MovieClip; - import flash.events.MouseEvent; - - public class Checkbox extends MovieClip - { - public var Enabled:Boolean = true; - public function Checkbox() - { - checkbox.gotoAndStop(1); - checkbox.addEventListener(MouseEvent.CLICK, Clicked); - } - - protected function Clicked(event) - { - if (!Enabled) return; - Toggle(); - if (OnClick != null) OnClick(OnClickParam); - } - - protected var checked = false; - public function set Checked(value) { checked = value; checkbox.gotoAndStop(checked ? 2 : 1); } - public function get Checked() { return checked; } - - public function set Text(value) { text.text = value; } - - public var OnClickParam; - public var OnClick; - - - public function Toggle() - { - checked = !checked; - checkbox.gotoAndStop(checked ? 2 : 1); - - - } - - } - -} diff --git a/Exporter-app.xml b/Exporter-app.xml index dbb9ba7..7deb7c5 100755 --- a/Exporter-app.xml +++ b/Exporter-app.xml @@ -16,7 +16,7 @@ Japanese App name goes here --> - + Exporter 1.0 Exporter diff --git a/Exporter.exe b/Exporter.exe index aa5d57e..7833fe5 100755 --- a/Exporter.exe +++ b/Exporter.exe Binary files differ diff --git a/Exporter.swf b/Exporter.swf index 484f56c..9c7464a 100644 --- a/Exporter.swf +++ b/Exporter.swf Binary files differ diff --git a/GraphicExport-app.xml b/GraphicExport-app.xml deleted file mode 100755 index 5144634..0000000 --- a/GraphicExport-app.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - GraphicExport - 1.0 - GraphicExport - - GraphicExport - - - GraphicExport.swf - standard - false - true - false - portrait - auto - true - true - true - - - false - false - desktop extendedDesktop diff --git a/GraphicExport.exe b/GraphicExport.exe deleted file mode 100755 index 56315aa..0000000 --- a/GraphicExport.exe +++ /dev/null Binary files differ diff --git a/GraphicExport.fla b/GraphicExport.fla deleted file mode 100755 index 0b78ed7..0000000 --- a/GraphicExport.fla +++ /dev/null Binary files differ diff --git a/GraphicExport.swf b/GraphicExport.swf deleted file mode 100644 index 542db97..0000000 --- a/GraphicExport.swf +++ /dev/null Binary files differ diff --git a/NewGraphicDialog.as b/NewGraphicDialog.as deleted file mode 100644 index 152011c..0000000 --- a/NewGraphicDialog.as +++ /dev/null @@ -1,224 +0,0 @@ -package { - - import flash.display.MovieClip; - import flash.events.MouseEvent; - import flash.events.*; - import flash.filesystem.File; - import flash.net.FileFilter; - import Defs.GraphicDef; - import flash.text.engine.GraphicElement; - - public class NewGraphicDialog extends MovieClip - { - - public function NewGraphicDialog() - { - // constructor code - Init(); - } - - var typeButtons:Array = new Array(); - - public function Init() - { - graphicPath.text = "Path to Graphic Here"; - - this.removeChild(browseButton); - - var newBrowseButton = new UI_GenericBlueButton(); - newBrowseButton.Text = "Browse"; - newBrowseButton.OnClick = BrowseForFile; - newBrowseButton.x = browseButton.x + (newBrowseButton.width / 2); - newBrowseButton.y = browseButton.y + (newBrowseButton.height / 2); - addChild(newBrowseButton); - - var newTestButton = new UI_GenericBlueButton(); - newTestButton.Text = "Export"; - newTestButton.OnClick = TestFile; - newTestButton.x = testButton.x + (newTestButton.width / 2); - newTestButton.y = testButton.y + (newTestButton.height / 2); - addChild(newTestButton); - - this.removeChild(typePlaceholderButton); - - var typeX = typePlaceholderButton.x; - var typeY = typePlaceholderButton.y + (typePlaceholderButton.height / 2); - - - var typeButton = new UI_GenericBlueButton(); - typeButton.Text = "Graphic (1)"; - typeButton.OnClick = function(){ SetType(1); } - typeButton.x = typeX + (typeButton.width / 2); - typeButton.y = typeY; - typeButtons.push(typeButton); - addChild(typeButton); - - typeX += typeButton.width + 5; - - typeButton = new UI_GenericBlueButton(); - typeButton.Text = "Skeletal (3)"; - typeButton.OnClick = function(){ SetType(3); } - typeButton.x = typeX + (typeButton.width / 2); - typeButton.y = typeY; - typeButtons.push(typeButton); - addChild(typeButton); - - typeX += typeButton.width + 5; - - typeButton = new UI_GenericBlueButton(); - typeButton.Text = "Scene (6)"; - typeButton.OnClick = function(){ SetType(6); } - typeButton.x = typeX + (typeButton.width / 2); - typeButton.y = typeY; - typeButtons.push(typeButton); - addChild(typeButton); - - animationCheckbox.Checked = true; - //browseButton - //typePlaceholderButton - //usesInput - //usesText.text = "" - } - - var usesInputDefaultText = "Comma Seperated List of Uses Here"; - - public static var fakeID = 9999999; - public function TestFile() - { - fakeID++; - var graphicName = graphicPath.text; - var graphicData = {id:fakeID,graphic:graphicPath.text,v:1,fs:0,p:0,type:selectedType}; - - //"export_params":{"uses":["background"],"available_sizes":["default"],"compress":false}} - - var graphicDef = new GraphicDef(graphicData); - - this.Hide(); - graphicExport.ExportItem(graphicDef); - } - - var selectedType = 1; - public function SetType(type:Number) - { - selectedType = type; - - for(var i = 0; i < typeButtons.length; i++) - { - typeButtons[i].Enabled = true; - } - - animationCheckbox.visible = false; - - switch(type) - { - case 1: { - typeButtons[0].Enabled = false; - animationCheckbox.visible = true; - break; - } - case 3: typeButtons[1].Enabled = false; break; - case 6: typeButtons[2].Enabled = false; break; - } - } - - var graphicExport:GraphicExport; - public function Show(parentClip) - { - this.graphicExport = parentClip; - - parentClip.addChild(this); - - SetType(selectedType); - - var graphicList = GameData.Instance().GraphicDefines; - - var usesString:String = ""; - var uniqueUseTypes:Array = new Array(); - for (var i = 0; i < graphicList.length; i++) - { - var graphicDef:GraphicDef = graphicList[i]; - var uses = graphicDef.ExportParams['uses']; - for (var usage in uses) - { - if (uniqueUseTypes[uses[usage]] == null) - { - uniqueUseTypes[uses[usage]] = uses[usage]; - usesString += uses[usage] + ", "; - } - } - } - - graphicPath.text = ""; - - } - - public function CloseClicked(event) - { - Hide(); - } - - public function Hide() - { - if (this.parent != null) this.parent.removeChild(this); - } - - public function BrowseForFile() - { - var file:File = new File(); - var swfTypeFilter:FileFilter = new FileFilter("SWF Files","*.swf"); - file.addEventListener(Event.SELECT, openFile); - file.browse([swfTypeFilter]); - } - - private function openFile(event:Event):void - { - _strace(event.target.nativePath); - var path:String = event.target.nativePath; - var pathParts:Array = path.split("Graphics\\"); - if (pathParts.length == 2) - { - var fileRemainder:String = pathParts[1]; - var withoutExtension:String = fileRemainder.split(".")[0]; - var pattern:RegExp = /\\/g; - withoutExtension = withoutExtension.replace(pattern, "/"); - _strace(withoutExtension); - graphicPath.text = withoutExtension; - - if (withoutExtension.indexOf("Backgrounds") > -1) - { - SetType(6); - } - - if (withoutExtension.indexOf("Monsters") > -1) - { - SetType(3); - } - - if (withoutExtension.indexOf("Characters") > -1) - { - SetType(3); - } - - if (withoutExtension.indexOf("Portraits") > -1) - { - SetType(1); - } - - if (withoutExtension.indexOf("Quest") > -1) - { - SetType(1); - } - - if (withoutExtension.indexOf("Equipment") > -1) - { - SetType(1); - } - - - } - } - - - } - -} diff --git a/PNGExportHelper.as b/PNGExportHelper.as deleted file mode 100644 index f8c4c9d..0000000 --- a/PNGExportHelper.as +++ /dev/null @@ -1,253 +0,0 @@ -package -{ - import flash.display.*; - import com.adobe.images.*; - import flash.utils.*; - import flash.net.*; - import flash.geom.Matrix; - import flash.geom.Rectangle; - import flash.geom.Point; - - public class PNGExportHelper - { - public static var UseExpandedBitmaps = false; - public static var AlphaThreshold = 5; - - private static function ExpandBitmapBorders(bd:BitmapData, bgColor = 0x0, passes = 1):BitmapData - { - /* - var thresh:BitmapData = new BitmapData(bd.width, bd.height, true, bgColor); - thresh.threshold(bd, bd.rect, new Point(), "<", (20 << 24), bgColor, 0xFF000000, true); - */ - var sampled:BitmapData = new BitmapData(bd.width, bd.height, true, bgColor); - bd.lock(); - sampled.lock(); - - for (var y = 0; y < bd.height; y++) - { - for (var x = 0; x < bd.width; x++) - { - var oldVal:uint = bd.getPixel32(x, y); - var a:uint = (oldVal & 0xFF000000) >>> 24; - var rgb:uint = (oldVal & 0xFFFFFF); - if (a > AlphaThreshold) - { - sampled.setPixel32(x, y, (0xFF << 24) | rgb); - } - else - { - sampled.setPixel32(x, y, bgColor); - } - } - } - sampled.unlock(); - bd.unlock(); - - return ExpandBitmapBordersInternal(sampled, bgColor, passes); - } - - private static function ExpandBitmapBordersInternal(bd:BitmapData, bgColor, passes):BitmapData - { - var output:BitmapData = new BitmapData(bd.width, bd.height, true, bgColor); - - var scale = 16; - var scaled:BitmapData = new BitmapData(bd.width/scale, bd.height/scale, true, bgColor); - var mat:Matrix = new Matrix(); - mat.scale(1/scale, 1/scale); - scaled.draw(bd, mat, null, null, null, true); - - output.lock(); - - var colors:Array = new Array(); - var weights:Array = new Array(); - - for (var oy = 0; oy < scaled.height; oy++) - { - - for (var ox = 0; ox < scaled.width; ox++) - { - - var scaledVal:uint = scaled.getPixel32(ox, oy); - var scaleda:uint = (scaledVal & 0xFF000000) >>> 24; - if (scaleda == 0 || scaleda == 255) - { - output.copyPixels(bd, new Rectangle(ox * scale, oy * scale, scale, scale), new Point(ox * scale, oy * scale)); - continue; - } else { - //_strace(scaleda+""); - } - - - for (var y = oy * scale; y < oy * scale + scale; y++) - { - for (var x = ox * scale; x < ox * scale + scale; x++) - { - var oldVal:uint = bd.getPixel32(x, y); - var a:uint = (oldVal & 0xFF000000) >>> 24; - var rgb:uint = (oldVal & 0xFFFFFF); - - if (a == 0 && rgb == bgColor) - { - colors.length = 0; - weights.length = 0; - - for (var y1 = y - 2; y1 <= y + 2; y1++) - { - for (var x1 = x - 2; x1 <= x + 2; x1++) - { - var dist = Math.abs(x1 - x) + Math.abs(y1 - y); - if (dist >= 3) continue; - - if (x1 >= 0 && x1 < bd.width && y1 >= 0 && y1 < bd.height) - { - colors.push(bd.getPixel(x1, y1)); - weights.push(1 - dist * 0.2); - } - } - } - - var newVal = AveragePixels(colors, weights, bgColor); - if (newVal == null) - { - newVal = oldVal; - } - else - { - var newR:uint = (newVal & 0xFF0000) >> 16; - var newG:uint = (newVal & 0xFF00) >> 8; - var newB:uint = (newVal & 0xFF); - - if (newVal != 0 && colors.length >= 4) - { - var bp = true; - } - - var sorted = colors.sort(function(a, b) - { - var aR:uint = (a & 0xFF0000) >> 16; - var aG:uint = (a & 0xFF00) >> 8; - var aB:uint = (a & 0xFF); - - var bR:uint = (b & 0xFF0000) >> 16; - var bG:uint = (b & 0xFF00) >> 8; - var bB:uint = (b & 0xFF); - - var diffA = Math.abs(aR - newR) + Math.abs(aG - newG) + Math.abs(aB - newB); - var diffB = Math.abs(bR - newR) + Math.abs(bG - newG) + Math.abs(bB - newB); - - return diffA - diffB; - - }, Array.RETURNINDEXEDARRAY | Array.DESCENDING); - - var toRemove = Math.min(2, colors.length - 4); - var removed = 0; - for (var i = 0; i < colors.length; i++) - { - var index = sorted.indexOf(i + removed); - if (index < toRemove) - { - colors.splice(i, 1); - weights.splice(i, 1); - removed++; - i--; - if (removed == toRemove) break; - } - } - - var fixOutliersVal = AveragePixels(colors, weights, bgColor); - if (fixOutliersVal == null) newVal = (0xFF << 24) | newVal; - - newVal = (0xFF << 24) | fixOutliersVal; - } - - output.setPixel32(x, y, newVal); - } - else - { - output.setPixel32(x, y, oldVal); - } - } - } - }//end outer scaled x - }//End outer scaled y - - bd.unlock(); - output.unlock(); - - passes--; - if (passes > 0) - { - return ExpandBitmapBordersInternal(output, bgColor, passes); - } - else - { - return output; - } - } - - private static function AveragePixels(colors:Array, weights:Array, bgColor:uint):uint - { - var rTotal = 0; - var gTotal = 0; - var bTotal = 0; - - var wTotal = 0; - - for (var i = 0; i < colors.length; i++) - { - var color:uint = colors[i]; - var a:uint = (color & 0xFF000000) >>> 24; - var rgb:uint = (color & 0xFFFFFF); - - if (a == 0 && rgb == bgColor) - { - colors.splice(i, 1); - weights.splice(i, 1); - i--; - continue; - } - - var r:uint = (rgb & 0xFF0000) >>> 16; - var g:uint = (rgb & 0xFF00) >>> 8; - var b:uint = (rgb & 0xFF); - var w = weights[i]; - - rTotal += w * r; - gTotal += w * g; - bTotal += w * b; - - wTotal += w; - } - - if (wTotal == 0) - { - return null; - } - - rTotal /= wTotal; - gTotal /= wTotal; - bTotal /= wTotal; - - var rFinal = Math.max(0, Math.min(255, Math.round(rTotal))); - var gFinal = Math.max(0, Math.min(255, Math.round(gTotal))); - var bFinal = Math.max(0, Math.min(255, Math.round(bTotal))); - - return (uint(rFinal) << 16) | (uint(gFinal) << 8) | (uint(bFinal)); - } - - - - public static function GetExportPNG(bd:BitmapData):ByteArray - { - if (!UseExpandedBitmaps) return PNGEncoder.encode(bd); - - var expanded:BitmapData = ExpandBitmapBorders(bd, 0x0, 2); - - //var fr:FileReference = new FileReference(); - //fr.save(PNGEncoder.encode(expanded), "output.png"); - - return PNGEncoderWithAlpha.encode(expanded, bd); - } - - } -} \ No newline at end of file diff --git a/PreviewHolder.as b/PreviewHolder.as deleted file mode 100644 index 587bf68..0000000 --- a/PreviewHolder.as +++ /dev/null @@ -1,57 +0,0 @@ -package { - import flash.display.MovieClip; - - public class PreviewHolder extends MovieClip - { - - var startingWidth = 1024; - var startingHeight = 1024; - - public function PreviewHolder() - { - startingWidth = this.width; - startingHeight = this.height; - } - - var clips:Array = new Array(); - public function AddClip(clip) - { - clips.push(clip); - this.addChild(clip); - ArrangeClips(); - } - - public function ArrangeClips() - { - var numCols = Math.ceil(Math.sqrt(clips.length)); - var maxY = 0; - var maxX = 0; - var clipIndex = 0; - for (var row = 0; row < numCols; row++) - { - var clipX = 0; - var clipY = maxY; - for (var col = 0; col < numCols; col++) - { - if (clipIndex == clips.length) break; - clips[clipIndex].x = clipX; - clips[clipIndex].y = clipY; - clipX += clips[clipIndex].width; - var clipBottom = clips[clipIndex].y + clips[clipIndex].height; - if (clipBottom > maxY) maxY = clipBottom; - - var clipRight = clips[clipIndex].x + clips[clipIndex].width; - if (clipRight > maxX) maxX = clipRight; - clipIndex++; - } - } - - var scale = Math.min(startingWidth / maxX, startingHeight / maxY); - if (scale > 1) scale = 1; - - this.scaleX = this.scaleY = scale; - } - - } - -} diff --git a/old/Checkbox.as b/old/Checkbox.as new file mode 100644 index 0000000..c5aaba2 --- /dev/null +++ b/old/Checkbox.as @@ -0,0 +1,42 @@ +package { + + import flash.display.MovieClip; + import flash.events.MouseEvent; + + public class Checkbox extends MovieClip + { + public var Enabled:Boolean = true; + public function Checkbox() + { + checkbox.gotoAndStop(1); + checkbox.addEventListener(MouseEvent.CLICK, Clicked); + } + + protected function Clicked(event) + { + if (!Enabled) return; + Toggle(); + if (OnClick != null) OnClick(OnClickParam); + } + + protected var checked = false; + public function set Checked(value) { checked = value; checkbox.gotoAndStop(checked ? 2 : 1); } + public function get Checked() { return checked; } + + public function set Text(value) { text.text = value; } + + public var OnClickParam; + public var OnClick; + + + public function Toggle() + { + checked = !checked; + checkbox.gotoAndStop(checked ? 2 : 1); + + + } + + } + +} diff --git a/old/GraphicExport-app.xml b/old/GraphicExport-app.xml new file mode 100644 index 0000000..5144634 --- /dev/null +++ b/old/GraphicExport-app.xml @@ -0,0 +1,41 @@ + + + + GraphicExport + 1.0 + GraphicExport + + GraphicExport + + + GraphicExport.swf + standard + false + true + false + portrait + auto + true + true + true + + + false + false + desktop extendedDesktop diff --git a/old/GraphicExport.exe b/old/GraphicExport.exe new file mode 100644 index 0000000..56315aa --- /dev/null +++ b/old/GraphicExport.exe Binary files differ diff --git a/old/GraphicExport.fla b/old/GraphicExport.fla new file mode 100644 index 0000000..0b78ed7 --- /dev/null +++ b/old/GraphicExport.fla Binary files differ diff --git a/Checkbox.as b/Checkbox.as deleted file mode 100644 index c5aaba2..0000000 --- a/Checkbox.as +++ /dev/null @@ -1,42 +0,0 @@ -package { - - import flash.display.MovieClip; - import flash.events.MouseEvent; - - public class Checkbox extends MovieClip - { - public var Enabled:Boolean = true; - public function Checkbox() - { - checkbox.gotoAndStop(1); - checkbox.addEventListener(MouseEvent.CLICK, Clicked); - } - - protected function Clicked(event) - { - if (!Enabled) return; - Toggle(); - if (OnClick != null) OnClick(OnClickParam); - } - - protected var checked = false; - public function set Checked(value) { checked = value; checkbox.gotoAndStop(checked ? 2 : 1); } - public function get Checked() { return checked; } - - public function set Text(value) { text.text = value; } - - public var OnClickParam; - public var OnClick; - - - public function Toggle() - { - checked = !checked; - checkbox.gotoAndStop(checked ? 2 : 1); - - - } - - } - -} diff --git a/Exporter-app.xml b/Exporter-app.xml index dbb9ba7..7deb7c5 100755 --- a/Exporter-app.xml +++ b/Exporter-app.xml @@ -16,7 +16,7 @@ Japanese App name goes here --> - + Exporter 1.0 Exporter diff --git a/Exporter.exe b/Exporter.exe index aa5d57e..7833fe5 100755 --- a/Exporter.exe +++ b/Exporter.exe Binary files differ diff --git a/Exporter.swf b/Exporter.swf index 484f56c..9c7464a 100644 --- a/Exporter.swf +++ b/Exporter.swf Binary files differ diff --git a/GraphicExport-app.xml b/GraphicExport-app.xml deleted file mode 100755 index 5144634..0000000 --- a/GraphicExport-app.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - GraphicExport - 1.0 - GraphicExport - - GraphicExport - - - GraphicExport.swf - standard - false - true - false - portrait - auto - true - true - true - - - false - false - desktop extendedDesktop diff --git a/GraphicExport.exe b/GraphicExport.exe deleted file mode 100755 index 56315aa..0000000 --- a/GraphicExport.exe +++ /dev/null Binary files differ diff --git a/GraphicExport.fla b/GraphicExport.fla deleted file mode 100755 index 0b78ed7..0000000 --- a/GraphicExport.fla +++ /dev/null Binary files differ diff --git a/GraphicExport.swf b/GraphicExport.swf deleted file mode 100644 index 542db97..0000000 --- a/GraphicExport.swf +++ /dev/null Binary files differ diff --git a/NewGraphicDialog.as b/NewGraphicDialog.as deleted file mode 100644 index 152011c..0000000 --- a/NewGraphicDialog.as +++ /dev/null @@ -1,224 +0,0 @@ -package { - - import flash.display.MovieClip; - import flash.events.MouseEvent; - import flash.events.*; - import flash.filesystem.File; - import flash.net.FileFilter; - import Defs.GraphicDef; - import flash.text.engine.GraphicElement; - - public class NewGraphicDialog extends MovieClip - { - - public function NewGraphicDialog() - { - // constructor code - Init(); - } - - var typeButtons:Array = new Array(); - - public function Init() - { - graphicPath.text = "Path to Graphic Here"; - - this.removeChild(browseButton); - - var newBrowseButton = new UI_GenericBlueButton(); - newBrowseButton.Text = "Browse"; - newBrowseButton.OnClick = BrowseForFile; - newBrowseButton.x = browseButton.x + (newBrowseButton.width / 2); - newBrowseButton.y = browseButton.y + (newBrowseButton.height / 2); - addChild(newBrowseButton); - - var newTestButton = new UI_GenericBlueButton(); - newTestButton.Text = "Export"; - newTestButton.OnClick = TestFile; - newTestButton.x = testButton.x + (newTestButton.width / 2); - newTestButton.y = testButton.y + (newTestButton.height / 2); - addChild(newTestButton); - - this.removeChild(typePlaceholderButton); - - var typeX = typePlaceholderButton.x; - var typeY = typePlaceholderButton.y + (typePlaceholderButton.height / 2); - - - var typeButton = new UI_GenericBlueButton(); - typeButton.Text = "Graphic (1)"; - typeButton.OnClick = function(){ SetType(1); } - typeButton.x = typeX + (typeButton.width / 2); - typeButton.y = typeY; - typeButtons.push(typeButton); - addChild(typeButton); - - typeX += typeButton.width + 5; - - typeButton = new UI_GenericBlueButton(); - typeButton.Text = "Skeletal (3)"; - typeButton.OnClick = function(){ SetType(3); } - typeButton.x = typeX + (typeButton.width / 2); - typeButton.y = typeY; - typeButtons.push(typeButton); - addChild(typeButton); - - typeX += typeButton.width + 5; - - typeButton = new UI_GenericBlueButton(); - typeButton.Text = "Scene (6)"; - typeButton.OnClick = function(){ SetType(6); } - typeButton.x = typeX + (typeButton.width / 2); - typeButton.y = typeY; - typeButtons.push(typeButton); - addChild(typeButton); - - animationCheckbox.Checked = true; - //browseButton - //typePlaceholderButton - //usesInput - //usesText.text = "" - } - - var usesInputDefaultText = "Comma Seperated List of Uses Here"; - - public static var fakeID = 9999999; - public function TestFile() - { - fakeID++; - var graphicName = graphicPath.text; - var graphicData = {id:fakeID,graphic:graphicPath.text,v:1,fs:0,p:0,type:selectedType}; - - //"export_params":{"uses":["background"],"available_sizes":["default"],"compress":false}} - - var graphicDef = new GraphicDef(graphicData); - - this.Hide(); - graphicExport.ExportItem(graphicDef); - } - - var selectedType = 1; - public function SetType(type:Number) - { - selectedType = type; - - for(var i = 0; i < typeButtons.length; i++) - { - typeButtons[i].Enabled = true; - } - - animationCheckbox.visible = false; - - switch(type) - { - case 1: { - typeButtons[0].Enabled = false; - animationCheckbox.visible = true; - break; - } - case 3: typeButtons[1].Enabled = false; break; - case 6: typeButtons[2].Enabled = false; break; - } - } - - var graphicExport:GraphicExport; - public function Show(parentClip) - { - this.graphicExport = parentClip; - - parentClip.addChild(this); - - SetType(selectedType); - - var graphicList = GameData.Instance().GraphicDefines; - - var usesString:String = ""; - var uniqueUseTypes:Array = new Array(); - for (var i = 0; i < graphicList.length; i++) - { - var graphicDef:GraphicDef = graphicList[i]; - var uses = graphicDef.ExportParams['uses']; - for (var usage in uses) - { - if (uniqueUseTypes[uses[usage]] == null) - { - uniqueUseTypes[uses[usage]] = uses[usage]; - usesString += uses[usage] + ", "; - } - } - } - - graphicPath.text = ""; - - } - - public function CloseClicked(event) - { - Hide(); - } - - public function Hide() - { - if (this.parent != null) this.parent.removeChild(this); - } - - public function BrowseForFile() - { - var file:File = new File(); - var swfTypeFilter:FileFilter = new FileFilter("SWF Files","*.swf"); - file.addEventListener(Event.SELECT, openFile); - file.browse([swfTypeFilter]); - } - - private function openFile(event:Event):void - { - _strace(event.target.nativePath); - var path:String = event.target.nativePath; - var pathParts:Array = path.split("Graphics\\"); - if (pathParts.length == 2) - { - var fileRemainder:String = pathParts[1]; - var withoutExtension:String = fileRemainder.split(".")[0]; - var pattern:RegExp = /\\/g; - withoutExtension = withoutExtension.replace(pattern, "/"); - _strace(withoutExtension); - graphicPath.text = withoutExtension; - - if (withoutExtension.indexOf("Backgrounds") > -1) - { - SetType(6); - } - - if (withoutExtension.indexOf("Monsters") > -1) - { - SetType(3); - } - - if (withoutExtension.indexOf("Characters") > -1) - { - SetType(3); - } - - if (withoutExtension.indexOf("Portraits") > -1) - { - SetType(1); - } - - if (withoutExtension.indexOf("Quest") > -1) - { - SetType(1); - } - - if (withoutExtension.indexOf("Equipment") > -1) - { - SetType(1); - } - - - } - } - - - } - -} diff --git a/PNGExportHelper.as b/PNGExportHelper.as deleted file mode 100644 index f8c4c9d..0000000 --- a/PNGExportHelper.as +++ /dev/null @@ -1,253 +0,0 @@ -package -{ - import flash.display.*; - import com.adobe.images.*; - import flash.utils.*; - import flash.net.*; - import flash.geom.Matrix; - import flash.geom.Rectangle; - import flash.geom.Point; - - public class PNGExportHelper - { - public static var UseExpandedBitmaps = false; - public static var AlphaThreshold = 5; - - private static function ExpandBitmapBorders(bd:BitmapData, bgColor = 0x0, passes = 1):BitmapData - { - /* - var thresh:BitmapData = new BitmapData(bd.width, bd.height, true, bgColor); - thresh.threshold(bd, bd.rect, new Point(), "<", (20 << 24), bgColor, 0xFF000000, true); - */ - var sampled:BitmapData = new BitmapData(bd.width, bd.height, true, bgColor); - bd.lock(); - sampled.lock(); - - for (var y = 0; y < bd.height; y++) - { - for (var x = 0; x < bd.width; x++) - { - var oldVal:uint = bd.getPixel32(x, y); - var a:uint = (oldVal & 0xFF000000) >>> 24; - var rgb:uint = (oldVal & 0xFFFFFF); - if (a > AlphaThreshold) - { - sampled.setPixel32(x, y, (0xFF << 24) | rgb); - } - else - { - sampled.setPixel32(x, y, bgColor); - } - } - } - sampled.unlock(); - bd.unlock(); - - return ExpandBitmapBordersInternal(sampled, bgColor, passes); - } - - private static function ExpandBitmapBordersInternal(bd:BitmapData, bgColor, passes):BitmapData - { - var output:BitmapData = new BitmapData(bd.width, bd.height, true, bgColor); - - var scale = 16; - var scaled:BitmapData = new BitmapData(bd.width/scale, bd.height/scale, true, bgColor); - var mat:Matrix = new Matrix(); - mat.scale(1/scale, 1/scale); - scaled.draw(bd, mat, null, null, null, true); - - output.lock(); - - var colors:Array = new Array(); - var weights:Array = new Array(); - - for (var oy = 0; oy < scaled.height; oy++) - { - - for (var ox = 0; ox < scaled.width; ox++) - { - - var scaledVal:uint = scaled.getPixel32(ox, oy); - var scaleda:uint = (scaledVal & 0xFF000000) >>> 24; - if (scaleda == 0 || scaleda == 255) - { - output.copyPixels(bd, new Rectangle(ox * scale, oy * scale, scale, scale), new Point(ox * scale, oy * scale)); - continue; - } else { - //_strace(scaleda+""); - } - - - for (var y = oy * scale; y < oy * scale + scale; y++) - { - for (var x = ox * scale; x < ox * scale + scale; x++) - { - var oldVal:uint = bd.getPixel32(x, y); - var a:uint = (oldVal & 0xFF000000) >>> 24; - var rgb:uint = (oldVal & 0xFFFFFF); - - if (a == 0 && rgb == bgColor) - { - colors.length = 0; - weights.length = 0; - - for (var y1 = y - 2; y1 <= y + 2; y1++) - { - for (var x1 = x - 2; x1 <= x + 2; x1++) - { - var dist = Math.abs(x1 - x) + Math.abs(y1 - y); - if (dist >= 3) continue; - - if (x1 >= 0 && x1 < bd.width && y1 >= 0 && y1 < bd.height) - { - colors.push(bd.getPixel(x1, y1)); - weights.push(1 - dist * 0.2); - } - } - } - - var newVal = AveragePixels(colors, weights, bgColor); - if (newVal == null) - { - newVal = oldVal; - } - else - { - var newR:uint = (newVal & 0xFF0000) >> 16; - var newG:uint = (newVal & 0xFF00) >> 8; - var newB:uint = (newVal & 0xFF); - - if (newVal != 0 && colors.length >= 4) - { - var bp = true; - } - - var sorted = colors.sort(function(a, b) - { - var aR:uint = (a & 0xFF0000) >> 16; - var aG:uint = (a & 0xFF00) >> 8; - var aB:uint = (a & 0xFF); - - var bR:uint = (b & 0xFF0000) >> 16; - var bG:uint = (b & 0xFF00) >> 8; - var bB:uint = (b & 0xFF); - - var diffA = Math.abs(aR - newR) + Math.abs(aG - newG) + Math.abs(aB - newB); - var diffB = Math.abs(bR - newR) + Math.abs(bG - newG) + Math.abs(bB - newB); - - return diffA - diffB; - - }, Array.RETURNINDEXEDARRAY | Array.DESCENDING); - - var toRemove = Math.min(2, colors.length - 4); - var removed = 0; - for (var i = 0; i < colors.length; i++) - { - var index = sorted.indexOf(i + removed); - if (index < toRemove) - { - colors.splice(i, 1); - weights.splice(i, 1); - removed++; - i--; - if (removed == toRemove) break; - } - } - - var fixOutliersVal = AveragePixels(colors, weights, bgColor); - if (fixOutliersVal == null) newVal = (0xFF << 24) | newVal; - - newVal = (0xFF << 24) | fixOutliersVal; - } - - output.setPixel32(x, y, newVal); - } - else - { - output.setPixel32(x, y, oldVal); - } - } - } - }//end outer scaled x - }//End outer scaled y - - bd.unlock(); - output.unlock(); - - passes--; - if (passes > 0) - { - return ExpandBitmapBordersInternal(output, bgColor, passes); - } - else - { - return output; - } - } - - private static function AveragePixels(colors:Array, weights:Array, bgColor:uint):uint - { - var rTotal = 0; - var gTotal = 0; - var bTotal = 0; - - var wTotal = 0; - - for (var i = 0; i < colors.length; i++) - { - var color:uint = colors[i]; - var a:uint = (color & 0xFF000000) >>> 24; - var rgb:uint = (color & 0xFFFFFF); - - if (a == 0 && rgb == bgColor) - { - colors.splice(i, 1); - weights.splice(i, 1); - i--; - continue; - } - - var r:uint = (rgb & 0xFF0000) >>> 16; - var g:uint = (rgb & 0xFF00) >>> 8; - var b:uint = (rgb & 0xFF); - var w = weights[i]; - - rTotal += w * r; - gTotal += w * g; - bTotal += w * b; - - wTotal += w; - } - - if (wTotal == 0) - { - return null; - } - - rTotal /= wTotal; - gTotal /= wTotal; - bTotal /= wTotal; - - var rFinal = Math.max(0, Math.min(255, Math.round(rTotal))); - var gFinal = Math.max(0, Math.min(255, Math.round(gTotal))); - var bFinal = Math.max(0, Math.min(255, Math.round(bTotal))); - - return (uint(rFinal) << 16) | (uint(gFinal) << 8) | (uint(bFinal)); - } - - - - public static function GetExportPNG(bd:BitmapData):ByteArray - { - if (!UseExpandedBitmaps) return PNGEncoder.encode(bd); - - var expanded:BitmapData = ExpandBitmapBorders(bd, 0x0, 2); - - //var fr:FileReference = new FileReference(); - //fr.save(PNGEncoder.encode(expanded), "output.png"); - - return PNGEncoderWithAlpha.encode(expanded, bd); - } - - } -} \ No newline at end of file diff --git a/PreviewHolder.as b/PreviewHolder.as deleted file mode 100644 index 587bf68..0000000 --- a/PreviewHolder.as +++ /dev/null @@ -1,57 +0,0 @@ -package { - import flash.display.MovieClip; - - public class PreviewHolder extends MovieClip - { - - var startingWidth = 1024; - var startingHeight = 1024; - - public function PreviewHolder() - { - startingWidth = this.width; - startingHeight = this.height; - } - - var clips:Array = new Array(); - public function AddClip(clip) - { - clips.push(clip); - this.addChild(clip); - ArrangeClips(); - } - - public function ArrangeClips() - { - var numCols = Math.ceil(Math.sqrt(clips.length)); - var maxY = 0; - var maxX = 0; - var clipIndex = 0; - for (var row = 0; row < numCols; row++) - { - var clipX = 0; - var clipY = maxY; - for (var col = 0; col < numCols; col++) - { - if (clipIndex == clips.length) break; - clips[clipIndex].x = clipX; - clips[clipIndex].y = clipY; - clipX += clips[clipIndex].width; - var clipBottom = clips[clipIndex].y + clips[clipIndex].height; - if (clipBottom > maxY) maxY = clipBottom; - - var clipRight = clips[clipIndex].x + clips[clipIndex].width; - if (clipRight > maxX) maxX = clipRight; - clipIndex++; - } - } - - var scale = Math.min(startingWidth / maxX, startingHeight / maxY); - if (scale > 1) scale = 1; - - this.scaleX = this.scaleY = scale; - } - - } - -} diff --git a/old/Checkbox.as b/old/Checkbox.as new file mode 100644 index 0000000..c5aaba2 --- /dev/null +++ b/old/Checkbox.as @@ -0,0 +1,42 @@ +package { + + import flash.display.MovieClip; + import flash.events.MouseEvent; + + public class Checkbox extends MovieClip + { + public var Enabled:Boolean = true; + public function Checkbox() + { + checkbox.gotoAndStop(1); + checkbox.addEventListener(MouseEvent.CLICK, Clicked); + } + + protected function Clicked(event) + { + if (!Enabled) return; + Toggle(); + if (OnClick != null) OnClick(OnClickParam); + } + + protected var checked = false; + public function set Checked(value) { checked = value; checkbox.gotoAndStop(checked ? 2 : 1); } + public function get Checked() { return checked; } + + public function set Text(value) { text.text = value; } + + public var OnClickParam; + public var OnClick; + + + public function Toggle() + { + checked = !checked; + checkbox.gotoAndStop(checked ? 2 : 1); + + + } + + } + +} diff --git a/old/GraphicExport-app.xml b/old/GraphicExport-app.xml new file mode 100644 index 0000000..5144634 --- /dev/null +++ b/old/GraphicExport-app.xml @@ -0,0 +1,41 @@ + + + + GraphicExport + 1.0 + GraphicExport + + GraphicExport + + + GraphicExport.swf + standard + false + true + false + portrait + auto + true + true + true + + + false + false + desktop extendedDesktop diff --git a/old/GraphicExport.exe b/old/GraphicExport.exe new file mode 100644 index 0000000..56315aa --- /dev/null +++ b/old/GraphicExport.exe Binary files differ diff --git a/old/GraphicExport.fla b/old/GraphicExport.fla new file mode 100644 index 0000000..0b78ed7 --- /dev/null +++ b/old/GraphicExport.fla Binary files differ diff --git a/old/GraphicExport.swf b/old/GraphicExport.swf new file mode 100644 index 0000000..542db97 --- /dev/null +++ b/old/GraphicExport.swf Binary files differ diff --git a/Checkbox.as b/Checkbox.as deleted file mode 100644 index c5aaba2..0000000 --- a/Checkbox.as +++ /dev/null @@ -1,42 +0,0 @@ -package { - - import flash.display.MovieClip; - import flash.events.MouseEvent; - - public class Checkbox extends MovieClip - { - public var Enabled:Boolean = true; - public function Checkbox() - { - checkbox.gotoAndStop(1); - checkbox.addEventListener(MouseEvent.CLICK, Clicked); - } - - protected function Clicked(event) - { - if (!Enabled) return; - Toggle(); - if (OnClick != null) OnClick(OnClickParam); - } - - protected var checked = false; - public function set Checked(value) { checked = value; checkbox.gotoAndStop(checked ? 2 : 1); } - public function get Checked() { return checked; } - - public function set Text(value) { text.text = value; } - - public var OnClickParam; - public var OnClick; - - - public function Toggle() - { - checked = !checked; - checkbox.gotoAndStop(checked ? 2 : 1); - - - } - - } - -} diff --git a/Exporter-app.xml b/Exporter-app.xml index dbb9ba7..7deb7c5 100755 --- a/Exporter-app.xml +++ b/Exporter-app.xml @@ -16,7 +16,7 @@ Japanese App name goes here --> - + Exporter 1.0 Exporter diff --git a/Exporter.exe b/Exporter.exe index aa5d57e..7833fe5 100755 --- a/Exporter.exe +++ b/Exporter.exe Binary files differ diff --git a/Exporter.swf b/Exporter.swf index 484f56c..9c7464a 100644 --- a/Exporter.swf +++ b/Exporter.swf Binary files differ diff --git a/GraphicExport-app.xml b/GraphicExport-app.xml deleted file mode 100755 index 5144634..0000000 --- a/GraphicExport-app.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - GraphicExport - 1.0 - GraphicExport - - GraphicExport - - - GraphicExport.swf - standard - false - true - false - portrait - auto - true - true - true - - - false - false - desktop extendedDesktop diff --git a/GraphicExport.exe b/GraphicExport.exe deleted file mode 100755 index 56315aa..0000000 --- a/GraphicExport.exe +++ /dev/null Binary files differ diff --git a/GraphicExport.fla b/GraphicExport.fla deleted file mode 100755 index 0b78ed7..0000000 --- a/GraphicExport.fla +++ /dev/null Binary files differ diff --git a/GraphicExport.swf b/GraphicExport.swf deleted file mode 100644 index 542db97..0000000 --- a/GraphicExport.swf +++ /dev/null Binary files differ diff --git a/NewGraphicDialog.as b/NewGraphicDialog.as deleted file mode 100644 index 152011c..0000000 --- a/NewGraphicDialog.as +++ /dev/null @@ -1,224 +0,0 @@ -package { - - import flash.display.MovieClip; - import flash.events.MouseEvent; - import flash.events.*; - import flash.filesystem.File; - import flash.net.FileFilter; - import Defs.GraphicDef; - import flash.text.engine.GraphicElement; - - public class NewGraphicDialog extends MovieClip - { - - public function NewGraphicDialog() - { - // constructor code - Init(); - } - - var typeButtons:Array = new Array(); - - public function Init() - { - graphicPath.text = "Path to Graphic Here"; - - this.removeChild(browseButton); - - var newBrowseButton = new UI_GenericBlueButton(); - newBrowseButton.Text = "Browse"; - newBrowseButton.OnClick = BrowseForFile; - newBrowseButton.x = browseButton.x + (newBrowseButton.width / 2); - newBrowseButton.y = browseButton.y + (newBrowseButton.height / 2); - addChild(newBrowseButton); - - var newTestButton = new UI_GenericBlueButton(); - newTestButton.Text = "Export"; - newTestButton.OnClick = TestFile; - newTestButton.x = testButton.x + (newTestButton.width / 2); - newTestButton.y = testButton.y + (newTestButton.height / 2); - addChild(newTestButton); - - this.removeChild(typePlaceholderButton); - - var typeX = typePlaceholderButton.x; - var typeY = typePlaceholderButton.y + (typePlaceholderButton.height / 2); - - - var typeButton = new UI_GenericBlueButton(); - typeButton.Text = "Graphic (1)"; - typeButton.OnClick = function(){ SetType(1); } - typeButton.x = typeX + (typeButton.width / 2); - typeButton.y = typeY; - typeButtons.push(typeButton); - addChild(typeButton); - - typeX += typeButton.width + 5; - - typeButton = new UI_GenericBlueButton(); - typeButton.Text = "Skeletal (3)"; - typeButton.OnClick = function(){ SetType(3); } - typeButton.x = typeX + (typeButton.width / 2); - typeButton.y = typeY; - typeButtons.push(typeButton); - addChild(typeButton); - - typeX += typeButton.width + 5; - - typeButton = new UI_GenericBlueButton(); - typeButton.Text = "Scene (6)"; - typeButton.OnClick = function(){ SetType(6); } - typeButton.x = typeX + (typeButton.width / 2); - typeButton.y = typeY; - typeButtons.push(typeButton); - addChild(typeButton); - - animationCheckbox.Checked = true; - //browseButton - //typePlaceholderButton - //usesInput - //usesText.text = "" - } - - var usesInputDefaultText = "Comma Seperated List of Uses Here"; - - public static var fakeID = 9999999; - public function TestFile() - { - fakeID++; - var graphicName = graphicPath.text; - var graphicData = {id:fakeID,graphic:graphicPath.text,v:1,fs:0,p:0,type:selectedType}; - - //"export_params":{"uses":["background"],"available_sizes":["default"],"compress":false}} - - var graphicDef = new GraphicDef(graphicData); - - this.Hide(); - graphicExport.ExportItem(graphicDef); - } - - var selectedType = 1; - public function SetType(type:Number) - { - selectedType = type; - - for(var i = 0; i < typeButtons.length; i++) - { - typeButtons[i].Enabled = true; - } - - animationCheckbox.visible = false; - - switch(type) - { - case 1: { - typeButtons[0].Enabled = false; - animationCheckbox.visible = true; - break; - } - case 3: typeButtons[1].Enabled = false; break; - case 6: typeButtons[2].Enabled = false; break; - } - } - - var graphicExport:GraphicExport; - public function Show(parentClip) - { - this.graphicExport = parentClip; - - parentClip.addChild(this); - - SetType(selectedType); - - var graphicList = GameData.Instance().GraphicDefines; - - var usesString:String = ""; - var uniqueUseTypes:Array = new Array(); - for (var i = 0; i < graphicList.length; i++) - { - var graphicDef:GraphicDef = graphicList[i]; - var uses = graphicDef.ExportParams['uses']; - for (var usage in uses) - { - if (uniqueUseTypes[uses[usage]] == null) - { - uniqueUseTypes[uses[usage]] = uses[usage]; - usesString += uses[usage] + ", "; - } - } - } - - graphicPath.text = ""; - - } - - public function CloseClicked(event) - { - Hide(); - } - - public function Hide() - { - if (this.parent != null) this.parent.removeChild(this); - } - - public function BrowseForFile() - { - var file:File = new File(); - var swfTypeFilter:FileFilter = new FileFilter("SWF Files","*.swf"); - file.addEventListener(Event.SELECT, openFile); - file.browse([swfTypeFilter]); - } - - private function openFile(event:Event):void - { - _strace(event.target.nativePath); - var path:String = event.target.nativePath; - var pathParts:Array = path.split("Graphics\\"); - if (pathParts.length == 2) - { - var fileRemainder:String = pathParts[1]; - var withoutExtension:String = fileRemainder.split(".")[0]; - var pattern:RegExp = /\\/g; - withoutExtension = withoutExtension.replace(pattern, "/"); - _strace(withoutExtension); - graphicPath.text = withoutExtension; - - if (withoutExtension.indexOf("Backgrounds") > -1) - { - SetType(6); - } - - if (withoutExtension.indexOf("Monsters") > -1) - { - SetType(3); - } - - if (withoutExtension.indexOf("Characters") > -1) - { - SetType(3); - } - - if (withoutExtension.indexOf("Portraits") > -1) - { - SetType(1); - } - - if (withoutExtension.indexOf("Quest") > -1) - { - SetType(1); - } - - if (withoutExtension.indexOf("Equipment") > -1) - { - SetType(1); - } - - - } - } - - - } - -} diff --git a/PNGExportHelper.as b/PNGExportHelper.as deleted file mode 100644 index f8c4c9d..0000000 --- a/PNGExportHelper.as +++ /dev/null @@ -1,253 +0,0 @@ -package -{ - import flash.display.*; - import com.adobe.images.*; - import flash.utils.*; - import flash.net.*; - import flash.geom.Matrix; - import flash.geom.Rectangle; - import flash.geom.Point; - - public class PNGExportHelper - { - public static var UseExpandedBitmaps = false; - public static var AlphaThreshold = 5; - - private static function ExpandBitmapBorders(bd:BitmapData, bgColor = 0x0, passes = 1):BitmapData - { - /* - var thresh:BitmapData = new BitmapData(bd.width, bd.height, true, bgColor); - thresh.threshold(bd, bd.rect, new Point(), "<", (20 << 24), bgColor, 0xFF000000, true); - */ - var sampled:BitmapData = new BitmapData(bd.width, bd.height, true, bgColor); - bd.lock(); - sampled.lock(); - - for (var y = 0; y < bd.height; y++) - { - for (var x = 0; x < bd.width; x++) - { - var oldVal:uint = bd.getPixel32(x, y); - var a:uint = (oldVal & 0xFF000000) >>> 24; - var rgb:uint = (oldVal & 0xFFFFFF); - if (a > AlphaThreshold) - { - sampled.setPixel32(x, y, (0xFF << 24) | rgb); - } - else - { - sampled.setPixel32(x, y, bgColor); - } - } - } - sampled.unlock(); - bd.unlock(); - - return ExpandBitmapBordersInternal(sampled, bgColor, passes); - } - - private static function ExpandBitmapBordersInternal(bd:BitmapData, bgColor, passes):BitmapData - { - var output:BitmapData = new BitmapData(bd.width, bd.height, true, bgColor); - - var scale = 16; - var scaled:BitmapData = new BitmapData(bd.width/scale, bd.height/scale, true, bgColor); - var mat:Matrix = new Matrix(); - mat.scale(1/scale, 1/scale); - scaled.draw(bd, mat, null, null, null, true); - - output.lock(); - - var colors:Array = new Array(); - var weights:Array = new Array(); - - for (var oy = 0; oy < scaled.height; oy++) - { - - for (var ox = 0; ox < scaled.width; ox++) - { - - var scaledVal:uint = scaled.getPixel32(ox, oy); - var scaleda:uint = (scaledVal & 0xFF000000) >>> 24; - if (scaleda == 0 || scaleda == 255) - { - output.copyPixels(bd, new Rectangle(ox * scale, oy * scale, scale, scale), new Point(ox * scale, oy * scale)); - continue; - } else { - //_strace(scaleda+""); - } - - - for (var y = oy * scale; y < oy * scale + scale; y++) - { - for (var x = ox * scale; x < ox * scale + scale; x++) - { - var oldVal:uint = bd.getPixel32(x, y); - var a:uint = (oldVal & 0xFF000000) >>> 24; - var rgb:uint = (oldVal & 0xFFFFFF); - - if (a == 0 && rgb == bgColor) - { - colors.length = 0; - weights.length = 0; - - for (var y1 = y - 2; y1 <= y + 2; y1++) - { - for (var x1 = x - 2; x1 <= x + 2; x1++) - { - var dist = Math.abs(x1 - x) + Math.abs(y1 - y); - if (dist >= 3) continue; - - if (x1 >= 0 && x1 < bd.width && y1 >= 0 && y1 < bd.height) - { - colors.push(bd.getPixel(x1, y1)); - weights.push(1 - dist * 0.2); - } - } - } - - var newVal = AveragePixels(colors, weights, bgColor); - if (newVal == null) - { - newVal = oldVal; - } - else - { - var newR:uint = (newVal & 0xFF0000) >> 16; - var newG:uint = (newVal & 0xFF00) >> 8; - var newB:uint = (newVal & 0xFF); - - if (newVal != 0 && colors.length >= 4) - { - var bp = true; - } - - var sorted = colors.sort(function(a, b) - { - var aR:uint = (a & 0xFF0000) >> 16; - var aG:uint = (a & 0xFF00) >> 8; - var aB:uint = (a & 0xFF); - - var bR:uint = (b & 0xFF0000) >> 16; - var bG:uint = (b & 0xFF00) >> 8; - var bB:uint = (b & 0xFF); - - var diffA = Math.abs(aR - newR) + Math.abs(aG - newG) + Math.abs(aB - newB); - var diffB = Math.abs(bR - newR) + Math.abs(bG - newG) + Math.abs(bB - newB); - - return diffA - diffB; - - }, Array.RETURNINDEXEDARRAY | Array.DESCENDING); - - var toRemove = Math.min(2, colors.length - 4); - var removed = 0; - for (var i = 0; i < colors.length; i++) - { - var index = sorted.indexOf(i + removed); - if (index < toRemove) - { - colors.splice(i, 1); - weights.splice(i, 1); - removed++; - i--; - if (removed == toRemove) break; - } - } - - var fixOutliersVal = AveragePixels(colors, weights, bgColor); - if (fixOutliersVal == null) newVal = (0xFF << 24) | newVal; - - newVal = (0xFF << 24) | fixOutliersVal; - } - - output.setPixel32(x, y, newVal); - } - else - { - output.setPixel32(x, y, oldVal); - } - } - } - }//end outer scaled x - }//End outer scaled y - - bd.unlock(); - output.unlock(); - - passes--; - if (passes > 0) - { - return ExpandBitmapBordersInternal(output, bgColor, passes); - } - else - { - return output; - } - } - - private static function AveragePixels(colors:Array, weights:Array, bgColor:uint):uint - { - var rTotal = 0; - var gTotal = 0; - var bTotal = 0; - - var wTotal = 0; - - for (var i = 0; i < colors.length; i++) - { - var color:uint = colors[i]; - var a:uint = (color & 0xFF000000) >>> 24; - var rgb:uint = (color & 0xFFFFFF); - - if (a == 0 && rgb == bgColor) - { - colors.splice(i, 1); - weights.splice(i, 1); - i--; - continue; - } - - var r:uint = (rgb & 0xFF0000) >>> 16; - var g:uint = (rgb & 0xFF00) >>> 8; - var b:uint = (rgb & 0xFF); - var w = weights[i]; - - rTotal += w * r; - gTotal += w * g; - bTotal += w * b; - - wTotal += w; - } - - if (wTotal == 0) - { - return null; - } - - rTotal /= wTotal; - gTotal /= wTotal; - bTotal /= wTotal; - - var rFinal = Math.max(0, Math.min(255, Math.round(rTotal))); - var gFinal = Math.max(0, Math.min(255, Math.round(gTotal))); - var bFinal = Math.max(0, Math.min(255, Math.round(bTotal))); - - return (uint(rFinal) << 16) | (uint(gFinal) << 8) | (uint(bFinal)); - } - - - - public static function GetExportPNG(bd:BitmapData):ByteArray - { - if (!UseExpandedBitmaps) return PNGEncoder.encode(bd); - - var expanded:BitmapData = ExpandBitmapBorders(bd, 0x0, 2); - - //var fr:FileReference = new FileReference(); - //fr.save(PNGEncoder.encode(expanded), "output.png"); - - return PNGEncoderWithAlpha.encode(expanded, bd); - } - - } -} \ No newline at end of file diff --git a/PreviewHolder.as b/PreviewHolder.as deleted file mode 100644 index 587bf68..0000000 --- a/PreviewHolder.as +++ /dev/null @@ -1,57 +0,0 @@ -package { - import flash.display.MovieClip; - - public class PreviewHolder extends MovieClip - { - - var startingWidth = 1024; - var startingHeight = 1024; - - public function PreviewHolder() - { - startingWidth = this.width; - startingHeight = this.height; - } - - var clips:Array = new Array(); - public function AddClip(clip) - { - clips.push(clip); - this.addChild(clip); - ArrangeClips(); - } - - public function ArrangeClips() - { - var numCols = Math.ceil(Math.sqrt(clips.length)); - var maxY = 0; - var maxX = 0; - var clipIndex = 0; - for (var row = 0; row < numCols; row++) - { - var clipX = 0; - var clipY = maxY; - for (var col = 0; col < numCols; col++) - { - if (clipIndex == clips.length) break; - clips[clipIndex].x = clipX; - clips[clipIndex].y = clipY; - clipX += clips[clipIndex].width; - var clipBottom = clips[clipIndex].y + clips[clipIndex].height; - if (clipBottom > maxY) maxY = clipBottom; - - var clipRight = clips[clipIndex].x + clips[clipIndex].width; - if (clipRight > maxX) maxX = clipRight; - clipIndex++; - } - } - - var scale = Math.min(startingWidth / maxX, startingHeight / maxY); - if (scale > 1) scale = 1; - - this.scaleX = this.scaleY = scale; - } - - } - -} diff --git a/old/Checkbox.as b/old/Checkbox.as new file mode 100644 index 0000000..c5aaba2 --- /dev/null +++ b/old/Checkbox.as @@ -0,0 +1,42 @@ +package { + + import flash.display.MovieClip; + import flash.events.MouseEvent; + + public class Checkbox extends MovieClip + { + public var Enabled:Boolean = true; + public function Checkbox() + { + checkbox.gotoAndStop(1); + checkbox.addEventListener(MouseEvent.CLICK, Clicked); + } + + protected function Clicked(event) + { + if (!Enabled) return; + Toggle(); + if (OnClick != null) OnClick(OnClickParam); + } + + protected var checked = false; + public function set Checked(value) { checked = value; checkbox.gotoAndStop(checked ? 2 : 1); } + public function get Checked() { return checked; } + + public function set Text(value) { text.text = value; } + + public var OnClickParam; + public var OnClick; + + + public function Toggle() + { + checked = !checked; + checkbox.gotoAndStop(checked ? 2 : 1); + + + } + + } + +} diff --git a/old/GraphicExport-app.xml b/old/GraphicExport-app.xml new file mode 100644 index 0000000..5144634 --- /dev/null +++ b/old/GraphicExport-app.xml @@ -0,0 +1,41 @@ + + + + GraphicExport + 1.0 + GraphicExport + + GraphicExport + + + GraphicExport.swf + standard + false + true + false + portrait + auto + true + true + true + + + false + false + desktop extendedDesktop diff --git a/old/GraphicExport.exe b/old/GraphicExport.exe new file mode 100644 index 0000000..56315aa --- /dev/null +++ b/old/GraphicExport.exe Binary files differ diff --git a/old/GraphicExport.fla b/old/GraphicExport.fla new file mode 100644 index 0000000..0b78ed7 --- /dev/null +++ b/old/GraphicExport.fla Binary files differ diff --git a/old/GraphicExport.swf b/old/GraphicExport.swf new file mode 100644 index 0000000..542db97 --- /dev/null +++ b/old/GraphicExport.swf Binary files differ diff --git a/old/NewGraphicDialog.as b/old/NewGraphicDialog.as new file mode 100644 index 0000000..152011c --- /dev/null +++ b/old/NewGraphicDialog.as @@ -0,0 +1,224 @@ +package { + + import flash.display.MovieClip; + import flash.events.MouseEvent; + import flash.events.*; + import flash.filesystem.File; + import flash.net.FileFilter; + import Defs.GraphicDef; + import flash.text.engine.GraphicElement; + + public class NewGraphicDialog extends MovieClip + { + + public function NewGraphicDialog() + { + // constructor code + Init(); + } + + var typeButtons:Array = new Array(); + + public function Init() + { + graphicPath.text = "Path to Graphic Here"; + + this.removeChild(browseButton); + + var newBrowseButton = new UI_GenericBlueButton(); + newBrowseButton.Text = "Browse"; + newBrowseButton.OnClick = BrowseForFile; + newBrowseButton.x = browseButton.x + (newBrowseButton.width / 2); + newBrowseButton.y = browseButton.y + (newBrowseButton.height / 2); + addChild(newBrowseButton); + + var newTestButton = new UI_GenericBlueButton(); + newTestButton.Text = "Export"; + newTestButton.OnClick = TestFile; + newTestButton.x = testButton.x + (newTestButton.width / 2); + newTestButton.y = testButton.y + (newTestButton.height / 2); + addChild(newTestButton); + + this.removeChild(typePlaceholderButton); + + var typeX = typePlaceholderButton.x; + var typeY = typePlaceholderButton.y + (typePlaceholderButton.height / 2); + + + var typeButton = new UI_GenericBlueButton(); + typeButton.Text = "Graphic (1)"; + typeButton.OnClick = function(){ SetType(1); } + typeButton.x = typeX + (typeButton.width / 2); + typeButton.y = typeY; + typeButtons.push(typeButton); + addChild(typeButton); + + typeX += typeButton.width + 5; + + typeButton = new UI_GenericBlueButton(); + typeButton.Text = "Skeletal (3)"; + typeButton.OnClick = function(){ SetType(3); } + typeButton.x = typeX + (typeButton.width / 2); + typeButton.y = typeY; + typeButtons.push(typeButton); + addChild(typeButton); + + typeX += typeButton.width + 5; + + typeButton = new UI_GenericBlueButton(); + typeButton.Text = "Scene (6)"; + typeButton.OnClick = function(){ SetType(6); } + typeButton.x = typeX + (typeButton.width / 2); + typeButton.y = typeY; + typeButtons.push(typeButton); + addChild(typeButton); + + animationCheckbox.Checked = true; + //browseButton + //typePlaceholderButton + //usesInput + //usesText.text = "" + } + + var usesInputDefaultText = "Comma Seperated List of Uses Here"; + + public static var fakeID = 9999999; + public function TestFile() + { + fakeID++; + var graphicName = graphicPath.text; + var graphicData = {id:fakeID,graphic:graphicPath.text,v:1,fs:0,p:0,type:selectedType}; + + //"export_params":{"uses":["background"],"available_sizes":["default"],"compress":false}} + + var graphicDef = new GraphicDef(graphicData); + + this.Hide(); + graphicExport.ExportItem(graphicDef); + } + + var selectedType = 1; + public function SetType(type:Number) + { + selectedType = type; + + for(var i = 0; i < typeButtons.length; i++) + { + typeButtons[i].Enabled = true; + } + + animationCheckbox.visible = false; + + switch(type) + { + case 1: { + typeButtons[0].Enabled = false; + animationCheckbox.visible = true; + break; + } + case 3: typeButtons[1].Enabled = false; break; + case 6: typeButtons[2].Enabled = false; break; + } + } + + var graphicExport:GraphicExport; + public function Show(parentClip) + { + this.graphicExport = parentClip; + + parentClip.addChild(this); + + SetType(selectedType); + + var graphicList = GameData.Instance().GraphicDefines; + + var usesString:String = ""; + var uniqueUseTypes:Array = new Array(); + for (var i = 0; i < graphicList.length; i++) + { + var graphicDef:GraphicDef = graphicList[i]; + var uses = graphicDef.ExportParams['uses']; + for (var usage in uses) + { + if (uniqueUseTypes[uses[usage]] == null) + { + uniqueUseTypes[uses[usage]] = uses[usage]; + usesString += uses[usage] + ", "; + } + } + } + + graphicPath.text = ""; + + } + + public function CloseClicked(event) + { + Hide(); + } + + public function Hide() + { + if (this.parent != null) this.parent.removeChild(this); + } + + public function BrowseForFile() + { + var file:File = new File(); + var swfTypeFilter:FileFilter = new FileFilter("SWF Files","*.swf"); + file.addEventListener(Event.SELECT, openFile); + file.browse([swfTypeFilter]); + } + + private function openFile(event:Event):void + { + _strace(event.target.nativePath); + var path:String = event.target.nativePath; + var pathParts:Array = path.split("Graphics\\"); + if (pathParts.length == 2) + { + var fileRemainder:String = pathParts[1]; + var withoutExtension:String = fileRemainder.split(".")[0]; + var pattern:RegExp = /\\/g; + withoutExtension = withoutExtension.replace(pattern, "/"); + _strace(withoutExtension); + graphicPath.text = withoutExtension; + + if (withoutExtension.indexOf("Backgrounds") > -1) + { + SetType(6); + } + + if (withoutExtension.indexOf("Monsters") > -1) + { + SetType(3); + } + + if (withoutExtension.indexOf("Characters") > -1) + { + SetType(3); + } + + if (withoutExtension.indexOf("Portraits") > -1) + { + SetType(1); + } + + if (withoutExtension.indexOf("Quest") > -1) + { + SetType(1); + } + + if (withoutExtension.indexOf("Equipment") > -1) + { + SetType(1); + } + + + } + } + + + } + +} diff --git a/Checkbox.as b/Checkbox.as deleted file mode 100644 index c5aaba2..0000000 --- a/Checkbox.as +++ /dev/null @@ -1,42 +0,0 @@ -package { - - import flash.display.MovieClip; - import flash.events.MouseEvent; - - public class Checkbox extends MovieClip - { - public var Enabled:Boolean = true; - public function Checkbox() - { - checkbox.gotoAndStop(1); - checkbox.addEventListener(MouseEvent.CLICK, Clicked); - } - - protected function Clicked(event) - { - if (!Enabled) return; - Toggle(); - if (OnClick != null) OnClick(OnClickParam); - } - - protected var checked = false; - public function set Checked(value) { checked = value; checkbox.gotoAndStop(checked ? 2 : 1); } - public function get Checked() { return checked; } - - public function set Text(value) { text.text = value; } - - public var OnClickParam; - public var OnClick; - - - public function Toggle() - { - checked = !checked; - checkbox.gotoAndStop(checked ? 2 : 1); - - - } - - } - -} diff --git a/Exporter-app.xml b/Exporter-app.xml index dbb9ba7..7deb7c5 100755 --- a/Exporter-app.xml +++ b/Exporter-app.xml @@ -16,7 +16,7 @@ Japanese App name goes here --> - + Exporter 1.0 Exporter diff --git a/Exporter.exe b/Exporter.exe index aa5d57e..7833fe5 100755 --- a/Exporter.exe +++ b/Exporter.exe Binary files differ diff --git a/Exporter.swf b/Exporter.swf index 484f56c..9c7464a 100644 --- a/Exporter.swf +++ b/Exporter.swf Binary files differ diff --git a/GraphicExport-app.xml b/GraphicExport-app.xml deleted file mode 100755 index 5144634..0000000 --- a/GraphicExport-app.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - GraphicExport - 1.0 - GraphicExport - - GraphicExport - - - GraphicExport.swf - standard - false - true - false - portrait - auto - true - true - true - - - false - false - desktop extendedDesktop diff --git a/GraphicExport.exe b/GraphicExport.exe deleted file mode 100755 index 56315aa..0000000 --- a/GraphicExport.exe +++ /dev/null Binary files differ diff --git a/GraphicExport.fla b/GraphicExport.fla deleted file mode 100755 index 0b78ed7..0000000 --- a/GraphicExport.fla +++ /dev/null Binary files differ diff --git a/GraphicExport.swf b/GraphicExport.swf deleted file mode 100644 index 542db97..0000000 --- a/GraphicExport.swf +++ /dev/null Binary files differ diff --git a/NewGraphicDialog.as b/NewGraphicDialog.as deleted file mode 100644 index 152011c..0000000 --- a/NewGraphicDialog.as +++ /dev/null @@ -1,224 +0,0 @@ -package { - - import flash.display.MovieClip; - import flash.events.MouseEvent; - import flash.events.*; - import flash.filesystem.File; - import flash.net.FileFilter; - import Defs.GraphicDef; - import flash.text.engine.GraphicElement; - - public class NewGraphicDialog extends MovieClip - { - - public function NewGraphicDialog() - { - // constructor code - Init(); - } - - var typeButtons:Array = new Array(); - - public function Init() - { - graphicPath.text = "Path to Graphic Here"; - - this.removeChild(browseButton); - - var newBrowseButton = new UI_GenericBlueButton(); - newBrowseButton.Text = "Browse"; - newBrowseButton.OnClick = BrowseForFile; - newBrowseButton.x = browseButton.x + (newBrowseButton.width / 2); - newBrowseButton.y = browseButton.y + (newBrowseButton.height / 2); - addChild(newBrowseButton); - - var newTestButton = new UI_GenericBlueButton(); - newTestButton.Text = "Export"; - newTestButton.OnClick = TestFile; - newTestButton.x = testButton.x + (newTestButton.width / 2); - newTestButton.y = testButton.y + (newTestButton.height / 2); - addChild(newTestButton); - - this.removeChild(typePlaceholderButton); - - var typeX = typePlaceholderButton.x; - var typeY = typePlaceholderButton.y + (typePlaceholderButton.height / 2); - - - var typeButton = new UI_GenericBlueButton(); - typeButton.Text = "Graphic (1)"; - typeButton.OnClick = function(){ SetType(1); } - typeButton.x = typeX + (typeButton.width / 2); - typeButton.y = typeY; - typeButtons.push(typeButton); - addChild(typeButton); - - typeX += typeButton.width + 5; - - typeButton = new UI_GenericBlueButton(); - typeButton.Text = "Skeletal (3)"; - typeButton.OnClick = function(){ SetType(3); } - typeButton.x = typeX + (typeButton.width / 2); - typeButton.y = typeY; - typeButtons.push(typeButton); - addChild(typeButton); - - typeX += typeButton.width + 5; - - typeButton = new UI_GenericBlueButton(); - typeButton.Text = "Scene (6)"; - typeButton.OnClick = function(){ SetType(6); } - typeButton.x = typeX + (typeButton.width / 2); - typeButton.y = typeY; - typeButtons.push(typeButton); - addChild(typeButton); - - animationCheckbox.Checked = true; - //browseButton - //typePlaceholderButton - //usesInput - //usesText.text = "" - } - - var usesInputDefaultText = "Comma Seperated List of Uses Here"; - - public static var fakeID = 9999999; - public function TestFile() - { - fakeID++; - var graphicName = graphicPath.text; - var graphicData = {id:fakeID,graphic:graphicPath.text,v:1,fs:0,p:0,type:selectedType}; - - //"export_params":{"uses":["background"],"available_sizes":["default"],"compress":false}} - - var graphicDef = new GraphicDef(graphicData); - - this.Hide(); - graphicExport.ExportItem(graphicDef); - } - - var selectedType = 1; - public function SetType(type:Number) - { - selectedType = type; - - for(var i = 0; i < typeButtons.length; i++) - { - typeButtons[i].Enabled = true; - } - - animationCheckbox.visible = false; - - switch(type) - { - case 1: { - typeButtons[0].Enabled = false; - animationCheckbox.visible = true; - break; - } - case 3: typeButtons[1].Enabled = false; break; - case 6: typeButtons[2].Enabled = false; break; - } - } - - var graphicExport:GraphicExport; - public function Show(parentClip) - { - this.graphicExport = parentClip; - - parentClip.addChild(this); - - SetType(selectedType); - - var graphicList = GameData.Instance().GraphicDefines; - - var usesString:String = ""; - var uniqueUseTypes:Array = new Array(); - for (var i = 0; i < graphicList.length; i++) - { - var graphicDef:GraphicDef = graphicList[i]; - var uses = graphicDef.ExportParams['uses']; - for (var usage in uses) - { - if (uniqueUseTypes[uses[usage]] == null) - { - uniqueUseTypes[uses[usage]] = uses[usage]; - usesString += uses[usage] + ", "; - } - } - } - - graphicPath.text = ""; - - } - - public function CloseClicked(event) - { - Hide(); - } - - public function Hide() - { - if (this.parent != null) this.parent.removeChild(this); - } - - public function BrowseForFile() - { - var file:File = new File(); - var swfTypeFilter:FileFilter = new FileFilter("SWF Files","*.swf"); - file.addEventListener(Event.SELECT, openFile); - file.browse([swfTypeFilter]); - } - - private function openFile(event:Event):void - { - _strace(event.target.nativePath); - var path:String = event.target.nativePath; - var pathParts:Array = path.split("Graphics\\"); - if (pathParts.length == 2) - { - var fileRemainder:String = pathParts[1]; - var withoutExtension:String = fileRemainder.split(".")[0]; - var pattern:RegExp = /\\/g; - withoutExtension = withoutExtension.replace(pattern, "/"); - _strace(withoutExtension); - graphicPath.text = withoutExtension; - - if (withoutExtension.indexOf("Backgrounds") > -1) - { - SetType(6); - } - - if (withoutExtension.indexOf("Monsters") > -1) - { - SetType(3); - } - - if (withoutExtension.indexOf("Characters") > -1) - { - SetType(3); - } - - if (withoutExtension.indexOf("Portraits") > -1) - { - SetType(1); - } - - if (withoutExtension.indexOf("Quest") > -1) - { - SetType(1); - } - - if (withoutExtension.indexOf("Equipment") > -1) - { - SetType(1); - } - - - } - } - - - } - -} diff --git a/PNGExportHelper.as b/PNGExportHelper.as deleted file mode 100644 index f8c4c9d..0000000 --- a/PNGExportHelper.as +++ /dev/null @@ -1,253 +0,0 @@ -package -{ - import flash.display.*; - import com.adobe.images.*; - import flash.utils.*; - import flash.net.*; - import flash.geom.Matrix; - import flash.geom.Rectangle; - import flash.geom.Point; - - public class PNGExportHelper - { - public static var UseExpandedBitmaps = false; - public static var AlphaThreshold = 5; - - private static function ExpandBitmapBorders(bd:BitmapData, bgColor = 0x0, passes = 1):BitmapData - { - /* - var thresh:BitmapData = new BitmapData(bd.width, bd.height, true, bgColor); - thresh.threshold(bd, bd.rect, new Point(), "<", (20 << 24), bgColor, 0xFF000000, true); - */ - var sampled:BitmapData = new BitmapData(bd.width, bd.height, true, bgColor); - bd.lock(); - sampled.lock(); - - for (var y = 0; y < bd.height; y++) - { - for (var x = 0; x < bd.width; x++) - { - var oldVal:uint = bd.getPixel32(x, y); - var a:uint = (oldVal & 0xFF000000) >>> 24; - var rgb:uint = (oldVal & 0xFFFFFF); - if (a > AlphaThreshold) - { - sampled.setPixel32(x, y, (0xFF << 24) | rgb); - } - else - { - sampled.setPixel32(x, y, bgColor); - } - } - } - sampled.unlock(); - bd.unlock(); - - return ExpandBitmapBordersInternal(sampled, bgColor, passes); - } - - private static function ExpandBitmapBordersInternal(bd:BitmapData, bgColor, passes):BitmapData - { - var output:BitmapData = new BitmapData(bd.width, bd.height, true, bgColor); - - var scale = 16; - var scaled:BitmapData = new BitmapData(bd.width/scale, bd.height/scale, true, bgColor); - var mat:Matrix = new Matrix(); - mat.scale(1/scale, 1/scale); - scaled.draw(bd, mat, null, null, null, true); - - output.lock(); - - var colors:Array = new Array(); - var weights:Array = new Array(); - - for (var oy = 0; oy < scaled.height; oy++) - { - - for (var ox = 0; ox < scaled.width; ox++) - { - - var scaledVal:uint = scaled.getPixel32(ox, oy); - var scaleda:uint = (scaledVal & 0xFF000000) >>> 24; - if (scaleda == 0 || scaleda == 255) - { - output.copyPixels(bd, new Rectangle(ox * scale, oy * scale, scale, scale), new Point(ox * scale, oy * scale)); - continue; - } else { - //_strace(scaleda+""); - } - - - for (var y = oy * scale; y < oy * scale + scale; y++) - { - for (var x = ox * scale; x < ox * scale + scale; x++) - { - var oldVal:uint = bd.getPixel32(x, y); - var a:uint = (oldVal & 0xFF000000) >>> 24; - var rgb:uint = (oldVal & 0xFFFFFF); - - if (a == 0 && rgb == bgColor) - { - colors.length = 0; - weights.length = 0; - - for (var y1 = y - 2; y1 <= y + 2; y1++) - { - for (var x1 = x - 2; x1 <= x + 2; x1++) - { - var dist = Math.abs(x1 - x) + Math.abs(y1 - y); - if (dist >= 3) continue; - - if (x1 >= 0 && x1 < bd.width && y1 >= 0 && y1 < bd.height) - { - colors.push(bd.getPixel(x1, y1)); - weights.push(1 - dist * 0.2); - } - } - } - - var newVal = AveragePixels(colors, weights, bgColor); - if (newVal == null) - { - newVal = oldVal; - } - else - { - var newR:uint = (newVal & 0xFF0000) >> 16; - var newG:uint = (newVal & 0xFF00) >> 8; - var newB:uint = (newVal & 0xFF); - - if (newVal != 0 && colors.length >= 4) - { - var bp = true; - } - - var sorted = colors.sort(function(a, b) - { - var aR:uint = (a & 0xFF0000) >> 16; - var aG:uint = (a & 0xFF00) >> 8; - var aB:uint = (a & 0xFF); - - var bR:uint = (b & 0xFF0000) >> 16; - var bG:uint = (b & 0xFF00) >> 8; - var bB:uint = (b & 0xFF); - - var diffA = Math.abs(aR - newR) + Math.abs(aG - newG) + Math.abs(aB - newB); - var diffB = Math.abs(bR - newR) + Math.abs(bG - newG) + Math.abs(bB - newB); - - return diffA - diffB; - - }, Array.RETURNINDEXEDARRAY | Array.DESCENDING); - - var toRemove = Math.min(2, colors.length - 4); - var removed = 0; - for (var i = 0; i < colors.length; i++) - { - var index = sorted.indexOf(i + removed); - if (index < toRemove) - { - colors.splice(i, 1); - weights.splice(i, 1); - removed++; - i--; - if (removed == toRemove) break; - } - } - - var fixOutliersVal = AveragePixels(colors, weights, bgColor); - if (fixOutliersVal == null) newVal = (0xFF << 24) | newVal; - - newVal = (0xFF << 24) | fixOutliersVal; - } - - output.setPixel32(x, y, newVal); - } - else - { - output.setPixel32(x, y, oldVal); - } - } - } - }//end outer scaled x - }//End outer scaled y - - bd.unlock(); - output.unlock(); - - passes--; - if (passes > 0) - { - return ExpandBitmapBordersInternal(output, bgColor, passes); - } - else - { - return output; - } - } - - private static function AveragePixels(colors:Array, weights:Array, bgColor:uint):uint - { - var rTotal = 0; - var gTotal = 0; - var bTotal = 0; - - var wTotal = 0; - - for (var i = 0; i < colors.length; i++) - { - var color:uint = colors[i]; - var a:uint = (color & 0xFF000000) >>> 24; - var rgb:uint = (color & 0xFFFFFF); - - if (a == 0 && rgb == bgColor) - { - colors.splice(i, 1); - weights.splice(i, 1); - i--; - continue; - } - - var r:uint = (rgb & 0xFF0000) >>> 16; - var g:uint = (rgb & 0xFF00) >>> 8; - var b:uint = (rgb & 0xFF); - var w = weights[i]; - - rTotal += w * r; - gTotal += w * g; - bTotal += w * b; - - wTotal += w; - } - - if (wTotal == 0) - { - return null; - } - - rTotal /= wTotal; - gTotal /= wTotal; - bTotal /= wTotal; - - var rFinal = Math.max(0, Math.min(255, Math.round(rTotal))); - var gFinal = Math.max(0, Math.min(255, Math.round(gTotal))); - var bFinal = Math.max(0, Math.min(255, Math.round(bTotal))); - - return (uint(rFinal) << 16) | (uint(gFinal) << 8) | (uint(bFinal)); - } - - - - public static function GetExportPNG(bd:BitmapData):ByteArray - { - if (!UseExpandedBitmaps) return PNGEncoder.encode(bd); - - var expanded:BitmapData = ExpandBitmapBorders(bd, 0x0, 2); - - //var fr:FileReference = new FileReference(); - //fr.save(PNGEncoder.encode(expanded), "output.png"); - - return PNGEncoderWithAlpha.encode(expanded, bd); - } - - } -} \ No newline at end of file diff --git a/PreviewHolder.as b/PreviewHolder.as deleted file mode 100644 index 587bf68..0000000 --- a/PreviewHolder.as +++ /dev/null @@ -1,57 +0,0 @@ -package { - import flash.display.MovieClip; - - public class PreviewHolder extends MovieClip - { - - var startingWidth = 1024; - var startingHeight = 1024; - - public function PreviewHolder() - { - startingWidth = this.width; - startingHeight = this.height; - } - - var clips:Array = new Array(); - public function AddClip(clip) - { - clips.push(clip); - this.addChild(clip); - ArrangeClips(); - } - - public function ArrangeClips() - { - var numCols = Math.ceil(Math.sqrt(clips.length)); - var maxY = 0; - var maxX = 0; - var clipIndex = 0; - for (var row = 0; row < numCols; row++) - { - var clipX = 0; - var clipY = maxY; - for (var col = 0; col < numCols; col++) - { - if (clipIndex == clips.length) break; - clips[clipIndex].x = clipX; - clips[clipIndex].y = clipY; - clipX += clips[clipIndex].width; - var clipBottom = clips[clipIndex].y + clips[clipIndex].height; - if (clipBottom > maxY) maxY = clipBottom; - - var clipRight = clips[clipIndex].x + clips[clipIndex].width; - if (clipRight > maxX) maxX = clipRight; - clipIndex++; - } - } - - var scale = Math.min(startingWidth / maxX, startingHeight / maxY); - if (scale > 1) scale = 1; - - this.scaleX = this.scaleY = scale; - } - - } - -} diff --git a/old/Checkbox.as b/old/Checkbox.as new file mode 100644 index 0000000..c5aaba2 --- /dev/null +++ b/old/Checkbox.as @@ -0,0 +1,42 @@ +package { + + import flash.display.MovieClip; + import flash.events.MouseEvent; + + public class Checkbox extends MovieClip + { + public var Enabled:Boolean = true; + public function Checkbox() + { + checkbox.gotoAndStop(1); + checkbox.addEventListener(MouseEvent.CLICK, Clicked); + } + + protected function Clicked(event) + { + if (!Enabled) return; + Toggle(); + if (OnClick != null) OnClick(OnClickParam); + } + + protected var checked = false; + public function set Checked(value) { checked = value; checkbox.gotoAndStop(checked ? 2 : 1); } + public function get Checked() { return checked; } + + public function set Text(value) { text.text = value; } + + public var OnClickParam; + public var OnClick; + + + public function Toggle() + { + checked = !checked; + checkbox.gotoAndStop(checked ? 2 : 1); + + + } + + } + +} diff --git a/old/GraphicExport-app.xml b/old/GraphicExport-app.xml new file mode 100644 index 0000000..5144634 --- /dev/null +++ b/old/GraphicExport-app.xml @@ -0,0 +1,41 @@ + + + + GraphicExport + 1.0 + GraphicExport + + GraphicExport + + + GraphicExport.swf + standard + false + true + false + portrait + auto + true + true + true + + + false + false + desktop extendedDesktop diff --git a/old/GraphicExport.exe b/old/GraphicExport.exe new file mode 100644 index 0000000..56315aa --- /dev/null +++ b/old/GraphicExport.exe Binary files differ diff --git a/old/GraphicExport.fla b/old/GraphicExport.fla new file mode 100644 index 0000000..0b78ed7 --- /dev/null +++ b/old/GraphicExport.fla Binary files differ diff --git a/old/GraphicExport.swf b/old/GraphicExport.swf new file mode 100644 index 0000000..542db97 --- /dev/null +++ b/old/GraphicExport.swf Binary files differ diff --git a/old/NewGraphicDialog.as b/old/NewGraphicDialog.as new file mode 100644 index 0000000..152011c --- /dev/null +++ b/old/NewGraphicDialog.as @@ -0,0 +1,224 @@ +package { + + import flash.display.MovieClip; + import flash.events.MouseEvent; + import flash.events.*; + import flash.filesystem.File; + import flash.net.FileFilter; + import Defs.GraphicDef; + import flash.text.engine.GraphicElement; + + public class NewGraphicDialog extends MovieClip + { + + public function NewGraphicDialog() + { + // constructor code + Init(); + } + + var typeButtons:Array = new Array(); + + public function Init() + { + graphicPath.text = "Path to Graphic Here"; + + this.removeChild(browseButton); + + var newBrowseButton = new UI_GenericBlueButton(); + newBrowseButton.Text = "Browse"; + newBrowseButton.OnClick = BrowseForFile; + newBrowseButton.x = browseButton.x + (newBrowseButton.width / 2); + newBrowseButton.y = browseButton.y + (newBrowseButton.height / 2); + addChild(newBrowseButton); + + var newTestButton = new UI_GenericBlueButton(); + newTestButton.Text = "Export"; + newTestButton.OnClick = TestFile; + newTestButton.x = testButton.x + (newTestButton.width / 2); + newTestButton.y = testButton.y + (newTestButton.height / 2); + addChild(newTestButton); + + this.removeChild(typePlaceholderButton); + + var typeX = typePlaceholderButton.x; + var typeY = typePlaceholderButton.y + (typePlaceholderButton.height / 2); + + + var typeButton = new UI_GenericBlueButton(); + typeButton.Text = "Graphic (1)"; + typeButton.OnClick = function(){ SetType(1); } + typeButton.x = typeX + (typeButton.width / 2); + typeButton.y = typeY; + typeButtons.push(typeButton); + addChild(typeButton); + + typeX += typeButton.width + 5; + + typeButton = new UI_GenericBlueButton(); + typeButton.Text = "Skeletal (3)"; + typeButton.OnClick = function(){ SetType(3); } + typeButton.x = typeX + (typeButton.width / 2); + typeButton.y = typeY; + typeButtons.push(typeButton); + addChild(typeButton); + + typeX += typeButton.width + 5; + + typeButton = new UI_GenericBlueButton(); + typeButton.Text = "Scene (6)"; + typeButton.OnClick = function(){ SetType(6); } + typeButton.x = typeX + (typeButton.width / 2); + typeButton.y = typeY; + typeButtons.push(typeButton); + addChild(typeButton); + + animationCheckbox.Checked = true; + //browseButton + //typePlaceholderButton + //usesInput + //usesText.text = "" + } + + var usesInputDefaultText = "Comma Seperated List of Uses Here"; + + public static var fakeID = 9999999; + public function TestFile() + { + fakeID++; + var graphicName = graphicPath.text; + var graphicData = {id:fakeID,graphic:graphicPath.text,v:1,fs:0,p:0,type:selectedType}; + + //"export_params":{"uses":["background"],"available_sizes":["default"],"compress":false}} + + var graphicDef = new GraphicDef(graphicData); + + this.Hide(); + graphicExport.ExportItem(graphicDef); + } + + var selectedType = 1; + public function SetType(type:Number) + { + selectedType = type; + + for(var i = 0; i < typeButtons.length; i++) + { + typeButtons[i].Enabled = true; + } + + animationCheckbox.visible = false; + + switch(type) + { + case 1: { + typeButtons[0].Enabled = false; + animationCheckbox.visible = true; + break; + } + case 3: typeButtons[1].Enabled = false; break; + case 6: typeButtons[2].Enabled = false; break; + } + } + + var graphicExport:GraphicExport; + public function Show(parentClip) + { + this.graphicExport = parentClip; + + parentClip.addChild(this); + + SetType(selectedType); + + var graphicList = GameData.Instance().GraphicDefines; + + var usesString:String = ""; + var uniqueUseTypes:Array = new Array(); + for (var i = 0; i < graphicList.length; i++) + { + var graphicDef:GraphicDef = graphicList[i]; + var uses = graphicDef.ExportParams['uses']; + for (var usage in uses) + { + if (uniqueUseTypes[uses[usage]] == null) + { + uniqueUseTypes[uses[usage]] = uses[usage]; + usesString += uses[usage] + ", "; + } + } + } + + graphicPath.text = ""; + + } + + public function CloseClicked(event) + { + Hide(); + } + + public function Hide() + { + if (this.parent != null) this.parent.removeChild(this); + } + + public function BrowseForFile() + { + var file:File = new File(); + var swfTypeFilter:FileFilter = new FileFilter("SWF Files","*.swf"); + file.addEventListener(Event.SELECT, openFile); + file.browse([swfTypeFilter]); + } + + private function openFile(event:Event):void + { + _strace(event.target.nativePath); + var path:String = event.target.nativePath; + var pathParts:Array = path.split("Graphics\\"); + if (pathParts.length == 2) + { + var fileRemainder:String = pathParts[1]; + var withoutExtension:String = fileRemainder.split(".")[0]; + var pattern:RegExp = /\\/g; + withoutExtension = withoutExtension.replace(pattern, "/"); + _strace(withoutExtension); + graphicPath.text = withoutExtension; + + if (withoutExtension.indexOf("Backgrounds") > -1) + { + SetType(6); + } + + if (withoutExtension.indexOf("Monsters") > -1) + { + SetType(3); + } + + if (withoutExtension.indexOf("Characters") > -1) + { + SetType(3); + } + + if (withoutExtension.indexOf("Portraits") > -1) + { + SetType(1); + } + + if (withoutExtension.indexOf("Quest") > -1) + { + SetType(1); + } + + if (withoutExtension.indexOf("Equipment") > -1) + { + SetType(1); + } + + + } + } + + + } + +} diff --git a/old/PNGExportHelper.as b/old/PNGExportHelper.as new file mode 100644 index 0000000..f8c4c9d --- /dev/null +++ b/old/PNGExportHelper.as @@ -0,0 +1,253 @@ +package +{ + import flash.display.*; + import com.adobe.images.*; + import flash.utils.*; + import flash.net.*; + import flash.geom.Matrix; + import flash.geom.Rectangle; + import flash.geom.Point; + + public class PNGExportHelper + { + public static var UseExpandedBitmaps = false; + public static var AlphaThreshold = 5; + + private static function ExpandBitmapBorders(bd:BitmapData, bgColor = 0x0, passes = 1):BitmapData + { + /* + var thresh:BitmapData = new BitmapData(bd.width, bd.height, true, bgColor); + thresh.threshold(bd, bd.rect, new Point(), "<", (20 << 24), bgColor, 0xFF000000, true); + */ + var sampled:BitmapData = new BitmapData(bd.width, bd.height, true, bgColor); + bd.lock(); + sampled.lock(); + + for (var y = 0; y < bd.height; y++) + { + for (var x = 0; x < bd.width; x++) + { + var oldVal:uint = bd.getPixel32(x, y); + var a:uint = (oldVal & 0xFF000000) >>> 24; + var rgb:uint = (oldVal & 0xFFFFFF); + if (a > AlphaThreshold) + { + sampled.setPixel32(x, y, (0xFF << 24) | rgb); + } + else + { + sampled.setPixel32(x, y, bgColor); + } + } + } + sampled.unlock(); + bd.unlock(); + + return ExpandBitmapBordersInternal(sampled, bgColor, passes); + } + + private static function ExpandBitmapBordersInternal(bd:BitmapData, bgColor, passes):BitmapData + { + var output:BitmapData = new BitmapData(bd.width, bd.height, true, bgColor); + + var scale = 16; + var scaled:BitmapData = new BitmapData(bd.width/scale, bd.height/scale, true, bgColor); + var mat:Matrix = new Matrix(); + mat.scale(1/scale, 1/scale); + scaled.draw(bd, mat, null, null, null, true); + + output.lock(); + + var colors:Array = new Array(); + var weights:Array = new Array(); + + for (var oy = 0; oy < scaled.height; oy++) + { + + for (var ox = 0; ox < scaled.width; ox++) + { + + var scaledVal:uint = scaled.getPixel32(ox, oy); + var scaleda:uint = (scaledVal & 0xFF000000) >>> 24; + if (scaleda == 0 || scaleda == 255) + { + output.copyPixels(bd, new Rectangle(ox * scale, oy * scale, scale, scale), new Point(ox * scale, oy * scale)); + continue; + } else { + //_strace(scaleda+""); + } + + + for (var y = oy * scale; y < oy * scale + scale; y++) + { + for (var x = ox * scale; x < ox * scale + scale; x++) + { + var oldVal:uint = bd.getPixel32(x, y); + var a:uint = (oldVal & 0xFF000000) >>> 24; + var rgb:uint = (oldVal & 0xFFFFFF); + + if (a == 0 && rgb == bgColor) + { + colors.length = 0; + weights.length = 0; + + for (var y1 = y - 2; y1 <= y + 2; y1++) + { + for (var x1 = x - 2; x1 <= x + 2; x1++) + { + var dist = Math.abs(x1 - x) + Math.abs(y1 - y); + if (dist >= 3) continue; + + if (x1 >= 0 && x1 < bd.width && y1 >= 0 && y1 < bd.height) + { + colors.push(bd.getPixel(x1, y1)); + weights.push(1 - dist * 0.2); + } + } + } + + var newVal = AveragePixels(colors, weights, bgColor); + if (newVal == null) + { + newVal = oldVal; + } + else + { + var newR:uint = (newVal & 0xFF0000) >> 16; + var newG:uint = (newVal & 0xFF00) >> 8; + var newB:uint = (newVal & 0xFF); + + if (newVal != 0 && colors.length >= 4) + { + var bp = true; + } + + var sorted = colors.sort(function(a, b) + { + var aR:uint = (a & 0xFF0000) >> 16; + var aG:uint = (a & 0xFF00) >> 8; + var aB:uint = (a & 0xFF); + + var bR:uint = (b & 0xFF0000) >> 16; + var bG:uint = (b & 0xFF00) >> 8; + var bB:uint = (b & 0xFF); + + var diffA = Math.abs(aR - newR) + Math.abs(aG - newG) + Math.abs(aB - newB); + var diffB = Math.abs(bR - newR) + Math.abs(bG - newG) + Math.abs(bB - newB); + + return diffA - diffB; + + }, Array.RETURNINDEXEDARRAY | Array.DESCENDING); + + var toRemove = Math.min(2, colors.length - 4); + var removed = 0; + for (var i = 0; i < colors.length; i++) + { + var index = sorted.indexOf(i + removed); + if (index < toRemove) + { + colors.splice(i, 1); + weights.splice(i, 1); + removed++; + i--; + if (removed == toRemove) break; + } + } + + var fixOutliersVal = AveragePixels(colors, weights, bgColor); + if (fixOutliersVal == null) newVal = (0xFF << 24) | newVal; + + newVal = (0xFF << 24) | fixOutliersVal; + } + + output.setPixel32(x, y, newVal); + } + else + { + output.setPixel32(x, y, oldVal); + } + } + } + }//end outer scaled x + }//End outer scaled y + + bd.unlock(); + output.unlock(); + + passes--; + if (passes > 0) + { + return ExpandBitmapBordersInternal(output, bgColor, passes); + } + else + { + return output; + } + } + + private static function AveragePixels(colors:Array, weights:Array, bgColor:uint):uint + { + var rTotal = 0; + var gTotal = 0; + var bTotal = 0; + + var wTotal = 0; + + for (var i = 0; i < colors.length; i++) + { + var color:uint = colors[i]; + var a:uint = (color & 0xFF000000) >>> 24; + var rgb:uint = (color & 0xFFFFFF); + + if (a == 0 && rgb == bgColor) + { + colors.splice(i, 1); + weights.splice(i, 1); + i--; + continue; + } + + var r:uint = (rgb & 0xFF0000) >>> 16; + var g:uint = (rgb & 0xFF00) >>> 8; + var b:uint = (rgb & 0xFF); + var w = weights[i]; + + rTotal += w * r; + gTotal += w * g; + bTotal += w * b; + + wTotal += w; + } + + if (wTotal == 0) + { + return null; + } + + rTotal /= wTotal; + gTotal /= wTotal; + bTotal /= wTotal; + + var rFinal = Math.max(0, Math.min(255, Math.round(rTotal))); + var gFinal = Math.max(0, Math.min(255, Math.round(gTotal))); + var bFinal = Math.max(0, Math.min(255, Math.round(bTotal))); + + return (uint(rFinal) << 16) | (uint(gFinal) << 8) | (uint(bFinal)); + } + + + + public static function GetExportPNG(bd:BitmapData):ByteArray + { + if (!UseExpandedBitmaps) return PNGEncoder.encode(bd); + + var expanded:BitmapData = ExpandBitmapBorders(bd, 0x0, 2); + + //var fr:FileReference = new FileReference(); + //fr.save(PNGEncoder.encode(expanded), "output.png"); + + return PNGEncoderWithAlpha.encode(expanded, bd); + } + + } +} \ No newline at end of file diff --git a/Checkbox.as b/Checkbox.as deleted file mode 100644 index c5aaba2..0000000 --- a/Checkbox.as +++ /dev/null @@ -1,42 +0,0 @@ -package { - - import flash.display.MovieClip; - import flash.events.MouseEvent; - - public class Checkbox extends MovieClip - { - public var Enabled:Boolean = true; - public function Checkbox() - { - checkbox.gotoAndStop(1); - checkbox.addEventListener(MouseEvent.CLICK, Clicked); - } - - protected function Clicked(event) - { - if (!Enabled) return; - Toggle(); - if (OnClick != null) OnClick(OnClickParam); - } - - protected var checked = false; - public function set Checked(value) { checked = value; checkbox.gotoAndStop(checked ? 2 : 1); } - public function get Checked() { return checked; } - - public function set Text(value) { text.text = value; } - - public var OnClickParam; - public var OnClick; - - - public function Toggle() - { - checked = !checked; - checkbox.gotoAndStop(checked ? 2 : 1); - - - } - - } - -} diff --git a/Exporter-app.xml b/Exporter-app.xml index dbb9ba7..7deb7c5 100755 --- a/Exporter-app.xml +++ b/Exporter-app.xml @@ -16,7 +16,7 @@ Japanese App name goes here --> - + Exporter 1.0 Exporter diff --git a/Exporter.exe b/Exporter.exe index aa5d57e..7833fe5 100755 --- a/Exporter.exe +++ b/Exporter.exe Binary files differ diff --git a/Exporter.swf b/Exporter.swf index 484f56c..9c7464a 100644 --- a/Exporter.swf +++ b/Exporter.swf Binary files differ diff --git a/GraphicExport-app.xml b/GraphicExport-app.xml deleted file mode 100755 index 5144634..0000000 --- a/GraphicExport-app.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - GraphicExport - 1.0 - GraphicExport - - GraphicExport - - - GraphicExport.swf - standard - false - true - false - portrait - auto - true - true - true - - - false - false - desktop extendedDesktop diff --git a/GraphicExport.exe b/GraphicExport.exe deleted file mode 100755 index 56315aa..0000000 --- a/GraphicExport.exe +++ /dev/null Binary files differ diff --git a/GraphicExport.fla b/GraphicExport.fla deleted file mode 100755 index 0b78ed7..0000000 --- a/GraphicExport.fla +++ /dev/null Binary files differ diff --git a/GraphicExport.swf b/GraphicExport.swf deleted file mode 100644 index 542db97..0000000 --- a/GraphicExport.swf +++ /dev/null Binary files differ diff --git a/NewGraphicDialog.as b/NewGraphicDialog.as deleted file mode 100644 index 152011c..0000000 --- a/NewGraphicDialog.as +++ /dev/null @@ -1,224 +0,0 @@ -package { - - import flash.display.MovieClip; - import flash.events.MouseEvent; - import flash.events.*; - import flash.filesystem.File; - import flash.net.FileFilter; - import Defs.GraphicDef; - import flash.text.engine.GraphicElement; - - public class NewGraphicDialog extends MovieClip - { - - public function NewGraphicDialog() - { - // constructor code - Init(); - } - - var typeButtons:Array = new Array(); - - public function Init() - { - graphicPath.text = "Path to Graphic Here"; - - this.removeChild(browseButton); - - var newBrowseButton = new UI_GenericBlueButton(); - newBrowseButton.Text = "Browse"; - newBrowseButton.OnClick = BrowseForFile; - newBrowseButton.x = browseButton.x + (newBrowseButton.width / 2); - newBrowseButton.y = browseButton.y + (newBrowseButton.height / 2); - addChild(newBrowseButton); - - var newTestButton = new UI_GenericBlueButton(); - newTestButton.Text = "Export"; - newTestButton.OnClick = TestFile; - newTestButton.x = testButton.x + (newTestButton.width / 2); - newTestButton.y = testButton.y + (newTestButton.height / 2); - addChild(newTestButton); - - this.removeChild(typePlaceholderButton); - - var typeX = typePlaceholderButton.x; - var typeY = typePlaceholderButton.y + (typePlaceholderButton.height / 2); - - - var typeButton = new UI_GenericBlueButton(); - typeButton.Text = "Graphic (1)"; - typeButton.OnClick = function(){ SetType(1); } - typeButton.x = typeX + (typeButton.width / 2); - typeButton.y = typeY; - typeButtons.push(typeButton); - addChild(typeButton); - - typeX += typeButton.width + 5; - - typeButton = new UI_GenericBlueButton(); - typeButton.Text = "Skeletal (3)"; - typeButton.OnClick = function(){ SetType(3); } - typeButton.x = typeX + (typeButton.width / 2); - typeButton.y = typeY; - typeButtons.push(typeButton); - addChild(typeButton); - - typeX += typeButton.width + 5; - - typeButton = new UI_GenericBlueButton(); - typeButton.Text = "Scene (6)"; - typeButton.OnClick = function(){ SetType(6); } - typeButton.x = typeX + (typeButton.width / 2); - typeButton.y = typeY; - typeButtons.push(typeButton); - addChild(typeButton); - - animationCheckbox.Checked = true; - //browseButton - //typePlaceholderButton - //usesInput - //usesText.text = "" - } - - var usesInputDefaultText = "Comma Seperated List of Uses Here"; - - public static var fakeID = 9999999; - public function TestFile() - { - fakeID++; - var graphicName = graphicPath.text; - var graphicData = {id:fakeID,graphic:graphicPath.text,v:1,fs:0,p:0,type:selectedType}; - - //"export_params":{"uses":["background"],"available_sizes":["default"],"compress":false}} - - var graphicDef = new GraphicDef(graphicData); - - this.Hide(); - graphicExport.ExportItem(graphicDef); - } - - var selectedType = 1; - public function SetType(type:Number) - { - selectedType = type; - - for(var i = 0; i < typeButtons.length; i++) - { - typeButtons[i].Enabled = true; - } - - animationCheckbox.visible = false; - - switch(type) - { - case 1: { - typeButtons[0].Enabled = false; - animationCheckbox.visible = true; - break; - } - case 3: typeButtons[1].Enabled = false; break; - case 6: typeButtons[2].Enabled = false; break; - } - } - - var graphicExport:GraphicExport; - public function Show(parentClip) - { - this.graphicExport = parentClip; - - parentClip.addChild(this); - - SetType(selectedType); - - var graphicList = GameData.Instance().GraphicDefines; - - var usesString:String = ""; - var uniqueUseTypes:Array = new Array(); - for (var i = 0; i < graphicList.length; i++) - { - var graphicDef:GraphicDef = graphicList[i]; - var uses = graphicDef.ExportParams['uses']; - for (var usage in uses) - { - if (uniqueUseTypes[uses[usage]] == null) - { - uniqueUseTypes[uses[usage]] = uses[usage]; - usesString += uses[usage] + ", "; - } - } - } - - graphicPath.text = ""; - - } - - public function CloseClicked(event) - { - Hide(); - } - - public function Hide() - { - if (this.parent != null) this.parent.removeChild(this); - } - - public function BrowseForFile() - { - var file:File = new File(); - var swfTypeFilter:FileFilter = new FileFilter("SWF Files","*.swf"); - file.addEventListener(Event.SELECT, openFile); - file.browse([swfTypeFilter]); - } - - private function openFile(event:Event):void - { - _strace(event.target.nativePath); - var path:String = event.target.nativePath; - var pathParts:Array = path.split("Graphics\\"); - if (pathParts.length == 2) - { - var fileRemainder:String = pathParts[1]; - var withoutExtension:String = fileRemainder.split(".")[0]; - var pattern:RegExp = /\\/g; - withoutExtension = withoutExtension.replace(pattern, "/"); - _strace(withoutExtension); - graphicPath.text = withoutExtension; - - if (withoutExtension.indexOf("Backgrounds") > -1) - { - SetType(6); - } - - if (withoutExtension.indexOf("Monsters") > -1) - { - SetType(3); - } - - if (withoutExtension.indexOf("Characters") > -1) - { - SetType(3); - } - - if (withoutExtension.indexOf("Portraits") > -1) - { - SetType(1); - } - - if (withoutExtension.indexOf("Quest") > -1) - { - SetType(1); - } - - if (withoutExtension.indexOf("Equipment") > -1) - { - SetType(1); - } - - - } - } - - - } - -} diff --git a/PNGExportHelper.as b/PNGExportHelper.as deleted file mode 100644 index f8c4c9d..0000000 --- a/PNGExportHelper.as +++ /dev/null @@ -1,253 +0,0 @@ -package -{ - import flash.display.*; - import com.adobe.images.*; - import flash.utils.*; - import flash.net.*; - import flash.geom.Matrix; - import flash.geom.Rectangle; - import flash.geom.Point; - - public class PNGExportHelper - { - public static var UseExpandedBitmaps = false; - public static var AlphaThreshold = 5; - - private static function ExpandBitmapBorders(bd:BitmapData, bgColor = 0x0, passes = 1):BitmapData - { - /* - var thresh:BitmapData = new BitmapData(bd.width, bd.height, true, bgColor); - thresh.threshold(bd, bd.rect, new Point(), "<", (20 << 24), bgColor, 0xFF000000, true); - */ - var sampled:BitmapData = new BitmapData(bd.width, bd.height, true, bgColor); - bd.lock(); - sampled.lock(); - - for (var y = 0; y < bd.height; y++) - { - for (var x = 0; x < bd.width; x++) - { - var oldVal:uint = bd.getPixel32(x, y); - var a:uint = (oldVal & 0xFF000000) >>> 24; - var rgb:uint = (oldVal & 0xFFFFFF); - if (a > AlphaThreshold) - { - sampled.setPixel32(x, y, (0xFF << 24) | rgb); - } - else - { - sampled.setPixel32(x, y, bgColor); - } - } - } - sampled.unlock(); - bd.unlock(); - - return ExpandBitmapBordersInternal(sampled, bgColor, passes); - } - - private static function ExpandBitmapBordersInternal(bd:BitmapData, bgColor, passes):BitmapData - { - var output:BitmapData = new BitmapData(bd.width, bd.height, true, bgColor); - - var scale = 16; - var scaled:BitmapData = new BitmapData(bd.width/scale, bd.height/scale, true, bgColor); - var mat:Matrix = new Matrix(); - mat.scale(1/scale, 1/scale); - scaled.draw(bd, mat, null, null, null, true); - - output.lock(); - - var colors:Array = new Array(); - var weights:Array = new Array(); - - for (var oy = 0; oy < scaled.height; oy++) - { - - for (var ox = 0; ox < scaled.width; ox++) - { - - var scaledVal:uint = scaled.getPixel32(ox, oy); - var scaleda:uint = (scaledVal & 0xFF000000) >>> 24; - if (scaleda == 0 || scaleda == 255) - { - output.copyPixels(bd, new Rectangle(ox * scale, oy * scale, scale, scale), new Point(ox * scale, oy * scale)); - continue; - } else { - //_strace(scaleda+""); - } - - - for (var y = oy * scale; y < oy * scale + scale; y++) - { - for (var x = ox * scale; x < ox * scale + scale; x++) - { - var oldVal:uint = bd.getPixel32(x, y); - var a:uint = (oldVal & 0xFF000000) >>> 24; - var rgb:uint = (oldVal & 0xFFFFFF); - - if (a == 0 && rgb == bgColor) - { - colors.length = 0; - weights.length = 0; - - for (var y1 = y - 2; y1 <= y + 2; y1++) - { - for (var x1 = x - 2; x1 <= x + 2; x1++) - { - var dist = Math.abs(x1 - x) + Math.abs(y1 - y); - if (dist >= 3) continue; - - if (x1 >= 0 && x1 < bd.width && y1 >= 0 && y1 < bd.height) - { - colors.push(bd.getPixel(x1, y1)); - weights.push(1 - dist * 0.2); - } - } - } - - var newVal = AveragePixels(colors, weights, bgColor); - if (newVal == null) - { - newVal = oldVal; - } - else - { - var newR:uint = (newVal & 0xFF0000) >> 16; - var newG:uint = (newVal & 0xFF00) >> 8; - var newB:uint = (newVal & 0xFF); - - if (newVal != 0 && colors.length >= 4) - { - var bp = true; - } - - var sorted = colors.sort(function(a, b) - { - var aR:uint = (a & 0xFF0000) >> 16; - var aG:uint = (a & 0xFF00) >> 8; - var aB:uint = (a & 0xFF); - - var bR:uint = (b & 0xFF0000) >> 16; - var bG:uint = (b & 0xFF00) >> 8; - var bB:uint = (b & 0xFF); - - var diffA = Math.abs(aR - newR) + Math.abs(aG - newG) + Math.abs(aB - newB); - var diffB = Math.abs(bR - newR) + Math.abs(bG - newG) + Math.abs(bB - newB); - - return diffA - diffB; - - }, Array.RETURNINDEXEDARRAY | Array.DESCENDING); - - var toRemove = Math.min(2, colors.length - 4); - var removed = 0; - for (var i = 0; i < colors.length; i++) - { - var index = sorted.indexOf(i + removed); - if (index < toRemove) - { - colors.splice(i, 1); - weights.splice(i, 1); - removed++; - i--; - if (removed == toRemove) break; - } - } - - var fixOutliersVal = AveragePixels(colors, weights, bgColor); - if (fixOutliersVal == null) newVal = (0xFF << 24) | newVal; - - newVal = (0xFF << 24) | fixOutliersVal; - } - - output.setPixel32(x, y, newVal); - } - else - { - output.setPixel32(x, y, oldVal); - } - } - } - }//end outer scaled x - }//End outer scaled y - - bd.unlock(); - output.unlock(); - - passes--; - if (passes > 0) - { - return ExpandBitmapBordersInternal(output, bgColor, passes); - } - else - { - return output; - } - } - - private static function AveragePixels(colors:Array, weights:Array, bgColor:uint):uint - { - var rTotal = 0; - var gTotal = 0; - var bTotal = 0; - - var wTotal = 0; - - for (var i = 0; i < colors.length; i++) - { - var color:uint = colors[i]; - var a:uint = (color & 0xFF000000) >>> 24; - var rgb:uint = (color & 0xFFFFFF); - - if (a == 0 && rgb == bgColor) - { - colors.splice(i, 1); - weights.splice(i, 1); - i--; - continue; - } - - var r:uint = (rgb & 0xFF0000) >>> 16; - var g:uint = (rgb & 0xFF00) >>> 8; - var b:uint = (rgb & 0xFF); - var w = weights[i]; - - rTotal += w * r; - gTotal += w * g; - bTotal += w * b; - - wTotal += w; - } - - if (wTotal == 0) - { - return null; - } - - rTotal /= wTotal; - gTotal /= wTotal; - bTotal /= wTotal; - - var rFinal = Math.max(0, Math.min(255, Math.round(rTotal))); - var gFinal = Math.max(0, Math.min(255, Math.round(gTotal))); - var bFinal = Math.max(0, Math.min(255, Math.round(bTotal))); - - return (uint(rFinal) << 16) | (uint(gFinal) << 8) | (uint(bFinal)); - } - - - - public static function GetExportPNG(bd:BitmapData):ByteArray - { - if (!UseExpandedBitmaps) return PNGEncoder.encode(bd); - - var expanded:BitmapData = ExpandBitmapBorders(bd, 0x0, 2); - - //var fr:FileReference = new FileReference(); - //fr.save(PNGEncoder.encode(expanded), "output.png"); - - return PNGEncoderWithAlpha.encode(expanded, bd); - } - - } -} \ No newline at end of file diff --git a/PreviewHolder.as b/PreviewHolder.as deleted file mode 100644 index 587bf68..0000000 --- a/PreviewHolder.as +++ /dev/null @@ -1,57 +0,0 @@ -package { - import flash.display.MovieClip; - - public class PreviewHolder extends MovieClip - { - - var startingWidth = 1024; - var startingHeight = 1024; - - public function PreviewHolder() - { - startingWidth = this.width; - startingHeight = this.height; - } - - var clips:Array = new Array(); - public function AddClip(clip) - { - clips.push(clip); - this.addChild(clip); - ArrangeClips(); - } - - public function ArrangeClips() - { - var numCols = Math.ceil(Math.sqrt(clips.length)); - var maxY = 0; - var maxX = 0; - var clipIndex = 0; - for (var row = 0; row < numCols; row++) - { - var clipX = 0; - var clipY = maxY; - for (var col = 0; col < numCols; col++) - { - if (clipIndex == clips.length) break; - clips[clipIndex].x = clipX; - clips[clipIndex].y = clipY; - clipX += clips[clipIndex].width; - var clipBottom = clips[clipIndex].y + clips[clipIndex].height; - if (clipBottom > maxY) maxY = clipBottom; - - var clipRight = clips[clipIndex].x + clips[clipIndex].width; - if (clipRight > maxX) maxX = clipRight; - clipIndex++; - } - } - - var scale = Math.min(startingWidth / maxX, startingHeight / maxY); - if (scale > 1) scale = 1; - - this.scaleX = this.scaleY = scale; - } - - } - -} diff --git a/old/Checkbox.as b/old/Checkbox.as new file mode 100644 index 0000000..c5aaba2 --- /dev/null +++ b/old/Checkbox.as @@ -0,0 +1,42 @@ +package { + + import flash.display.MovieClip; + import flash.events.MouseEvent; + + public class Checkbox extends MovieClip + { + public var Enabled:Boolean = true; + public function Checkbox() + { + checkbox.gotoAndStop(1); + checkbox.addEventListener(MouseEvent.CLICK, Clicked); + } + + protected function Clicked(event) + { + if (!Enabled) return; + Toggle(); + if (OnClick != null) OnClick(OnClickParam); + } + + protected var checked = false; + public function set Checked(value) { checked = value; checkbox.gotoAndStop(checked ? 2 : 1); } + public function get Checked() { return checked; } + + public function set Text(value) { text.text = value; } + + public var OnClickParam; + public var OnClick; + + + public function Toggle() + { + checked = !checked; + checkbox.gotoAndStop(checked ? 2 : 1); + + + } + + } + +} diff --git a/old/GraphicExport-app.xml b/old/GraphicExport-app.xml new file mode 100644 index 0000000..5144634 --- /dev/null +++ b/old/GraphicExport-app.xml @@ -0,0 +1,41 @@ + + + + GraphicExport + 1.0 + GraphicExport + + GraphicExport + + + GraphicExport.swf + standard + false + true + false + portrait + auto + true + true + true + + + false + false + desktop extendedDesktop diff --git a/old/GraphicExport.exe b/old/GraphicExport.exe new file mode 100644 index 0000000..56315aa --- /dev/null +++ b/old/GraphicExport.exe Binary files differ diff --git a/old/GraphicExport.fla b/old/GraphicExport.fla new file mode 100644 index 0000000..0b78ed7 --- /dev/null +++ b/old/GraphicExport.fla Binary files differ diff --git a/old/GraphicExport.swf b/old/GraphicExport.swf new file mode 100644 index 0000000..542db97 --- /dev/null +++ b/old/GraphicExport.swf Binary files differ diff --git a/old/NewGraphicDialog.as b/old/NewGraphicDialog.as new file mode 100644 index 0000000..152011c --- /dev/null +++ b/old/NewGraphicDialog.as @@ -0,0 +1,224 @@ +package { + + import flash.display.MovieClip; + import flash.events.MouseEvent; + import flash.events.*; + import flash.filesystem.File; + import flash.net.FileFilter; + import Defs.GraphicDef; + import flash.text.engine.GraphicElement; + + public class NewGraphicDialog extends MovieClip + { + + public function NewGraphicDialog() + { + // constructor code + Init(); + } + + var typeButtons:Array = new Array(); + + public function Init() + { + graphicPath.text = "Path to Graphic Here"; + + this.removeChild(browseButton); + + var newBrowseButton = new UI_GenericBlueButton(); + newBrowseButton.Text = "Browse"; + newBrowseButton.OnClick = BrowseForFile; + newBrowseButton.x = browseButton.x + (newBrowseButton.width / 2); + newBrowseButton.y = browseButton.y + (newBrowseButton.height / 2); + addChild(newBrowseButton); + + var newTestButton = new UI_GenericBlueButton(); + newTestButton.Text = "Export"; + newTestButton.OnClick = TestFile; + newTestButton.x = testButton.x + (newTestButton.width / 2); + newTestButton.y = testButton.y + (newTestButton.height / 2); + addChild(newTestButton); + + this.removeChild(typePlaceholderButton); + + var typeX = typePlaceholderButton.x; + var typeY = typePlaceholderButton.y + (typePlaceholderButton.height / 2); + + + var typeButton = new UI_GenericBlueButton(); + typeButton.Text = "Graphic (1)"; + typeButton.OnClick = function(){ SetType(1); } + typeButton.x = typeX + (typeButton.width / 2); + typeButton.y = typeY; + typeButtons.push(typeButton); + addChild(typeButton); + + typeX += typeButton.width + 5; + + typeButton = new UI_GenericBlueButton(); + typeButton.Text = "Skeletal (3)"; + typeButton.OnClick = function(){ SetType(3); } + typeButton.x = typeX + (typeButton.width / 2); + typeButton.y = typeY; + typeButtons.push(typeButton); + addChild(typeButton); + + typeX += typeButton.width + 5; + + typeButton = new UI_GenericBlueButton(); + typeButton.Text = "Scene (6)"; + typeButton.OnClick = function(){ SetType(6); } + typeButton.x = typeX + (typeButton.width / 2); + typeButton.y = typeY; + typeButtons.push(typeButton); + addChild(typeButton); + + animationCheckbox.Checked = true; + //browseButton + //typePlaceholderButton + //usesInput + //usesText.text = "" + } + + var usesInputDefaultText = "Comma Seperated List of Uses Here"; + + public static var fakeID = 9999999; + public function TestFile() + { + fakeID++; + var graphicName = graphicPath.text; + var graphicData = {id:fakeID,graphic:graphicPath.text,v:1,fs:0,p:0,type:selectedType}; + + //"export_params":{"uses":["background"],"available_sizes":["default"],"compress":false}} + + var graphicDef = new GraphicDef(graphicData); + + this.Hide(); + graphicExport.ExportItem(graphicDef); + } + + var selectedType = 1; + public function SetType(type:Number) + { + selectedType = type; + + for(var i = 0; i < typeButtons.length; i++) + { + typeButtons[i].Enabled = true; + } + + animationCheckbox.visible = false; + + switch(type) + { + case 1: { + typeButtons[0].Enabled = false; + animationCheckbox.visible = true; + break; + } + case 3: typeButtons[1].Enabled = false; break; + case 6: typeButtons[2].Enabled = false; break; + } + } + + var graphicExport:GraphicExport; + public function Show(parentClip) + { + this.graphicExport = parentClip; + + parentClip.addChild(this); + + SetType(selectedType); + + var graphicList = GameData.Instance().GraphicDefines; + + var usesString:String = ""; + var uniqueUseTypes:Array = new Array(); + for (var i = 0; i < graphicList.length; i++) + { + var graphicDef:GraphicDef = graphicList[i]; + var uses = graphicDef.ExportParams['uses']; + for (var usage in uses) + { + if (uniqueUseTypes[uses[usage]] == null) + { + uniqueUseTypes[uses[usage]] = uses[usage]; + usesString += uses[usage] + ", "; + } + } + } + + graphicPath.text = ""; + + } + + public function CloseClicked(event) + { + Hide(); + } + + public function Hide() + { + if (this.parent != null) this.parent.removeChild(this); + } + + public function BrowseForFile() + { + var file:File = new File(); + var swfTypeFilter:FileFilter = new FileFilter("SWF Files","*.swf"); + file.addEventListener(Event.SELECT, openFile); + file.browse([swfTypeFilter]); + } + + private function openFile(event:Event):void + { + _strace(event.target.nativePath); + var path:String = event.target.nativePath; + var pathParts:Array = path.split("Graphics\\"); + if (pathParts.length == 2) + { + var fileRemainder:String = pathParts[1]; + var withoutExtension:String = fileRemainder.split(".")[0]; + var pattern:RegExp = /\\/g; + withoutExtension = withoutExtension.replace(pattern, "/"); + _strace(withoutExtension); + graphicPath.text = withoutExtension; + + if (withoutExtension.indexOf("Backgrounds") > -1) + { + SetType(6); + } + + if (withoutExtension.indexOf("Monsters") > -1) + { + SetType(3); + } + + if (withoutExtension.indexOf("Characters") > -1) + { + SetType(3); + } + + if (withoutExtension.indexOf("Portraits") > -1) + { + SetType(1); + } + + if (withoutExtension.indexOf("Quest") > -1) + { + SetType(1); + } + + if (withoutExtension.indexOf("Equipment") > -1) + { + SetType(1); + } + + + } + } + + + } + +} diff --git a/old/PNGExportHelper.as b/old/PNGExportHelper.as new file mode 100644 index 0000000..f8c4c9d --- /dev/null +++ b/old/PNGExportHelper.as @@ -0,0 +1,253 @@ +package +{ + import flash.display.*; + import com.adobe.images.*; + import flash.utils.*; + import flash.net.*; + import flash.geom.Matrix; + import flash.geom.Rectangle; + import flash.geom.Point; + + public class PNGExportHelper + { + public static var UseExpandedBitmaps = false; + public static var AlphaThreshold = 5; + + private static function ExpandBitmapBorders(bd:BitmapData, bgColor = 0x0, passes = 1):BitmapData + { + /* + var thresh:BitmapData = new BitmapData(bd.width, bd.height, true, bgColor); + thresh.threshold(bd, bd.rect, new Point(), "<", (20 << 24), bgColor, 0xFF000000, true); + */ + var sampled:BitmapData = new BitmapData(bd.width, bd.height, true, bgColor); + bd.lock(); + sampled.lock(); + + for (var y = 0; y < bd.height; y++) + { + for (var x = 0; x < bd.width; x++) + { + var oldVal:uint = bd.getPixel32(x, y); + var a:uint = (oldVal & 0xFF000000) >>> 24; + var rgb:uint = (oldVal & 0xFFFFFF); + if (a > AlphaThreshold) + { + sampled.setPixel32(x, y, (0xFF << 24) | rgb); + } + else + { + sampled.setPixel32(x, y, bgColor); + } + } + } + sampled.unlock(); + bd.unlock(); + + return ExpandBitmapBordersInternal(sampled, bgColor, passes); + } + + private static function ExpandBitmapBordersInternal(bd:BitmapData, bgColor, passes):BitmapData + { + var output:BitmapData = new BitmapData(bd.width, bd.height, true, bgColor); + + var scale = 16; + var scaled:BitmapData = new BitmapData(bd.width/scale, bd.height/scale, true, bgColor); + var mat:Matrix = new Matrix(); + mat.scale(1/scale, 1/scale); + scaled.draw(bd, mat, null, null, null, true); + + output.lock(); + + var colors:Array = new Array(); + var weights:Array = new Array(); + + for (var oy = 0; oy < scaled.height; oy++) + { + + for (var ox = 0; ox < scaled.width; ox++) + { + + var scaledVal:uint = scaled.getPixel32(ox, oy); + var scaleda:uint = (scaledVal & 0xFF000000) >>> 24; + if (scaleda == 0 || scaleda == 255) + { + output.copyPixels(bd, new Rectangle(ox * scale, oy * scale, scale, scale), new Point(ox * scale, oy * scale)); + continue; + } else { + //_strace(scaleda+""); + } + + + for (var y = oy * scale; y < oy * scale + scale; y++) + { + for (var x = ox * scale; x < ox * scale + scale; x++) + { + var oldVal:uint = bd.getPixel32(x, y); + var a:uint = (oldVal & 0xFF000000) >>> 24; + var rgb:uint = (oldVal & 0xFFFFFF); + + if (a == 0 && rgb == bgColor) + { + colors.length = 0; + weights.length = 0; + + for (var y1 = y - 2; y1 <= y + 2; y1++) + { + for (var x1 = x - 2; x1 <= x + 2; x1++) + { + var dist = Math.abs(x1 - x) + Math.abs(y1 - y); + if (dist >= 3) continue; + + if (x1 >= 0 && x1 < bd.width && y1 >= 0 && y1 < bd.height) + { + colors.push(bd.getPixel(x1, y1)); + weights.push(1 - dist * 0.2); + } + } + } + + var newVal = AveragePixels(colors, weights, bgColor); + if (newVal == null) + { + newVal = oldVal; + } + else + { + var newR:uint = (newVal & 0xFF0000) >> 16; + var newG:uint = (newVal & 0xFF00) >> 8; + var newB:uint = (newVal & 0xFF); + + if (newVal != 0 && colors.length >= 4) + { + var bp = true; + } + + var sorted = colors.sort(function(a, b) + { + var aR:uint = (a & 0xFF0000) >> 16; + var aG:uint = (a & 0xFF00) >> 8; + var aB:uint = (a & 0xFF); + + var bR:uint = (b & 0xFF0000) >> 16; + var bG:uint = (b & 0xFF00) >> 8; + var bB:uint = (b & 0xFF); + + var diffA = Math.abs(aR - newR) + Math.abs(aG - newG) + Math.abs(aB - newB); + var diffB = Math.abs(bR - newR) + Math.abs(bG - newG) + Math.abs(bB - newB); + + return diffA - diffB; + + }, Array.RETURNINDEXEDARRAY | Array.DESCENDING); + + var toRemove = Math.min(2, colors.length - 4); + var removed = 0; + for (var i = 0; i < colors.length; i++) + { + var index = sorted.indexOf(i + removed); + if (index < toRemove) + { + colors.splice(i, 1); + weights.splice(i, 1); + removed++; + i--; + if (removed == toRemove) break; + } + } + + var fixOutliersVal = AveragePixels(colors, weights, bgColor); + if (fixOutliersVal == null) newVal = (0xFF << 24) | newVal; + + newVal = (0xFF << 24) | fixOutliersVal; + } + + output.setPixel32(x, y, newVal); + } + else + { + output.setPixel32(x, y, oldVal); + } + } + } + }//end outer scaled x + }//End outer scaled y + + bd.unlock(); + output.unlock(); + + passes--; + if (passes > 0) + { + return ExpandBitmapBordersInternal(output, bgColor, passes); + } + else + { + return output; + } + } + + private static function AveragePixels(colors:Array, weights:Array, bgColor:uint):uint + { + var rTotal = 0; + var gTotal = 0; + var bTotal = 0; + + var wTotal = 0; + + for (var i = 0; i < colors.length; i++) + { + var color:uint = colors[i]; + var a:uint = (color & 0xFF000000) >>> 24; + var rgb:uint = (color & 0xFFFFFF); + + if (a == 0 && rgb == bgColor) + { + colors.splice(i, 1); + weights.splice(i, 1); + i--; + continue; + } + + var r:uint = (rgb & 0xFF0000) >>> 16; + var g:uint = (rgb & 0xFF00) >>> 8; + var b:uint = (rgb & 0xFF); + var w = weights[i]; + + rTotal += w * r; + gTotal += w * g; + bTotal += w * b; + + wTotal += w; + } + + if (wTotal == 0) + { + return null; + } + + rTotal /= wTotal; + gTotal /= wTotal; + bTotal /= wTotal; + + var rFinal = Math.max(0, Math.min(255, Math.round(rTotal))); + var gFinal = Math.max(0, Math.min(255, Math.round(gTotal))); + var bFinal = Math.max(0, Math.min(255, Math.round(bTotal))); + + return (uint(rFinal) << 16) | (uint(gFinal) << 8) | (uint(bFinal)); + } + + + + public static function GetExportPNG(bd:BitmapData):ByteArray + { + if (!UseExpandedBitmaps) return PNGEncoder.encode(bd); + + var expanded:BitmapData = ExpandBitmapBorders(bd, 0x0, 2); + + //var fr:FileReference = new FileReference(); + //fr.save(PNGEncoder.encode(expanded), "output.png"); + + return PNGEncoderWithAlpha.encode(expanded, bd); + } + + } +} \ No newline at end of file diff --git a/old/PreviewHolder.as b/old/PreviewHolder.as new file mode 100644 index 0000000..587bf68 --- /dev/null +++ b/old/PreviewHolder.as @@ -0,0 +1,57 @@ +package { + import flash.display.MovieClip; + + public class PreviewHolder extends MovieClip + { + + var startingWidth = 1024; + var startingHeight = 1024; + + public function PreviewHolder() + { + startingWidth = this.width; + startingHeight = this.height; + } + + var clips:Array = new Array(); + public function AddClip(clip) + { + clips.push(clip); + this.addChild(clip); + ArrangeClips(); + } + + public function ArrangeClips() + { + var numCols = Math.ceil(Math.sqrt(clips.length)); + var maxY = 0; + var maxX = 0; + var clipIndex = 0; + for (var row = 0; row < numCols; row++) + { + var clipX = 0; + var clipY = maxY; + for (var col = 0; col < numCols; col++) + { + if (clipIndex == clips.length) break; + clips[clipIndex].x = clipX; + clips[clipIndex].y = clipY; + clipX += clips[clipIndex].width; + var clipBottom = clips[clipIndex].y + clips[clipIndex].height; + if (clipBottom > maxY) maxY = clipBottom; + + var clipRight = clips[clipIndex].x + clips[clipIndex].width; + if (clipRight > maxX) maxX = clipRight; + clipIndex++; + } + } + + var scale = Math.min(startingWidth / maxX, startingHeight / maxY); + if (scale > 1) scale = 1; + + this.scaleX = this.scaleY = scale; + } + + } + +}