Posted by: pierrot | on August 17, 2014
YAPI-HUD v2 Optional Full Map.
Posted in | 4 Comments » Tags: Jappie Toutenhoofd
< ![CDATA[
///////////////////////////////////////////////
//———————————————
// YAPI – Yet Another Page Indicator
// HUD-style – Head Up Display
//
// set this script on event Position-Changed
// New in v2
// – Full Map (optional)
// – Set on any Container
// ToDo:
// – Fade out
//////////////////////////////////////////////
/* config */
var BG_color = 0x33000000;
var HUD_color = 0x7700FF00;
var PNL_color = 0xEEFF1122;
var Full_Map = true; // true or false
/* end-config */
// Create Image on cell-size
var d = LL.getEvent().getContainer();
if (d.getItemByLabel(“HUD”)==null) { Initialsetup();}
var hud = d.getItemByLabel(“HUD”);
var hudW = hud.getWidth();
var hudH = hud.getHeight();
var hud_ratio = hudW / hudH;
var img = LL.createImage( hudW, hudH);
hud.setBoxBackground(img, “n”);
var p = new Paint();
p.setAntiAlias(true);
var c = img.draw();
// Outer Hud base on BoundingBox
var bb = d.getBoundingBox();
var cntW = bb.getRight() – bb.getLeft();
var cntH = bb.getBottom() – bb.getTop();
var cnt_ratio = cntW / cntH;
if (hud_ratio > cnt_ratio)
{ // Container is higher
var cnt_scale = hudH / cntH;
}else{ // Container is wider
var cnt_scale = hudW / cntW;
}
p.setStyle(Paint.Style.FILL);
p.setColor(BG_color);
c.drawRect (0, 0, (cntW * cnt_scale), (cntH * cnt_scale), p);
p.setStyle(Paint.Style.STROKE);
p.setColor(HUD_color);
p.setStrokeWidth(3);
// Map based on Items
if ( Full_Map )
{
var Mitems = d.getItems();
for( var mi=0;mi { var cMi = Mitems.getAt(mi); if ( cMi.getProperties().getString(“i.pinMode”) == “NONE”) { // Map item size if (cMi.getProperties().getBoolean(“i.onGrid”)) { var ItmL = (cMi.getCell().getLeft() * cMi.getParent().getCellWidth() ) – bb.getLeft(); var ItmT = (cMi.getCell().getTop() * cMi.getParent().getCellHeight()) – bb.getTop() ; }else{ var ItmL = cMi.getPositionX() – bb.getLeft(); var ItmT = cMi.getPositionY() – bb.getTop() ; } var ItmR = ItmL + ( cMi.getWidth() * cMi.getScaleX() ); var ItmB = ItmT + ( cMi.getHeight() * cMi.getScaleY() ); // Map item color var Cimg = null; var px = 0x00000000; if ( (cMi.getType() == “Shortcut” || cMi.getType() == “Folder” ) && (cMi.getProperties().getBoolean(“s.iconVisibility”)) ) { Cimg = cMi.getCustomIcon()||cMi.getDefaultIcon(); var bmp = Cimg.getBitmap(); px = bmp.getPixel(Cimg.getWidth()* .41, Cimg.getHeight()* .71); if (Color.alpha(px) < 255) {px = bmp.getPixel(Cimg.getWidth()* .62, Cimg.getHeight()* .37);} if (Color.alpha(px) < 255) {px = bmp.getPixel(Cimg.getWidth()* .48, Cimg.getHeight()* .51);} } // icon visible if (cMi.getType() != ” StopPoint” || cMi.getType() != “Unlocker” || Color.alpha(px) < 99 ) { Cimg = cMi.getBoxBackground(“n”); if (Cimg != null && !Cimg.isNinePatch()) { var bmp = Cimg.getBitmap(); px = bmp.getPixel(Cimg.getWidth()* .5, Cimg.getHeight()* .5); } } // non stoppoint if (Color.alpha(px) < 50) { px = cMi.getProperties().getBox(‘i.box’).getColor(‘c’,’n’); } if (Color.alpha(px) < 50) { px = PNL_color; } p.setStyle( Paint.Style.FILL); p.setColor(px); c.drawRect (ItmL * cnt_scale , ItmT * cnt_scale , ItmR * cnt_scale , ItmB * cnt_scale , p); } // pinMode } // for } // Full_Map // Inner Hud based on Current View //drawRect ( Left, Top, Right, Bottom, Paint) var VwL = d.getPositionX() – bb.getLeft(); var VwT = d.getPositionY() – bb.getTop() ; var VwR = VwL + ( d.getWidth() / d.getPositionScale()); var VwB = VwT + ( d.getHeight() / d.getPositionScale()); p.setStyle(Paint.Style.FILL); p.setColor(HUD_color); c.drawRect (VwL * cnt_scale , VwT * cnt_scale , VwR * cnt_scale , VwB * cnt_scale , p); img.update(); // Create HUD shortcut function Initialsetup() { var newHud = d.addShortcut(“HUD”,new Intent(),0,0); d.setItemZIndex(newHud.getId(),d.getItems().getLength()); var pe = newHud.getProperties().edit(); pe.setBoolean(“i.onGrid”,false); pe.setString(“i.pinMode”,”XY”); pe.setBoolean(“i.enabled”,false); pe.setBoolean(“s.iconVisibility”,false); pe.setBoolean(“s.labelVisibility”,false); pe.commit(); } ]]>
var cMi = Mitems.getAt(mi);
if ( cMi.getProperties().getString(“i.pinMode”) == “NONE”)
// Map item size
if (cMi.getProperties().getBoolean(“i.onGrid”))
var ItmL = (cMi.getCell().getLeft() * cMi.getParent().getCellWidth() ) – bb.getLeft();
var ItmT = (cMi.getCell().getTop() * cMi.getParent().getCellHeight()) – bb.getTop() ;
}else{
var ItmL = cMi.getPositionX() – bb.getLeft();
var ItmT = cMi.getPositionY() – bb.getTop() ;
var ItmR = ItmL + ( cMi.getWidth() * cMi.getScaleX() );
var ItmB = ItmT + ( cMi.getHeight() * cMi.getScaleY() );
// Map item color
var Cimg = null;
var px = 0x00000000;
if (
(cMi.getType() == “Shortcut”
|| cMi.getType() == “Folder”
) && (cMi.getProperties().getBoolean(“s.iconVisibility”))
)
Cimg = cMi.getCustomIcon()||cMi.getDefaultIcon();
var bmp = Cimg.getBitmap();
px = bmp.getPixel(Cimg.getWidth()* .41, Cimg.getHeight()* .71);
if (Color.alpha(px) < 255)
{px = bmp.getPixel(Cimg.getWidth()* .62, Cimg.getHeight()* .37);}
{px = bmp.getPixel(Cimg.getWidth()* .48, Cimg.getHeight()* .51);}
} // icon visible
if (cMi.getType() != ” StopPoint” || cMi.getType() != “Unlocker” || Color.alpha(px) < 99 )
Cimg = cMi.getBoxBackground(“n”);
if (Cimg != null && !Cimg.isNinePatch())
px = bmp.getPixel(Cimg.getWidth()* .5, Cimg.getHeight()* .5);
} // non stoppoint
if (Color.alpha(px) < 50)
px = cMi.getProperties().getBox(‘i.box’).getColor(‘c’,’n’);
px = PNL_color;
p.setStyle( Paint.Style.FILL);
p.setColor(px);
c.drawRect (ItmL * cnt_scale , ItmT * cnt_scale , ItmR * cnt_scale , ItmB * cnt_scale , p);
} // pinMode
} // for
} // Full_Map
// Inner Hud based on Current View
//drawRect ( Left, Top, Right, Bottom, Paint)
var VwL = d.getPositionX() – bb.getLeft();
var VwT = d.getPositionY() – bb.getTop() ;
var VwR = VwL + ( d.getWidth() / d.getPositionScale());
var VwB = VwT + ( d.getHeight() / d.getPositionScale());
c.drawRect (VwL * cnt_scale , VwT * cnt_scale , VwR * cnt_scale , VwB * cnt_scale , p);
img.update();
// Create HUD shortcut
function Initialsetup()
var newHud = d.addShortcut(“HUD”,new Intent(),0,0);
d.setItemZIndex(newHud.getId(),d.getItems().getLength());
var pe = newHud.getProperties().edit();
pe.setBoolean(“i.onGrid”,false);
pe.setString(“i.pinMode”,”XY”);
pe.setBoolean(“i.enabled”,false);
pe.setBoolean(“s.iconVisibility”,false);
pe.setBoolean(“s.labelVisibility”,false);
pe.commit();
]]>
Awesome, just awesome.
Post it in the wiki, when you can.
Wow ! Really good !
Very nice. Looking forward to the fade out that is in your to do. Would be perfect after that.
Your email address will not be published. Required fields are marked *
Comment
Name *
Email *
Website
< ![CDATA[
///////////////////////////////////////////////
//———————————————
// YAPI – Yet Another Page Indicator
// HUD-style – Head Up Display
//
//———————————————
// set this script on event Position-Changed
//———————————————
//
// New in v2
// – Full Map (optional)
// – Set on any Container
//———————————————
// ToDo:
// – Fade out
//////////////////////////////////////////////
/* config */
var BG_color = 0x33000000;
var HUD_color = 0x7700FF00;
var PNL_color = 0xEEFF1122;
var Full_Map = true; // true or false
/* end-config */
// Create Image on cell-size
var d = LL.getEvent().getContainer();
if (d.getItemByLabel(“HUD”)==null) { Initialsetup();}
var hud = d.getItemByLabel(“HUD”);
var hudW = hud.getWidth();
var hudH = hud.getHeight();
var hud_ratio = hudW / hudH;
var img = LL.createImage( hudW, hudH);
hud.setBoxBackground(img, “n”);
var p = new Paint();
p.setAntiAlias(true);
var c = img.draw();
// Outer Hud base on BoundingBox
var bb = d.getBoundingBox();
var cntW = bb.getRight() – bb.getLeft();
var cntH = bb.getBottom() – bb.getTop();
var cnt_ratio = cntW / cntH;
if (hud_ratio > cnt_ratio)
{ // Container is higher
var cnt_scale = hudH / cntH;
}else{ // Container is wider
var cnt_scale = hudW / cntW;
}
p.setStyle(Paint.Style.FILL);
p.setColor(BG_color);
c.drawRect (0, 0, (cntW * cnt_scale), (cntH * cnt_scale), p);
p.setStyle(Paint.Style.STROKE);
p.setColor(HUD_color);
p.setStrokeWidth(3);
c.drawRect (0, 0, (cntW * cnt_scale), (cntH * cnt_scale), p);
// Map based on Items
if ( Full_Map )
{
var Mitems = d.getItems();
for( var mi=0;mi
{
var cMi = Mitems.getAt(mi);
if ( cMi.getProperties().getString(“i.pinMode”) == “NONE”)
{
// Map item size
if (cMi.getProperties().getBoolean(“i.onGrid”))
{
var ItmL = (cMi.getCell().getLeft() * cMi.getParent().getCellWidth() ) – bb.getLeft();
var ItmT = (cMi.getCell().getTop() * cMi.getParent().getCellHeight()) – bb.getTop() ;
}else{
var ItmL = cMi.getPositionX() – bb.getLeft();
var ItmT = cMi.getPositionY() – bb.getTop() ;
}
var ItmR = ItmL + ( cMi.getWidth() * cMi.getScaleX() );
var ItmB = ItmT + ( cMi.getHeight() * cMi.getScaleY() );
// Map item color
var Cimg = null;
var px = 0x00000000;
if (
(cMi.getType() == “Shortcut”
|| cMi.getType() == “Folder”
) && (cMi.getProperties().getBoolean(“s.iconVisibility”))
)
{
Cimg = cMi.getCustomIcon()||cMi.getDefaultIcon();
var bmp = Cimg.getBitmap();
px = bmp.getPixel(Cimg.getWidth()* .41, Cimg.getHeight()* .71);
if (Color.alpha(px) < 255)
{px = bmp.getPixel(Cimg.getWidth()* .62, Cimg.getHeight()* .37);}
if (Color.alpha(px) < 255)
{px = bmp.getPixel(Cimg.getWidth()* .48, Cimg.getHeight()* .51);}
} // icon visible
if (cMi.getType() != ” StopPoint” || cMi.getType() != “Unlocker” || Color.alpha(px) < 99 )
{
Cimg = cMi.getBoxBackground(“n”);
if (Cimg != null && !Cimg.isNinePatch())
{
var bmp = Cimg.getBitmap();
px = bmp.getPixel(Cimg.getWidth()* .5, Cimg.getHeight()* .5);
}
} // non stoppoint
if (Color.alpha(px) < 50)
{
px = cMi.getProperties().getBox(‘i.box’).getColor(‘c’,’n’);
}
if (Color.alpha(px) < 50)
{
px = PNL_color;
}
p.setStyle( Paint.Style.FILL);
p.setColor(px);
c.drawRect (ItmL * cnt_scale , ItmT * cnt_scale , ItmR * cnt_scale , ItmB * cnt_scale , p);
} // pinMode
} // for
} // Full_Map
// Inner Hud based on Current View
//drawRect ( Left, Top, Right, Bottom, Paint)
var VwL = d.getPositionX() – bb.getLeft();
var VwT = d.getPositionY() – bb.getTop() ;
var VwR = VwL + ( d.getWidth() / d.getPositionScale());
var VwB = VwT + ( d.getHeight() / d.getPositionScale());
p.setStyle(Paint.Style.FILL);
p.setColor(HUD_color);
c.drawRect (VwL * cnt_scale , VwT * cnt_scale , VwR * cnt_scale , VwB * cnt_scale , p);
img.update();
// Create HUD shortcut
function Initialsetup()
{
var newHud = d.addShortcut(“HUD”,new Intent(),0,0);
d.setItemZIndex(newHud.getId(),d.getItems().getLength());
var pe = newHud.getProperties().edit();
pe.setBoolean(“i.onGrid”,false);
pe.setString(“i.pinMode”,”XY”);
pe.setBoolean(“i.enabled”,false);
pe.setBoolean(“s.iconVisibility”,false);
pe.setBoolean(“s.labelVisibility”,false);
pe.commit();
}
]]>
< ![CDATA[
Awesome, just awesome.
Post it in the wiki, when you can.
]]>
< ![CDATA[
Wow ! Really good !
]]>
< ![CDATA[
Very nice. Looking forward to the fade out that is in your to do. Would be perfect after that.
]]>