diff --git a/Locales/ja.qm b/Locales/ja.qm index 4d94940..853a861 100644 Binary files a/Locales/ja.qm and b/Locales/ja.qm differ diff --git a/Locales/zh.qm b/Locales/zh.qm index 751b0f0..a766be2 100644 Binary files a/Locales/zh.qm and b/Locales/zh.qm differ diff --git a/Locales/zh_TW.qm b/Locales/zh_TW.qm index f43bac1..7673028 100644 Binary files a/Locales/zh_TW.qm and b/Locales/zh_TW.qm differ diff --git a/Presets/Circle/preview.png b/Presets/Circle/preview.png index 9d1a619..34d3b54 100644 Binary files a/Presets/Circle/preview.png and b/Presets/Circle/preview.png differ diff --git a/Presets/Circle/settings.xml b/Presets/Circle/settings.xml index 69253ab..98b0473 100644 --- a/Presets/Circle/settings.xml +++ b/Presets/Circle/settings.xml @@ -1,5 +1,5 @@ "nvg://advp.widget.mashiros.top/advp-style-preset/circle" - {"Main Color":"#ff4500","Line Position":0,"Line Width":1,"Max Range":50,"Data Length":0,"Channel":2,"Reverse":false,"Rotate":false,"Ratate Speed":10,"Angle":0,"Data Settings":{"Auto Normalizing":true,"Amplitude":10,"Unit Style":0}} + {"Gradient Style":0,"Radial Gradient Settings":{"Inside Position Color":"#f44336","Middle Position Color":"#4caf50","Outside Position Color":"#03a9f4","Inside Position":40,"Middle Position":60,"Outside Position":80},"Conical Gradient Settings":{"Start Position Color":"#f44336","Quarter Position Color":"#4caf50","Middle Position Color":"#03a9f4","End Position Color":"#ffeb3b"},"Main Color":"#ff4500","Line Position":0,"Line Width":1,"Max Range":80,"Data Length":0,"Channel":2,"Reverse":false,"Rotate":false,"Ratate Speed":10,"Angle":0,"Data Settings":{"Auto Normalizing":true,"Amplitude":10,"Unit Style":0}} \ No newline at end of file diff --git a/Presets/Gradient_Line/preset.json b/Presets/Gradient_Line/preset.json deleted file mode 100644 index 8d2612c..0000000 --- a/Presets/Gradient_Line/preset.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "source": "nvg://advp.widget.mashiros.top/widget", - "settings": "settings.xml" -} \ No newline at end of file diff --git a/Presets/Gradient_Line/preview.png b/Presets/Gradient_Line/preview.png deleted file mode 100644 index 46191eb..0000000 Binary files a/Presets/Gradient_Line/preview.png and /dev/null differ diff --git a/Presets/Gradient_Line/settings.xml b/Presets/Gradient_Line/settings.xml deleted file mode 100644 index a14c747..0000000 --- a/Presets/Gradient_Line/settings.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - "nvg://advp.widget.mashiros.top/advp-style-preset/gradient_line" - {"Gradient Direction":0,"Start Position Color":"#f44336","Middle Position Color":"#4caf50","End Position Color":"#03a9f4","Center Line":true,"Line Position":0,"Data Length":0,"Channel":2,"Rotate Settings":{"Center Enable":false,"Center Angle":10,"Line Enable":false,"Line Angle":10},"Data Settings":{"Auto Normalizing":true,"Amplitude":10,"Unit Style":0}} - \ No newline at end of file diff --git a/Presets/Line/settings.xml b/Presets/Line/settings.xml index 9b4df8e..cfe4c52 100644 --- a/Presets/Line/settings.xml +++ b/Presets/Line/settings.xml @@ -1,5 +1,5 @@ - {"Center Line":true,"Center Color":"#ff4500","Line Color":"#ff4500","Line Position":0,"Data Length":0,"Channel":2,"Rotate Settings":{"Center Enable":false,"Center Angle":10,"Line Enable":false,"Line Angle":10},"Data Settings":{"Auto Normalizing":true,"Amplitude":10,"Unit Style":0}} + {"Enable Gradient":false,"Gradient Direction":0,"Start Position Color":"#f44336","Middle Position Color":"#4caf50","End Position Color":"#03a9f4","Center Line":true,"Center Color":"#ff4500","Center Width":20,"Line Color":"#ff4500","Line Position":0,"Data Length":0,"Channel":2,"Direction":0,"Rotate Settings":{"Center Enable":false,"Center Angle":10,"Line Enable":false,"Line Angle":10,"X Scale":100,"Y Scale":100,"X Offset":0,"Y Offset":0},"Data Settings":{"Auto Normalizing":true,"Amplitude":10,"Unit Style":0}} "nvg://advp.widget.mashiros.top/advp-style-preset/line" \ No newline at end of file diff --git a/Presets/Solidcircle/preview.png b/Presets/Solidcircle/preview.png index e13d40c..b2157d9 100644 Binary files a/Presets/Solidcircle/preview.png and b/Presets/Solidcircle/preview.png differ diff --git a/Presets/Solidcircle/settings.xml b/Presets/Solidcircle/settings.xml index eb8e7b6..85e540d 100644 --- a/Presets/Solidcircle/settings.xml +++ b/Presets/Solidcircle/settings.xml @@ -1,5 +1,5 @@ "nvg://advp.widget.mashiros.top/advp-style-preset/solidcircle" - {"Main Color":"#ff4500","Line Position":0,"Line Width":1,"Max Range":50,"Data Length":0,"Channel":2,"Reverse":false,"Rotate":false,"Ratate Speed":10,"Angle":0,"Data Settings":{"Auto Normalizing":true,"Amplitude":10,"Unit Style":0}} + {"Gradient Style":0,"Radial Gradient Settings":{"Inside Position Color":"#f44336","Middle Position Color":"#4caf50","Outside Position Color":"#03a9f4","Inside Position":40,"Middle Position":60,"Outside Position":80},"Conical Gradient Settings":{"Start Position Color":"#f44336","Quarter Position Color":"#4caf50","Middle Position Color":"#03a9f4","End Position Color":"#ffeb3b"},"Main Color":"#ff4500","Line Position":0,"Line Width":1,"Max Range":80,"Data Length":0,"Channel":2,"Reverse":false,"Rotate":false,"Ratate Speed":10,"Angle":0,"Data Settings":{"Auto Normalizing":true,"Amplitude":10,"Unit Style":0}} \ No newline at end of file diff --git a/Presets/Waves/settings.xml b/Presets/Waves/settings.xml index c2bc705..f519fd9 100644 --- a/Presets/Waves/settings.xml +++ b/Presets/Waves/settings.xml @@ -1,5 +1,5 @@ "nvg://advp.widget.mashiros.top/advp-style-preset/waves" - {"Line Width":1,"Line Color":"#ff4500","Data Length":0,"Data Settings":{"Auto Normalizing":true,"Amplitude":10,"Unit Style":0}} + {"Enable Gradient":false,"Gradient Direction":0,"Start Position Color":"#f44336","Middle Position Color":"#4caf50","End Position Color":"#03a9f4","Direction":0,"Line Color":"#ff4500","Line Width":1,"Data Length":0,"Rotate Settings":{"Center Enable":false,"Center Angle":10,"Line Enable":false,"Line Angle":10,"X Scale":100,"Y Scale":100,"X Offset":0,"Y Offset":0},"Data Settings":{"Auto Normalizing":true,"Amplitude":10,"Unit Style":0}} \ No newline at end of file diff --git a/package.json b/package.json index 68a3b65..09ea770 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ -{ +{ "name": "top.mashiros.widget.advp", - "version": "1.3.0", + "version": "1.4.0", "title": { "en": "ADV Plugin", @@ -62,17 +62,6 @@ "entry": "./styles/Preset_line/Style.qml" }, { - "location": "/advp-style-preset/gradient_line", - "catalog": "top.mashiros.advp-style", - "title": { - "en": "Gradient Line", - "zh": "渐变线", - "zh_TW": "漸變線", - "ja": "グラデーションライン" - }, - "entry": "./styles/Preset_gradient_line/Style.qml" - }, - { "location": "/advp-style-preset/waves", "catalog": "top.mashiros.advp-style", "title": { @@ -187,6 +176,17 @@ }, "preview": "Presets/Ordinal_Scale_UI_bottom/preview.png", "entry": "Presets/Ordinal_Scale_UI_bottom/preset.json" + }, + { + "location": "/advp-style-preset/gradient_line", + "catalog": "top.mashiros.advp-style-temp", + "title": { + "en": "Gradient Line", + "zh": "渐变线", + "zh_TW": "漸變線", + "ja": "グラデーションライン" + }, + "entry": "./styles/Preset_line/Style.qml" } ] } diff --git a/qml/Common.qml b/qml/Common.qml index 326c519..09fab2c 100644 --- a/qml/Common.qml +++ b/qml/Common.qml @@ -128,6 +128,8 @@ Item { for (let prop in sourceObj) { if (sourceObj.hasOwnProperty(prop) && sourceObj[prop] !== undefined) { if (typeof sourceObj[prop] === 'object') { + if (targetObj[prop] === undefined) + targetObj[prop] = {}; Object.assign(targetObj[prop], sourceObj[prop]); } else { targetObj[prop] = sourceObj[prop]; diff --git a/qml/Main.qml b/qml/Main.qml index a55db76..810edaa 100644 --- a/qml/Main.qml +++ b/qml/Main.qml @@ -37,12 +37,6 @@ T.Widget { preference = item.preference; defaultValues = item.defaultValues; style = item.style; - if (!widget.settings[widget.settings.current_style]) { - widget.settings[widget.settings.current_style] = defaultValues; - }else if(widget.settings[widget.settings.current_style]["Version"] !== defaultValues["Version"]) { - delete widget.settings[widget.settings.current_style]["Version"]; - widget.settings[widget.settings.current_style] = Common.updateObject(Common.deepClone(defaultValues), widget.settings[widget.settings.current_style]); - } } } @@ -72,7 +66,7 @@ T.Widget { Component.onCompleted: { Common.widgetsNum++; - if ((!widget.settings.current_style) || (Common.stylesURL.indexOf(widget.settings.current_style) === -1)) { + if (!widget.settings.current_style) { widget.settings.current_style = Common.stylesURL[0]; } } diff --git a/qml/api/AdvpCanvasTemplate.qml b/qml/api/AdvpCanvasTemplate.qml index fc70e12..3be503f 100644 --- a/qml/api/AdvpCanvasTemplate.qml +++ b/qml/api/AdvpCanvasTemplate.qml @@ -11,8 +11,20 @@ Canvas { signal audioDataUpdeted(var data) signal configsUpdated() + signal completed() + signal versionUpdated(string old) + readonly property var configs: widget.settings[widget.settings.current_style] ?? defaultValues + function updateObject(target, source) { + return Common.updateObject(Common.deepClone(target), Common.deepClone(source)); + } + + onVersionUpdated: { + delete widget.settings[widget.settings.current_style]["Version"]; + widget.settings[widget.settings.current_style] = updateObject(defaultValues, widget.settings[widget.settings.current_style]); + } + onConfigsChanged: { if (context) { configsUpdated(); @@ -30,4 +42,13 @@ Canvas { target: Common onAudioDataUpdated: audioDataUpdeted(audioData) } + + Component.onCompleted: { + if (!widget.settings[widget.settings.current_style]) { + widget.settings[widget.settings.current_style] = defaultValues; + }else if(widget.settings[widget.settings.current_style]["Version"] !== defaultValues["Version"]) { + versionUpdated(widget.settings[widget.settings.current_style]["Version"]); + } + completed(); + } } diff --git a/readme.md b/readme.md index 1174479..1c05330 100644 --- a/readme.md +++ b/readme.md @@ -12,7 +12,7 @@ ## 特色 * 整合客户端与服务器端的功能,使用更简单 -* 预设6种频谱显示形式,其中每种都可以进一步自定义设置其样式 +* 预设5种频谱显示形式,其中每种都可以进一步自定义设置其样式 * 提供了Style的开发接口,供开发者添加更多的可视化样式 * 导入第三方Style类似其他插件,预计支持steam创意工坊下载 * 服务端崩溃后自启动 @@ -21,7 +21,7 @@ 安装并启用插件后,默认加载第一种预设Style样式。右键点击挂件可调出菜单,在挂件菜单中点击“样式设置...”选项,呼出样式设置窗口。点击其中的样式选项可切换不同的样式风格,若此样式提供可配置项,则在样式选项下方会出现配置项。 -
+
## 服务器设置 diff --git a/styles/Preset_Ordinal_Scale_UI_bottom/Style.qml b/styles/Preset_Ordinal_Scale_UI_bottom/Style.qml index 3e5a9e3..6ace99c 100644 --- a/styles/Preset_Ordinal_Scale_UI_bottom/Style.qml +++ b/styles/Preset_Ordinal_Scale_UI_bottom/Style.qml @@ -110,7 +110,7 @@ AdvpStyleTemplate { requestPaint(); } - Component.onCompleted: { + onCompleted: { for (let i = 0; i < 128; i++) { audioData[i] = 0; } diff --git a/styles/Preset_circle/Style.qml b/styles/Preset_circle/Style.qml index 00ee6e1..fb54291 100644 --- a/styles/Preset_circle/Style.qml +++ b/styles/Preset_circle/Style.qml @@ -1,115 +1,185 @@ import QtQuick 2.12 +import QtGraphicalEffects 1.12 import NERvGear.Preferences 1.0 as P import "../../qml/api" AdvpStyleTemplate { - style: AdvpCanvasTemplate { - readonly property var audioData: new Array(128) - - //configs - readonly property int linePosition: configs["Line Position"] - readonly property real maxRange: configs["Max Range"] / 100 - readonly property int uDataLen: Math.pow(2, configs["Data Length"]) - readonly property int dataLength: 64/uDataLen - readonly property int channel: configs["Channel"] - readonly property bool reverse: configs["Reverse"] - readonly property bool rotateFlag: configs["Rotate"] - readonly property real rSpeed: configs["Ratate Speed"] / 100 - readonly property real angle: configs["Angle"] - readonly property bool autoNormalizing: configs["Data Settings"]["Auto Normalizing"] - readonly property real amplitude: 400/configs["Data Settings"]["Amplitude"] - readonly property int unitStyle: configs["Data Settings"]["Unit Style"] - - readonly property int total: channel*dataLength - - readonly property real dotGap: 360/total - property real offsetAngle: 0 - property var outerPos: [] - property var innerPos: [] - readonly property real degUnit: Math.PI/180 - - readonly property real subRatio: 0.2*maxRange - readonly property real mainRatio: 1-subRatio*2.5 - - readonly property real minLength: Math.min(width, height) - readonly property real ratio:minLength*subRatio - readonly property real halfWidth: width/2 - readonly property real halfHeight: height/2 - readonly property real halfMinLength: minLength/2 - - - onConfigsUpdated: { - context.lineWidth = configs["Line Width"]; - context.strokeStyle = configs["Main Color"]; + style: Rectangle { + id: main + width: widget.width; + height: widget.height; + + property int gradientStyle + + RadialGradient { + id: radialGradient + anchors.fill: parent + visible: gradientStyle===1 + horizontalRadius: Math.min(width, height)/2 + verticalRadius: horizontalRadius + gradient: Gradient { + GradientStop {id: radialGradient_pstart} + GradientStop {id: radialGradient_pmiddle} + GradientStop {id: radialGradient_pend} + } } - function createPoint() { - outerPos.length = 0; - innerPos.length = 0; - let deg, deltaR, r1, r2, _rhmLen; - _rhmLen = mainRatio*halfMinLength; - - for (let j=0; j < channel; j++) { - for (let i=0; i < dataLength; i++) { - deg = degUnit*((i+j*dataLength)*dotGap + offsetAngle); - deltaR = audioData[reverse*(dataLength-i-1)+(!reverse)*(i+j*dataLength)] * ratio; - r1 = _rhmLen+1+deltaR*(linePosition!==2); - r2 = _rhmLen-1-deltaR*(linePosition!==1); - outerPos.push([halfWidth+Math.cos(deg)*r1,halfHeight+Math.sin(deg)*r1]); - innerPos.push([halfWidth+Math.cos(deg)*r2,halfHeight+Math.sin(deg)*r2]); - } + ConicalGradient { + id: conicalGradient + anchors.fill: parent + visible: gradientStyle===2 + angle: -90; + gradient: Gradient { + GradientStop{id: conicalGradient_pstart; position: 0.0} + GradientStop{id: conicalGradient_pquarter; position: 0.25} + GradientStop {id: conicalGradient_phalf; position: 0.5} + GradientStop {id: conicalGradient_p3quarter; position: 0.75} + GradientStop{id: conicalGradient_pend; position: 1.0} } - offsetAngle = rotateFlag ? ((offsetAngle + rSpeed) % 360) : angle; } - onAudioDataUpdeted: { - let normalizing_ratio = autoNormalizing ? data[128] : amplitude; - if (unitStyle) { - //对数化显示 - for(let i=0; i{}) + centerLineFlag = configs["Center Line"]; + center_color = configs["Center Color"]; + center_width = configs["Center Width"]/10; + linePosition = configs["Line Position"]; + vertical_flag = configs["Direction"]; + gradientEnable = configs["Enable Gradient"]; + context.lineWidth = configs["Line Width"]; + main.color = configs["Line Color"]; + _y_dy = configs["Rotate Settings"]["Center Enable"]*Math.tan(configs["Rotate Settings"]["Center Angle"]*Math.PI/180)*(vertical_flag ? height/2 : width/2); + if (gradientEnable) { + gradient_mask.start = Qt.point(0, height*(configs["Gradient Direction"]===2)); + gradient_mask.end = Qt.point(width*(configs["Gradient Direction"]!==1), height*(configs["Gradient Direction"]%2)); + p_start.color = configs["Start Position Color"]; + p_middle.color = configs["Middle Position Color"]; + p_end.color = configs["End Position Color"]; + } + centerLine.requestPaint(); } - if (centerLineFlag) { - context.fillStyle = center_color; - context.fillRect(0, halfHeight-_y_dy, width, 2); + + onAudioDataUpdeted: { + let normalizing_ratio = autoNormalizing ? data[128] : amplitude; + if (unitStyle) { + //对数化显示 + for(let i=l_start; i{}) - context.lineWidth = configs["Line Width"]; - context.strokeStyle = configs["Line Color"]; - } + readonly property int uDataLen: Math.pow(2, configs["Data Length"]); + readonly property int dataLength: 64/uDataLen + readonly property int unitStyle: configs["Data Settings"]["Unit Style"] - onAudioDataUpdeted: { - let normalizing_ratio = autoNormalizing ? data[128]*2 : amplitude; - if (unitStyle) { - //对数化显示 - for(let i=0; i{}) + gradientEnable = configs["Enable Gradient"]; + context.lineWidth = configs["Line Width"]; + main.color = configs["Line Color"]; + if (gradientEnable) { + gradient_mask.start = Qt.point(0, height*(configs["Gradient Direction"]===2)); + gradient_mask.end = Qt.point(width*(configs["Gradient Direction"]!==1), height*(configs["Gradient Direction"]%2)); + p_start.color = configs["Start Position Color"]; + p_middle.color = configs["Middle Position Color"]; + p_end.color = configs["End Position Color"]; } - audioData[i] /= (uDataLen * normalizing_ratio); } - for(let i=dataLength; i