Created
July 26, 2015 02:24
-
-
Save SinZ163/71a6ba1cbc901c44b08e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package { | |
import flash.display.MovieClip; | |
import ModDotaLib.Utils.AssetUtils; | |
import ValveLib.Globals; | |
import flash.utils.getQualifiedClassName; | |
import flash.utils.getDefinitionByName; | |
import flash.utils.Timer; | |
import flash.events.TimerEvent; | |
import flash.geom.Point; | |
import flash.text.TextFormat; | |
import flash.text.TextFormatAlign; | |
import flash.text.TextField; | |
import flash.events.Event; | |
public class Mini_UI extends MovieClip { | |
//GameAPI stuff, requried for this to work | |
public var gameAPI:Object; | |
public var globals:Object; | |
public var elementName:String; | |
public var inventory:MovieClip; | |
public var action:MovieClip; | |
public var scoreboard:MovieClip; | |
public var MiniUIStuff:Object; | |
public function Mini_UI() { | |
// constructor code | |
trace("#CONSTRUCTOR++"); | |
} | |
public function onLoaded() : void { | |
MiniUIStuff = new Object(); | |
this.gameAPI.OnReady(); | |
trace("###LOADING"); | |
var repeatTimer:Timer = new Timer(10000, 1); | |
repeatTimer.addEventListener(TimerEvent.TIMER, Stuff); | |
repeatTimer.start(); | |
} | |
private function LeftAlignedTextFieldChanged(e:Event):void { | |
var left_align:TextFormat = new TextFormat(); | |
left_align.align = TextFormatAlign.LEFT; | |
e.target.setTextFormat(left_align); | |
} | |
public function Stuff(e:TimerEvent) { | |
inventory = globals.Loader_inventory.movieClip; | |
action = globals.Loader_actionpanel.movieClip; | |
scoreboard = globals.Loader_scoreboard.movieClip; | |
//PrintTable(globals); | |
trace("#OBJECTS MADE"); | |
scoreboard.topBackground.visible = false; | |
inventory.inventory.rocks_16_9.visible = false; | |
inventory.inventory.light_16_9.visible = false; | |
inventory.inventory.background_wide.visible = false; | |
inventory.inventory.spacer.visible = false; //The thing between ActionPanel and Inventory (iirc only shown on 16:9); | |
action.middle.light_16_9.visible = false; | |
action.middle.spacer_16_9.visible = false; | |
action.middle.centerBGRight.visible = false; | |
action.middle.centerBGLeftWide.visible = false; | |
action.middle.centerBGLeft.visible = false; | |
//action.middle.portraitHolder.visible = false; //The psuedo location of the portrait | |
//action.middle.econItem.visible = false; //Unknown | |
//action.middle.portraitBlocker.visible = false; //Unknown | |
action.middle.attributesBG.visible = false; //The popup when hovering over attributes | |
//action.middle.statRegion.visible = false; //Unknown | |
//action.middle.portraitFrame_wide.visible = false; //UI around the portrait | |
//TODO: add config setting for | |
action.middle.minimapOffButton.visible = false; //The square thing in the top left of the minimap | |
//action.middle.minimapBorder.visible = false; //Minimap border (needs a larger delay) | |
trace("##Made shit invisible"); | |
scoreboard.menuButtons.scaleX = 0.75; | |
scoreboard.menuButtons.scaleY = 0.75; | |
scoreboard.Button_UptoDB.scaleX = 0.75; | |
scoreboard.Button_UptoDB.scaleY = 0.75; | |
trace("##Scaled top left buttons"); | |
var StatsBarCoords:Point = new Point(300,300); | |
var left_align:TextFormat = new TextFormat(); | |
left_align.align = TextFormatAlign.LEFT; | |
var attributesCoords:Point = action.middle.stats.globalToLocal(StatsBarCoords); | |
action.middle.stats.strIcon.x = attributesCoords.x; | |
action.middle.stats.strIcon.y = attributesCoords.y; | |
attributesCoords.x = attributesCoords.x + action.middle.stats.strIcon.width; | |
action.middle.stats.strLabel.x = attributesCoords.x; | |
action.middle.stats.strLabel.y = attributesCoords.y; | |
action.middle.stats.strLabel.setTextFormat(left_align); | |
action.middle.stats.strLabel.defaultTextFormat = left_align; | |
action.middle.stats.strLabel.addEventListener(Event.CHANGE, LeftAlignedTextFieldChanged); | |
attributesCoords.x = attributesCoords.x + action.middle.stats.strLabel.width; | |
action.middle.stats.agiIcon.x = attributesCoords.x; | |
action.middle.stats.agiIcon.y = attributesCoords.y - 0.4*action.middle.stats.strIcon.height; | |
attributesCoords.x = attributesCoords.x + action.middle.stats.agiIcon.width; | |
action.middle.stats.agiLabel.x = attributesCoords.x; | |
action.middle.stats.agiLabel.y = attributesCoords.y; | |
action.middle.stats.agiLabel.setTextFormat(left_align); | |
action.middle.stats.agiLabel.defaultTextFormat = left_align; | |
action.middle.stats.strLabel.addEventListener(Event.CHANGE, LeftAlignedTextFieldChanged); | |
attributesCoords.x = attributesCoords.x + action.middle.stats.agiLabel.width; | |
action.middle.stats.intIcon.x = attributesCoords.x; | |
action.middle.stats.intIcon.y = attributesCoords.y - 0.8*action.middle.stats.agiIcon.height; | |
attributesCoords.x = attributesCoords.x + action.middle.stats.intIcon.width; | |
action.middle.stats.intLabel.x = attributesCoords.x; | |
action.middle.stats.intLabel.y = attributesCoords.y; | |
action.middle.stats.intLabel.setTextFormat(left_align); | |
action.middle.stats.intLabel.defaultTextFormat = left_align; | |
action.middle.stats.strLabel.addEventListener(Event.CHANGE, LeftAlignedTextFieldChanged); | |
attributesCoords.x = attributesCoords.x + action.middle.stats.intLabel.width; | |
trace("##Moved attributes"); | |
StatsBarCoords = action.middle.stats.localToGlobal(attributesCoords); | |
var statsCoords:Point = action.middle.attributes.globalToLocal(StatsBarCoords); | |
action.middle.attributes.movespeedLabel.x = statsCoords.x; | |
action.middle.attributes.movespeedLabel.y = statsCoords.y; | |
statsCoords.x = statsCoords.x + action.middle.attributes.movespeedLabel.width; | |
action.middle.attributes.defLabel.x = statsCoords.x; | |
action.middle.attributes.defLabel.y = statsCoords.y; | |
statsCoords.x = statsCoords.x + action.middle.attributes.defLabel.width; | |
action.middle.attributes.attackLabel.x = statsCoords.x; | |
action.middle.attributes.attackLabel.y = statsCoords.y; | |
//statsCoords.x = statsCoords.x + action.middle.attributes.attackLabel.width; | |
trace("##Moved stats"); | |
var itemCoords:Point = new Point(500,500); | |
var itemLocals:Point = inventory.inventory.items.globalToLocal(itemCoords); | |
var i:int = 0; | |
for (i=0; i < 6; i++) { | |
inventory.inventory.items["Item"+i].x = itemLocals.x - 0.7*(5-i)*inventory.inventory.items["Item"+i].width; | |
inventory.inventory.items["Item"+i].y = itemLocals.y; | |
inventory.inventory.items["binding"+i].x = itemLocals.x - 0.7*(5-i)*inventory.inventory.items["Item"+i].width; | |
inventory.inventory.items["binding"+i].y = itemLocals.y; | |
} | |
trace("##Moved items"); | |
var portraitCoords:Point = action.middle.portraitHolder.localToGlobal(new Point(0,0)); | |
portraitCoords.x = portraitCoords.x; | |
portraitCoords.y = portraitCoords.y - 500; | |
var portraitLocal:Point = action.middle.globalToLocal(portraitCoords); | |
action.gameAPI.SetPortraitPosition(portraitCoords.x,portraitCoords.y,action.middle.portraitHolder.width * action.middle.scaleX,action.middle.portraitHolder.height * action.middle.scaleY); | |
action.middle.portraitHolder.x = portraitLocal.x; | |
action.middle.portraitHolder.y = portraitLocal.y; | |
trace("##Moved portrait"); | |
MiniUIStuff["topbar"] = new MovieClip(); | |
scoreboard.addChildAt(MiniUIStuff["topbar"], scoreboard.getChildIndex(scoreboard.topBackground)); | |
MiniUIStuff["topbar"].visible = true; | |
MiniUIStuff["topbar"].x = scoreboard.globalToLocal(new Point(0,0)).x; | |
MiniUIStuff["topbar"].y = scoreboard.globalToLocal(new Point(0,0)).y; | |
MiniUIStuff["topbar"].width = width; | |
MiniUIStuff["topbar"].height = 4 * height / 100; //4% of height | |
Globals.instance.LoadImageWithCallback("Mini-UI/default/topbar.png", MiniUIStuff["topbar"], true, imageLoaded); | |
trace("##Created topbar image"); | |
//Set HUD | |
/* | |
//ActionPanel | |
HUDReplacementData:Array = [ | |
["minimapborder",this.middle.minimapBorder], | |
["portrait_wide",this.middle.portraitFrame_wide], | |
["portrait_4_3",this.middle.portraitFrame_4_3], | |
["spacer_16_9",this.middle.spacer_16_9], | |
["spacer_16_10",this.middle.spacer_16_10], | |
["center_left",this.middle.centerBGLeft], | |
["center_left_wide",this.middle.centerBGLeftWide], | |
["center_right",this.middle.centerBGRight], | |
["light_4_3",this.middle.light_4_3.content], | |
["light_16_9",this.middle.light_16_9.content], | |
["light_16_10",this.middle.light_16_10.content] | |
]; | |
//scoreboard | |
this.HUDReplacementData = [ | |
["topBackground",this.topBackground], | |
["dayNight",this.topbar.dayNight.content] | |
]; | |
//inventory | |
this.HUDReplacementData = [ | |
["background_4_3",this.inventory.background_4_3], | |
["background_wide",this.inventory.background_wide], | |
["spacer",this.inventory.spacer], | |
["rocks_4_3",this.inventory.rocks_4_3], | |
["rocks_16_9",this.inventory.rocks_16_9], | |
["rocks_16_10",this.inventory.rocks_16_10], | |
["light_4_3",this.inventory.light_4_3.content], | |
["light_16_9",this.inventory.light_16_9.content], | |
["light_right_16_10",this.inventory.light_16_10.content], | |
["stash_active_lower",this.inventory.stash_anim.stash.activeLower], | |
["stash_upper",this.inventory.stash_anim.stash.bg.bg.upper], | |
["stash_lower",this.inventory.stash_anim.stash.bg.bg.lower] | |
]; | |
*/ | |
} | |
public function imageLoaded() { | |
trace("###MINI_UI IT LOADED!!!"); | |
MiniUIStuff["topbar"].visible = true; | |
MiniUIStuff["topbar"].x = 100; | |
MiniUIStuff["topbar"].y = 100; | |
} | |
//Stolen from Frota | |
public function strRep(str, count) { | |
var output = ""; | |
for(var i=0; i<count; i++) { | |
output = output + str; | |
} | |
return output; | |
} | |
public function isPrintable(t) { | |
if(t == null || t is Number || t is String || t is Boolean || t is Function || t is Array) { | |
return true; | |
} | |
// Check for vectors | |
if(flash.utils.getQualifiedClassName(t).indexOf('__AS3__.vec::Vector') == 0) return true; | |
return false; | |
} | |
public function PrintTable(t, indent=0, done=null) { | |
var i:int, key, key1, v:*; | |
// Validate input | |
if(isPrintable(t)) { | |
trace("PrintTable called with incorrect arguments!"); | |
return; | |
} | |
if(indent == 0) { | |
trace(t.name+" "+t+": {") | |
} | |
// Stop loops | |
done ||= new flash.utils.Dictionary(true); | |
if(done[t]) { | |
trace(strRep("\t", indent)+"<loop object> "+t); | |
return; | |
} | |
done[t] = true; | |
// Grab this class | |
var thisClass = flash.utils.getQualifiedClassName(t); | |
// Print methods | |
for each(key1 in flash.utils.describeType(t)..method) { | |
// Check if this is part of our class | |
if(key1.@declaredBy == thisClass) { | |
// Yes, log it | |
trace(strRep("\t", indent+1)+key1.@name+"()"); | |
} | |
} | |
// Check for text | |
if("text" in t) { | |
trace(strRep("\t", indent+1)+"text: "+t.text); | |
} | |
// Print variables | |
for each(key1 in flash.utils.describeType(t)..variable) { | |
key = key1.@name; | |
v = t[key]; | |
// Check if we can print it in one line | |
if(isPrintable(v)) { | |
trace(strRep("\t", indent+1)+key+": "+v); | |
} else { | |
switch(key) { | |
case "Loader_combat_log": | |
return; | |
default: | |
// Open bracket | |
trace(strRep("\t", indent+1)+key+": {"); | |
// Recurse! | |
PrintTable(v, indent+1, done) | |
// Close bracket | |
trace(strRep("\t", indent+1)+"}"); | |
break; | |
} | |
} | |
} | |
// Find other keys | |
for(key in t) { | |
v = t[key]; | |
// Check if we can print it in one line | |
if(isPrintable(v)) { | |
trace(strRep("\t", indent+1)+key+": "+v); | |
} else { | |
// Open bracket | |
trace(strRep("\t", indent+1)+key+": {"); | |
// Recurse! | |
PrintTable(v, indent+1, done) | |
// Close bracket | |
trace(strRep("\t", indent+1)+"}"); | |
} | |
} | |
// Get children | |
if(t is MovieClip) { | |
// Loop over children | |
for(i = 0; i < t.numChildren; i++) { | |
// Open bracket | |
trace(strRep("\t", indent+1)+t.name+" "+t+": {"); | |
// Recurse! | |
PrintTable(t.getChildAt(i), indent+1, done); | |
// Close bracket | |
trace(strRep("\t", indent+1)+"}"); | |
} | |
} | |
// Close bracket | |
if(indent == 0) { | |
trace("}"); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment