wsh_panel_mod (1.5.6)

Begonnen von HighDef, 10. Dezember 2013, 16:39:29

Vorheriges Thema - Nächstes Thema

HighDef

Hallo zusammen!

Nach langer, langer Zeit bin ich mal wieder dazu gekommen, an meiner (von Tedgo's DarkOne "inspirierter") Oberfläche herumzubasteln.

Aber mit folgendem Script:

// ===== Trackinfo Panel ===========================================
// ===== Code by super-gau and tedGo

function RGBA(r, g, b, a) {
return ((a << 24) | (r << 16) | (g << 8) | (b));
}

var DT_CENTER = 0x00000001;
var DT_WORDBREAK = 0x00000010;

var g_font_a = gdi.Font("Arial", 14, 0);
var g_font_b = gdi.Font("Arial", 12, 0);
var g_font_c = gdi.Font("Arial", 4, 0);
var g_font_d = gdi.Font("Arial", 16, 0);

var ww, wh;

function StrMeasure(text, g_font, width, colour, gr) {
this.text = text.replace(/&/, "&&");
this.g_font = g_font;
this.colour = colour;
this.measureString = gr.MeasureString(text, g_font, 0, 0, width, 100, 0);
this.height = this.measureString.Height;
}

function Trackinfo(x, y, w, h)  {
this.left = x;
this.top = y;
this.w = w;
this.h = h;
this.right = x + w;
this.bottom = y + h;

this.arrayCounter = 0;

this.draw = function (gr) {
var strMeasureArray = new Array();
this.arrayCounter = 0;

var metadb = fb.GetNowPlaying();

if (metadb) {
var fileinfo = metadb.GetFileInfo();

txt = fileinfo.MetaValue(fileinfo.MetaFind("artist"), 0);
this.addStrMeasure(txt.toUpperCase(), strMeasureArray, g_font_d, RGBA(128, 192, 255, 255), gr);

txt = fb.TitleFormat("    ").Eval();
this.addStrMeasure(txt, strMeasureArray, g_font_c, RGBA(128, 192, 255, 255), gr);

txt = fileinfo.MetaValue(fileinfo.MetaFind(["work"]), 0);
this.addStrMeasure(txt.toUpperCase(), strMeasureArray, g_font_a, RGBA(192, 224, 255, 255), gr);

txt = fb.TitleFormat("    ").Eval();
this.addStrMeasure(txt, strMeasureArray, g_font_c, RGBA(128, 192, 255, 255), gr);

txt = fb.TitleFormat("%title%").Eval();
this.addStrMeasure(txt.toUpperCase(), strMeasureArray, g_font_a, RGBA(255, 255, 255, 255), gr);

txt = fb.TitleFormat("[%track date%]").Eval();
this.addStrMeasure(txt.toUpperCase(), strMeasureArray, g_font_a, RGBA(255, 255, 255, 255), gr, "(", ")");

    txt = fb.TitleFormat("[%trackinfo%]").Eval();
this.addStrMeasure(txt, strMeasureArray, g_font_b, RGBA(255, 255, 255, 255), gr, "(", ")");

txt = fb.TitleFormat("['('%composer%')']").Eval();
this.addStrMeasure(txt, strMeasureArray, g_font_b, RGBA(192, 192, 192, 255), gr);

txt = fb.TitleFormat("    ").Eval();
this.addStrMeasure(txt, strMeasureArray, g_font_c, RGBA(128, 192, 255, 255), gr);

txt = fileinfo.MetaValue(fileinfo.MetaFind("orchestra"), 0);
this.addStrMeasure(txt, strMeasureArray, g_font_b, RGBA(128, 192, 255, 255), gr);

txt = fileinfo.MetaValue(fileinfo.MetaFind("conductor"), 0);
this.addStrMeasure(txt, strMeasureArray, g_font_b, RGBA(128, 192, 255, 255), gr);

            txt = fb.TitleFormat("[%performer%]").Eval();
this.addStrMeasure(txt, strMeasureArray, g_font_b, RGBA(192, 224, 255, 255), gr);

            txt = fb.TitleFormat("    ").Eval();
this.addStrMeasure(txt, strMeasureArray, g_font_c, RGBA(128, 192, 255, 255), gr);
                   
txt = fb.TitleFormat("[© %date%][ - %label%]").Eval();
this.addStrMeasure(txt, strMeasureArray, g_font_b, RGBA(128, 192, 255, 255), gr);

            txt = fb.TitleFormat("    ").Eval();
this.addStrMeasure(txt, strMeasureArray, g_font_c, RGBA(128, 192, 255, 255), gr);

txt = fb.TitleFormat("[%info%]").Eval();
this.addStrMeasure(txt, strMeasureArray, g_font_b, RGBA(192, 192, 255, 255), gr, "(", ")");



var infoHeight = 20;
for (var i = 0; i < strMeasureArray.length; i++) {
infoHeight += strMeasureArray[i].height;
}

var lastBottom = (wh - infoHeight) / 2;
for (var i = 0; i < strMeasureArray.length; i++) {
gr.GdiDrawText(strMeasureArray[i].text, strMeasureArray[i].g_font,strMeasureArray[i].colour, this.left, lastBottom,

this.w, strMeasureArray[i].height, DT_CENTER | DT_WORDBREAK);
lastBottom = lastBottom + strMeasureArray[i].height;
}
}
}

this.addStrMeasure = function( text, strMeasureArray, g_font, colour, gr,  preText, postText ) {
text = (text == null || text.lenght<1) ? null : text;
preText = (preText == null) ? "" : preText;
postText = (postText == null) ? "" : postText;
if (text) {
text = preText + text + postText;
strMeasureArray[this.arrayCounter] = new StrMeasure(text, g_font, this.w, colour, gr);
this.arrayCounter++;
}
}
}

function on_paint(gr) {
gr.FillSolidRect(0, 0, ww, wh, RGBA(0, 0, 0, 0));
trackinfo.draw(gr);
}


function on_size() {
ww = window.Width;
wh = window.Height;

trackinfo = new Trackinfo(0, 0, ww, wh);
}

function on_playback_new_track(metadb){
window.repaint();
}

function on_playback_stop(){
window.repaint();
}

function on_playback_edited() {
window.repaint();
}

function on_playback_dynamic_info_track() {
window.repaint();
}


habe ich folgendes Problem:



es wird ein Stück vom Text "abgeschnitten", sobald mehr als eine Reihe (hier z.B. "performer") Text angezeigt werden soll ...

Hüüüülfäähhh !

Ich blicke bei diesen script einfach nicht durch, an was ich da drehen müsste, damit ich das Problem in den Griff bekomme.

Danke schonmal im voraus für Eure Zeit und Mühe,

Grüsse
Harald

P.S.:
und danke an Tedgo für sein DarkOne!

mh12

Hallo,

also als schnelle Hilfe, die Zeile die die Ausgabe steuert und die Du anpassen kannst ist die #102:

gr.GdiDrawText(strMeasureArray[i].text, strMeasureArray[i].g_font,strMeasureArray[i].colour, this.left, lastBottom,
this.w, strMeasureArray[i].height, DT_CENTER | DT_WORDBREAK);


Der Parameter strMeasureArray.height steht für die Höhe, die die Textbox hat. Da brauchst Du einfach etwas mehr Spielraum, ich habe das mal ersetzt mit strMeasureArray.height+10 und egal, ob der Gesamttext jetzt 3- oder 5-zeilig wird, die Zeile wird immer komplett angezeigt.

HighDef

 :top:

Das sieht doch schonmal gut aus!
Vielen Dank für die Hilfe!

Grüsse
Harald