OnlineSection.java

package ui.entities.config;

import jakarta.persistence.Access;
import jakarta.persistence.AccessType;
import jakarta.persistence.Embeddable;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import sidplay.ini.converter.BeanToStringConverter;
import ui.common.properties.ShadowField;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

@Embeddable
@Access(AccessType.PROPERTY)
public class OnlineSection {

    /**
     * URL where the JSIDPlay2 is deployed to.
     */
    public static final String DEPLOYMENT_URL = "https://haendel.ddns.net/~ken/";

    public static final String JSIDPLAY2_SIDBLASTER_DOC_URL = DEPLOYMENT_URL + "sidblaster.html";
    public static final String JSIDPLAY2_C64MUSIC_URL = DEPLOYMENT_URL + "online/hvsc/C64Music.zip";
    public static final String JSIDPLAY2_HVSC_DATA_URL = DEPLOYMENT_URL + "online/hvsc/HVSC.data";
    public static final String JSIDPLAY2_HVSC_SCRIPT_URL = DEPLOYMENT_URL + "online/hvsc/HVSC.script";
    public static final String JSIDPLAY2_HVSC_PROPERTIES_URL = DEPLOYMENT_URL + "online/hvsc/HVSC.properties";
    public static final String JSIDPLAY2_CGSC_URL = DEPLOYMENT_URL + "online/cgsc/CGSC.zip";
    public static final String JSIDPLAY2_CGSC_SCRIPT_URL = DEPLOYMENT_URL + "online/cgsc/CGSC.script";
    public static final String JSIDPLAY2_CGSC_DATA_URL = DEPLOYMENT_URL + "online/cgsc/CGSC.data";
    public static final String JSIDPLAY2_CGSC_PROPERTIES_URL = DEPLOYMENT_URL + "online/cgsc/CGSC.properties";
    public static final String JSIDPLAY2_HVMEC_URL = DEPLOYMENT_URL + "online/hvmec/HVMEC.zip";
    public static final String JSIDPLAY2_DEMOS_URL = DEPLOYMENT_URL + "online/demos/Demos.zip";
    public static final String JSIDPLAY2_C64MAGAZINES_URL = DEPLOYMENT_URL + "online/magazines/C64Magazines.zip";
    public static final String JSIDPLAY2_GAMEBASE64_URL = DEPLOYMENT_URL + "online/gamebase/GameBase64.zip";
    public static final String JSIDPLAY2_GAMEBASE64_MUSIC_URL = DEPLOYMENT_URL + "music/";
    public static final String JSIDPLAY2_GAMEBASE64_SCREENSHOTS_URL = DEPLOYMENT_URL + "screenshots/";
    public static final String JSIDPLAY2_GAMEBASE64_PHOTOS_URL = DEPLOYMENT_URL + "photos/";
    public static final String JSIDPLAY2_GAMEBASE64_GAMES_URL = DEPLOYMENT_URL + "games/";
    public static final String JSIDPLAY2_FAVORITES_URL = DEPLOYMENT_URL + "jsidplay2.js2";

    /**
     * URL of the JSIDPlay2 AppServer.
     */
    public static final String APP_SERVER_URL = "https://haendel.ddns.net";

    public static final String OFFLINE_PLAYER_WASM_GC_SAB_URL = APP_SERVER_URL
            + "/static/teavm/c64jukebox.vue?teavmFormat=WASM_GC_SAB";

    public static final String OFFLINE_PLAYER_WASM_GC_URL = APP_SERVER_URL
            + "/static/teavm/c64jukebox.vue?teavmFormat=WASM_GC";

    public static final String OFFLINE_PLAYER_JS_URL = APP_SERVER_URL + "/static/teavm/c64jukebox.vue?teavmFormat=JS";

    public static final String OFFLINE_PLAYER_JS_EM2015_URL = APP_SERVER_URL
            + "/static/teavm/c64jukebox.vue?teavmFormat=JS_EM2015";

    /**
     * URL where SOASC downloads are located.
     */
    public static final String SOASC_BASE = "https://www.6581-8580.com/socse/dl.php?d=";

    public static final String SOASC_8580_R5_URL = SOASC_BASE
            + "soasc/hvsc/{0,number,000}/MP3{1}_T{2,number,000}.sid_CSG8580R5.mp3";
    public static final String SOASC_6581_R4_URL = SOASC_BASE
            + "soasc/hvsc/{0,number,000}/MP3{1}_T{2,number,000}.sid_MOS6581R4.mp3";
    public static final String SOASC_6581_R3_URL = SOASC_BASE
            + "soasc/hvsc/{0,number,000}/MP3{1}_T{2,number,000}.sid_MOS6581R3.mp3";
    public static final String SOASC_6581_R2_URL = SOASC_BASE
            + "soasc/hvsc/{0,number,000}/MP3{1}_T{2,number,000}.sid_MOS6581R2.mp3";

    /**
     * URL where Assembly64 services are located.
     */
    public static final String DEFAULT_ASSEMBLY64_URL = "https://hackerswithstyle.se";

    public static final Map<String, String> ASSEMBLY64_HEADERS;

    static {
        HashMap<String, String> assembly64Headers = new HashMap<>();
        assembly64Headers.put("client-id", "jsidplay2");
        ASSEMBLY64_HEADERS = Collections.unmodifiableMap(assembly64Headers);
    }

    public static final double DEFAULT_ZOOM = 1.5;

    private ShadowField<StringProperty, String> hvscUrl = new ShadowField<>(SimpleStringProperty::new,
            JSIDPLAY2_C64MUSIC_URL);

    public String getHvscUrl() {
        return hvscUrl.get();
    }

    public void setHvscUrl(String hvscUrl) {
        this.hvscUrl.set(hvscUrl);
    }

    public final StringProperty hvscUrlProperty() {
        return hvscUrl.property();
    }

    private ShadowField<StringProperty, String> hvscSearchIndexUrl = new ShadowField<>(SimpleStringProperty::new,
            JSIDPLAY2_HVSC_SCRIPT_URL);

    public String getHvscSearchIndexUrl() {
        return hvscSearchIndexUrl.get();
    }

    public void setHvscSearchIndexUrl(String hvscSearchIndexUrl) {
        this.hvscSearchIndexUrl.set(hvscSearchIndexUrl);
    }

    private ShadowField<StringProperty, String> hvscSearchIndexDataUrl = new ShadowField<>(SimpleStringProperty::new,
            JSIDPLAY2_HVSC_DATA_URL);

    public String getHvscSearchIndexDataUrl() {
        return hvscSearchIndexDataUrl.get();
    }

    public void setHvscSearchIndexDataUrl(String hvscSearchIndexDataUrl) {
        this.hvscSearchIndexDataUrl.set(hvscSearchIndexDataUrl);
    }

    public final StringProperty hvscSearchIndexUrlProperty() {
        return hvscSearchIndexUrl.property();
    }

    private ShadowField<StringProperty, String> hvscSearchIndexPropertiesUrl = new ShadowField<>(
            SimpleStringProperty::new, JSIDPLAY2_HVSC_PROPERTIES_URL);

    public String getHvscSearchIndexPropertiesUrl() {
        return hvscSearchIndexPropertiesUrl.get();
    }

    public void setHvscSearchIndexPropertiesUrl(String hvscSearchIndexPropertiesUrl) {
        this.hvscSearchIndexPropertiesUrl.set(hvscSearchIndexPropertiesUrl);
    }

    public final StringProperty hvscSearchIndexPropertiesUrlProperty() {
        return hvscSearchIndexPropertiesUrl.property();
    }

    private ShadowField<StringProperty, String> cgscUrl = new ShadowField<>(SimpleStringProperty::new,
            JSIDPLAY2_CGSC_URL);

    public String getCgscUrl() {
        return cgscUrl.get();
    }

    public void setCgscUrl(String cgscUrl) {
        this.cgscUrl.set(cgscUrl);
    }

    public final StringProperty cgscUrlProperty() {
        return cgscUrl.property();
    }

    private ShadowField<StringProperty, String> cgscSearchIndexUrl = new ShadowField<>(SimpleStringProperty::new,
            JSIDPLAY2_CGSC_SCRIPT_URL);

    public String getCgscSearchIndexUrl() {
        return cgscSearchIndexUrl.get();
    }

    public void setCgscSearchIndexUrl(String cgscSearchIndexUrl) {
        this.cgscSearchIndexUrl.set(cgscSearchIndexUrl);
    }

    public final StringProperty cgscSearchIndexUrlProperty() {
        return cgscSearchIndexUrl.property();
    }

    private ShadowField<StringProperty, String> cgscSearchIndexDataUrl = new ShadowField<>(SimpleStringProperty::new,
            JSIDPLAY2_CGSC_DATA_URL);

    public String getCgscSearchIndexDataUrl() {
        return cgscSearchIndexDataUrl.get();
    }

    public void setCgscSearchIndexDataUrl(String cgscSearchIndexDataUrl) {
        this.cgscSearchIndexDataUrl.set(cgscSearchIndexDataUrl);
    }

    public final StringProperty cgscSearchIndexDataUrlProperty() {
        return cgscSearchIndexDataUrl.property();
    }

    private ShadowField<StringProperty, String> cgscSearchIndexPropertiesUrl = new ShadowField<>(
            SimpleStringProperty::new, JSIDPLAY2_CGSC_PROPERTIES_URL);

    public String getCgscSearchIndexPropertiesUrl() {
        return cgscSearchIndexPropertiesUrl.get();
    }

    public void setCgscSearchIndexPropertiesUrl(String cgscSearchIndexPropertiesUrl) {
        this.cgscSearchIndexPropertiesUrl.set(cgscSearchIndexPropertiesUrl);
    }

    public final StringProperty cgscSearchIndexPropertiesUrlProperty() {
        return cgscSearchIndexPropertiesUrl.property();
    }

    private ShadowField<StringProperty, String> hvmecUrl = new ShadowField<>(SimpleStringProperty::new,
            JSIDPLAY2_HVMEC_URL);

    public String getHvmecUrl() {
        return hvmecUrl.get();
    }

    public void setHvmecUrl(String hvmecUrl) {
        this.hvmecUrl.set(hvmecUrl);
    }

    public final StringProperty hvmecUrlProperty() {
        return hvmecUrl.property();
    }

    private ShadowField<StringProperty, String> demosUrl = new ShadowField<>(SimpleStringProperty::new,
            JSIDPLAY2_DEMOS_URL);

    public String getDemosUrl() {
        return demosUrl.get();
    }

    public void setDemosUrl(String demosUrl) {
        this.demosUrl.set(demosUrl);
    }

    public final StringProperty demosUrlProperty() {
        return demosUrl.property();
    }

    private ShadowField<StringProperty, String> magazinesUrl = new ShadowField<>(SimpleStringProperty::new,
            JSIDPLAY2_C64MAGAZINES_URL);

    public String getMagazinesUrl() {
        return magazinesUrl.get();
    }

    public void setMagazinesUrl(String magazinesUrl) {
        this.magazinesUrl.set(magazinesUrl);
    }

    public final StringProperty magazinesUrlProperty() {
        return magazinesUrl.property();
    }

    private ShadowField<StringProperty, String> gamebaseUrl = new ShadowField<>(SimpleStringProperty::new,
            JSIDPLAY2_GAMEBASE64_URL);

    public String getGamebaseUrl() {
        return gamebaseUrl.get();
    }

    public void setGamebaseUrl(String gamebaseUrl) {
        this.gamebaseUrl.set(gamebaseUrl);
    }

    public final StringProperty gamebaseUrlProperty() {
        return gamebaseUrl.property();
    }

    private ShadowField<StringProperty, String> soasc6581R2 = new ShadowField<>(SimpleStringProperty::new,
            SOASC_6581_R2_URL);

    public String getSoasc6581R2() {
        return soasc6581R2.get();
    }

    public void setSoasc6581R2(String soasc6581r2) {
        soasc6581R2.set(soasc6581r2);
    }

    public final StringProperty soasc6581R2Property() {
        return soasc6581R2.property();
    }

    private ShadowField<StringProperty, String> soasc6581R3 = new ShadowField<>(SimpleStringProperty::new,
            SOASC_6581_R3_URL);

    public String getSoasc6581R3() {
        return soasc6581R3.get();
    }

    public void setSoasc6581R3(String soasc6581r3) {
        soasc6581R3.set(soasc6581r3);
    }

    public final StringProperty soasc6581R3Property() {
        return soasc6581R3.property();
    }

    private ShadowField<StringProperty, String> soasc6581R4 = new ShadowField<>(SimpleStringProperty::new,
            SOASC_6581_R4_URL);

    public String getSoasc6581R4() {
        return soasc6581R4.get();
    }

    public void setSoasc6581R4(String soasc6581r4) {
        soasc6581R4.set(soasc6581r4);
    }

    public final StringProperty soasc6581R4Property() {
        return soasc6581R4.property();
    }

    private ShadowField<StringProperty, String> soasc8580R5 = new ShadowField<>(SimpleStringProperty::new,
            SOASC_8580_R5_URL);

    public String getSoasc8580R5() {
        return soasc8580R5.get();
    }

    public void setSoasc8580R5(String soasc8580r5) {
        soasc8580R5.set(soasc8580r5);
    }

    public final StringProperty soasc8580R5Property() {
        return soasc8580R5.property();
    }

    private ShadowField<StringProperty, String> gb64MusicUrl = new ShadowField<>(SimpleStringProperty::new,
            JSIDPLAY2_GAMEBASE64_MUSIC_URL);

    public String getGb64MusicUrl() {
        return gb64MusicUrl.get();
    }

    public void setGb64MusicUrl(String gb64MusicUrl) {
        this.gb64MusicUrl.set(gb64MusicUrl);
    }

    public final StringProperty gb64MusicUrlProperty() {
        return gb64MusicUrl.property();
    }

    private ShadowField<StringProperty, String> gb64ScreenshotUrl = new ShadowField<>(SimpleStringProperty::new,
            JSIDPLAY2_GAMEBASE64_SCREENSHOTS_URL);

    public String getGb64ScreenshotUrl() {
        return gb64ScreenshotUrl.get();
    }

    public void setGb64ScreenshotUrl(String gb64ScreenshotUrl) {
        this.gb64ScreenshotUrl.set(gb64ScreenshotUrl);
    }

    public final StringProperty gb64ScreenshotUrlProperty() {
        return gb64ScreenshotUrl.property();
    }

    private ShadowField<StringProperty, String> gb64PhotosUrl = new ShadowField<>(SimpleStringProperty::new,
            JSIDPLAY2_GAMEBASE64_PHOTOS_URL);

    public String getGb64PhotosUrl() {
        return gb64PhotosUrl.get();
    }

    public void setGb64PhotosUrl(String gb64PhotosUrl) {
        this.gb64PhotosUrl.set(gb64PhotosUrl);
    }

    public final StringProperty gb64PhotosUrlProperty() {
        return gb64PhotosUrl.property();
    }

    private ShadowField<StringProperty, String> gb64GamesUrl = new ShadowField<>(SimpleStringProperty::new,
            JSIDPLAY2_GAMEBASE64_GAMES_URL);

    public String getGb64GamesUrl() {
        return gb64GamesUrl.get();
    }

    public void setGb64GamesUrl(String gb64GamesUrl) {
        this.gb64GamesUrl.set(gb64GamesUrl);
    }

    public final StringProperty gb64GamesUrlProperty() {
        return gb64GamesUrl.property();
    }

    private ShadowField<StringProperty, String> assembly64Url = new ShadowField<>(SimpleStringProperty::new,
            DEFAULT_ASSEMBLY64_URL);

    public String getAssembly64Url() {
        return assembly64Url.get();
    }

    public void setAssembly64Url(String assembly64Url) {
        this.assembly64Url.set(assembly64Url);
    }

    public final StringProperty assembly64UrlProperty() {
        return assembly64Url.property();
    }

    private ShadowField<StringProperty, String> favoritesUrl = new ShadowField<>(SimpleStringProperty::new,
            JSIDPLAY2_FAVORITES_URL);

    public String getFavoritesUrl() {
        return favoritesUrl.get();
    }

    public void setFavoritesUrl(String favoritesUrl) {
        this.favoritesUrl.set(favoritesUrl);
    }

    public final StringProperty favoritesUrlProperty() {
        return favoritesUrl.property();
    }

    private ShadowField<StringProperty, String> offlinePlayerWasmGcSabUrl = new ShadowField<>(SimpleStringProperty::new,
            OFFLINE_PLAYER_WASM_GC_SAB_URL);

    public String getOfflinePlayerWasmGcSabUrl() {
        return offlinePlayerWasmGcSabUrl.get();
    }

    public void setOfflinePlayerWasmGcSabUrl(String offlinePlayerWasmGcSabUrl) {
        this.offlinePlayerWasmGcSabUrl.set(offlinePlayerWasmGcSabUrl);
    }

    public final StringProperty offlinePlayerWasmGcSabUrlProperty() {
        return offlinePlayerWasmGcSabUrl.property();
    }

    private ShadowField<StringProperty, String> offlinePlayerWasmGcUrl = new ShadowField<>(SimpleStringProperty::new,
            OFFLINE_PLAYER_WASM_GC_URL);

    public String getOfflinePlayerWasmGcUrl() {
        return offlinePlayerWasmGcUrl.get();
    }

    public void setOfflinePlayerWasmGcUrl(String offlinePlayerWasmGcUrl) {
        this.offlinePlayerWasmGcUrl.set(offlinePlayerWasmGcUrl);
    }

    public final StringProperty offlinePlayerWasmGcUrlProperty() {
        return offlinePlayerWasmGcUrl.property();
    }

    private ShadowField<StringProperty, String> offlinePlayerJsUrl = new ShadowField<>(SimpleStringProperty::new,
            OFFLINE_PLAYER_JS_URL);

    public String getOfflinePlayerJsUrl() {
        return offlinePlayerJsUrl.get();
    }

    public void setOfflinePlayerJsUrl(String offlinePlayerJsUrl) {
        this.offlinePlayerJsUrl.set(offlinePlayerJsUrl);
    }

    public final StringProperty offlinePlayerJsUrlProperty() {
        return offlinePlayerJsUrl.property();
    }

    private ShadowField<StringProperty, String> offlinePlayerJsEm2015Url = new ShadowField<>(SimpleStringProperty::new,
            OFFLINE_PLAYER_JS_EM2015_URL);

    public String getOfflinePlayerJsEm2015Url() {
        return offlinePlayerJsEm2015Url.get();
    }

    public void setOfflinePlayerJsEm2015Url(String offlinePlayerJsEm2015Url) {
        this.offlinePlayerJsEm2015Url.set(offlinePlayerJsEm2015Url);
    }

    public final StringProperty offlinePlayerJsEm2015UrlProperty() {
        return offlinePlayerJsEm2015Url.property();
    }

    private ShadowField<StringProperty, String> sidBlasterDocUrl = new ShadowField<>(SimpleStringProperty::new,
            JSIDPLAY2_SIDBLASTER_DOC_URL);

    public String getSidBlasterDocUrl() {
        return sidBlasterDocUrl.get();
    }

    public void setSidBlasterDocUrl(String sidBlasterDocUrl) {
        this.sidBlasterDocUrl.set(sidBlasterDocUrl);
    }

    public final StringProperty sidBlasterDocUrlProperty() {
        return sidBlasterDocUrl.property();
    }

    private ShadowField<DoubleProperty, Number> zoom = new ShadowField<>(
            number -> new SimpleDoubleProperty(number.doubleValue()), DEFAULT_ZOOM);

    public double getZoom() {
        return zoom.get().doubleValue();
    }

    public void setZoom(double zoom) {
        this.zoom.set(zoom);
    }

    public final DoubleProperty zoomProperty() {
        return zoom.property();
    }

    @Override
    public final String toString() {
        return BeanToStringConverter.toString(this);
    }
}