Skip to content

Commit

Permalink
Merge pull request #90 from AlwinEsch/Nexus-change
Browse files Browse the repository at this point in the history
[Nexus] API related update
  • Loading branch information
AlwinEsch authored Jan 1, 2022
2 parents 6956b19 + 2b7c56b commit 0096f52
Show file tree
Hide file tree
Showing 8 changed files with 160 additions and 94 deletions.
12 changes: 6 additions & 6 deletions src/PresetsLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ bool CPresetLoader::Load(const std::string& path)
if (entry[0].isString())
preset.name = entry[0].asString();
else
preset.name = kodi::GetLocalizedString(entry[0].asInt(), "Unknown preset name " +
std::to_string(index + 1));
preset.name = kodi::addon::GetLocalizedString(entry[0].asInt(), "Unknown preset name " +
std::to_string(index + 1));

// Check shader file included within addon or outside and set by user
const std::string usedDirName = kodi::vfs::GetDirectoryName(entry[1].asString());
Expand All @@ -88,7 +88,7 @@ bool CPresetLoader::Load(const std::string& path)
else if (!usedDirName.empty())
preset.file = entry[1].asString();
else
preset.file = kodi::GetAddonPath("resources/shaders/" + entry[1].asString());
preset.file = kodi::addon::GetAddonPath("resources/shaders/" + entry[1].asString());

if (!kodi::vfs::FileExists(preset.file))
throw kodi::tools::StringUtils::Format("On %s defined GLSL shader file '%s' not found",
Expand All @@ -108,7 +108,7 @@ bool CPresetLoader::Load(const std::string& path)
else if (!usedDirName.empty())
preset.channel[i] = entry[i + 2].asString();
else if (!entry[i + 2].asString().empty())
preset.channel[i] = kodi::GetAddonPath("resources/" + entry[i + 2].asString());
preset.channel[i] = kodi::addon::GetAddonPath("resources/" + entry[i + 2].asString());

if (!preset.channel[i].empty() && preset.channel[i] != "audio")
{
Expand Down Expand Up @@ -151,8 +151,8 @@ bool CPresetLoader::Load(const std::string& path)

// Inform user that maybe their own preset list is wrong
if (!ret)
kodi::QueueNotification(QUEUE_OWN_STYLE, kodi::GetLocalizedString(30030),
kodi::GetLocalizedString(30031), "", 5000, true, 20000);
kodi::QueueNotification(QUEUE_OWN_STYLE, kodi::addon::GetLocalizedString(30030),
kodi::addon::GetLocalizedString(30031), "", 5000, true, 20000);

return ret;
}
Expand Down
48 changes: 24 additions & 24 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,22 +118,22 @@ CVisualizationShadertoy::CVisualizationShadertoy()
m_magnitudeBuffer(new float[NUM_BANDS]()),
m_pcm(new float[AUDIO_BUFFER]())
{
m_settingsUseOwnshader = kodi::GetSettingBoolean("ownshader");
m_settingsUseOwnshader = kodi::addon::GetSettingBoolean("ownshader");
if (m_settingsUseOwnshader)
m_currentPreset = -1;
else
m_currentPreset = kodi::GetSettingInt("lastpresetidx");
m_currentPreset = kodi::addon::GetSettingInt("lastpresetidx");

m_presetsJSONFile = kodi::GetSettingString("presetfile");
m_presetsJSONFile = kodi::addon::GetSettingString("presetfile");
if (m_presetsJSONFile.empty() || !kodi::vfs::FileExists(m_presetsJSONFile))
m_presetsJSONFile = kodi::GetAddonPath("resources/presets.json");
m_presetsJSONFile = kodi::addon::GetAddonPath("resources/presets.json");

/* In case of preset file change, set current selected preset to 0 */
if (kodi::GetSettingString("lastpresetfile") != m_presetsJSONFile)
if (kodi::addon::GetSettingString("lastpresetfile") != m_presetsJSONFile)
{
m_currentPreset = 0;
kodi::SetSettingInt("lastpresetidx", m_currentPreset);
kodi::SetSettingString("lastpresetfile", m_presetsJSONFile);
kodi::addon::SetSettingInt("lastpresetidx", m_currentPreset);
kodi::addon::SetSettingString("lastpresetfile", m_presetsJSONFile);
}

m_presets.Load(m_presetsJSONFile);
Expand Down Expand Up @@ -251,7 +251,7 @@ bool CVisualizationShadertoy::NextPreset()
{
m_currentPreset = (m_currentPreset + 1) % m_presets.GetPresetsAmount();
Launch(m_currentPreset);
kodi::SetSettingInt("lastpresetidx", m_currentPreset);
kodi::addon::SetSettingInt("lastpresetidx", m_currentPreset);
}
return true;
}
Expand All @@ -262,7 +262,7 @@ bool CVisualizationShadertoy::PrevPreset()
{
m_currentPreset = (m_currentPreset - 1) % m_presets.GetPresetsAmount();
Launch(m_currentPreset);
kodi::SetSettingInt("lastpresetidx", m_currentPreset);
kodi::addon::SetSettingInt("lastpresetidx", m_currentPreset);
}
return true;
}
Expand All @@ -273,7 +273,7 @@ bool CVisualizationShadertoy::LoadPreset(int select)
{
m_currentPreset = select % m_presets.GetPresetsAmount();
Launch(m_currentPreset);
kodi::SetSettingInt("lastpresetidx", m_currentPreset);
kodi::addon::SetSettingInt("lastpresetidx", m_currentPreset);
}
return true;
}
Expand All @@ -284,7 +284,7 @@ bool CVisualizationShadertoy::RandomPreset()
{
m_currentPreset = (int)((std::rand() / (float)RAND_MAX) * m_presets.GetPresetsAmount());
Launch(m_currentPreset);
kodi::SetSettingInt("lastpresetidx", m_currentPreset);
kodi::addon::SetSettingInt("lastpresetidx", m_currentPreset);
}
return true;
}
Expand Down Expand Up @@ -438,15 +438,15 @@ void CVisualizationShadertoy::Launch(int preset)

if (preset < 0)
{
m_usedShaderFile = kodi::GetSettingString("shader");
m_shaderTextures[0].audio = kodi::GetSettingBoolean("texture0-sound");
m_shaderTextures[0].texture = kodi::GetSettingString("texture0");
m_shaderTextures[1].audio = kodi::GetSettingBoolean("texture1-sound");
m_shaderTextures[1].texture = kodi::GetSettingString("texture1");
m_shaderTextures[2].audio = kodi::GetSettingBoolean("texture2-sound");
m_shaderTextures[2].texture = kodi::GetSettingString("texture2");
m_shaderTextures[3].audio = kodi::GetSettingBoolean("texture3-sound");
m_shaderTextures[3].texture = kodi::GetSettingString("texture3");
m_usedShaderFile = kodi::addon::GetSettingString("shader");
m_shaderTextures[0].audio = kodi::addon::GetSettingBoolean("texture0-sound");
m_shaderTextures[0].texture = kodi::addon::GetSettingString("texture0");
m_shaderTextures[1].audio = kodi::addon::GetSettingBoolean("texture1-sound");
m_shaderTextures[1].texture = kodi::addon::GetSettingString("texture1");
m_shaderTextures[2].audio = kodi::addon::GetSettingBoolean("texture2-sound");
m_shaderTextures[2].texture = kodi::addon::GetSettingString("texture2");
m_shaderTextures[3].audio = kodi::addon::GetSettingBoolean("texture3-sound");
m_shaderTextures[3].texture = kodi::addon::GetSettingString("texture3");
}
else
{
Expand Down Expand Up @@ -525,7 +525,7 @@ void CVisualizationShadertoy::UnloadTextures()
void CVisualizationShadertoy::LoadPreset(const std::string& shaderPath)
{
UnloadPreset();
std::string vertShadertoyShader = kodi::GetAddonPath("resources/shaders/main_shadertoy_" GL_TYPE_STRING ".vert.glsl");
std::string vertShadertoyShader = kodi::addon::GetAddonPath("resources/shaders/main_shadertoy_" GL_TYPE_STRING ".vert.glsl");
if (!m_shadertoyShader.LoadShaderFiles(vertShadertoyShader, shaderPath) ||
!m_shadertoyShader.CompileAndLink("", "", fsHeader, fsFooter))
{
Expand All @@ -550,8 +550,8 @@ void CVisualizationShadertoy::LoadPreset(const std::string& shaderPath)
m_state.uScale = glGetUniformLocation(shadertoyShader, "uScale");
m_state.attr_vertex_e = glGetAttribLocation(shadertoyShader, "vertex");

std::string vertShader = kodi::GetAddonPath("resources/shaders/main_display_" GL_TYPE_STRING ".vert.glsl");
std::string fraqShader = kodi::GetAddonPath("resources/shaders/main_display_" GL_TYPE_STRING ".frag.glsl");
std::string vertShader = kodi::addon::GetAddonPath("resources/shaders/main_display_" GL_TYPE_STRING ".vert.glsl");
std::string fraqShader = kodi::addon::GetAddonPath("resources/shaders/main_display_" GL_TYPE_STRING ".frag.glsl");
if (!m_displayShader.LoadShaderFiles(vertShader, fraqShader) ||
!m_displayShader.CompileAndLink())
{
Expand Down Expand Up @@ -683,7 +683,7 @@ float CVisualizationShadertoy::LinearToDecibels(float linear)
int CVisualizationShadertoy::DetermineBitsPrecision()
{
m_state.fbwidth = 32, m_state.fbheight = 26*10;
LoadPreset(kodi::GetAddonPath("resources/shaders/main_test.frag.glsl"));
LoadPreset(kodi::addon::GetAddonPath("resources/shaders/main_test.frag.glsl"));
RenderTo(m_shadertoyShader.ProgramHandle(), m_state.effect_fb);
glFinish();

Expand Down
2 changes: 1 addition & 1 deletion src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#include "kissfft/kiss_fft.h"

class ATTRIBUTE_HIDDEN CVisualizationShadertoy
class ATTR_DLL_LOCAL CVisualizationShadertoy
: public kodi::addon::CAddonBase
, public kodi::addon::CInstanceVisualization
{
Expand Down
6 changes: 5 additions & 1 deletion visualization.shadertoy/addon.xml.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon
id="visualization.shadertoy"
version="20.1.1"
version="20.2.0"
name="Shadertoy"
provider-name="Team Kodi">
<requires>@ADDON_DEPENDS@</requires>
Expand All @@ -26,9 +26,13 @@
<screenshot>resources/screenshot-05.jpg</screenshot>
<screenshot>resources/screenshot-06.jpg</screenshot>
</assets>
<summary lang="da_DK">Visualiseringer fra Shadertoy</summary>
<summary lang="de_DE">Visualisierungen von Shadertoy</summary>
<summary lang="en_GB">Visualizations from Shadertoy</summary>
<summary lang="zh_CN">来自ShaderToy的可视化效果</summary>
<description lang="da_DK">Denne musikvisualisering er baseret på Shadertoy-baserede GPU-programmer.</description>
<description lang="de_DE">Diese Musikvisualisierung basiert auf Shadertoy-basierten GPU-Programmen.</description>
<description lang="en_GB">This music visualization is based on Shadertoy based GPU programs.</description>
<description lang="zh_CN">次音乐可视化是基于基于Shadertoy的GPU程序。</description>
</extension>
</addon>
4 changes: 4 additions & 0 deletions visualization.shadertoy/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[B]20.2.0[/B]
- Translation updates by Weblate
- Kodi main API update to version 2.0.0

[B]20.1.1[/B]
- Fix possible compile error about missing jsoncpp include

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@
msgid ""
msgstr ""
"Project-Id-Version: KODI Addons\n"
"Report-Msgid-Bugs-To: https://github.com/xbmc/visualization.shadertoy/issues\n"
"Report-Msgid-Bugs-To: [email protected]\n"
"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n"
"PO-Revision-Date: 2021-08-04 13:29+0000\n"
"PO-Revision-Date: 2021-12-08 12:13+0000\n"
"Last-Translator: Christian Gade <[email protected]>\n"
"Language-Team: Danish <https://kodi.weblate.cloud/projects/kodi-add-ons-look-and-feel/visualization-shadertoy/da_dk/>\n"
"Language: da_dk\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.7.2\n"
"X-Generator: Weblate 4.9.1\n"

msgctxt "Addon Summary"
msgid "Visualizations from Shadertoy"
msgstr ""
msgstr "Visualiseringer fra Shadertoy"

msgctxt "Addon Description"
msgid "This music visualization is based on Shadertoy based GPU programs."
msgstr ""
msgstr "Denne musikvisualisering er baseret på Shadertoy-baserede GPU-programmer."

#. Settings category
msgctxt "#30000"
Expand Down Expand Up @@ -153,42 +153,42 @@ msgstr "Kanal 3 som *.png"
#. Header text shown on notification dialog and on file selection dialog
msgctxt "#30030"
msgid "Shadertoy Visualization"
msgstr ""
msgstr "Shadertoy Visualisering"

#. Notification message shown on the screen when an incorrect preset list is given
msgctxt "#30031"
msgid "Cannot read the JSON file. Please check the formatting is correct and the file is available."
msgstr ""
msgstr "Kan ikke læse JSON-filen. Kontroller at formateringen er korrekt, og at filen er tilgængelig."

#. Settings value to open dialog for file selection
msgctxt "#30032"
msgid "Path to custom preset list"
msgstr ""
msgstr "Sti til brugerdefineret liste med forudindstillinger"

#. Help text related to setting string with id 30032
msgctxt "#30033"
msgid "Set the path to your custom JSON-formatted preset file. If no path is configured, the add-on will use the default preset file."
msgstr ""
msgstr "Indstil stien til din brugerdefinerede JSON-formaterede fil med forudindstillinger. Hvis der ikke er konfigureret nogen sti, bruger add-on'et standardfilen med forudindstillinger."

#. Settings group name
msgctxt "#30034"
msgid "Configure a single shader"
msgstr ""
msgstr "Konfigurer en enkelt shader"

#. Settings value to open a dialog for showing help about the preset file
msgctxt "#30035"
msgid "Show help about preset file"
msgstr ""
msgstr "Vis hjælp til den forudindstillede fil"

#. Help text related to setting string with id 30035
msgctxt "#30036"
msgid "Open to read about creating the JSON-formatted preset file."
msgstr ""
msgstr "Åben for at læse om oprettelse af den JSON-formaterede forudindstillede fil."

#. Header text on the help dialog within settings, related to the help text of string ID 30038
msgctxt "#30037"
msgid "Help about defining your own shaders in the JSON file"
msgstr ""
msgstr "Hjælp til at definere dine egne shaders i JSON-filen"

#. Help text about showing the JSON-formatted preset file in a text window.
#. Same text also on visualization.shadertoy/resources/presets.json.md, for here
Expand Down Expand Up @@ -225,3 +225,32 @@ msgid ""
"[ [COLOR red]\"Fractal Land by Kali\"[/COLOR], [COLOR red]\"fractalland.frag.glsl\"[/COLOR], [COLOR red]\"tex02.png\"[/COLOR], [COLOR red]\"tex15.png\"[/COLOR], [COLOR red]\"audio\"[/COLOR], [COLOR red]\"\"[/COLOR] ]\n"
"][COLOR green]}[/COLOR][/COLOR]"
msgstr ""
"[B][I]JSON-fil til brugerdefinerede shaderlister[/I][/B]\n"
"\n"
"Filen [B]presets.json[/B] bruges til at præcisere brugerdefinerede shadere.\n"
"En brugerdefineret sti til shaderfilerne (GLSL) kan indtastes i indstillinger for dette add-on.\n"
"\n"
"Indholdet i [B]presets.json[/B] skal være:\n"
"[I] 1.[/I] Navn på forudindstilling. Enten direkte indtastet navn eller defineret i [I]resources/language/.../strings.po[/I]\n"
"[I] 2.[/I] GLSL shader der bruges. Hvis ingen brugerdefineret sti er indtastet, bruges standarden [B]resources/[/B]. Indstil brugerdefineret sti til './' for at bruge shaders fra samme stil som din [B]presets.json[/B]-fil.\n"
"[I] 3.[/I] Kanalværdi value 0. Definerer den brugte tekstur (f.eks.. PNG-fil). Det kan også indstilles til \"audio\" for at sende relateret streamdata til teksturen. PNG- og GLSL-filerne skal placeres i samme mappe.\n"
"[I] 4.[/I] Defination af kanalværdi 1.\n"
"[I] 5.[/I] Defination af kanalværdi 2.\n"
"[I] 6.[/I] Defination af kanalværdi 3.\n"
"[I] 7.[/I] [I][Valgfri][/I] tilføj teksten [B]\"gl_only\"[/B] for kun at gøre denne forudindstilling tilgængelig for OpenGL.\n"
"\n"
"[B]Eksempel:[/B]\n"
"[COLOR white][COLOR green]{[/COLOR] [COLOR blue]\"forudindstillinger\"[/COLOR]:[\n"
"[COLOR gray]/* Standard metode brugt af selve add-on'et */[/COLOR]\n"
"[ [COLOR red]\"The Disco Tunnel af poljere\"[/COLOR], [COLOR red]\"discotunnel.frag.glsl\"[/COLOR], [COLOR red]\"tex02.png\"[/COLOR], [COLOR red]\"tex15.png\"[/COLOR], [COLOR red]\"audio\"[/COLOR], [COLOR red]\"\"[/COLOR] ],\n"
"[COLOR gray]/* Beskrivelse defineret i strings.po */[/COLOR]\n"
"[ 30100, [COLOR red]\"audioeclipse.frag.glsl\"[/COLOR], [COLOR red]\"audio\"[/COLOR], [COLOR red]\"\"[/COLOR], [COLOR red]\"\"[/COLOR], [COLOR red]\"\"[/COLOR] ],\n"
"[COLOR gray]/* Præciser brugerdefinerede filstier */[/COLOR]\n"
"[ [COLOR red]\"Min egen\"[/COLOR], [COLOR red]\"/sti/til/glsl/min.frag.glsl\"[/COLOR], [COLOR red]\"audio\"[/COLOR], [COLOR red]\"/sti/til/png-filer/mit_billede.png\"[/COLOR], [COLOR red]\"\"[/COLOR], [COLOR red]\"\"[/COLOR] ],\n"
"[COLOR gray]/* >Forudindstilling kun tilgængelig for OpenGL (se 7) */[/COLOR]\n"
"[ [COLOR red]\"Polar Beats af sauj123\"[/COLOR], [COLOR red]\"polarbeats.frag.glsl\"[/COLOR], [COLOR red]\"audio\"[/COLOR], [COLOR red]\"\"[/COLOR], [COLOR red]\"\"[/COLOR], [COLOR red]\"\"[/COLOR], [COLOR red]\"gl_only\"[/COLOR] ],\n"
"[COLOR gray]/* GLSL- og PNG-filer er i samme mappe som presets.json */[/COLOR]\n"
"[ [COLOR red]\"En mere\"[/COLOR], [COLOR red]\"./another.frag.glsl\"[/COLOR], [COLOR red]\"./min_01.png\"[/COLOR], [COLOR red]\"./min_02.png\"[/COLOR], [COLOR red]\"audio\"[/COLOR], [COLOR red]\"\"[/COLOR] ],\n"
"[COLOR gray]/* Vælg teksturbillede efter filnavn, brug standard \"resources/\"-mappe */[/COLOR]\n"
"[ [COLOR red]\"Fractal Land af Kali\"[/COLOR], [COLOR red]\"fractalland.frag.glsl\"[/COLOR], [COLOR red]\"tex02.png\"[/COLOR], [COLOR red]\"tex15.png\"[/COLOR], [COLOR red]\"audio\"[/COLOR], [COLOR red]\"\"[/COLOR] ]\n"
"][COLOR green]}[/COLOR][/COLOR]"
Loading

0 comments on commit 0096f52

Please sign in to comment.