Konfigurieren von DUI v2 64bit

Begonnen von mexx, 09. November 2022, 16:09:21

Vorheriges Thema - Nächstes Thema

grimes

Kann ich nicht nachvollziehen. Was ist Feld Info/Text? Welche Codierung hat die txt-Datei? (UTF-8-BOM)

mexx

Ich glaube Panel Info/Text wäre korrekter gewesen (s. Anhang)

Hier das Script:
// ==PREPROCESSOR==
// @name "Text Reader"
// @author "marc2003"
// @import "%fb2k_component_path%helpers.txt"
// @import "%fb2k_component_path%samples\js\lodash.min.js"
// @import "%fb2k_component_path%samples\js\common.js"
// @import "%fb2k_component_path%samples\js\panel.js"
// @import "%fb2k_component_path%samples\js\text.js"
// ==/PREPROCESSOR==

// https://marc2k3.github.io/jscript-panel/gallery/text-reader/

var panel = new _panel()

panel.draw_header = function (gr, text) {
    gr.WriteText(text, this.fonts.title, this.colours.highlight, LM, 0, this.w - (LM * 2), TM, DWRITE_TEXT_ALIGNMENT_CENTER, DWRITE_PARAGRAPH_ALIGNMENT_CENTER, DWRITE_WORD_WRAPPING_NO_WRAP, DWRITE_TRIMMING_GRANULARITY_CHARACTER);
    gr.DrawLine(LM, TM + 0.5, this.w - LM, TM + 0.5, 1, this.colours.highlight);
   
}

var text = new _text('text_reader2', LM, TM, 0, 0);

panel.item_focus_change();

function on_colours_changed() {
    panel.colours_changed();
    window.Repaint();
}

function on_font_changed() {
    panel.font_changed();
    window.Repaint();
}

function on_item_focus_change() {
    panel.item_focus_change();
}

function on_key_down(k) {
    text.key_down(k);
}

function on_metadb_changed() {
    text.metadb_changed();
}

function on_mouse_lbtn_up(x, y) {
    text.lbtn_up(x, y);
}

function on_mouse_move(x, y) {
    text.move(x, y);
}

function on_mouse_rbtn_up(x, y) {
    return panel.rbtn_up(x, y, text);
}

function on_mouse_wheel(s) {
    text.wheel(s);
}

function on_paint(gr) {
    panel.paint(gr);
    panel.draw_header(gr, text.header_text());
    text.paint(gr);
}

function on_playback_dynamic_info_track() {
    panel.item_focus_change();
}

function on_playback_new_track() {
    panel.item_focus_change();
}

function on_playback_stop(reason) {
    if (reason != 2) {
        panel.item_focus_change();
    }
}

function on_playlist_switch() {
    panel.item_focus_change();
}

function on_size() {
    panel.size();
    text.w = panel.w - (LM * 2);
    text.h = panel.h - TM;
    text.size();
}

Die Textdatei ist in UTF-8 gespeichert.

grimes

Kann es nachvollziehen. Bei mir funktioniert die Kodierung UTF8-BOM, (konvertieren mit notepad++).

mexx

#33
Danke...UTF8-BOM geht bei mir auch. :top:

Konvertieren geht auch mit dem Windows Editor. Unten bei Konvertieren UTF-8 mit BOM einstellen. Dann nochmaliges abspeichern und überschreiben

mexx

Noch eine Frage zur Anzeige der Länderflagge.

Wie kann ich es erreichen, das die Größe der Flagge sich an die Größe der JScript-Fenster anpasst?

Hier das verwendete Script von grimes:

//flag by grimes
//fb2k v2+, JScript Panel 3+
//DUI/CUI ready

// ==PREPROCESSOR==
// @name "flag"
// @version "2"
// @author "grimes"
// ==/PREPROCESSOR==


var cfg_foobarpath = window.GetProperty("foobar path:", fb.Profilepath);
var cfg_flag = window.GetProperty("flag folder:", "flags");
var svg_file = cfg_foobarpath + cfg_flag + "\\noflag.svg";
var svg_content = utils.ReadUTF8(svg_file);

var dui = window.IsDefaultUI;

var original = utils.LoadSVG(svg_file);

function on_paint(gr) {
    gr.FillRectangle(0, 0, window.Width, window.Height, dui == 1 ? window.GetColourDUI(1) : window.GetColourCUI(3)); 
    if (original) {
        var scale = 0;
        var x = 0,
            y = 0;
        var scale_w = window.Width / original.Width;
        var scale_h = window.Height / original.Height;

        if (scale_w <= scale_h) {
            scale = scale_w;
            y = (window.Height - original.Height * scale) / 2;
        } else {
            scale = scale_h;
            x = (window.Width - original.Width * scale) / 2;
        }
        gr.DrawImage(original, x, y, original.Width * scale, original.Height * scale, 0, 0, original.Width, original.Height);
    }
}

if(fb.IsPlaying || fb.IsPaused) {
    country = fb.TitleFormat("%country%").Eval();
    original = utils.LoadSVG(cfg_foobarpath + cfg_flag + "\\" + country + ".svg");
    window.Repaint(); 
}
else {
    original = utils.LoadSVG(svg_file);
    window.Repaint();
}

function on_playback_new_track() {
    country = fb.TitleFormat("%country%").Eval();
    original = utils.LoadSVG(cfg_foobarpath + cfg_flag + "\\" + country + ".svg");
    window.Repaint();
}

function on_playback_stop(reason) {
    original = utils.LoadSVG(svg_file);
    window.Repaint();
}

grimes

Ersetze entsprechende Zeile mit:
gr.DrawImage(original, 0, 0, window.Width, window.Height, 0, 0, original.Width, original.Height);

mexx