diff --git a/.appveyor.yml b/.appveyor.yml new file mode 100644 index 000000000..5568b5d67 --- /dev/null +++ b/.appveyor.yml @@ -0,0 +1,80 @@ +init: + - ps: if ($env:APPVEYOR_REPO_TAG -eq "true") { $env:TAG_VERSION = "$env:APPVEYOR_REPO_TAG_NAME.$env:APPVEYOR_BUILD_NUMBER" } else { $env:TAG_VERSION = "v3.0.$env:APPVEYOR_BUILD_NUMBER" } + - ps: $env:TAG_VERSION = $env:TAG_VERSION -replace 'v','' + - ps: Write-Host "Setting version to '$env:TAG_VERSION'" + - ps: Update-AppveyorBuild -Version "$env:TAG_VERSION" + +environment: + matrix: + - job_name: Windows x64 Build + platform: x64 + appveyor_build_worker_image: Visual Studio 2019 + configuration: ReleaseWindows + - job_name: Windows x86 Build + platform: x86 + appveyor_build_worker_image: Visual Studio 2019 + configuration: ReleaseWindows + + BugsplatDatabase: sjofnllc + PfxDownloadUrl: + secure: T8uKu+tTR2G7LDE1zPGNOi+prl4YaKXP6DOC5eU6A14FEQkd8PFR3nQ1WMwryphJ + PfxDownloadPasswd: + secure: nAIqrjhaoamhiuAcae/xNw== + PfxPassword: + secure: +vWSGzLkiBGVIxfPb+iRtD+/maQjI2d92hN4PoNAxMc= + +branches: + except: + - localbuilding + +pull_requests: + do_not_increment_build_number: true + +build: + project: radegast.sln + parallel: true + verbosity: minimal + +cache: + - packages -> **\packages.config + - '%LocalAppData%\NuGet\Cache' + +dotnet_csproj: + patch: true + file: '**\*.csproj;**\*.props' + version: '{version}' + assembly_version: '{version}' + file_version: '{version}' + +before_build: + - nuget restore radegast.sln + - ps: util/InstallRemotePfx.ps1 -PfxDownloadUrl $env:PfxDownloadUrl -PfxDownloadUser AppVeyor -PfxDownloadPasswd $env:PfxDownloadPasswd -PfxPasswd $env:PfxPassword + +after_build: + - ps: New-Item -ItemType directory -Path .\$env:PLATFORM + - cmd: '7z a -ttar -so Radegast-%TAG_VERSION%.tar %APPVEYOR_BUILD_FOLDER%\bin\Release\ | 7z a -si Radegast_%PLATFORM%-%TAG_VERSION%.tbz' + - ps: Copy-Item bin\Release\RadegastSetup_$env:PLATFORM.msi RadegastSetup_$env:PLATFORM-$env:TAG_VERSION.msi + - ps: Copy-Item bin\Release\RadegastBundle_$env:PLATFORM.exe RadegastSetup_$env:PLATFORM-$env:TAG_VERSION.exe + +artifacts: + - path: 'RadegastSetup*.exe' + name: 'Radegast Windows x64 Bundle' + type: Auto + - path: 'RadegastSetup*.msi' + name: 'Radegast Windows x64 MSI' + type: Auto + - path: 'Radegast*.tbz' + name: 'Radegast Linux x64' + type: Auto + - path: 'RadegastSetup*.exe' + name: 'Radegast Windows x86 Bundle' + type: Auto + - path: 'RadegastSetup*.msi' + name: 'Radegast Windows x86 MSI' + type: Auto + - path: 'Radegast-*.tbz' + name: 'Radegast Linux x86' + type: Auto + - path: 'bin\Release\Radegast.pdb' + name: 'Radegast symbols' + type: Auto diff --git a/.gitignore b/.gitignore index 942751b06..0eb4ea55d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,12 +2,17 @@ *.suo bin obj +packages compile.bat -*.sln *.sln.cache -*.csproj *.bak *.resources *~ *.userprefs -.vs \ No newline at end of file +.vs +.idea +libremetaverse/ +sparkle/ +Radegast/Generated/ +ProductInstallFiles.wxs +.DS_Store diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 3269b371c..000000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "libopenmetaverse"] - path = libopenmetaverse - url = https://github.com/openmetaversefoundation/libopenmetaverse.git diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 3f76ddb24..000000000 --- a/.travis.yml +++ /dev/null @@ -1,33 +0,0 @@ -language: csharp -solution: Radegast.sln - -os: - - linux - -branches: - except: - - /^build-/ - -install: - - "export BUILD_MAJOR=2" - - "export BUILD_MINOR=19" - - "export GIT_TAG=build-$BUILD_MAJOR.$BUILD_MINOR.$TRAVIS_BUILD_NUMBER-$TRAVIS_OS_NAME-$TRAVIS_BRANCH-$(date -u '+%Y-%m-%d')" - - "export GIT_ARTIFACT=Radegast-$GIT_TAG.zip" - - "./ci/install.sh" - -before_deploy: - - "./ci/before_deploy.sh" - -deploy: - provider: releases - api_key: - secure: wDIvmLG2B0wA4Ngp+avp1qQOU3lpUIC79C/iEo/BDNA4TQJLeAvYrQ7mXVjXrSP41LCB9aWmjjlTJk8nRbEcTWwiYTRDPRqvxo32/BPsW6zaBrqHGP1dF3R8L/KtVRf97iNJJRXWHZssNYsuakBKTHp6dPt68qU6k3cig7aiVH/qTwawYpI9/qtUUdfuN3h9/PciujyAr/XBpTzS7xLHsHShchMpgEVhGqtjd+yR2z0qojNs645Iit7lZOMrtjuqNLjxXS3WLbWVHT22upX+00ovlJXT6fUtkHKWuAW3hSEN525/I8bl7NExLpy9yOUa/D1JALBgrd2qxhsECJ+sJ9ms59iQxYJOOpfuk6KIjmtD+i4f6h2rSOjOtbc1dUvA9+SH27o00DPjFQKPA0lLqEPGBxdlFE0ocOHI2UW1wvTRSAUhJe6QLLatVLJl5TfcDOsM7JC29XeuHXL1wHFRqEq8agpdR8UqueaDkfAWVPXQRywVD/aUFrMMJEfxTncVhRXepLL3z2uHwjpRaw5JJ7hsU5eaEEvIRMzR73IOCHlfmqCtjE7bMVmO9Zn0BjGJURHCk77I395QLWnCOuMShWm1OnH5Klxjehlgqtpdhaj83OgsnE7/sXsMPaqxwtzusTRsRYmJz/4D5B7/TPVNDzK2Xewr0NKEBmY3n/MnAqc= - skip_cleanup: true - file: $GIT_ARTIFACT - on: - repo: nooperation/radegast - all_branches: true - -env: - global: - secure: u7t+c2187aIGA/Kn/DV1/4kjJ/BmQ6/x5AKAbqdFy7R8xdY2ohOpbITclZ7aox+6PdErmrQBUNZoTfQmehYTw/DOIhA6DE3N4wJ0tGVMnOWAwsX/KWddeQkycfF/SIhcOUrl+3Muv9CJiskYHul7mnfNZzv78ZHFfoaP3zt0Jy6JEOJmAiE36OLh9NBGRyRjVWLg4AVTXdNo0vFmOZgzOoJHPAtkB/18OjZp1RHe5l9io5ww4BY/ZcxodG52WaqTwKh2fCt1juF64a1rncQiUgkBWl7jocErS3DOQ9c5/60kAhimEVAKyaSJJlpBXbYwY7IIAatDwa6ep/0xZ5pIh6QW0ffSXuxBrf15NmlKZqmuUVJ32avVRJ53rvg2MZLrsJwBC+8bsrk6RyXoph/lCweiepHm5v0c68i89xviXXV8X9xN8fxyCGQOMKR6xP7/uMbpEbIWiSmuz5ayw19HFKkTeefqWq+Q4McaTOXf56lJ7gQIDN1QLOlmGJd7A57ftJYlfr5He7hS5ciXrEshDh+Yu4PdIUz2pB73LsHmT22XPWs575g0nxwcsE3dv86h/CuVWuOyZT6u5DIokj4k+rF2rXqqXCrJ3/Wp9T26S3UO/Q5gVVXTEymIsBqjPzbnbuRcYwK97r8vEXJ1dGKZMrhNX33GnqBVVIfrs7ZJHas= diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 000000000..77a9f5c54 --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,10 @@ + + + 1.0.0 + Radegast Metaverse Client + Sjofn LLC + Copyright (c) 2009-2015, Radegast Development Team. Copyright (c) 2016-2022, Sjofn, LLC. All rights reserved. + Radegast is a trademark of Sjofn LLC. + Sjofn LLC + + diff --git a/Install/RadegastBundle/BuildProperties.wxi b/Install/RadegastBundle/BuildProperties.wxi new file mode 100644 index 000000000..a338c0824 --- /dev/null +++ b/Install/RadegastBundle/BuildProperties.wxi @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/Install/RadegastBundle/Bundle.wxs b/Install/RadegastBundle/Bundle.wxs new file mode 100644 index 000000000..16f9e5595 --- /dev/null +++ b/Install/RadegastBundle/Bundle.wxs @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Install/RadegastBundle/NetFx48.wxs b/Install/RadegastBundle/NetFx48.wxs new file mode 100644 index 000000000..39b03cc53 --- /dev/null +++ b/Install/RadegastBundle/NetFx48.wxs @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + WIXNETFX4RELEASEINSTALLED >= "#$(var.NetFx48MinRelease)" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Install/RadegastBundle/RadegastBundle.wixproj b/Install/RadegastBundle/RadegastBundle.wixproj new file mode 100644 index 000000000..9e228fc40 --- /dev/null +++ b/Install/RadegastBundle/RadegastBundle.wixproj @@ -0,0 +1,102 @@ + + + + Release + x86 + 3.1.0 + cccc26b5-aa17-47d8-8d5d-707a78ec9a10 + 2.0 + RadegastBundle_$(Platform) + Bundle + + + ..\..\bin\$(Configuration)\ + obj\$(Configuration)\ + x86 + true + true + + + ..\..\bin\Release\ + obj\Release\ + x86 + true + true + + + ..\..\bin\$(Configuration)\ + obj\$(Configuration)\ + x64 + true + true + + + ..\..\bin\Release\ + obj\Release\ + x64 + true + true + + + + + + + + $(WixExtDir)\WixUtilExtension.dll + WixUtilExtension + + + $(WixExtDir)\WixNetFxExtension.dll + WixNetFxExtension + + + $(WixExtDir)\WixBalExtension.dll + WixBalExtension + + + + + RadegastSetup + {0f0271af-0841-45a5-8737-9239550839b7} + True + True + Binaries;Content;Satellites + INSTALLFOLDER + + + + + + + + + + + + + + + + + + $([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots', 'KitsRoot10', null, RegistryView.Registry32, RegistryView.Default)) + $([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots', 'KitsRoot81', null, RegistryView.Registry32, RegistryView.Default)) + $([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots', 'KitsRoot', null, RegistryView.Registry32, RegistryView.Default)) + $(WindowsKitsRoot)bin\x64\ + $(WindowsKitsRoot)bin\$(Platform)\ + $([System.IO.Directory]::GetDirectories('$(WindowsKitsRoot)bin',"10.0.*")) + $(SignToolPathBin.Split(';').Length) + $([MSBuild]::Add(-1, $(SignToolPathLen))) + $(SignToolPathBin.Split(';').GetValue($(SignToolPathIndex)))\ + $(SignToolPathBase)x64\ + $(SignToolPathBase)$(Platform)\ + + + + + + + + + \ No newline at end of file diff --git a/Install/RadegastBundle/assets/license.rtf b/Install/RadegastBundle/assets/license.rtf new file mode 100644 index 000000000..5a946cc04 Binary files /dev/null and b/Install/RadegastBundle/assets/license.rtf differ diff --git a/Install/RadegastBundle/assets/radegast.ico b/Install/RadegastBundle/assets/radegast.ico new file mode 100644 index 000000000..80e2e85a5 Binary files /dev/null and b/Install/RadegastBundle/assets/radegast.ico differ diff --git a/Install/RadegastSetup/BuildProperties.wxi b/Install/RadegastSetup/BuildProperties.wxi new file mode 100644 index 000000000..8d333f92a --- /dev/null +++ b/Install/RadegastSetup/BuildProperties.wxi @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/Install/RadegastSetup/NetFx48.wxs b/Install/RadegastSetup/NetFx48.wxs new file mode 100644 index 000000000..0aa1125db --- /dev/null +++ b/Install/RadegastSetup/NetFx48.wxs @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + WIXNETFX4RELEASEINSTALLED >= "#$(var.NetFx48MinRelease)" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Install/RadegastSetup/Product.wxs b/Install/RadegastSetup/Product.wxs new file mode 100644 index 000000000..d31768fce --- /dev/null +++ b/Install/RadegastSetup/Product.wxs @@ -0,0 +1,108 @@ + + + + + + + + + + + + + + + + + + + + + + + + $(var.productDesc) + $(var.companyName) + + $(var.aboutUrl) + $(var.aboutUrl) + $(var.aboutUrl) + + https://radegast.life/ + + $(var.totalFileSize) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Install/RadegastSetup/RadegastSetup.wixproj b/Install/RadegastSetup/RadegastSetup.wixproj new file mode 100644 index 000000000..755d0b6cd --- /dev/null +++ b/Install/RadegastSetup/RadegastSetup.wixproj @@ -0,0 +1,126 @@ + + + + Release + x86 + 3.1.0 + 0f0271af-0841-45a5-8737-9239550839b7 + 2.0 + RadegastSetup_$(Platform) + Package + RadegastSetup + + + ..\..\bin\$(Configuration)\ + obj\$(Configuration)\ + x86 + true + true + ICE99 + + + ..\..\bin\Release\ + obj\Release\ + x86 + true + true + False + ICE99 + + + ..\..\bin\$(Configuration)\ + obj\$(Configuration)\ + x64 + true + true + ICE99 + + + ..\..\bin\Release\ + obj\Release\ + x64 + true + true + False + ICE99 + + + + + + + + + + + $(WixExtDir)\WixNetFxExtension.dll + WixNetFxExtension + + + $(WixExtDir)\WixUtilExtension.dll + WixUtilExtension + + + $(WixExtDir)\WixUIExtension.dll + WixUIExtension + + + + + + + + + + + + + + + + + + + + Radegast + {f02f3c44-dcfc-964f-0516-85f7f141ccdd} + True + True + Binaries;Content;Satellites + INSTALLFOLDER + + + + + + + + + + + + + + + + + $([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots', 'KitsRoot10', null, RegistryView.Registry32, RegistryView.Default)) + $([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots', 'KitsRoot81', null, RegistryView.Registry32, RegistryView.Default)) + $([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots', 'KitsRoot', null, RegistryView.Registry32, RegistryView.Default)) + $(WindowsKitsRoot)bin\x64\ + $(WindowsKitsRoot)bin\$(Platform)\ + $([System.IO.Directory]::GetDirectories('$(WindowsKitsRoot)bin',"10.0.*")) + $(SignToolPathBin.Split(';').Length) + $([MSBuild]::Add(-1, $(SignToolPathLen))) + $(SignToolPathBin.Split(';').GetValue($(SignToolPathIndex)))\ + $(SignToolPathBase)x64\ + $(SignToolPathBase)$(Platform)\ + + + + + + + + + \ No newline at end of file diff --git a/Install/RadegastSetup/UI.wxi b/Install/RadegastSetup/UI.wxi new file mode 100644 index 000000000..77f7d9ccc --- /dev/null +++ b/Install/RadegastSetup/UI.wxi @@ -0,0 +1,12 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Install/RadegastSetup/VCRedist.wxs b/Install/RadegastSetup/VCRedist.wxs new file mode 100644 index 000000000..8f29b93ad --- /dev/null +++ b/Install/RadegastSetup/VCRedist.wxs @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/Install/RadegastSetup/VoicePack.wxs b/Install/RadegastSetup/VoicePack.wxs new file mode 100644 index 000000000..42bc7d6ff --- /dev/null +++ b/Install/RadegastSetup/VoicePack.wxs @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Install/RadegastSetup/assets/license.rtf b/Install/RadegastSetup/assets/license.rtf new file mode 100644 index 000000000..5a946cc04 Binary files /dev/null and b/Install/RadegastSetup/assets/license.rtf differ diff --git a/Install/RadegastSetup/assets/radegast.ico b/Install/RadegastSetup/assets/radegast.ico new file mode 100644 index 000000000..80e2e85a5 Binary files /dev/null and b/Install/RadegastSetup/assets/radegast.ico differ diff --git a/Install/RadegastSetup/slvoice/DbgHelp.dll b/Install/RadegastSetup/slvoice/DbgHelp.dll new file mode 100644 index 000000000..660d9207d Binary files /dev/null and b/Install/RadegastSetup/slvoice/DbgHelp.dll differ diff --git a/Install/RadegastSetup/slvoice/README.txt b/Install/RadegastSetup/slvoice/README.txt new file mode 100644 index 000000000..0ddceb98d --- /dev/null +++ b/Install/RadegastSetup/slvoice/README.txt @@ -0,0 +1,3 @@ +The files in this directory are governed under their respective licenses as held by Linden Lab and Vivox under the LGPL 2.1 + +Additional license holders can be found in vivox_licenses.txt diff --git a/Install/RadegastSetup/slvoice/SLVoice.exe b/Install/RadegastSetup/slvoice/SLVoice.exe new file mode 100644 index 000000000..7094b317b Binary files /dev/null and b/Install/RadegastSetup/slvoice/SLVoice.exe differ diff --git a/Install/RadegastSetup/slvoice/ortp.dll b/Install/RadegastSetup/slvoice/ortp.dll new file mode 100644 index 000000000..7d8a27331 Binary files /dev/null and b/Install/RadegastSetup/slvoice/ortp.dll differ diff --git a/Install/RadegastSetup/slvoice/ortp.pdb b/Install/RadegastSetup/slvoice/ortp.pdb new file mode 100644 index 000000000..5673e0923 Binary files /dev/null and b/Install/RadegastSetup/slvoice/ortp.pdb differ diff --git a/Install/RadegastSetup/slvoice/vivox_licenses.txt b/Install/RadegastSetup/slvoice/vivox_licenses.txt new file mode 100644 index 000000000..a0d16af6a --- /dev/null +++ b/Install/RadegastSetup/slvoice/vivox_licenses.txt @@ -0,0 +1,244 @@ +/* Copyright (c) 2013-2018 by Mercer Road Corp + * + * Permission to use, copy, modify or distribute this software in binary or source form + * for any purpose is allowed only under explicit prior consent in writing from Mercer Road Corp + * + * THE SOFTWARE IS PROVIDED "AS IS" AND MERCER ROAD CORP DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL MERCER ROAD CORP + * BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS + * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +/* ==================================================================== +* The Apache Software License, Version 1.1 +* +* Copyright (c) 2000-2001 The Apache Software Foundation. All rights +* reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* 1. Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* +* 2. Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* +* 3. The end-user documentation included with the redistribution, +* if any, must include the following acknowledgment: +* "This product includes software developed by the +* Apache Software Foundation (http://www.apache.org/)." +* Alternately, this acknowledgment may appear in the software itself, +* if and wherever such third-party acknowledgments normally appear. +* +* 4. The names "Apache" and "Apache Software Foundation" must +* not be used to endorse or promote products derived from this +* software without prior written permission. For written +* permission, please contact apache@apache.org. +* +* 5. Products derived from this software may not be called "Apache", +* nor may "Apache" appear in their name, without prior written +* permission of the Apache Software Foundation. +* +* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR +* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +* SUCH DAMAGE. +* ==================================================================== +* +* This software consists of voluntary contributions made by many +* individuals on behalf of the Apache Software Foundation. For more +* information on the Apache Software Foundation, please see +* . +*/ + +/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All +rights reserved. +License to copy and use this software is granted provided that it +is identified as the "RSA Data Security, Inc. MD5 Message-Digest +Algorithm" in all material mentioning or referencing this software +or this function. +License is also granted to make and use derivative works provided +that such works are identified as "derived from the RSA Data +Security, Inc. MD5 Message-Digest Algorithm" in all material +mentioning or referencing the derived work. +RSA Data Security, Inc. makes no representations concerning either +the merchantability of this software or the suitability of this +software for any particular purpose. It is provided "as is" +without express or implied warranty of any kind. +These notices must be retained in any copies of any part of this +documentation and/or software. +*/ + + +/* ==================================================================== +* The Vovida Software License, Version 1.0 +* +* Copyright (c) 2000 Vovida Networks, Inc. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* 1. Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* +* 2. Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* +* 3. The names "VOCAL", "Vovida Open Communication Application Library", +* and "Vovida Open Communication Application Library (VOCAL)" must +* not be used to endorse or promote products derived from this +* software without prior written permission. For written +* permission, please contact vocal@vovida.org. +* +* 4. Products derived from this software may not be called "VOCAL", nor +* may "VOCAL" appear in their name, without prior written +* permission of Vovida Networks, Inc. +* +* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED +* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND +* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA +* NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES +* IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, +* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE +* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +* DAMAGE. +* +* ==================================================================== +* +* This software consists of voluntary contributions made by Vovida +* Networks, Inc. and many individuals on behalf of Vovida Networks, +* Inc. For more information on Vovida Networks, Inc., please see +* . +* +*/ + +/* Copyright (C) 2007-2008 Jean-Marc Valin +Copyright (C) 2008 Thorvald Natvig + +File: resample.c +Arbitrary resampling code +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: +1. Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. +3. The name of the author may not be used to endorse or promote products +derived from this software without specific prior written permission. +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +*/ + +/* +Copyright 2001-2011 Xiph.Org, Skype Limited, Octasic, + Jean-Marc Valin, Timothy B. Terriberry, + CSIRO, Gregory Maxwell, Mark Borgerding, + Erik de Castro Lopo + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +- Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + +- Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. + +- Neither the name of Internet Society, IETF or IETF Trust, nor the +names of specific contributors, may be used to endorse or promote +products derived from this software without specific prior written +permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER +OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Opus is subject to the royalty-free patent licenses which are +specified at: + +Xiph.Org Foundation: +https://datatracker.ietf.org/ipr/1524/ + +Microsoft Corporation: +https://datatracker.ietf.org/ipr/1914/ + +Broadcom Corporation: +https://datatracker.ietf.org/ipr/1526/ +*/ + +The accompanying product may be protected by one or more U.S. and foreign patents and/or pending patent applications held by Polycom, Inc. + + +Tencent is pleased to support the open source community by making RapidJSON available. + +Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. + +If you have downloaded a copy of the RapidJSON binary from Tencent, please note that the RapidJSON binary is licensed under the MIT License. +If you have downloaded a copy of the RapidJSON source code from Tencent, please note that RapidJSON source code is licensed under the MIT License, except for the third-party components listed below which are subject to different license terms. Your integration of RapidJSON into your own projects may require compliance with the MIT License, as well as the other licenses applicable to the third-party components included within RapidJSON. To avoid the problematic JSON license in your own projects, it's sufficient to exclude the bin/jsonchecker/ directory, as it's the only code under the JSON license. +A copy of the MIT License is included in this file. + +The msinttypes r29 +Copyright (c) 2006-2013 Alexander Chemeris +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. +* Neither the name of copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Terms of the MIT License: +-------------------------------------------------------------------- + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/Install/RadegastSetup/slvoice/vivox_sdk_license.txt b/Install/RadegastSetup/slvoice/vivox_sdk_license.txt new file mode 100644 index 000000000..10ec0d4fe --- /dev/null +++ b/Install/RadegastSetup/slvoice/vivox_sdk_license.txt @@ -0,0 +1,182 @@ +================= +Vivox SDK License +================= + +RSA Data Security, Inc. MD5 Message-Digest Algorithm + +================ + +Audio coding: Polycom Siren14TM (ITU-T Rec. G.722.1 Annex C) + +Open Source Software Licensing +Each open source software component utilized by this product is subject to its own copyright and licensing terms, as listed below. + + +************************************************************* +************************************************************* + +/** + * OpenAL cross platform audio library + * Copyright (C) 1999-2000 by authors. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * Or go to http://www.gnu.org/copyleft/lgpl.html + */ + +************************************************************* +************************************************************* +RTP code under Lesser General Public License + +/* +The oRTP library is an RTP (Realtime Transport Protocol - rfc3550) stack. +Copyright (C) 2001 Simon MORLAT simon.morlat@linphone.org + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +************************************************************ +************************************************************* + + + + +/* + * The Vovida Software License, Version 1.0 + * + * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The names "VOCAL", "Vovida Open Communication Application Library", + * and "Vovida Open Communication Application Library (VOCAL)" must + * not be used to endorse or promote products derived from this + * software without prior written permission. For written + * permission, please contact vocal@vovida.org. + * + * 4. Products derived from this software may not be called "VOCAL", nor + * may "VOCAL" appear in their name, without prior written + * permission of Vovida Networks, Inc. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND + * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA + * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES + * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * + * This software consists of voluntary contributions made by Vovida + * Networks, Inc. and many individuals on behalf of Vovida Networks, + * Inc. For more information on Vovida Networks, Inc., please see + * + * + */ +************************************************************* +************************************************************* + +Internet Software Consortium code + +/* This is from the BIND 4.9.4 release, modified to compile by itself*/ +/* Copyright (c) 1996 by Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS + * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +************************************************************* + +************************************************************* + +************************************************************ + +http://tinyxpath.sourceforge.net/ + +TinyXPath is covered by the zlib license : + + www.sourceforge.net/projects/tinyxpath + Copyright (c) 2002-2006 Yves Berquin (yvesb@users.sourceforge.net) + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any + damages arising from the use of this software. + + Permission is granted to anyone to use this software for any + purpose, including commercial applications, and to alter it and + redistribute it freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation + would be appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and + must not be misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source distribution. + + +************************************************************ +************************************************************ + +THE FREE SOFTWARE FOUNDATION + +Any customer may request the source code for all open source portions of this product which are covered by the Free Software Foundation's General Public License (GPL), for a period of three years from purchase. Please contact the vendor from whom you obtained this product for instructions. A fee equivalent to the cost of making the code available may be charged. Alternatively, customers may choose to download desired GPL components directly from their original vendors. Specifically, this product contains the following GPL-licensed components: + +From Vivox: + - Assorted software components. To request source, contact Vivox at: + Vivox, Inc. + Attn: customer support + 40 Speen Street Suite 402 + Framingham, MA 01701 + diff --git a/Install/RadegastSetup/slvoice/vivoxsdk.dll b/Install/RadegastSetup/slvoice/vivoxsdk.dll new file mode 100644 index 000000000..232130031 Binary files /dev/null and b/Install/RadegastSetup/slvoice/vivoxsdk.dll differ diff --git a/Install/RadegastSetup/slvoice/vivoxsdk.lib b/Install/RadegastSetup/slvoice/vivoxsdk.lib new file mode 100644 index 000000000..631145ae2 Binary files /dev/null and b/Install/RadegastSetup/slvoice/vivoxsdk.lib differ diff --git a/Install/RadegastSetup/slvoice/vivoxsdk.pdb b/Install/RadegastSetup/slvoice/vivoxsdk.pdb new file mode 100644 index 000000000..1f6c05c65 Binary files /dev/null and b/Install/RadegastSetup/slvoice/vivoxsdk.pdb differ diff --git a/Install/RadegastSetup/slvoice/zlib1.dll b/Install/RadegastSetup/slvoice/zlib1.dll new file mode 100644 index 000000000..1cf8a476e Binary files /dev/null and b/Install/RadegastSetup/slvoice/zlib1.dll differ diff --git a/Install/RadegastSetup/vcredist/Microsoft_VC120_CRT_x86.msm b/Install/RadegastSetup/vcredist/Microsoft_VC120_CRT_x86.msm new file mode 100644 index 000000000..a1bee6630 Binary files /dev/null and b/Install/RadegastSetup/vcredist/Microsoft_VC120_CRT_x86.msm differ diff --git a/Install/RadegastSetup/vcredist/Microsoft_VC140_CRT_x86.msm b/Install/RadegastSetup/vcredist/Microsoft_VC140_CRT_x86.msm new file mode 100644 index 000000000..d39c257d1 Binary files /dev/null and b/Install/RadegastSetup/vcredist/Microsoft_VC140_CRT_x86.msm differ diff --git a/LICENSE.txt b/LICENSE.txt index d2c728ec4..46951a37a 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,69 +1,156 @@ -Radegast Metaverse Client -Copyright (c) 2009-2014, Radegast Development Team -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the application "Radegast", nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -Based on SLeek (BSD License) -Copyright 2006-2008, Paul Clement (a.k.a. Delta) -All rights reserved. - -Uses PrimMesher (BSD License) - 2010 Dahlia Trimble -http://forge.opensimulator.org/gf/project/primmesher/ - -Uses AIMLBot (LGPL License) -The AIMLBot library (Program#) is a .NET implementation of the AIML standard. - 2006 Nicholas H.Tollervey (http://ntoll.org) -http://aimlbot.sourceforge.net/ - -Uses FMOD Library (FMOD Non Commercial License) -FMOD Ex SoundSystem Copyright 2005-2009 Firelight Technologies Pty, Ltd. -Redistributions in binary form must follow the following rules: -* The FMOD library cannot be used for resale or other commercial distribution -* This license cannot be used for products which do not make profit but are still commercially released -* This license cannot be used for commercial services, where the executable containing fmod is not sold, but the data is -(If you want to redistribute Radegast commercially, remove fmodex.dll, fmodex*.so and fmodex*.dylib) - -Uses Ogg Vorbis codec (BSD License) -Copyright 2002, Xiph.org Foundation - -Uses log4net (Apache 2.0 License) -Copyright Apache Software Foundation - -Uses LSL parser from OpenSimulator project (BSD License) -Copyright Contributors, http://opensimulator.org/ - -Uses OpenTK library (MIT License) -Copyright 2006 - 2009 The Open Toolkit library. -http://www.opentk.com/ - -Uses artwork files are licenced under the -Creative Commons Share and Share Alike 3.0 -Copyright 2002-2009 Linden Research Inc. - -Command Line Library (MIT License) -Copyright 2005 - 2010 Giacomo Stelluti Scala -http://commandline.codeplex.com/ +GNU LESSER GENERAL PUBLIC LICENSE +Version 3, 29 June 2007 +Copyright(c) 2009-2014, Radegast Development Team +Copyright(c) 2016-2021, Sjofn, LLC + +Everyone is permitted to copy and distribute verbatim copies of this license +document, but changing it is not allowed. + +This version of the GNU Lesser General Public License incorporates the terms +and conditions of version 3 of the GNU General Public License, supplemented +by the additional permissions listed below. + +0. Additional Definitions. + +As used herein, this License refers to version 3 of the GNU Lesser General +Public License, and the GNU GPL refers to version 3 of the +GNU General Public License. + +The Library refers to a covered work governed by this License, other than +an Application or a Combined Work as defined below. + +An Application is any work that makes use of an interface provided by the +Library, but which is not otherwise based on the Library. Defining a subclass +of a class defined by the Library is deemed a mode of using an interface +provided by the Library. + +A Combined Work is a work produced by combining or linking an Application +with the Library. The particular version of the Library with which the +Combined Work was made is also called the Linked Version. + +The Minimal Corresponding Source for a Combined Work means the Corresponding +Source for the Combined Work, excluding any source code for portions of the +Combined Work that, considered in isolation, are based on the Application, +and not on the Linked Version. + +The Corresponding Application Code for a Combined Work means the object code +and/or source code for the Application, including any data and utility programs +needed for reproducing the Combined Work from the Application, but excluding +the System Libraries of the Combined Work. + +1. Exception to Section 3 of the GNU GPL. + +You may convey a covered work under sections 3 and 4 of this License without +being bound by section 3 of the GNU GPL. + +2. Conveying Modified Versions. + +If you modify a copy of the Library, and, in your modifications, a facility +refers to a function or data to be supplied by an Application that uses the +facility (other than as an argument passed when the facility is invoked), +then you may convey a copy of the modified version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the function or + data, the facility still operates, and performs whatever part of its + purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of this + License applicable to that copy. + +3. Object Code Incorporating Material from Library Header Files. + +The object code form of an Application may incorporate material from a header +file that is part of the Library. You may convey such object code under terms +of your choice, provided that, if the incorporated material is not limited to +numerical parameters, data structure layouts and accessors, or small macros, +inline functions and templates (ten or fewer lines in length), +you do both of the following: + + a) Give prominent notice with each copy of the object code that the Library + is used in it and that the Library and its use are covered by this License. + + b) Accompany the object code with a copy of the GNU GPL + and this license document. + +4. Combined Works. + +You may convey a Combined Work under terms of your choice that, taken together, +effectively do not restrict modification of the portions of the Library +contained in the Combined Work and reverse engineering for debugging such +modifications, if you also do each of the following: + + a) Give prominent notice with each copy of the Combined Work that the + Library is used in it and that the Library and its use are covered + by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and + this license document. + + c) For a Combined Work that displays copyright notices during execution, + include the copyright notice for the Library among these notices, as well + as a reference directing the user to the copies of the GNU GPL + and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form suitable + for, and under terms that permit, the user to recombine or relink + the Application with a modified version of the Linked Version to + produce a modified Combined Work, in the manner specified by section 6 + of the GNU GPL for conveying Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time a + copy of the Library already present on the user's computer system, + and (b) will operate properly with a modified version of the Library + that is interface-compatible with the Linked Version. + + e) Provide Installation Information, but only if you would otherwise be + required to provide such information under section 6 of the GNU GPL, and + only to the extent that such information is necessary to install and + execute a modified version of the Combined Work produced by recombining + or relinking the Application with a modified version of the Linked Version. + (If you use option 4d0, the Installation Information must accompany the + Minimal Corresponding Source and Corresponding Application Code. If you + use option 4d1, you must provide the Installation Information in the + manner specified by section 6 of the GNU GPL for + conveying Corresponding Source.) + +5. Combined Libraries. + +You may place library facilities that are a work based on the Library side by +side in a single library together with other library facilities that are not +Applications and are not covered by this License, and convey such a combined +library under terms of your choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based on + the Library, uncombined with any other library facilities, conveyed under + the terms of this License. + + b) Give prominent notice with the combined library that part of it is a + work based on the Library, and explaining where to find the accompanying + uncombined form of the same work. + +6. Revised Versions of the GNU Lesser General Public License. + +The Free Software Foundation may publish revised and/or new versions of the +GNU Lesser General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Library as you +received it specifies that a certain numbered version of the GNU Lesser +General Public License or any later version applies to it, you have the +option of following the terms and conditions either of that published version +or of any later version published by the Free Software Foundation. If the +Library as you received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser General +Public License ever published by the Free Software Foundation. + +If the Library as you received it specifies that a proxy can decide whether +future versions of the GNU Lesser General Public License shall apply, that +proxy's public statement of acceptance of any version is permanent +authorization for you to choose that version for the Library. diff --git a/README.md b/README.md index b9ffcfcf4..ae929c52a 100644 --- a/README.md +++ b/README.md @@ -1,79 +1,107 @@ -# Author +``` +██████╗ █████╗ ██████╗ ███████╗ ██████╗ █████╗ ███████╗████████╗ +██╔══██╗██╔══██╗██╔══██╗██╔════╝██╔════╝ ██╔══██╗██╔════╝╚══██╔══╝ +██████╔╝███████║██║ ██║█████╗ ██║ ███╗███████║███████╗ ██║ +██╔══██╗██╔══██║██║ ██║██╔══╝ ██║ ██║██╔══██║╚════██║ ██║ +██║ ██║██║ ██║██████╔╝███████╗╚██████╔╝██║ ██║███████║ ██║ +╚═╝ ╚═╝╚═╝ ╚═╝╚═════╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝ ╚═╝ +``` +Radegast Metaverse Client (http://radegast.life/) -Project founder and development lead: +[![License: LGPL v3](https://img.shields.io/badge/License-LGPL%20v3-blue.svg)](https://github.com/cinderblocks/radegast/blob/master/LICENSE.txt) +[![Latest version downloads](https://img.shields.io/github/downloads-pre/cinderblocks/radegast/latest/total)](https://radegast.life/downloads/) +[![Build status](https://ci.appveyor.com/api/projects/status/g34olv3opd2vho32/branch/master?svg=true)](https://ci.appveyor.com/project/cinderblocks57647/radegast/branch/master) +[![Commits per month](https://img.shields.io/github/commit-activity/m/cinderblocks/radegast)](https://www.github.com/cinderblocks/radegast/) +[![ZEC](https://img.shields.io/keybase/zec/cinder)](https://keybase.io/cinder) [![BTC](https://img.shields.io/keybase/btc/cinder)](https://keybase.io/cinder) -* **Latif Khalifa** (email latifer radegast.org) +## Getting started -Developers: +Radegast is a virtual world client compatible with Second Life and OpenSimulator. +Its main purpose is to provide an alternative client to Linden Lab derived virtual world viewers. +There is a strong focus on accessability and non-3D interaction. + +### Prerequisites + +Radegast requires .NET Framework 4.8 or compatible Mono version to build and run. + +### Contributing + +Pull requests are nice. Try not to be a dick, and we will all get along just fine. + +## Authors + +### Project founder: + +* **Latif Khalifa** + +### Current maintainer and lead developer: + +* **Cinder Roxley** (email cinder cinderblocks.biz) + +### Contributors: + +* **nooperation** +* **Luminous Luminos** + +### Alumni Contributors: * **Douglas R. Miles** * **Mojito Sorbet** * **Robin Cornelius** * **Revolution Smythe** -# License - -**Radegast Metaverse Client**
-*Copyright © 2009-2016, Radegast Development Team*
-*All rights reserved.* +## License -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: +**Radegast Metaverse Client** +* Copyright © 2009-2018, Radegast Development Team +* Copyright © 2017-2022, Sjofn, LLC. +* All rights reserved. -* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -* Neither the name of the application "Radegast", nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + Radegast is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. -*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.* + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# Bundled libraries +## Acknowledgments -Based on SLeek (BSD License)
-Copyright © 2006-2008, Paul Clement (a.k.a. Delta)
-All rights reserved.
+Based on SLeek +Copyright © 2006-2008, Paul Clement (a.k.a. Delta) +All rights reserved. -Uses PrimMesher (BSD License)
-© 2010 Dahlia Trimble
-http://forge.opensimulator.org/gf/project/primmesher/
+PrimMesher +Copyright © 2010 Dahlia Trimble +http://forge.opensimulator.org/gf/project/primmesher/ -Uses AIMLBot (LGPL License)
-The AIMLBot library (Program#) is a .NET implementation of the AIML standard.
-© 2006 Nicholas H.Tollervey (http://ntoll.org)
-http://aimlbot.sourceforge.net/
+Ogg Vorbis +Copyright © 2002, Xiph.org Foundation -Uses FMOD Library (FMOD Non Commercial License)
-FMOD Ex SoundSystem Copyright © 2005-2009 Firelight Technologies Pty, Ltd.
-Redistributions in binary form must follow the following rules: -* The FMOD library cannot be used for resale or other commercial distribution -* This license cannot be used for products which do not make profit but are still commercially released -* This license cannot be used for commercial services, where the executable containing fmod is not sold, but the data is -(If you want to redistribute Radegast commercially, remove fmodex.dll, fmodex*.so and fmodex*.dylib)
+log4net +Copyright © Apache Software Foundation -Uses Ogg Vorbis codec (BSD License)
-Copyright © 2002, Xiph.org Foundation
+OpenTK 3D +Copyright © 2006-2014 Stefanos Apostolopoulos for the Open Toolkit library. -Uses log4net (Apache 2.0 License)
-Copyright © Apache Software Foundation
+OpenJpegDotNet +Copyright © 2021 Takuya Takuchi and Sjofn LLC -Uses LSL parser from OpenSimulator project (BSD License)
-Copyright © Contributors, http://opensimulator.org/
+Command Line Library +Copyright © 2005-2010 Giacomo Stelluti Scala -Uses TAO OpenGL framework (MIT License)
-Copyright © 2003-2007 Tao Framework Team
-http://www.taoframework.com
-All rights reserved.
+CSAT Library +Copyright © 2011 mjt +http://code.google.com/p/csat/ -Uses artwork files are licenced under the
-Creative Commons Share and Share Alike 3.0
-Copyright © 2002-2009 Linden Research Inc.
+zlib.net +Copyright © 1996-2017 Greg Roelofs, Jean-loup Gailly and Mark Adler. -Command Line Library (MIT License)
-Copyright © 2005 - 2010 Giacomo Stelluti Scala
-http://commandline.codeplex.com/
+AIMLBot +The AIMLBot library (Program#) is a .NET implementation of the AIML standard. +Copyright © 2006 Nicholas H.Tollervey (http://ntoll.org) +http://aimlbot.sourceforge.net/ -Uses code snippets from CSAT Library (MIT License)
-Copyright © 2011 mjt
-http://code.google.com/p/csat/
+SmartIrc4net +Copyright © 2003-2005 Mirco Bauer +http://www.meebey.net/projects/smartirc4net/ -Uses SmartIrc4net (LGPL)
-Copyright © 2003-2005 Mirco Bauer
-http://www.meebey.net/projects/smartirc4net/
+Artwork files are licenced under the +Creative Commons Share and Share Alike 3.0 +Copyright © 2002-2009 Linden Research Inc. diff --git a/Radegast.sln b/Radegast.sln new file mode 100644 index 000000000..e474cc19a --- /dev/null +++ b/Radegast.sln @@ -0,0 +1,362 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29403.142 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Radegast", "Radegast\Radegast.csproj", "{F02F3C44-DCFC-964F-0516-85F7F141CCDD}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Radegast.Plugin.Alice", "plugins\Radegast.Plugin.Alice\Radegast.Plugin.Alice.csproj", "{F9B15290-651E-0E8B-2E12-A6E89A3D30F3}" + ProjectSection(ProjectDependencies) = postProject + {F02F3C44-DCFC-964F-0516-85F7F141CCDD} = {F02F3C44-DCFC-964F-0516-85F7F141CCDD} + {9305ECC4-7FFF-1417-686C-AB2754057B83} = {9305ECC4-7FFF-1417-686C-AB2754057B83} + EndProjectSection +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Radegast.Plugin.SimpleBuilder", "plugins\Radegast.Plugin.SimpleBuilder\Radegast.Plugin.SimpleBuilder.csproj", "{6CADC6BB-D8C5-ADE5-A172-3D7F0D4A427F}" + ProjectSection(ProjectDependencies) = postProject + {F02F3C44-DCFC-964F-0516-85F7F141CCDD} = {F02F3C44-DCFC-964F-0516-85F7F141CCDD} + EndProjectSection +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Radegast.Plugin.IRC", "plugins\Radegast.Plugin.IRC\Radegast.Plugin.IRC.csproj", "{195B1187-85BC-EE94-0E2A-35477A8A2554}" + ProjectSection(ProjectDependencies) = postProject + {F02F3C44-DCFC-964F-0516-85F7F141CCDD} = {F02F3C44-DCFC-964F-0516-85F7F141CCDD} + EndProjectSection +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Radegast.Plugin.Speech", "plugins\Radegast.Plugin.Speech\RadSpeech\Radegast.Plugin.Speech.csproj", "{9305ECC4-7FFF-1417-686C-AB2754057B83}" + ProjectSection(ProjectDependencies) = postProject + {F02F3C44-DCFC-964F-0516-85F7F141CCDD} = {F02F3C44-DCFC-964F-0516-85F7F141CCDD} + EndProjectSection +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RadSpeechLin", "plugins\Radegast.Plugin.Speech\RadSpeechLin\RadSpeechLin.csproj", "{17A48A95-0307-1A3A-AC8C-52F098CEE5BC}" + ProjectSection(ProjectDependencies) = postProject + {F02F3C44-DCFC-964F-0516-85F7F141CCDD} = {F02F3C44-DCFC-964F-0516-85F7F141CCDD} + {9305ECC4-7FFF-1417-686C-AB2754057B83} = {9305ECC4-7FFF-1417-686C-AB2754057B83} + EndProjectSection +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RadSpeechWin", "plugins\Radegast.Plugin.Speech\RadSpeechWin\RadSpeechWin.csproj", "{E2D28A95-CE35-1A3A-77BB-52F063FDE5BC}" + ProjectSection(ProjectDependencies) = postProject + {F02F3C44-DCFC-964F-0516-85F7F141CCDD} = {F02F3C44-DCFC-964F-0516-85F7F141CCDD} + {9305ECC4-7FFF-1417-686C-AB2754057B83} = {9305ECC4-7FFF-1417-686C-AB2754057B83} + EndProjectSection +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RadSpeechMac", "plugins\Radegast.Plugin.Speech\RadSpeechMac\RadSpeechMac.csproj", "{45A78A95-310A-1A3A-DA8F-52F0C6D1E5BC}" + ProjectSection(ProjectDependencies) = postProject + {F02F3C44-DCFC-964F-0516-85F7F141CCDD} = {F02F3C44-DCFC-964F-0516-85F7F141CCDD} + {9305ECC4-7FFF-1417-686C-AB2754057B83} = {9305ECC4-7FFF-1417-686C-AB2754057B83} + EndProjectSection +EndProject +Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "RadegastBundle", "Install\RadegastBundle\RadegastBundle.wixproj", "{CCCC26B5-AA17-47D8-8D5D-707A78EC9A10}" + ProjectSection(ProjectDependencies) = postProject + {0F0271AF-0841-45A5-8737-9239550839B7} = {0F0271AF-0841-45A5-8737-9239550839B7} + EndProjectSection +EndProject +Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "RadegastSetup", "Install\RadegastSetup\RadegastSetup.wixproj", "{0F0271AF-0841-45A5-8737-9239550839B7}" + ProjectSection(ProjectDependencies) = postProject + {195B1187-85BC-EE94-0E2A-35477A8A2554} = {195B1187-85BC-EE94-0E2A-35477A8A2554} + {F9B15290-651E-0E8B-2E12-A6E89A3D30F3} = {F9B15290-651E-0E8B-2E12-A6E89A3D30F3} + {E2D28A95-CE35-1A3A-77BB-52F063FDE5BC} = {E2D28A95-CE35-1A3A-77BB-52F063FDE5BC} + {6CADC6BB-D8C5-ADE5-A172-3D7F0D4A427F} = {6CADC6BB-D8C5-ADE5-A172-3D7F0D4A427F} + {9305ECC4-7FFF-1417-686C-AB2754057B83} = {9305ECC4-7FFF-1417-686C-AB2754057B83} + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{08765E83-89EC-45F8-945B-5A1A8F88C92E}" + ProjectSection(SolutionItems) = preProject + .appveyor.yml = .appveyor.yml + .gitignore = .gitignore + Directory.Build.props = Directory.Build.props + LICENSE.txt = LICENSE.txt + README.md = README.md + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + ReleaseLinux|Any CPU = ReleaseLinux|Any CPU + ReleaseLinux|x64 = ReleaseLinux|x64 + ReleaseLinux|x86 = ReleaseLinux|x86 + ReleaseMacOS|Any CPU = ReleaseMacOS|Any CPU + ReleaseMacOS|x64 = ReleaseMacOS|x64 + ReleaseMacOS|x86 = ReleaseMacOS|x86 + ReleaseWindows|Any CPU = ReleaseWindows|Any CPU + ReleaseWindows|x64 = ReleaseWindows|x64 + ReleaseWindows|x86 = ReleaseWindows|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F02F3C44-DCFC-964F-0516-85F7F141CCDD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F02F3C44-DCFC-964F-0516-85F7F141CCDD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F02F3C44-DCFC-964F-0516-85F7F141CCDD}.Debug|x64.ActiveCfg = Debug|x64 + {F02F3C44-DCFC-964F-0516-85F7F141CCDD}.Debug|x64.Build.0 = Debug|x64 + {F02F3C44-DCFC-964F-0516-85F7F141CCDD}.Debug|x86.ActiveCfg = Debug|x86 + {F02F3C44-DCFC-964F-0516-85F7F141CCDD}.Debug|x86.Build.0 = Debug|x86 + {F02F3C44-DCFC-964F-0516-85F7F141CCDD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F02F3C44-DCFC-964F-0516-85F7F141CCDD}.Release|Any CPU.Build.0 = Release|Any CPU + {F02F3C44-DCFC-964F-0516-85F7F141CCDD}.Release|x64.ActiveCfg = Release|x64 + {F02F3C44-DCFC-964F-0516-85F7F141CCDD}.Release|x64.Build.0 = Release|x64 + {F02F3C44-DCFC-964F-0516-85F7F141CCDD}.Release|x86.ActiveCfg = Release|x86 + {F02F3C44-DCFC-964F-0516-85F7F141CCDD}.Release|x86.Build.0 = Release|x86 + {F02F3C44-DCFC-964F-0516-85F7F141CCDD}.ReleaseLinux|Any CPU.ActiveCfg = Release|Any CPU + {F02F3C44-DCFC-964F-0516-85F7F141CCDD}.ReleaseLinux|Any CPU.Build.0 = Release|Any CPU + {F02F3C44-DCFC-964F-0516-85F7F141CCDD}.ReleaseLinux|x64.ActiveCfg = Release|x64 + {F02F3C44-DCFC-964F-0516-85F7F141CCDD}.ReleaseLinux|x64.Build.0 = Release|x64 + {F02F3C44-DCFC-964F-0516-85F7F141CCDD}.ReleaseLinux|x86.ActiveCfg = Release|x86 + {F02F3C44-DCFC-964F-0516-85F7F141CCDD}.ReleaseLinux|x86.Build.0 = Release|x86 + {F02F3C44-DCFC-964F-0516-85F7F141CCDD}.ReleaseMacOS|Any CPU.ActiveCfg = Release|Any CPU + {F02F3C44-DCFC-964F-0516-85F7F141CCDD}.ReleaseMacOS|Any CPU.Build.0 = Release|Any CPU + {F02F3C44-DCFC-964F-0516-85F7F141CCDD}.ReleaseMacOS|x64.ActiveCfg = Release|x64 + {F02F3C44-DCFC-964F-0516-85F7F141CCDD}.ReleaseMacOS|x64.Build.0 = Release|x64 + {F02F3C44-DCFC-964F-0516-85F7F141CCDD}.ReleaseMacOS|x86.ActiveCfg = Release|x86 + {F02F3C44-DCFC-964F-0516-85F7F141CCDD}.ReleaseMacOS|x86.Build.0 = Release|x86 + {F02F3C44-DCFC-964F-0516-85F7F141CCDD}.ReleaseWindows|Any CPU.ActiveCfg = Release|Any CPU + {F02F3C44-DCFC-964F-0516-85F7F141CCDD}.ReleaseWindows|Any CPU.Build.0 = Release|Any CPU + {F02F3C44-DCFC-964F-0516-85F7F141CCDD}.ReleaseWindows|x64.ActiveCfg = Release|x64 + {F02F3C44-DCFC-964F-0516-85F7F141CCDD}.ReleaseWindows|x64.Build.0 = Release|x64 + {F02F3C44-DCFC-964F-0516-85F7F141CCDD}.ReleaseWindows|x86.ActiveCfg = Release|x86 + {F02F3C44-DCFC-964F-0516-85F7F141CCDD}.ReleaseWindows|x86.Build.0 = Release|x86 + {F9B15290-651E-0E8B-2E12-A6E89A3D30F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F9B15290-651E-0E8B-2E12-A6E89A3D30F3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F9B15290-651E-0E8B-2E12-A6E89A3D30F3}.Debug|x64.ActiveCfg = Debug|x64 + {F9B15290-651E-0E8B-2E12-A6E89A3D30F3}.Debug|x64.Build.0 = Debug|x64 + {F9B15290-651E-0E8B-2E12-A6E89A3D30F3}.Debug|x86.ActiveCfg = Debug|x86 + {F9B15290-651E-0E8B-2E12-A6E89A3D30F3}.Debug|x86.Build.0 = Debug|x86 + {F9B15290-651E-0E8B-2E12-A6E89A3D30F3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F9B15290-651E-0E8B-2E12-A6E89A3D30F3}.Release|Any CPU.Build.0 = Release|Any CPU + {F9B15290-651E-0E8B-2E12-A6E89A3D30F3}.Release|x64.ActiveCfg = Release|x64 + {F9B15290-651E-0E8B-2E12-A6E89A3D30F3}.Release|x64.Build.0 = Release|x64 + {F9B15290-651E-0E8B-2E12-A6E89A3D30F3}.Release|x86.ActiveCfg = Release|x86 + {F9B15290-651E-0E8B-2E12-A6E89A3D30F3}.Release|x86.Build.0 = Release|x86 + {F9B15290-651E-0E8B-2E12-A6E89A3D30F3}.ReleaseLinux|Any CPU.ActiveCfg = Release|Any CPU + {F9B15290-651E-0E8B-2E12-A6E89A3D30F3}.ReleaseLinux|Any CPU.Build.0 = Release|Any CPU + {F9B15290-651E-0E8B-2E12-A6E89A3D30F3}.ReleaseLinux|x64.ActiveCfg = Release|x64 + {F9B15290-651E-0E8B-2E12-A6E89A3D30F3}.ReleaseLinux|x64.Build.0 = Release|x64 + {F9B15290-651E-0E8B-2E12-A6E89A3D30F3}.ReleaseLinux|x86.ActiveCfg = Release|x86 + {F9B15290-651E-0E8B-2E12-A6E89A3D30F3}.ReleaseLinux|x86.Build.0 = Release|x86 + {F9B15290-651E-0E8B-2E12-A6E89A3D30F3}.ReleaseMacOS|Any CPU.ActiveCfg = Release|Any CPU + {F9B15290-651E-0E8B-2E12-A6E89A3D30F3}.ReleaseMacOS|Any CPU.Build.0 = Release|Any CPU + {F9B15290-651E-0E8B-2E12-A6E89A3D30F3}.ReleaseMacOS|x64.ActiveCfg = Release|x64 + {F9B15290-651E-0E8B-2E12-A6E89A3D30F3}.ReleaseMacOS|x64.Build.0 = Release|x64 + {F9B15290-651E-0E8B-2E12-A6E89A3D30F3}.ReleaseMacOS|x86.ActiveCfg = Release|x86 + {F9B15290-651E-0E8B-2E12-A6E89A3D30F3}.ReleaseMacOS|x86.Build.0 = Release|x86 + {F9B15290-651E-0E8B-2E12-A6E89A3D30F3}.ReleaseWindows|Any CPU.ActiveCfg = Release|Any CPU + {F9B15290-651E-0E8B-2E12-A6E89A3D30F3}.ReleaseWindows|Any CPU.Build.0 = Release|Any CPU + {F9B15290-651E-0E8B-2E12-A6E89A3D30F3}.ReleaseWindows|x64.ActiveCfg = Release|x64 + {F9B15290-651E-0E8B-2E12-A6E89A3D30F3}.ReleaseWindows|x64.Build.0 = Release|x64 + {F9B15290-651E-0E8B-2E12-A6E89A3D30F3}.ReleaseWindows|x86.ActiveCfg = Release|x86 + {F9B15290-651E-0E8B-2E12-A6E89A3D30F3}.ReleaseWindows|x86.Build.0 = Release|x86 + {6CADC6BB-D8C5-ADE5-A172-3D7F0D4A427F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6CADC6BB-D8C5-ADE5-A172-3D7F0D4A427F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6CADC6BB-D8C5-ADE5-A172-3D7F0D4A427F}.Debug|x64.ActiveCfg = Debug|x64 + {6CADC6BB-D8C5-ADE5-A172-3D7F0D4A427F}.Debug|x64.Build.0 = Debug|x64 + {6CADC6BB-D8C5-ADE5-A172-3D7F0D4A427F}.Debug|x86.ActiveCfg = Debug|x86 + {6CADC6BB-D8C5-ADE5-A172-3D7F0D4A427F}.Debug|x86.Build.0 = Debug|x86 + {6CADC6BB-D8C5-ADE5-A172-3D7F0D4A427F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6CADC6BB-D8C5-ADE5-A172-3D7F0D4A427F}.Release|Any CPU.Build.0 = Release|Any CPU + {6CADC6BB-D8C5-ADE5-A172-3D7F0D4A427F}.Release|x64.ActiveCfg = Release|x64 + {6CADC6BB-D8C5-ADE5-A172-3D7F0D4A427F}.Release|x64.Build.0 = Release|x64 + {6CADC6BB-D8C5-ADE5-A172-3D7F0D4A427F}.Release|x86.ActiveCfg = Release|x86 + {6CADC6BB-D8C5-ADE5-A172-3D7F0D4A427F}.Release|x86.Build.0 = Release|x86 + {6CADC6BB-D8C5-ADE5-A172-3D7F0D4A427F}.ReleaseLinux|Any CPU.ActiveCfg = Release|Any CPU + {6CADC6BB-D8C5-ADE5-A172-3D7F0D4A427F}.ReleaseLinux|Any CPU.Build.0 = Release|Any CPU + {6CADC6BB-D8C5-ADE5-A172-3D7F0D4A427F}.ReleaseLinux|x64.ActiveCfg = Release|x64 + {6CADC6BB-D8C5-ADE5-A172-3D7F0D4A427F}.ReleaseLinux|x64.Build.0 = Release|x64 + {6CADC6BB-D8C5-ADE5-A172-3D7F0D4A427F}.ReleaseLinux|x86.ActiveCfg = Release|x86 + {6CADC6BB-D8C5-ADE5-A172-3D7F0D4A427F}.ReleaseLinux|x86.Build.0 = Release|x86 + {6CADC6BB-D8C5-ADE5-A172-3D7F0D4A427F}.ReleaseMacOS|Any CPU.ActiveCfg = Release|Any CPU + {6CADC6BB-D8C5-ADE5-A172-3D7F0D4A427F}.ReleaseMacOS|Any CPU.Build.0 = Release|Any CPU + {6CADC6BB-D8C5-ADE5-A172-3D7F0D4A427F}.ReleaseMacOS|x64.ActiveCfg = Release|x64 + {6CADC6BB-D8C5-ADE5-A172-3D7F0D4A427F}.ReleaseMacOS|x64.Build.0 = Release|x64 + {6CADC6BB-D8C5-ADE5-A172-3D7F0D4A427F}.ReleaseMacOS|x86.ActiveCfg = Release|x86 + {6CADC6BB-D8C5-ADE5-A172-3D7F0D4A427F}.ReleaseMacOS|x86.Build.0 = Release|x86 + {6CADC6BB-D8C5-ADE5-A172-3D7F0D4A427F}.ReleaseWindows|Any CPU.ActiveCfg = Release|Any CPU + {6CADC6BB-D8C5-ADE5-A172-3D7F0D4A427F}.ReleaseWindows|Any CPU.Build.0 = Release|Any CPU + {6CADC6BB-D8C5-ADE5-A172-3D7F0D4A427F}.ReleaseWindows|x64.ActiveCfg = Release|x64 + {6CADC6BB-D8C5-ADE5-A172-3D7F0D4A427F}.ReleaseWindows|x64.Build.0 = Release|x64 + {6CADC6BB-D8C5-ADE5-A172-3D7F0D4A427F}.ReleaseWindows|x86.ActiveCfg = Release|x86 + {6CADC6BB-D8C5-ADE5-A172-3D7F0D4A427F}.ReleaseWindows|x86.Build.0 = Release|x86 + {195B1187-85BC-EE94-0E2A-35477A8A2554}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {195B1187-85BC-EE94-0E2A-35477A8A2554}.Debug|Any CPU.Build.0 = Debug|Any CPU + {195B1187-85BC-EE94-0E2A-35477A8A2554}.Debug|x64.ActiveCfg = Debug|x64 + {195B1187-85BC-EE94-0E2A-35477A8A2554}.Debug|x64.Build.0 = Debug|x64 + {195B1187-85BC-EE94-0E2A-35477A8A2554}.Debug|x86.ActiveCfg = Debug|x86 + {195B1187-85BC-EE94-0E2A-35477A8A2554}.Debug|x86.Build.0 = Debug|x86 + {195B1187-85BC-EE94-0E2A-35477A8A2554}.Release|Any CPU.ActiveCfg = Release|Any CPU + {195B1187-85BC-EE94-0E2A-35477A8A2554}.Release|Any CPU.Build.0 = Release|Any CPU + {195B1187-85BC-EE94-0E2A-35477A8A2554}.Release|x64.ActiveCfg = Release|x64 + {195B1187-85BC-EE94-0E2A-35477A8A2554}.Release|x64.Build.0 = Release|x64 + {195B1187-85BC-EE94-0E2A-35477A8A2554}.Release|x86.ActiveCfg = Release|x86 + {195B1187-85BC-EE94-0E2A-35477A8A2554}.Release|x86.Build.0 = Release|x86 + {195B1187-85BC-EE94-0E2A-35477A8A2554}.ReleaseLinux|Any CPU.ActiveCfg = Release|Any CPU + {195B1187-85BC-EE94-0E2A-35477A8A2554}.ReleaseLinux|Any CPU.Build.0 = Release|Any CPU + {195B1187-85BC-EE94-0E2A-35477A8A2554}.ReleaseLinux|x64.ActiveCfg = Release|x64 + {195B1187-85BC-EE94-0E2A-35477A8A2554}.ReleaseLinux|x64.Build.0 = Release|x64 + {195B1187-85BC-EE94-0E2A-35477A8A2554}.ReleaseLinux|x86.ActiveCfg = Release|x86 + {195B1187-85BC-EE94-0E2A-35477A8A2554}.ReleaseLinux|x86.Build.0 = Release|x86 + {195B1187-85BC-EE94-0E2A-35477A8A2554}.ReleaseMacOS|Any CPU.ActiveCfg = Release|Any CPU + {195B1187-85BC-EE94-0E2A-35477A8A2554}.ReleaseMacOS|Any CPU.Build.0 = Release|Any CPU + {195B1187-85BC-EE94-0E2A-35477A8A2554}.ReleaseMacOS|x64.ActiveCfg = Release|x64 + {195B1187-85BC-EE94-0E2A-35477A8A2554}.ReleaseMacOS|x64.Build.0 = Release|x64 + {195B1187-85BC-EE94-0E2A-35477A8A2554}.ReleaseMacOS|x86.ActiveCfg = Release|x86 + {195B1187-85BC-EE94-0E2A-35477A8A2554}.ReleaseMacOS|x86.Build.0 = Release|x86 + {195B1187-85BC-EE94-0E2A-35477A8A2554}.ReleaseWindows|Any CPU.ActiveCfg = Release|Any CPU + {195B1187-85BC-EE94-0E2A-35477A8A2554}.ReleaseWindows|Any CPU.Build.0 = Release|Any CPU + {195B1187-85BC-EE94-0E2A-35477A8A2554}.ReleaseWindows|x64.ActiveCfg = Release|x64 + {195B1187-85BC-EE94-0E2A-35477A8A2554}.ReleaseWindows|x64.Build.0 = Release|x64 + {195B1187-85BC-EE94-0E2A-35477A8A2554}.ReleaseWindows|x86.ActiveCfg = Release|x86 + {195B1187-85BC-EE94-0E2A-35477A8A2554}.ReleaseWindows|x86.Build.0 = Release|x86 + {9305ECC4-7FFF-1417-686C-AB2754057B83}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9305ECC4-7FFF-1417-686C-AB2754057B83}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9305ECC4-7FFF-1417-686C-AB2754057B83}.Debug|x64.ActiveCfg = Debug|x64 + {9305ECC4-7FFF-1417-686C-AB2754057B83}.Debug|x64.Build.0 = Debug|x64 + {9305ECC4-7FFF-1417-686C-AB2754057B83}.Debug|x86.ActiveCfg = Debug|x86 + {9305ECC4-7FFF-1417-686C-AB2754057B83}.Debug|x86.Build.0 = Debug|x86 + {9305ECC4-7FFF-1417-686C-AB2754057B83}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9305ECC4-7FFF-1417-686C-AB2754057B83}.Release|Any CPU.Build.0 = Release|Any CPU + {9305ECC4-7FFF-1417-686C-AB2754057B83}.Release|x64.ActiveCfg = Release|x64 + {9305ECC4-7FFF-1417-686C-AB2754057B83}.Release|x64.Build.0 = Release|x64 + {9305ECC4-7FFF-1417-686C-AB2754057B83}.Release|x86.ActiveCfg = Release|x86 + {9305ECC4-7FFF-1417-686C-AB2754057B83}.Release|x86.Build.0 = Release|x86 + {9305ECC4-7FFF-1417-686C-AB2754057B83}.ReleaseLinux|Any CPU.ActiveCfg = Release|Any CPU + {9305ECC4-7FFF-1417-686C-AB2754057B83}.ReleaseLinux|Any CPU.Build.0 = Release|Any CPU + {9305ECC4-7FFF-1417-686C-AB2754057B83}.ReleaseLinux|x64.ActiveCfg = Release|x64 + {9305ECC4-7FFF-1417-686C-AB2754057B83}.ReleaseLinux|x64.Build.0 = Release|x64 + {9305ECC4-7FFF-1417-686C-AB2754057B83}.ReleaseLinux|x86.ActiveCfg = Release|x86 + {9305ECC4-7FFF-1417-686C-AB2754057B83}.ReleaseLinux|x86.Build.0 = Release|x86 + {9305ECC4-7FFF-1417-686C-AB2754057B83}.ReleaseMacOS|Any CPU.ActiveCfg = Release|Any CPU + {9305ECC4-7FFF-1417-686C-AB2754057B83}.ReleaseMacOS|Any CPU.Build.0 = Release|Any CPU + {9305ECC4-7FFF-1417-686C-AB2754057B83}.ReleaseMacOS|x64.ActiveCfg = Release|x64 + {9305ECC4-7FFF-1417-686C-AB2754057B83}.ReleaseMacOS|x64.Build.0 = Release|x64 + {9305ECC4-7FFF-1417-686C-AB2754057B83}.ReleaseMacOS|x86.ActiveCfg = Release|x86 + {9305ECC4-7FFF-1417-686C-AB2754057B83}.ReleaseMacOS|x86.Build.0 = Release|x86 + {9305ECC4-7FFF-1417-686C-AB2754057B83}.ReleaseWindows|Any CPU.ActiveCfg = Release|Any CPU + {9305ECC4-7FFF-1417-686C-AB2754057B83}.ReleaseWindows|Any CPU.Build.0 = Release|Any CPU + {9305ECC4-7FFF-1417-686C-AB2754057B83}.ReleaseWindows|x64.ActiveCfg = Release|x64 + {9305ECC4-7FFF-1417-686C-AB2754057B83}.ReleaseWindows|x64.Build.0 = Release|x64 + {9305ECC4-7FFF-1417-686C-AB2754057B83}.ReleaseWindows|x86.ActiveCfg = Release|x86 + {9305ECC4-7FFF-1417-686C-AB2754057B83}.ReleaseWindows|x86.Build.0 = Release|x86 + {17A48A95-0307-1A3A-AC8C-52F098CEE5BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {17A48A95-0307-1A3A-AC8C-52F098CEE5BC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {17A48A95-0307-1A3A-AC8C-52F098CEE5BC}.Debug|x64.ActiveCfg = Debug|x64 + {17A48A95-0307-1A3A-AC8C-52F098CEE5BC}.Debug|x64.Build.0 = Debug|x64 + {17A48A95-0307-1A3A-AC8C-52F098CEE5BC}.Debug|x86.ActiveCfg = Debug|x86 + {17A48A95-0307-1A3A-AC8C-52F098CEE5BC}.Debug|x86.Build.0 = Debug|x86 + {17A48A95-0307-1A3A-AC8C-52F098CEE5BC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {17A48A95-0307-1A3A-AC8C-52F098CEE5BC}.Release|Any CPU.Build.0 = Release|Any CPU + {17A48A95-0307-1A3A-AC8C-52F098CEE5BC}.Release|x64.ActiveCfg = Release|x64 + {17A48A95-0307-1A3A-AC8C-52F098CEE5BC}.Release|x64.Build.0 = Release|x64 + {17A48A95-0307-1A3A-AC8C-52F098CEE5BC}.Release|x86.ActiveCfg = Release|x86 + {17A48A95-0307-1A3A-AC8C-52F098CEE5BC}.Release|x86.Build.0 = Release|x86 + {17A48A95-0307-1A3A-AC8C-52F098CEE5BC}.ReleaseLinux|Any CPU.ActiveCfg = Release|Any CPU + {17A48A95-0307-1A3A-AC8C-52F098CEE5BC}.ReleaseLinux|Any CPU.Build.0 = Release|Any CPU + {17A48A95-0307-1A3A-AC8C-52F098CEE5BC}.ReleaseLinux|x64.ActiveCfg = Release|x64 + {17A48A95-0307-1A3A-AC8C-52F098CEE5BC}.ReleaseLinux|x64.Build.0 = Release|x64 + {17A48A95-0307-1A3A-AC8C-52F098CEE5BC}.ReleaseLinux|x86.ActiveCfg = Release|x86 + {17A48A95-0307-1A3A-AC8C-52F098CEE5BC}.ReleaseLinux|x86.Build.0 = Release|x86 + {17A48A95-0307-1A3A-AC8C-52F098CEE5BC}.ReleaseMacOS|Any CPU.ActiveCfg = Release|Any CPU + {17A48A95-0307-1A3A-AC8C-52F098CEE5BC}.ReleaseMacOS|Any CPU.Build.0 = Release|Any CPU + {17A48A95-0307-1A3A-AC8C-52F098CEE5BC}.ReleaseMacOS|x64.ActiveCfg = Release|x64 + {17A48A95-0307-1A3A-AC8C-52F098CEE5BC}.ReleaseMacOS|x86.ActiveCfg = Release|x86 + {17A48A95-0307-1A3A-AC8C-52F098CEE5BC}.ReleaseWindows|Any CPU.ActiveCfg = Release|Any CPU + {17A48A95-0307-1A3A-AC8C-52F098CEE5BC}.ReleaseWindows|Any CPU.Build.0 = Release|Any CPU + {17A48A95-0307-1A3A-AC8C-52F098CEE5BC}.ReleaseWindows|x64.ActiveCfg = Release|x64 + {17A48A95-0307-1A3A-AC8C-52F098CEE5BC}.ReleaseWindows|x86.ActiveCfg = Release|x86 + {E2D28A95-CE35-1A3A-77BB-52F063FDE5BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E2D28A95-CE35-1A3A-77BB-52F063FDE5BC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E2D28A95-CE35-1A3A-77BB-52F063FDE5BC}.Debug|x64.ActiveCfg = Debug|x64 + {E2D28A95-CE35-1A3A-77BB-52F063FDE5BC}.Debug|x64.Build.0 = Debug|x64 + {E2D28A95-CE35-1A3A-77BB-52F063FDE5BC}.Debug|x86.ActiveCfg = Debug|x86 + {E2D28A95-CE35-1A3A-77BB-52F063FDE5BC}.Debug|x86.Build.0 = Debug|x86 + {E2D28A95-CE35-1A3A-77BB-52F063FDE5BC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E2D28A95-CE35-1A3A-77BB-52F063FDE5BC}.Release|Any CPU.Build.0 = Release|Any CPU + {E2D28A95-CE35-1A3A-77BB-52F063FDE5BC}.Release|x64.ActiveCfg = Release|x64 + {E2D28A95-CE35-1A3A-77BB-52F063FDE5BC}.Release|x64.Build.0 = Release|x64 + {E2D28A95-CE35-1A3A-77BB-52F063FDE5BC}.Release|x86.ActiveCfg = Release|x86 + {E2D28A95-CE35-1A3A-77BB-52F063FDE5BC}.Release|x86.Build.0 = Release|x86 + {E2D28A95-CE35-1A3A-77BB-52F063FDE5BC}.ReleaseLinux|Any CPU.ActiveCfg = Release|Any CPU + {E2D28A95-CE35-1A3A-77BB-52F063FDE5BC}.ReleaseLinux|Any CPU.Build.0 = Release|Any CPU + {E2D28A95-CE35-1A3A-77BB-52F063FDE5BC}.ReleaseLinux|x64.ActiveCfg = Release|x64 + {E2D28A95-CE35-1A3A-77BB-52F063FDE5BC}.ReleaseLinux|x86.ActiveCfg = Release|x86 + {E2D28A95-CE35-1A3A-77BB-52F063FDE5BC}.ReleaseMacOS|Any CPU.ActiveCfg = Release|Any CPU + {E2D28A95-CE35-1A3A-77BB-52F063FDE5BC}.ReleaseMacOS|Any CPU.Build.0 = Release|Any CPU + {E2D28A95-CE35-1A3A-77BB-52F063FDE5BC}.ReleaseMacOS|x64.ActiveCfg = Release|x64 + {E2D28A95-CE35-1A3A-77BB-52F063FDE5BC}.ReleaseMacOS|x86.ActiveCfg = Release|x86 + {E2D28A95-CE35-1A3A-77BB-52F063FDE5BC}.ReleaseWindows|Any CPU.ActiveCfg = Release|Any CPU + {E2D28A95-CE35-1A3A-77BB-52F063FDE5BC}.ReleaseWindows|Any CPU.Build.0 = Release|Any CPU + {E2D28A95-CE35-1A3A-77BB-52F063FDE5BC}.ReleaseWindows|x64.ActiveCfg = Release|x64 + {E2D28A95-CE35-1A3A-77BB-52F063FDE5BC}.ReleaseWindows|x64.Build.0 = Release|x64 + {E2D28A95-CE35-1A3A-77BB-52F063FDE5BC}.ReleaseWindows|x86.ActiveCfg = Release|x86 + {E2D28A95-CE35-1A3A-77BB-52F063FDE5BC}.ReleaseWindows|x86.Build.0 = Release|x86 + {45A78A95-310A-1A3A-DA8F-52F0C6D1E5BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {45A78A95-310A-1A3A-DA8F-52F0C6D1E5BC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {45A78A95-310A-1A3A-DA8F-52F0C6D1E5BC}.Debug|x64.ActiveCfg = Debug|x64 + {45A78A95-310A-1A3A-DA8F-52F0C6D1E5BC}.Debug|x64.Build.0 = Debug|x64 + {45A78A95-310A-1A3A-DA8F-52F0C6D1E5BC}.Debug|x86.ActiveCfg = Debug|x86 + {45A78A95-310A-1A3A-DA8F-52F0C6D1E5BC}.Debug|x86.Build.0 = Debug|x86 + {45A78A95-310A-1A3A-DA8F-52F0C6D1E5BC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {45A78A95-310A-1A3A-DA8F-52F0C6D1E5BC}.Release|Any CPU.Build.0 = Release|Any CPU + {45A78A95-310A-1A3A-DA8F-52F0C6D1E5BC}.Release|x64.ActiveCfg = Release|x64 + {45A78A95-310A-1A3A-DA8F-52F0C6D1E5BC}.Release|x64.Build.0 = Release|x64 + {45A78A95-310A-1A3A-DA8F-52F0C6D1E5BC}.Release|x86.ActiveCfg = Release|x86 + {45A78A95-310A-1A3A-DA8F-52F0C6D1E5BC}.Release|x86.Build.0 = Release|x86 + {45A78A95-310A-1A3A-DA8F-52F0C6D1E5BC}.ReleaseLinux|Any CPU.ActiveCfg = Release|Any CPU + {45A78A95-310A-1A3A-DA8F-52F0C6D1E5BC}.ReleaseLinux|Any CPU.Build.0 = Release|Any CPU + {45A78A95-310A-1A3A-DA8F-52F0C6D1E5BC}.ReleaseLinux|x64.ActiveCfg = Release|x64 + {45A78A95-310A-1A3A-DA8F-52F0C6D1E5BC}.ReleaseLinux|x86.ActiveCfg = Release|x86 + {45A78A95-310A-1A3A-DA8F-52F0C6D1E5BC}.ReleaseMacOS|Any CPU.ActiveCfg = Release|Any CPU + {45A78A95-310A-1A3A-DA8F-52F0C6D1E5BC}.ReleaseMacOS|Any CPU.Build.0 = Release|Any CPU + {45A78A95-310A-1A3A-DA8F-52F0C6D1E5BC}.ReleaseMacOS|x64.ActiveCfg = Release|x64 + {45A78A95-310A-1A3A-DA8F-52F0C6D1E5BC}.ReleaseMacOS|x64.Build.0 = Release|x64 + {45A78A95-310A-1A3A-DA8F-52F0C6D1E5BC}.ReleaseMacOS|x86.ActiveCfg = Release|x86 + {45A78A95-310A-1A3A-DA8F-52F0C6D1E5BC}.ReleaseMacOS|x86.Build.0 = Release|x86 + {45A78A95-310A-1A3A-DA8F-52F0C6D1E5BC}.ReleaseWindows|Any CPU.ActiveCfg = Release|Any CPU + {45A78A95-310A-1A3A-DA8F-52F0C6D1E5BC}.ReleaseWindows|Any CPU.Build.0 = Release|Any CPU + {45A78A95-310A-1A3A-DA8F-52F0C6D1E5BC}.ReleaseWindows|x64.ActiveCfg = Release|x64 + {45A78A95-310A-1A3A-DA8F-52F0C6D1E5BC}.ReleaseWindows|x86.ActiveCfg = Release|x86 + {CCCC26B5-AA17-47D8-8D5D-707A78EC9A10}.Debug|Any CPU.ActiveCfg = Release|x86 + {CCCC26B5-AA17-47D8-8D5D-707A78EC9A10}.Debug|x64.ActiveCfg = Release|x64 + {CCCC26B5-AA17-47D8-8D5D-707A78EC9A10}.Debug|x86.ActiveCfg = Release|x86 + {CCCC26B5-AA17-47D8-8D5D-707A78EC9A10}.Release|Any CPU.ActiveCfg = Release|x86 + {CCCC26B5-AA17-47D8-8D5D-707A78EC9A10}.Release|x64.ActiveCfg = Release|x86 + {CCCC26B5-AA17-47D8-8D5D-707A78EC9A10}.Release|x86.ActiveCfg = Release|x86 + {CCCC26B5-AA17-47D8-8D5D-707A78EC9A10}.ReleaseLinux|Any CPU.ActiveCfg = Release|x64 + {CCCC26B5-AA17-47D8-8D5D-707A78EC9A10}.ReleaseLinux|Any CPU.Build.0 = Release|x64 + {CCCC26B5-AA17-47D8-8D5D-707A78EC9A10}.ReleaseLinux|x64.ActiveCfg = ReleaseWindows|x86 + {CCCC26B5-AA17-47D8-8D5D-707A78EC9A10}.ReleaseLinux|x86.ActiveCfg = ReleaseWindows|x86 + {CCCC26B5-AA17-47D8-8D5D-707A78EC9A10}.ReleaseMacOS|Any CPU.ActiveCfg = Release|x64 + {CCCC26B5-AA17-47D8-8D5D-707A78EC9A10}.ReleaseMacOS|Any CPU.Build.0 = Release|x64 + {CCCC26B5-AA17-47D8-8D5D-707A78EC9A10}.ReleaseMacOS|x64.ActiveCfg = ReleaseWindows|x86 + {CCCC26B5-AA17-47D8-8D5D-707A78EC9A10}.ReleaseMacOS|x86.ActiveCfg = ReleaseWindows|x86 + {CCCC26B5-AA17-47D8-8D5D-707A78EC9A10}.ReleaseWindows|Any CPU.ActiveCfg = ReleaseWindows|x86 + {CCCC26B5-AA17-47D8-8D5D-707A78EC9A10}.ReleaseWindows|x64.ActiveCfg = ReleaseWindows|x64 + {CCCC26B5-AA17-47D8-8D5D-707A78EC9A10}.ReleaseWindows|x64.Build.0 = ReleaseWindows|x64 + {CCCC26B5-AA17-47D8-8D5D-707A78EC9A10}.ReleaseWindows|x86.ActiveCfg = ReleaseWindows|x86 + {CCCC26B5-AA17-47D8-8D5D-707A78EC9A10}.ReleaseWindows|x86.Build.0 = ReleaseWindows|x86 + {0F0271AF-0841-45A5-8737-9239550839B7}.Debug|Any CPU.ActiveCfg = Release|x86 + {0F0271AF-0841-45A5-8737-9239550839B7}.Debug|x64.ActiveCfg = Release|x64 + {0F0271AF-0841-45A5-8737-9239550839B7}.Debug|x86.ActiveCfg = Release|x86 + {0F0271AF-0841-45A5-8737-9239550839B7}.Release|Any CPU.ActiveCfg = Release|x86 + {0F0271AF-0841-45A5-8737-9239550839B7}.Release|x64.ActiveCfg = Release|x86 + {0F0271AF-0841-45A5-8737-9239550839B7}.Release|x86.ActiveCfg = Release|x86 + {0F0271AF-0841-45A5-8737-9239550839B7}.ReleaseLinux|Any CPU.ActiveCfg = Release|x64 + {0F0271AF-0841-45A5-8737-9239550839B7}.ReleaseLinux|Any CPU.Build.0 = Release|x64 + {0F0271AF-0841-45A5-8737-9239550839B7}.ReleaseLinux|x64.ActiveCfg = ReleaseWindows|x86 + {0F0271AF-0841-45A5-8737-9239550839B7}.ReleaseLinux|x86.ActiveCfg = ReleaseWindows|x86 + {0F0271AF-0841-45A5-8737-9239550839B7}.ReleaseMacOS|Any CPU.ActiveCfg = Release|x64 + {0F0271AF-0841-45A5-8737-9239550839B7}.ReleaseMacOS|Any CPU.Build.0 = Release|x64 + {0F0271AF-0841-45A5-8737-9239550839B7}.ReleaseMacOS|x64.ActiveCfg = ReleaseWindows|x86 + {0F0271AF-0841-45A5-8737-9239550839B7}.ReleaseMacOS|x86.ActiveCfg = ReleaseWindows|x86 + {0F0271AF-0841-45A5-8737-9239550839B7}.ReleaseWindows|Any CPU.ActiveCfg = ReleaseWindows|x86 + {0F0271AF-0841-45A5-8737-9239550839B7}.ReleaseWindows|x64.ActiveCfg = ReleaseWindows|x64 + {0F0271AF-0841-45A5-8737-9239550839B7}.ReleaseWindows|x64.Build.0 = ReleaseWindows|x64 + {0F0271AF-0841-45A5-8737-9239550839B7}.ReleaseWindows|x86.ActiveCfg = ReleaseWindows|x86 + {0F0271AF-0841-45A5-8737-9239550839B7}.ReleaseWindows|x86.Build.0 = ReleaseWindows|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {826CED37-F899-43A9-8117-21878E146F81} + EndGlobalSection +EndGlobal diff --git a/Radegast.sln.DotSettings b/Radegast.sln.DotSettings new file mode 100644 index 000000000..6e6a5b166 --- /dev/null +++ b/Radegast.sln.DotSettings @@ -0,0 +1,7 @@ + + True + True + True + True + True + True \ No newline at end of file diff --git a/Radegast/AutogenerateFiles.targets b/Radegast/AutogenerateFiles.targets new file mode 100644 index 000000000..4b1c4de89 --- /dev/null +++ b/Radegast/AutogenerateFiles.targets @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Radegast/Automation/AutoSit.cs b/Radegast/Automation/AutoSit.cs index 2f1e452fa..e4aef4da4 100644 --- a/Radegast/Automation/AutoSit.cs +++ b/Radegast/Automation/AutoSit.cs @@ -1,35 +1,24 @@ -// -// Radegast Metaverse Client -//Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Timers; using OpenMetaverse; @@ -50,13 +39,12 @@ public static explicit operator AutoSitPreferences(OSD osd){ PrimitiveName = "" }; - if (osd != null && osd.Type == OSDType.Map) - { - OSDMap map = (OSDMap)osd; - prefs.Primitive = map.ContainsKey("Primitive") ? map["Primitive"].AsUUID() : UUID.Zero; - prefs.PrimitiveName = prefs.Primitive != UUID.Zero && map.ContainsKey("PrimitiveName") ? map["PrimitiveName"].AsString() : ""; - prefs.Enabled = map.ContainsKey("Enabled") ? map["Enabled"].AsBoolean() : false; - } + if (osd == null || osd.Type != OSDType.Map) return prefs; + + OSDMap map = (OSDMap)osd; + prefs.Primitive = map.ContainsKey("Primitive") ? map["Primitive"].AsUUID() : UUID.Zero; + prefs.PrimitiveName = prefs.Primitive != UUID.Zero && map.ContainsKey("PrimitiveName") ? map["PrimitiveName"].AsString() : ""; + prefs.Enabled = map.ContainsKey("Enabled") && map["Enabled"].AsBoolean(); return prefs; } @@ -67,11 +55,13 @@ public static implicit operator OSD(AutoSitPreferences prefs){ public static explicit operator OSDMap(AutoSitPreferences prefs) { - OSDMap map = new OSDMap(3); + OSDMap map = new OSDMap(3) + { + ["Primitive"] = prefs.Primitive, + ["PrimitiveName"] = prefs.PrimitiveName, + ["Enabled"] = prefs.Enabled + }; - map["Primitive"] = prefs.Primitive; - map["PrimitiveName"] = prefs.PrimitiveName; - map["Enabled"] = prefs.Enabled; return map; } @@ -92,9 +82,9 @@ public AutoSit(RadegastInstance instance) { m_instance = instance; m_Timer = new Timer(10 * 1000); - m_Timer.Elapsed += new ElapsedEventHandler((sender, args) => { + m_Timer.Elapsed += (sender, args) => { TrySit(); - }); + }; m_Timer.Enabled = false; } @@ -110,7 +100,7 @@ public void Dispose() public AutoSitPreferences Preferences { - get { return !m_instance.Client.Network.Connected ? null : (AutoSitPreferences)m_instance.ClientSettings; } + get => !m_instance.Client.Network.Connected ? null : (AutoSitPreferences)m_instance.ClientSettings; set { m_instance.ClientSettings["AutoSit"] = value; @@ -143,17 +133,16 @@ public void PrimitiveContextAction(object sender, EventArgs e) public void Objects_ObjectProperties(object sender, ObjectPropertiesEventArgs e) { - if (e.Properties.ObjectID == Preferences.Primitive) + if (e.Properties.ObjectID != Preferences.Primitive) return; + + Preferences = new AutoSitPreferences { - Preferences = new AutoSitPreferences - { - Primitive = Preferences.Primitive, - PrimitiveName = e.Properties.Name, - Enabled = Preferences.Enabled - }; + Primitive = Preferences.Primitive, + PrimitiveName = e.Properties.Name, + Enabled = Preferences.Enabled + }; - m_instance.Client.Objects.ObjectProperties -= Objects_ObjectProperties; - } + m_instance.Client.Objects.ObjectProperties -= Objects_ObjectProperties; } public void TrySit() diff --git a/Radegast/Automation/LSLHelper.cs b/Radegast/Automation/LSLHelper.cs index 877fd0af0..8e135c576 100644 --- a/Radegast/Automation/LSLHelper.cs +++ b/Radegast/Automation/LSLHelper.cs @@ -1,36 +1,25 @@ -// -// Radegast Metaverse Client -//Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows.Forms; using System.Threading; using OpenMetaverse; @@ -41,17 +30,15 @@ namespace Radegast.Automation public class LSLHelper : IDisposable { public bool Enabled; - public UUID AllowedOwner; + public HashSet AllowedOwners; RadegastInstance instance; - GridClient client - { - get { return instance.Client; } - } + GridClient client => instance.Client; public LSLHelper(RadegastInstance instance) { this.instance = instance; + AllowedOwners = new HashSet(StringComparer.OrdinalIgnoreCase); } public void Dispose() @@ -67,7 +54,12 @@ public void LoadSettings() return; OSDMap map = (OSDMap)instance.ClientSettings["LSLHelper"]; Enabled = map["enabled"]; - AllowedOwner = map["allowed_owner"]; + AllowedOwners.Clear(); + var allowedOwnerList = map["allowed_owner"].AsString(); + if (!string.IsNullOrWhiteSpace(allowedOwnerList)) + { + AllowedOwners.UnionWith(allowedOwnerList.Split(';')); + } } catch { } } @@ -77,9 +69,11 @@ public void SaveSettings() if (!client.Network.Connected) return; try { - OSDMap map = new OSDMap(2); - map["enabled"] = Enabled; - map["allowed_owner"] = AllowedOwner; + OSDMap map = new OSDMap(2) + { + ["enabled"] = Enabled, + ["allowed_owner"] = string.Join(";", AllowedOwners) + }; instance.ClientSettings["LSLHelper"] = map; } catch { } @@ -103,14 +97,14 @@ public bool ProcessIM(InstantMessageEventArgs e) { case InstantMessageDialog.MessageFromObject: { - if (e.IM.FromAgentID != AllowedOwner) + if (!AllowedOwners.Contains(e.IM.FromAgentID.ToString())) { return true; } string[] args = e.IM.Message.Trim().Split('^'); if (args.Length < 1) return false; - switch (args[0].Trim()) + switch (args[0].Trim().ToLower()) { case "group_invite": { @@ -145,13 +139,41 @@ public bool ProcessIM(InstantMessageEventArgs e) if (item == null) return false; client.Inventory.GiveItem(item.UUID, item.Name, item.AssetType, sendTo, true); - WorkPool.QueueUserWorkItem(sync => + ThreadPool.QueueUserWorkItem(sync => instance.TabConsole.DisplayNotificationInChat( - string.Format("Gave {0} to {1}", item.Name, instance.Names.Get(sendTo, true)), + $"Gave {item.Name} to {instance.Names.Get(sendTo, true)}", ChatBufferTextStyle.ObjectChat) ); return true; } + case "say": /* This one doesn't work yet. I don't know why. TODO. - Nico */ + { + if (args.Length < 2) return true; + ChatType ct = ChatType.Normal; + int chan = 0; + if (args.Length > 2 && int.TryParse(args[2].Trim(), out chan) && chan < 0) + { + chan = 0; + } + if (args.Length > 3) + { + switch (args[3].Trim().ToLower()) + { + case "whisper": + { + ct = ChatType.Whisper; + break; + } + case "shout": + { + ct = ChatType.Shout; + } + break; + } + } + client.Self.Chat(args[1].Trim(), chan, ct); + return true; + } } } break; @@ -165,7 +187,7 @@ private void ProcessInvite(string[] args) if (args == null || args.Length < 4) return; - WorkPool.QueueUserWorkItem(sync => + ThreadPool.QueueUserWorkItem(sync => { try { @@ -190,19 +212,19 @@ private void ProcessInvite(string[] args) client.Groups.GroupMembersReply += handler; client.Groups.RequestGroupMembers(groupID); - bool success = gotMembers.WaitOne(30 * 1000, false); + gotMembers.WaitOne(30 * 1000, false); client.Groups.GroupMembersReply -= handler; if (Members != null && Members.ContainsKey(invitee)) { instance.TabConsole.DisplayNotificationInChat( - string.Format("Not inviting {0} ({1}) to {2} ({3}), already member", instance.Names.Get(invitee, true), invitee, instance.Groups[groupID].Name, groupID), + $"Not inviting {instance.Names.Get(invitee, true)} ({invitee}) to {instance.Groups[groupID].Name} ({groupID}), already member", ChatBufferTextStyle.ObjectChat); } else { instance.TabConsole.DisplayNotificationInChat( - string.Format("Inviting {0} ({1}) to {2} ({3})", instance.Names.Get(invitee, true), invitee, instance.Groups[groupID].Name, groupID), + $"Inviting {instance.Names.Get(invitee, true)} ({invitee}) to {instance.Groups[groupID].Name} ({groupID})", ChatBufferTextStyle.ObjectChat); client.Groups.Invite(groupID, new List(1) { roleID }, invitee); } @@ -210,7 +232,7 @@ private void ProcessInvite(string[] args) else { instance.TabConsole.DisplayNotificationInChat( - string.Format("Cannot invite to group {0}, I don't appear to be in it.", groupID), + $"Cannot invite to group {groupID}, I don't appear to be in it.", ChatBufferTextStyle.Error); } } diff --git a/Radegast/Automation/PseudoHome.cs b/Radegast/Automation/PseudoHome.cs index 0747c5138..06f6cb1cd 100644 --- a/Radegast/Automation/PseudoHome.cs +++ b/Radegast/Automation/PseudoHome.cs @@ -1,37 +1,24 @@ -// -// Radegast Metaverse Client -//Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Implements RAD-354 +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Timers; using OpenMetaverse; @@ -58,7 +45,7 @@ public static explicit operator PseudoHomePreferences(OSD osd) if (osd != null && osd.Type == OSDType.Map) { OSDMap map = (OSDMap)osd; - prefs.Enabled = map.ContainsKey("Enabled") ? map["Enabled"].AsBoolean() : false; + prefs.Enabled = map.ContainsKey("Enabled") && map["Enabled"].AsBoolean(); prefs.Region = map.ContainsKey("Region") ? map["Region"].AsString().Trim() : ""; prefs.Position = map.ContainsKey("Position") ? map["Position"].AsVector3() : new Vector3(); prefs.Tolerance = map.ContainsKey("Tolerance") ? Math.Min(256, Math.Max(1, map["Tolerance"].AsUInteger())) : 256; @@ -74,12 +61,14 @@ public static implicit operator OSD(PseudoHomePreferences prefs) public static explicit operator OSDMap(PseudoHomePreferences prefs) { - OSDMap map = new OSDMap(4); + OSDMap map = new OSDMap(4) + { + ["Enabled"] = prefs != null && prefs.Enabled, + ["Region"] = prefs?.Region != null ? prefs.Region.Trim() : string.Empty, + ["Position"] = prefs?.Position ?? Vector3.Zero, + ["Tolerance"] = prefs?.Tolerance ?? 256 + }; - map["Enabled"] = prefs != null ? prefs.Enabled : false; - map["Region"] = prefs != null && prefs.Region != null ? prefs.Region.Trim() : string.Empty; - map["Position"] = prefs != null ? prefs.Position : Vector3.Zero; - map["Tolerance"] = prefs != null ? prefs.Tolerance : 256; return map; } @@ -105,20 +94,17 @@ public PseudoHome(RadegastInstance instance) { m_instance = instance; m_Timer = new Timer(5000); - m_Timer.Elapsed += new ElapsedEventHandler((sender, args) => { + m_Timer.Elapsed += (sender, args) => { ETGoHome(); - }); + }; m_Timer.Enabled = false; } public PseudoHomePreferences Preferences { - get { return !m_instance.Client.Network.Connected ? null : (PseudoHomePreferences)m_instance.ClientSettings; } + get => !m_instance.Client.Network.Connected ? null : (PseudoHomePreferences)m_instance.ClientSettings; - set - { - m_instance.ClientSettings["PseudoHome"] = value; - } + set => m_instance.ClientSettings["PseudoHome"] = value; } public void ETGoHome() diff --git a/Radegast/Core/AutoPilot.cs b/Radegast/Core/AutoPilot.cs index 61a169916..0e6fff093 100644 --- a/Radegast/Core/AutoPilot.cs +++ b/Radegast/Core/AutoPilot.cs @@ -1,33 +1,23 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/* + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System.Collections.Generic; using OpenMetaverse; @@ -56,18 +46,15 @@ int NextWaypoint System.Threading.Thread.Sleep(500); Client.Self.AutoPilotLocal((int)Waypoints[nwp].X, (int)Waypoints[nwp].Y, (int)Waypoints[nwp].Z); } - get - { - return nwp; - } + get => nwp; } public AutoPilot(GridClient client) { Client = client; Ticker.Enabled = false; - Ticker.Elapsed += new System.Timers.ElapsedEventHandler(Ticker_Elapsed); - Client.Objects.TerseObjectUpdate += new System.EventHandler(Objects_TerseObjectUpdate); + Ticker.Elapsed += Ticker_Elapsed; + Client.Objects.TerseObjectUpdate += Objects_TerseObjectUpdate; } void Objects_TerseObjectUpdate(object sender, TerseObjectUpdateEventArgs e) diff --git a/Radegast/Core/AutoPilot2.cs b/Radegast/Core/AutoPilot2.cs deleted file mode 100644 index 874bcfc26..000000000 --- a/Radegast/Core/AutoPilot2.cs +++ /dev/null @@ -1,501 +0,0 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// -using System; -using System.Timers; -using System.Collections.Generic; -using OpenMetaverse; - -namespace Radegast -{ - public class AutoPilot2 - { - #region Declarations - /// - /// Delegate to pass the coordinate value of next waypoint to an event-handler - /// - public delegate void WaypointDelegate(Vector3d waypoint); - - /// - /// Delegate to pass the coordinate value of next waypoint and the new Status of AutoPilot to an event-handler - /// - public delegate void AutoPilotStatusDelegate(AutoPilotStatus newStatus, Vector3d nextWaypoint); - - /// - /// Enum declaration representing the statuses of AutoPilot - /// - public enum AutoPilotStatus - { - Idle, - Paused, - Moving, - Cancelled, - Finished, - Failed - } - #endregion Declarations - - #region Private Variables - private GridClient Client; - private Vector3d myGlobalPosition; - private List waypoints = new List(); - private int waypointIndex = 0; - private AutoPilotStatus status = AutoPilotStatus.Idle; - private double waypointRadius = 2d; - private Timer ticker = new Timer(500); - private int stuckTimeout = 10000; - private int lastDistance = 0; - private int lastDistanceChanged = -1; - #endregion Private Variables - - #region Public Variables/Properties - public bool Loop = false; - - /// - /// The Status of the AutoPilot instance - /// - public AutoPilotStatus Status - { - get - { - return status; - } - } - - /// - /// The Vector3d Waypoints in the AutoPilot instance - /// - /// Must have at least 2 Waypoints - public List Waypoints - { - get - { - return waypoints; - } - set - { - if (value.Count > 1) - { - Stop(AutoPilotStatus.Idle); - waypoints = value; - } - else - { - throw new ArgumentOutOfRangeException("Waypoints", "Must have at least 2 Waypoints"); - } - } - } - - /// - /// The previous Vector3d Waypoint along the path. Returns Vector3d.Zero if there is no previous waypoint. - /// - public Vector3d PreviousWaypoint - { - get - { - return waypointIndex >= 1 ? waypoints[waypointIndex - 1] : Vector3d.Zero; - } - } - - /// - /// The next Vector3d Waypoint along the path. Returns Vector3d.Zero if there is no next waypoint. - /// - public Vector3d NextWaypoint - { - get - { - return waypointIndex < waypoints.Count ? waypoints[waypointIndex] : Vector3d.Zero; - } - } - - /// - /// The next Waypoint's index. A new value will immediately take effect if AutoPilot is not Idle - /// - /// NextWaypointIndex must be greater than or equal to 0 and less than the number of Waypoints - /// Must have at least 2 Waypoints - public int NextWaypointIndex - { - set - { - if (waypoints.Count > 1) - { - if (Loop) - { - waypointIndex = value % waypoints.Count; - } - else if (value < waypoints.Count && value >= 0) - { - waypointIndex = value; - } - else - { - throw new ArgumentOutOfRangeException("NextWaypointIndex", "Value must be greater than or equal to 0 and less than the number of Waypoints"); - } - if (status != AutoPilotStatus.Idle) - { - Client.Self.AutoPilotCancel(); - SetStatus(AutoPilotStatus.Moving); - Client.Self.AutoPilot(waypoints[waypointIndex].X, waypoints[waypointIndex].Y, waypoints[waypointIndex].Z); - } - } - else - { - throw new Exception("Must have at least 2 Waypoints"); - } - } - get - { - return waypointIndex; - } - } - - /// - /// The next Waypoint's index - /// - public bool NextWaypointIsFinal - { - get - { - return waypointIndex == (waypoints.Count - 1); - } - } - - /// - /// Returns true if next Waypoint is the Start - /// - public bool NextWaypointIsStart - { - get - { - return waypointIndex == 0 && waypoints.Count > 1; - } - } - - /// - /// The Waypoint detection radius - /// - /// WaypointRadius must be greater than 0 - public double WaypointRadius - { - get - { - return waypointRadius; - } - set - { - if (value > 0) - { - waypointRadius = value; - } - else - { - throw new ArgumentOutOfRangeException("WaypointRadius", "Value must be greater than 0"); - } - } - } - - /// - /// The timeout in milliseconds before being considered stuck - /// - /// StuckTimeout must be greater than 0 - public int StuckTimeout - { - get - { - return stuckTimeout; - } - set - { - if (value > 0) - { - stuckTimeout = value; - } - else - { - throw new ArgumentOutOfRangeException("StuckTimeout", "Value must be greater than 0"); - } - } - } - #endregion Public Variables/Properties - - #region Public Events - /// - /// Event for when agent arrives at a Waypoint - /// - public event WaypointDelegate OnWaypointArrival; - - /// - /// Event for when AutoPilot's status changes - /// - public event AutoPilotStatusDelegate OnStatusChange; - #endregion Public Events - - /// - /// Constructor. - /// - /// The GridClient to use - public AutoPilot2(GridClient client) - { - Client = client; - Client.Objects.TerseObjectUpdate += new System.EventHandler(Objects_TerseObjectUpdate); - ticker.Elapsed += new ElapsedEventHandler(ticker_Elapsed); - } - - #region Public Methods - /// - /// Triggers Autopilot to move towards next waypoint along the path - /// - /// Next Waypoint index - public int MoveToNextWaypoint() - { - return MoveToNextWaypoint(true); - } - - /// - /// Triggers Autopilot to move towards next waypoint along the path - /// - /// Increment current Waypoint index - /// Must have at least 2 Waypoints - /// Next Waypoint index - public int MoveToNextWaypoint(bool increment) - { - if (waypoints.Count > 1) - { - if (increment) - { - NextWaypointIndex++; - } - else - { - Client.Self.AutoPilotCancel(); - Vector3d nextWaypoint = NextWaypoint; - SetStatus(AutoPilotStatus.Moving); - Client.Self.AutoPilot(nextWaypoint.X, nextWaypoint.Y, nextWaypoint.Z); - } - return waypointIndex; - } - else - { - throw new Exception("Must have at least 2 Waypoints"); - } - } - - /// - /// Starts AutoPilot from an Idle state. Will trigger a Moving status change. - /// - /// Must have at least 2 Waypoints - /// Status must be Idle - /// Next Waypoint index - public int Start() - { - if (waypoints.Count > 1) - { - if (status == AutoPilotStatus.Idle) - { - ticker.Start(); - return MoveToNextWaypoint(false); - } - else - { - throw new Exception("Status must be Idle"); - } - } - else - { - throw new Exception("Must have at least 2 Waypoints"); - } - } - - /// - /// Restarts AutoPilot. Will trigger a Cancel status change if not already cancelled. - /// - /// Must have at least 2 Waypoints - /// Next Waypoint index - public int Restart() - { - if (waypoints.Count > 1) - { - Stop(); - lastDistanceChanged = -1; - return MoveToNextWaypoint(false); - } - else - { - throw new Exception("Must have at least 2 Waypoints"); - } - } - - /// - /// Pauses AutoPilot from a Moving state. Will trigger a Paused status change. - /// - /// Status must be Moving - /// Next Waypoint index - public int Pause() - { - if (status == AutoPilotStatus.Moving) - { - ticker.Stop(); - Client.Self.AutoPilotCancel(); - SetStatus(AutoPilotStatus.Paused); - return waypointIndex; - } - else - { - throw new Exception("Status must be Moving"); - } - } - - /// - /// Resumes AutoPilot from a Paused state. Will trigger a Moving status change. - /// - /// Status must be Paused - /// Next Waypoint index - public int Resume() - { - if (status == AutoPilotStatus.Paused) - { - ticker.Start(); - return MoveToNextWaypoint(false); - } - else - { - throw new Exception("Status must be Paused"); - } - } - - /// - /// Stops AutoPilot. Will trigger a Cancel status change if not already cancelled. - /// - public void Stop() - { - Stop(AutoPilotStatus.Cancelled); - } - - /// - /// Stops AutoPilot. Will trigger the given status if not already in that state. - /// - /// The new status for AutoPilot. Cannot be Moving - /// newStatus cannot be Moving - public void Stop(AutoPilotStatus newStatus) - { - if (newStatus != AutoPilotStatus.Moving) - { - ticker.Stop(); - Client.Self.AutoPilotCancel(); - SetStatus(newStatus); - lastDistanceChanged = -1; - waypointIndex = 0; - } - else - { - throw new ArgumentOutOfRangeException("newStatus", "Value cannot be Moving"); - } - } - #endregion Public Methods - - #region Private Methods - /// - /// Sets AutoPilot's Status. If newStatus is different from current Status than it will cause OnStatusChange event trigger. - /// - /// The new Status AutoPilot is to be changed to - /// True if OnStatusChanged triggered - private bool SetStatus(AutoPilotStatus newStatus) - { - AutoPilotStatus oldStatus = status; - if (oldStatus != newStatus) - { - status = newStatus; - if (OnStatusChange != null) - { - OnStatusChange(status, NextWaypoint); - } - return true; - } - else - { - return false; - } - } - - /// - /// Event Handler for waypoint distance checking - /// - private void Objects_TerseObjectUpdate(object sender, TerseObjectUpdateEventArgs e) - { - if (status == AutoPilotStatus.Moving && e.Update.Avatar && e.Update.LocalID == Client.Self.LocalID) - { - uint regionX, regionY; - Utils.LongToUInts(e.Simulator.Handle, out regionX, out regionY); - myGlobalPosition = new Vector3d( - regionX + e.Update.Position.X, - regionY + e.Update.Position.Y, - e.Update.Position.Z - ); - if (Vector3d.Distance(myGlobalPosition, NextWaypoint) <= waypointRadius) - { - if (NextWaypointIsFinal && !Loop) - { - Stop(AutoPilotStatus.Finished); - } - else - { - if (OnWaypointArrival != null) - { - OnWaypointArrival(NextWaypoint); - } - MoveToNextWaypoint(); - } - } - } - } - - /// - /// Event Handler for Timer which detects if agent is stuck - /// - private void ticker_Elapsed(object sender, ElapsedEventArgs e) - { - if (status == AutoPilotStatus.Moving) - { - int distance = (int)Vector3d.Distance(myGlobalPosition, NextWaypoint); - if (distance != lastDistance || lastDistanceChanged < 0) - { - lastDistance = distance; - lastDistanceChanged = System.Environment.TickCount; - } - else if (Math.Abs(System.Environment.TickCount - lastDistanceChanged) > stuckTimeout) - { - Vector3d nextWaypoint = NextWaypoint; - Stop(AutoPilotStatus.Failed); - } - } - } - #endregion Private Methods - } -} \ No newline at end of file diff --git a/Radegast/Core/ChatBufferItem.cs b/Radegast/Core/ChatBufferItem.cs index 96ab366b2..3f5ffb5aa 100644 --- a/Radegast/Core/ChatBufferItem.cs +++ b/Radegast/Core/ChatBufferItem.cs @@ -1,33 +1,23 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using OpenMetaverse; @@ -35,13 +25,6 @@ namespace Radegast { public class ChatBufferItem { - private DateTime timestamp; - private string from; - private UUID id; - private string text; - private ChatBufferTextStyle style; - private ChatEventArgs rawMessage; - public ChatBufferItem() { @@ -49,48 +32,24 @@ public ChatBufferItem() public ChatBufferItem(DateTime timestamp, string from, UUID id, string text, ChatBufferTextStyle style) { - this.timestamp = timestamp; - this.from = from; - this.id = id; - this.text = text; - this.style = style; + Timestamp = timestamp; + From = from; + ID = id; + Text = text; + Style = style; } - public DateTime Timestamp - { - get { return timestamp; } - set { timestamp = value; } - } + public DateTime Timestamp { get; set; } - public string From - { - get { return from; } - set { from = value; } - } + public string From { get; set; } - public UUID ID - { - get { return id; } - set { id = value; } - } + public UUID ID { get; set; } - public string Text - { - get { return text; } - set { text = value; } - } + public string Text { get; set; } - public ChatBufferTextStyle Style - { - get { return style; } - set { style = value; } - } + public ChatBufferTextStyle Style { get; set; } - public ChatEventArgs RawMessage - { - get { return rawMessage; } - set { rawMessage = value; } - } + public ChatEventArgs RawMessage { get; set; } } public enum ChatBufferTextStyle diff --git a/Radegast/Core/ChatTextManager.cs b/Radegast/Core/ChatTextManager.cs index 33f311948..d53dd9fd1 100644 --- a/Radegast/Core/ChatTextManager.cs +++ b/Radegast/Core/ChatTextManager.cs @@ -1,42 +1,32 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/* + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2023, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections.Generic; using System.Drawing; using System.Text; -using Radegast.Netcom; +using Radegast; using OpenMetaverse; using OpenMetaverse.StructuredData; -using System.Web.Script.Serialization; -using System.ComponentModel; +using System.Reflection; +using Newtonsoft.Json; namespace Radegast { @@ -46,9 +36,8 @@ public class ChatTextManager : IDisposable public event EventHandler ChatLineAdded; private RadegastInstance instance; - private RadegastNetcom netcom { get { return instance.Netcom; } } - private GridClient client { get { return instance.Client; } } - private ITextPrinter textPrinter; + private Radegast.Netcom netcom => instance.Netcom; + private GridClient client => instance.Client; private List textBuffer; @@ -58,29 +47,28 @@ public class ChatTextManager : IDisposable public ChatTextManager(RadegastInstance instance, ITextPrinter textPrinter) { - this.textPrinter = textPrinter; - this.textBuffer = new List(); + TextPrinter = textPrinter; + textBuffer = new List(); this.instance = instance; InitializeConfig(); // Callbacks - netcom.ChatReceived += new EventHandler(netcom_ChatReceived); - netcom.ChatSent += new EventHandler(netcom_ChatSent); - netcom.AlertMessageReceived += new EventHandler(netcom_AlertMessageReceived); + netcom.ChatReceived += netcom_ChatReceived; + netcom.ChatSent += netcom_ChatSent; + netcom.AlertMessageReceived += netcom_AlertMessageReceived; } public void Dispose() { - netcom.ChatReceived -= new EventHandler(netcom_ChatReceived); - netcom.ChatSent -= new EventHandler(netcom_ChatSent); - netcom.AlertMessageReceived -= new EventHandler(netcom_AlertMessageReceived); + netcom.ChatReceived -= netcom_ChatReceived; + netcom.ChatSent -= netcom_ChatSent; + netcom.AlertMessageReceived -= netcom_AlertMessageReceived; } private void InitializeConfig() { Settings s = instance.GlobalSettings; - var serializer = new JavaScriptSerializer(); if (s["chat_timestamps"].Type == OSDType.Unknown) { @@ -90,7 +78,7 @@ private void InitializeConfig() { try { - s["chat_fonts"] = serializer.Serialize(Settings.DefaultFontSettings); + s["chat_fonts"] = JsonConvert.SerializeObject(Settings.DefaultFontSettings); } catch (Exception ex) { @@ -100,7 +88,7 @@ private void InitializeConfig() try { - fontSettings = serializer.Deserialize>(s["chat_fonts"]); + fontSettings = JsonConvert.DeserializeObject>(s["chat_fonts"]); } catch (Exception ex) { @@ -109,7 +97,7 @@ private void InitializeConfig() showTimestamps = s["chat_timestamps"].AsBoolean(); - s.OnSettingChanged += new Settings.SettingChangedCallback(s_OnSettingChanged); + s.OnSettingChanged += s_OnSettingChanged; } void s_OnSettingChanged(object sender, SettingsEventArgs e) @@ -119,12 +107,11 @@ void s_OnSettingChanged(object sender, SettingsEventArgs e) showTimestamps = e.Value.AsBoolean(); ReprintAllText(); } - else if(e.Key == "chat_fonts") + else if (e.Key == "chat_fonts") { try { - var serializer = new JavaScriptSerializer(); - fontSettings = serializer.Deserialize>(e.Value); + fontSettings = JsonConvert.DeserializeObject>(e.Value); } catch (Exception ex) { @@ -143,7 +130,7 @@ private void netcom_ChatSent(object sender, ChatSentEventArgs e) private void netcom_AlertMessageReceived(object sender, AlertMessageEventArgs e) { - if (e.Message.ToLower().Contains("autopilot canceled")) return; //workaround the stupid autopilot alerts + if (e.NotificationId == "AutopilotCanceled") { return; } // workaround the stupid autopilot alerts ChatBufferItem item = new ChatBufferItem( DateTime.Now, "Alert message", UUID.Zero, ": " + e.Message, ChatBufferTextStyle.Alert); @@ -159,7 +146,10 @@ private void netcom_ChatReceived(object sender, ChatEventArgs e) public void PrintStartupMessage() { ChatBufferItem title = new ChatBufferItem( - DateTime.Now, "", UUID.Zero, Properties.Resources.RadegastTitle + " " + RadegastBuild.VersionString, ChatBufferTextStyle.StartupTitle); + DateTime.Now, "", + UUID.Zero, + Properties.Resources.RadegastTitle + " " + Assembly.GetExecutingAssembly().GetName().Version, + ChatBufferTextStyle.StartupTitle); ChatBufferItem ready = new ChatBufferItem( DateTime.Now, "", UUID.Zero, "Ready.", ChatBufferTextStyle.StatusBlue); @@ -172,10 +162,7 @@ public void PrintStartupMessage() public void ProcessBufferItem(ChatBufferItem item, bool addToBuffer) { - if (ChatLineAdded != null) - { - ChatLineAdded(this, new ChatLineAddedArgs(item)); - } + ChatLineAdded?.Invoke(this, new ChatLineAddedArgs(item)); lock (SyncChat) { @@ -184,60 +171,60 @@ public void ProcessBufferItem(ChatBufferItem item, bool addToBuffer) if (showTimestamps) { - if(fontSettings.ContainsKey("Timestamp")) + if (fontSettings.ContainsKey("Timestamp")) { var fontSetting = fontSettings["Timestamp"]; - textPrinter.ForeColor = fontSetting.ForeColor; - textPrinter.BackColor = fontSetting.BackColor; - textPrinter.Font = fontSetting.Font; - textPrinter.PrintText(item.Timestamp.ToString("[HH:mm] ")); + TextPrinter.ForeColor = fontSetting.ForeColor; + TextPrinter.BackColor = fontSetting.BackColor; + TextPrinter.Font = fontSetting.Font; + TextPrinter.PrintText(item.Timestamp.ToString("[HH:mm] ")); } else { - textPrinter.ForeColor = SystemColors.GrayText; - textPrinter.BackColor = Color.Transparent; - textPrinter.Font = Settings.FontSetting.DefaultFont; - textPrinter.PrintText(item.Timestamp.ToString("[HH:mm] ")); + TextPrinter.ForeColor = SystemColors.GrayText; + TextPrinter.BackColor = Color.Transparent; + TextPrinter.Font = Settings.FontSetting.DefaultFont; + TextPrinter.PrintText(item.Timestamp.ToString("[HH:mm] ")); } } - if(fontSettings.ContainsKey("Name")) + if (fontSettings.ContainsKey("Name")) { var fontSetting = fontSettings["Name"]; - textPrinter.ForeColor = fontSetting.ForeColor; - textPrinter.BackColor = fontSetting.BackColor; - textPrinter.Font = fontSetting.Font; + TextPrinter.ForeColor = fontSetting.ForeColor; + TextPrinter.BackColor = fontSetting.BackColor; + TextPrinter.Font = fontSetting.Font; } else { - textPrinter.ForeColor = SystemColors.WindowText; - textPrinter.BackColor = Color.Transparent; - textPrinter.Font = Settings.FontSetting.DefaultFont; + TextPrinter.ForeColor = SystemColors.WindowText; + TextPrinter.BackColor = Color.Transparent; + TextPrinter.Font = Settings.FontSetting.DefaultFont; } if (item.Style == ChatBufferTextStyle.Normal && item.ID != UUID.Zero && instance.GlobalSettings["av_name_link"]) { - textPrinter.InsertLink(item.From, string.Format("secondlife:///app/agent/{0}/about", item.ID)); + TextPrinter.InsertLink(item.From, $"secondlife:///app/agent/{item.ID}/about"); } else { - textPrinter.PrintText(item.From); + TextPrinter.PrintText(item.From); } - if(fontSettings.ContainsKey(item.Style.ToString())) + if (fontSettings.ContainsKey(item.Style.ToString())) { var fontSetting = fontSettings[item.Style.ToString()]; - textPrinter.ForeColor = fontSetting.ForeColor; - textPrinter.BackColor = fontSetting.BackColor; - textPrinter.Font = fontSetting.Font; + TextPrinter.ForeColor = fontSetting.ForeColor; + TextPrinter.BackColor = fontSetting.BackColor; + TextPrinter.Font = fontSetting.Font; } else { - textPrinter.ForeColor = SystemColors.WindowText; - textPrinter.BackColor = Color.Transparent; - textPrinter.Font = Settings.FontSetting.DefaultFont; + TextPrinter.ForeColor = SystemColors.WindowText; + TextPrinter.BackColor = Color.Transparent; + TextPrinter.Font = Settings.FontSetting.DefaultFont; } - textPrinter.PrintTextLine(item.Text); + TextPrinter.PrintTextLine(item.Text); } } @@ -264,7 +251,7 @@ private void ProcessOutgoingChat(ChatSentEventArgs e) sb.Append(e.Message); ChatBufferItem item = new ChatBufferItem( - DateTime.Now, string.Format("(channel {0}) {1}", e.Channel, client.Self.Name), client.Self.AgentID, sb.ToString(), ChatBufferTextStyle.StatusDarkBlue); + DateTime.Now, $"(channel {e.Channel}) {client.Self.Name}", client.Self.AgentID, sb.ToString(), ChatBufferTextStyle.StatusDarkBlue); ProcessBufferItem(item, true); @@ -273,12 +260,15 @@ private void ProcessOutgoingChat(ChatSentEventArgs e) private void ProcessIncomingChat(ChatEventArgs e) { - if (string.IsNullOrEmpty(e.Message)) return; + if (string.IsNullOrEmpty(e.Message)) { return; } // Check if the sender agent is muted - if (e.SourceType == ChatSourceType.Agent && - null != client.Self.MuteList.Find(me => me.Type == MuteType.Resident && me.ID == e.SourceID) - ) return; + if (e.SourceType == ChatSourceType.Agent + && client.Self.MuteList.Find(me => me.Type == MuteType.Resident + && me.ID == e.SourceID) != null) + { + return; + } // Check if it's script debug if (e.Type == ChatType.Debug && !instance.GlobalSettings["show_script_errors"]) @@ -289,12 +279,17 @@ private void ProcessIncomingChat(ChatEventArgs e) // Check if sender object is muted if (e.SourceType == ChatSourceType.Object && null != client.Self.MuteList.Find(me => - (me.Type == MuteType.Resident && me.ID == e.OwnerID) // Owner muted - || (me.Type == MuteType.Object && me.ID == e.SourceID) // Object muted by ID - || (me.Type == MuteType.ByName && me.Name == e.FromName) // Object muted by name - )) return; + (me.Type == MuteType.Resident && me.ID == e.OwnerID) // Owner muted + || (me.Type == MuteType.Object && me.ID == e.SourceID) // Object muted by ID + || (me.Type == MuteType.ByName && me.Name == e.FromName) // Object muted by name + )) + { + return; + } - if (instance.RLV.Enabled && e.Message.StartsWith("@")) + if (instance.RLV.Enabled + && e.Type == ChatType.OwnerSay + && e.Message.StartsWith("@")) { instance.RLV.TryProcessCMD(e); #if !DEBUG @@ -304,21 +299,14 @@ private void ProcessIncomingChat(ChatEventArgs e) #endif } - ChatBufferItem item = new ChatBufferItem(); - item.ID = e.SourceID; - item.RawMessage = e; + ChatBufferItem item = new ChatBufferItem { ID = e.SourceID, RawMessage = e }; StringBuilder sb = new StringBuilder(); - if (e.SourceType == ChatSourceType.Agent) - { - item.From = instance.Names.Get(e.SourceID, e.FromName); - } - else - { - item.From = e.FromName; - } + item.From = e.SourceType == ChatSourceType.Agent + ? instance.Names.Get(e.SourceID, e.FromName) + : e.FromName; - bool isEmote = e.Message.ToLower().StartsWith("/me "); + bool isEmote = e.Message.StartsWith("/me ", StringComparison.OrdinalIgnoreCase); if (!isEmote) { @@ -337,18 +325,28 @@ private void ProcessIncomingChat(ChatEventArgs e) if (isEmote) { - if (e.SourceType == ChatSourceType.Agent && instance.RLV.RestictionActive("recvemote", e.SourceID.ToString())) + if (e.SourceType == ChatSourceType.Agent && + instance.RLV.RestictionActive("recvemote", e.SourceID.ToString())) + { sb.Append(" ..."); + } else + { sb.Append(e.Message.Substring(3)); + } } else { sb.Append(": "); - if (e.SourceType == ChatSourceType.Agent && !e.Message.StartsWith("/") && instance.RLV.RestictionActive("recvchat", e.SourceID.ToString())) + if (e.SourceType == ChatSourceType.Agent && !e.Message.StartsWith("/") && + instance.RLV.RestictionActive("recvchat", e.SourceID.ToString())) + { sb.Append("..."); + } else + { sb.Append(e.Message); + } } item.Timestamp = DateTime.Now; @@ -357,15 +355,15 @@ private void ProcessIncomingChat(ChatEventArgs e) switch (e.SourceType) { case ChatSourceType.Agent: - if(e.FromName.EndsWith("Linden")) + if (e.FromName.EndsWith("Linden")) { item.Style = ChatBufferTextStyle.LindenChat; } - else if(isEmote) + else if (isEmote) { item.Style = ChatBufferTextStyle.Emote; } - else if(e.SourceID == client.Self.AgentID) + else if (e.SourceID == client.Self.AgentID) { item.Style = ChatBufferTextStyle.Self; } @@ -375,24 +373,20 @@ private void ProcessIncomingChat(ChatEventArgs e) } break; case ChatSourceType.Object: - if (e.Type == ChatType.OwnerSay) + switch (e.Type) { - if(isEmote) - { + case ChatType.OwnerSay when isEmote: item.Style = ChatBufferTextStyle.Emote; - } - else - { + break; + case ChatType.OwnerSay: item.Style = ChatBufferTextStyle.OwnerSay; - } - } - else if (e.Type == ChatType.Debug) - { - item.Style = ChatBufferTextStyle.Error; - } - else - { - item.Style = ChatBufferTextStyle.ObjectChat; + break; + case ChatType.Debug: + item.Style = ChatBufferTextStyle.Error; + break; + default: + item.Style = ChatBufferTextStyle.ObjectChat; + break; } break; } @@ -405,7 +399,7 @@ private void ProcessIncomingChat(ChatEventArgs e) public void ReprintAllText() { - textPrinter.ClearText(); + TextPrinter.ClearText(); foreach (ChatBufferItem item in textBuffer) { @@ -418,21 +412,16 @@ public void ClearInternalBuffer() textBuffer.Clear(); } - public ITextPrinter TextPrinter - { - get { return textPrinter; } - set { textPrinter = value; } - } + public ITextPrinter TextPrinter { get; set; } } public class ChatLineAddedArgs : EventArgs { - ChatBufferItem mItem; - public ChatBufferItem Item { get { return mItem; } } + public ChatBufferItem Item { get; } public ChatLineAddedArgs(ChatBufferItem item) { - mItem = item; + Item = item; } } } diff --git a/Radegast/Core/ClientSignatures.cs b/Radegast/Core/ClientSignatures.cs deleted file mode 100644 index b962b6ac8..000000000 --- a/Radegast/Core/ClientSignatures.cs +++ /dev/null @@ -1,76 +0,0 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id: IMTextManager.cs 361 2009-10-24 15:04:57Z latifer $ -// -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; -using System.Reflection; -using OpenMetaverse; -using OpenMetaverse.StructuredData; - -namespace Radegast -{ - public class ClientSignatures - { - public static Dictionary Signatures { get; private set; } - - static ClientSignatures() - { - Signatures = new Dictionary(); - - try - { - OSDMap clients = (OSDMap)OSDParser.DeserializeLLSDXml(Properties.Resources.client_signatures); - - foreach (KeyValuePair kvp in clients) - { - UUID sig; - - if (UUID.TryParse(kvp.Key, out sig)) - { - if (kvp.Value.Type == OSDType.Map) - { - OSDMap client = (OSDMap)kvp.Value; - if (client.ContainsKey("name")) - { - Signatures.Add(sig, client["name"].AsString()); - } - } - } - } - } - catch - { - Logger.Log("Failed to parse client signatures.", Helpers.LogLevel.Warning); - } - } - } -} diff --git a/Radegast/Core/Commands/CommandsManager.cs b/Radegast/Core/Commands/CommandsManager.cs index 5d34901d7..f43c39f42 100644 --- a/Radegast/Core/Commands/CommandsManager.cs +++ b/Radegast/Core/Commands/CommandsManager.cs @@ -1,47 +1,32 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections.Generic; -#if (COGBOT_LIBOMV || USE_STHREADS) -using ThreadPoolUtil; -using Thread = ThreadPoolUtil.Thread; -using ThreadPool = ThreadPoolUtil.ThreadPool; -using Monitor = ThreadPoolUtil.Monitor; -#endif using System.Threading; +using System.Threading.Tasks; using OpenMetaverse; namespace Radegast.Commands { - public class CommandsManager : ICommandInterpreter, IDisposable + public class CommandsManager : ICommandInterpreter { public static string CmdPrefix = "//"; public readonly List CommandsLoaded = new List(); @@ -51,7 +36,7 @@ public class CommandsManager : ICommandInterpreter, IDisposable public Queue> CommandQueue = new Queue>(); public AutoResetEvent CommandQueued = new AutoResetEvent(false); - private Thread _commandWorker; + private CancellationTokenSource commandWorkerCancelToken; public CommandsManager(RadegastInstance inst) { @@ -59,65 +44,56 @@ public CommandsManager(RadegastInstance inst) AddCmd("help", "Shows help info", "help help", (name, cmdargs, writeline) => { - string args = String.Join(" ", cmdargs); + string args = string.Join(" ", cmdargs); Help(args, writeline); lock (InterpretersLoaded) foreach (ICommandInterpreter manager in InterpretersLoaded) - { - manager.Help(args, writeline); - } + { + manager.Help(args, writeline); + } }); - _commandWorker = new Thread(CommandsManager_CommandWorker) - { - Name = "CommandsManager Worker", - IsBackground = true - }; - _commandWorker.Start(); + commandWorkerCancelToken = new CancellationTokenSource(); + Task task = Task.Factory.StartNew(CommandWorker, + commandWorkerCancelToken.Token, TaskCreationOptions.LongRunning, TaskScheduler.Default); } - void CommandsManager_CommandWorker() + void CommandWorker() { - try + while (true) { - while (true) + if (commandWorkerCancelToken.Token.IsCancellationRequested) + { + break; + } + if (CommandQueue.Count == 0) + { + CommandQueued.WaitOne(); + } + if (commandWorkerCancelToken.Token.IsCancellationRequested) + { + break; + } + KeyValuePair todo; + lock (CommandQueue) { if (CommandQueue.Count == 0) - CommandQueued.WaitOne(); - KeyValuePair todo; - lock (CommandQueue) { - if (CommandQueue.Count == 0) - { - continue; - } - todo = CommandQueue.Dequeue(); - } - try - { - - todo.Value(); - } - catch (ThreadAbortException) - { - break; - } - catch (Exception ex) - { - instance.TabConsole.DisplayNotificationInChat( - string.Format("Command error: {0} \n{1} {2} ", todo.Key, ex.Message, ex.StackTrace)); + continue; } + todo = CommandQueue.Dequeue(); } - } - finally - { - CommandQueue.Clear(); try { - if (CommandQueued != null) CommandQueued.Close(); + + todo.Value(); } - catch (Exception) + catch (Exception ex) { + instance.TabConsole.DisplayNotificationInChat( + string.Format("Command error: {0} \n{1} {2} ", todo.Key, ex.Message, ex.StackTrace)); } } + CommandQueue.Clear(); + CommandQueued?.Close(); } public void EnqueueCommand(string name, ThreadStart ts) @@ -193,7 +169,7 @@ public bool LoadType(Type type) c = type.GetConstructor(Type.EmptyTypes); if (c != null) { - IRadegastCommand plug = (IRadegastCommand)c.Invoke(new object[0]); + IRadegastCommand plug = (IRadegastCommand)c.Invoke(Array.Empty()); LoadCommand(plug); return true; } @@ -202,7 +178,7 @@ public bool LoadType(Type type) { Logger.Log("ERROR in Radegast Command: " + type + " because " + ex.Message + " " + ex.StackTrace, Helpers.LogLevel.Debug); - throw ex; + throw; } return false; } @@ -215,7 +191,7 @@ public bool LoadType(Type type) if (ci.GetParameters().Length > 0) continue; try { - ICommandInterpreter plug = (ICommandInterpreter)ci.Invoke(new object[0]); + ICommandInterpreter plug = (ICommandInterpreter)ci.Invoke(Array.Empty()); LoadInterpreter(plug); loadedType = true; break; @@ -223,7 +199,7 @@ public bool LoadType(Type type) catch (Exception ex) { Logger.Log("ERROR in Radegast ICommandInterpreter: " + type + " because " + ex.Message + " " + ex.StackTrace, Helpers.LogLevel.Debug); - throw ex; + throw; } } } @@ -263,7 +239,7 @@ private void WriteLine(string fmt, object[] args) /// public void ExecuteCommand(string cmdline) { - ExecuteCommand(this.WriteLine, cmdline); + ExecuteCommand(WriteLine, cmdline); } /// @@ -343,8 +319,8 @@ public void Dispose() InterpretersLoaded.Clear(); } CommandsByName.Clear(); - _commandWorker.Abort(); - _commandWorker = null; + commandWorkerCancelToken.Cancel(); + commandWorkerCancelToken.Dispose(); CommandQueued = null; } diff --git a/Radegast/Core/Commands/FaceCommand.cs b/Radegast/Core/Commands/FaceCommand.cs index 4bdbbed1a..2e1c062e5 100644 --- a/Radegast/Core/Commands/FaceCommand.cs +++ b/Radegast/Core/Commands/FaceCommand.cs @@ -1,36 +1,24 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// -using System; +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System.Collections.Generic; -using System.Text; using System.Text.RegularExpressions; using System.Windows.Forms; @@ -40,7 +28,7 @@ namespace Radegast.Commands { public class FaceCommand : RadegastCommand { - TabsConsole TC { get { return Instance.TabConsole; } } + TabsConsole TC => Instance.TabConsole; ObjectsConsole Objects; ChatConsole Chat; Vector3 targetPos = Vector3.Zero; @@ -133,7 +121,7 @@ public override void Execute(string name, string[] cmdArgs, ConsoleWriteLine Wri } KnownHeading kh = null; - kh = StateManager.KnownHeadings.Find((KnownHeading h) => { return h.ID == subcmd.ToUpper(); }); + kh = StateManager.KnownHeadings.Find(h => h.ID == subcmd.ToUpper()); if (kh != null) { Client.Self.Movement.BodyRotation = Client.Self.Movement.HeadRotation = kh.Heading; @@ -149,7 +137,7 @@ public override void Execute(string name, string[] cmdArgs, ConsoleWriteLine Wri { case "person": List people = Chat.GetAvatarList(); - UUID person = people.Find((UUID id) => { return Instance.Names.Get(id).ToLower().StartsWith(subarg.ToLower()); }); + UUID person = people.Find(id => Instance.Names.Get(id).ToLower().StartsWith(subarg.ToLower())); if (person == UUID.Zero) { WriteLine("Could not find {0}", subarg); @@ -187,11 +175,8 @@ public override void Execute(string name, string[] cmdArgs, ConsoleWriteLine Wri Objects = (ObjectsConsole)TC.Tabs["objects"].Control; List prims = Objects.GetObjectList(); - Primitive target = prims.Find((Primitive prim) => - { - return prim.Properties != null - && prim.Properties.Name.ToLower().Contains(subarg.ToLower()); - }); + Primitive target = prims.Find(prim => + prim.Properties != null && prim.Properties.Name.ToLower().Contains(subarg.ToLower())); if (target == null) { diff --git a/Radegast/Core/Commands/FindCommand.cs b/Radegast/Core/Commands/FindCommand.cs index 7f99f7443..c9d29fe01 100644 --- a/Radegast/Core/Commands/FindCommand.cs +++ b/Radegast/Core/Commands/FindCommand.cs @@ -1,33 +1,23 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections.Generic; using System.Text; @@ -40,7 +30,7 @@ namespace Radegast.Commands { public class FindCommand : RadegastCommand { - TabsConsole TC { get { return Instance.TabConsole; } } + TabsConsole TC => Instance.TabConsole; ObjectsConsole Objects; ChatConsole Chat; ConsoleWriteLine wl; @@ -115,13 +105,10 @@ public override void Execute(string name, string[] cmdArgs, ConsoleWriteLine Wri Objects = (ObjectsConsole)TC.Tabs["objects"].Control; List prims = Objects.GetObjectList(); - List targets = prims.FindAll((Primitive prim) => - { - return prim.Properties != null - && prim.Properties.Name.ToLower().Contains(subarg.ToLower()); - }); + List targets = prims.FindAll(prim => prim.Properties != null + && prim.Properties.Name.ToLower().Contains(subarg.ToLower())); - if (targets == null || targets.Count == 0) + if (targets.Count == 0) { WriteLine("Could not find '{0}' nearby", subarg); return; @@ -158,8 +145,8 @@ public override void Execute(string name, string[] cmdArgs, ConsoleWriteLine Wri if (subcmd == "person") { List people = Chat.GetAvatarList(); - people = people.FindAll((UUID id) => { return id != Client.Self.AgentID && Instance.Names.Get(id).ToLower().StartsWith(subarg.ToLower()); }); - if (people == null || people.Count == 0) + people = people.FindAll(id => id != Client.Self.AgentID && Instance.Names.Get(id).ToLower().StartsWith(subarg.ToLower())); + if (people.Count == 0) { WriteLine("Could not find {0}", subarg); return; @@ -172,7 +159,7 @@ public override void Execute(string name, string[] cmdArgs, ConsoleWriteLine Wri Vector3 targetPos = Vector3.Zero; // try to find where they are - Avatar avi = Client.Network.CurrentSim.ObjectsAvatars.Find((Avatar av) => { return av.ID == person; }); + Avatar avi = Client.Network.CurrentSim.ObjectsAvatars.Find(av => av.ID == person); if (avi != null) { @@ -223,7 +210,6 @@ public override void Execute(string name, string[] cmdArgs, ConsoleWriteLine Wri } wl(sb.ToString()); - return; } } } diff --git a/Radegast/Core/Commands/FollowCommand.cs b/Radegast/Core/Commands/FollowCommand.cs index f7c975f8b..aa2d4e7eb 100644 --- a/Radegast/Core/Commands/FollowCommand.cs +++ b/Radegast/Core/Commands/FollowCommand.cs @@ -1,37 +1,24 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// -using System; +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System.Collections.Generic; -using System.Text; -using System.Text.RegularExpressions; using System.Windows.Forms; using OpenMetaverse; @@ -40,7 +27,7 @@ namespace Radegast.Commands { public class FollowCommand : RadegastCommand { - TabsConsole TC { get { return Instance.TabConsole; } } + TabsConsole TC => Instance.TabConsole; ChatConsole Chat; public FollowCommand(RadegastInstance instance) @@ -87,7 +74,7 @@ public override void Execute(string name, string[] cmdArgs, ConsoleWriteLine Wri } List people = Chat.GetAvatarList(); - UUID person = people.Find((UUID id) => { return Instance.Names.Get(id).ToLower().StartsWith(cmd.ToLower()); }); + UUID person = people.Find(id => Instance.Names.Get(id).ToLower().StartsWith(cmd.ToLower())); if (person == UUID.Zero) { WriteLine("Could not find {0}", cmd); diff --git a/Radegast/Core/Commands/GoCommand.cs b/Radegast/Core/Commands/GoCommand.cs index bbabcf561..e98252354 100644 --- a/Radegast/Core/Commands/GoCommand.cs +++ b/Radegast/Core/Commands/GoCommand.cs @@ -1,36 +1,24 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// -using System; +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System.Collections.Generic; -using System.Text; using System.Text.RegularExpressions; using System.Windows.Forms; @@ -42,7 +30,7 @@ public class GoCommand : RadegastCommand { Regex subCommand; RegexOptions regexOptions = RegexOptions.Compiled | RegexOptions.CultureInvariant | RegexOptions.ExplicitCapture | RegexOptions.IgnoreCase; - TabsConsole TC { get { return Instance.TabConsole; } } + TabsConsole TC => Instance.TabConsole; ObjectsConsole Objects; ChatConsole Chat; Vector3 targetPos = Vector3.Zero; @@ -142,7 +130,7 @@ public override void Execute(string name, string[] cmdArgs, ConsoleWriteLine Wri if (args.Count > 0) { - kh = StateManager.KnownHeadings.Find((KnownHeading h) => { return h.ID == args[0].ToUpper(); }); + kh = StateManager.KnownHeadings.Find(h => h.ID == args[0].ToUpper()); if (kh != null) heading = kh.Heading; } @@ -181,7 +169,7 @@ public override void Execute(string name, string[] cmdArgs, ConsoleWriteLine Wri case "person": List people = Chat.GetAvatarList(); - UUID person = people.Find((UUID id) => { return Instance.Names.Get(id).ToLower().StartsWith(subarg.ToLower()); }); + UUID person = people.Find(id => Instance.Names.Get(id).ToLower().StartsWith(subarg.ToLower())); if (person == UUID.Zero) { WriteLine("Could not find {0}", subarg); @@ -220,11 +208,8 @@ public override void Execute(string name, string[] cmdArgs, ConsoleWriteLine Wri Objects = (ObjectsConsole)TC.Tabs["objects"].Control; List prims = Objects.GetObjectList(); - Primitive target = prims.Find((Primitive prim) => - { - return prim.Properties != null - && prim.Properties.Name.ToLower().Contains(subarg.ToLower()); - }); + Primitive target = prims.Find(prim => prim.Properties != null + && prim.Properties.Name.ToLower().Contains(subarg.ToLower())); if (target == null) { diff --git a/Radegast/Core/Commands/ICommandInterpreter.cs b/Radegast/Core/Commands/ICommandInterpreter.cs index 5a28ab7c0..b6d9af062 100644 --- a/Radegast/Core/Commands/ICommandInterpreter.cs +++ b/Radegast/Core/Commands/ICommandInterpreter.cs @@ -1,35 +1,24 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; -using System.Collections.Generic; namespace Radegast.Commands { diff --git a/Radegast/Core/Commands/IRadegastCommand.cs b/Radegast/Core/Commands/IRadegastCommand.cs index 8aec9e27e..44138baf7 100644 --- a/Radegast/Core/Commands/IRadegastCommand.cs +++ b/Radegast/Core/Commands/IRadegastCommand.cs @@ -1,33 +1,23 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; namespace Radegast diff --git a/Radegast/Core/Commands/LoadPluginCommand.cs b/Radegast/Core/Commands/LoadPluginCommand.cs index ec9c7ee85..ba18d40eb 100644 --- a/Radegast/Core/Commands/LoadPluginCommand.cs +++ b/Radegast/Core/Commands/LoadPluginCommand.cs @@ -1,57 +1,35 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; -using System.Reflection; -using System.IO; -using OpenMetaverse; namespace Radegast.Commands { public class LoadPluginCommand : IRadegastCommand { private RadegastInstance instance; - public string Name - { - get { return "loadplugin"; } - } + public string Name => "loadplugin"; - public string Description - { - get { return "Loads plugins from a path"; } - } + public string Description => "Loads plugins from a path"; - public string Usage - { - get { return "loadplugin c:\\\\myplugindir\\\\plugin.dll"; } - } + public string Usage => "loadplugin c:\\\\myplugindir\\\\plugin.dll"; public void StartCommand(RadegastInstance inst) { @@ -68,7 +46,7 @@ public void Execute(string n, string[] cmdArgs, ConsoleWriteLine WriteLine) string loadfilename = String.Join(" ", cmdArgs); try { - instance.PluginManager.LoadAssembly(loadfilename, true); + instance.PluginManager.LoadPlugin(loadfilename); } catch (Exception ex) { diff --git a/Radegast/Core/Commands/ParcelInfoCommand.cs b/Radegast/Core/Commands/ParcelInfoCommand.cs index fe56ba011..17b350de3 100644 --- a/Radegast/Core/Commands/ParcelInfoCommand.cs +++ b/Radegast/Core/Commands/ParcelInfoCommand.cs @@ -1,35 +1,24 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id: CommandsManager.cs 226 2009-09-12 18:10:30Z logicmoo $ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; -using System.Collections.Generic; using System.Threading; using System.Text; using OpenMetaverse; @@ -49,13 +38,13 @@ public ParcelInfoCommand(RadegastInstance instance) Usage = Name; this.instance = instance; - this.instance.Netcom.ClientDisconnected += new EventHandler(Netcom_ClientDisconnected); + this.instance.Netcom.ClientDisconnected += Netcom_ClientDisconnected; } public override void Dispose() { base.Dispose(); - instance.Netcom.ClientDisconnected -= new EventHandler(Netcom_ClientDisconnected); + instance.Netcom.ClientDisconnected -= Netcom_ClientDisconnected; } public override void Execute(string name, string[] cmdArgs, ConsoleWriteLine WriteLine) @@ -79,12 +68,12 @@ public override void Execute(string name, string[] cmdArgs, ConsoleWriteLine Wri if (ParcelsDownloaded.WaitOne(30000, false) && Client.Network.Connected) { - sb.AppendFormat("Downloaded {0} Parcels in {1} " + System.Environment.NewLine, + sb.AppendFormat("Downloaded {0} Parcels in {1} " + Environment.NewLine, Client.Network.CurrentSim.Parcels.Count, Client.Network.CurrentSim.Name); Client.Network.CurrentSim.Parcels.ForEach(delegate(Parcel parcel) { - sb.AppendFormat("Parcel[{0}]: Name: \"{1}\", Description: \"{2}\" ACLBlacklist Count: {3}, ACLWhiteList Count: {5} Traffic: {4}" + System.Environment.NewLine, + sb.AppendFormat("Parcel[{0}]: Name: \"{1}\", Description: \"{2}\" ACLBlacklist Count: {3}, ACLWhiteList Count: {5} Traffic: {4}" + Environment.NewLine, parcel.LocalID, parcel.Name, parcel.Desc, parcel.AccessBlackList.Count, parcel.Dwell, parcel.AccessWhiteList.Count); }); diff --git a/Radegast/Core/Commands/RadegastCommand.cs b/Radegast/Core/Commands/RadegastCommand.cs index 85c18ece7..7a60b3df2 100644 --- a/Radegast/Core/Commands/RadegastCommand.cs +++ b/Radegast/Core/Commands/RadegastCommand.cs @@ -1,34 +1,23 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// -using System; +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using OpenMetaverse; namespace Radegast.Commands @@ -36,28 +25,24 @@ namespace Radegast.Commands public class RadegastCommand : IRadegastCommand { private readonly CommandExecuteDelegate _execute; - private Radegast.RadegastInstance _instance; /// /// Radegast instance received during start command /// - protected RadegastInstance Instance { get { return _instance; } } + protected RadegastInstance Instance { get; private set; } /// /// GridClinet associated with RadegastInstanc received during command startup /// - protected GridClient Client { get { return _instance.Client; } } + protected GridClient Client => Instance.Client; + /// - /// for subclasses (they should override Execute) - /// - /// - /// /// For simple creation of new commands /// /// public RadegastCommand(RadegastInstance inst) { - _instance = inst; + Instance = inst; _execute = null; } @@ -68,28 +53,28 @@ public RadegastCommand(RadegastInstance inst) /// public RadegastCommand(RadegastInstance inst, CommandExecuteDelegate exec) { - _instance = inst; + Instance = inst; _execute = exec; } - virtual public string Name { get; set; } + public virtual string Name { get; set; } - virtual public string Description { get; set; } + public virtual string Description { get; set; } - virtual public string Usage { get; set; } + public virtual string Usage { get; set; } - virtual public void StartCommand(RadegastInstance inst) + public virtual void StartCommand(RadegastInstance inst) { - _instance = inst; + Instance = inst; } // maybe we shoould make this class abstract to force people to implement - virtual public void Dispose() + public virtual void Dispose() { - _instance = null; + Instance = null; } - virtual public void Execute(string name, string[] cmdArgs, ConsoleWriteLine WriteLine) + public virtual void Execute(string name, string[] cmdArgs, ConsoleWriteLine WriteLine) { if (_execute == null) WriteLine("Someone did not implement {0}!", name); else _execute(name, cmdArgs, WriteLine); diff --git a/Radegast/Core/Commands/ScriptInfoCommand.cs b/Radegast/Core/Commands/ScriptInfoCommand.cs index ece04ff42..7bef20112 100644 --- a/Radegast/Core/Commands/ScriptInfoCommand.cs +++ b/Radegast/Core/Commands/ScriptInfoCommand.cs @@ -1,36 +1,24 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// -using System; +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System.Collections.Generic; -using System.Threading; using System.Text; using OpenMetaverse; using OpenMetaverse.Messages.Linden; @@ -51,24 +39,20 @@ public ScriptInfoCommand(RadegastInstance instance) this.instance = instance; } - public override void Dispose() - { - base.Dispose(); - } - public override void Execute(string name, string[] cmdArgs, ConsoleWriteLine WriteLine) { if (cmdArgs.Length == 0) { AttachmentInfo(WriteLine); } - else if (cmdArgs[0] == "avatar") - { - AttachmentInfo(WriteLine); - } - else if (cmdArgs[0] == "parcel") + else switch (cmdArgs[0]) { - ParcelInfo(WriteLine); + case "avatar": + AttachmentInfo(WriteLine); + break; + case "parcel": + ParcelInfo(WriteLine); + break; } } @@ -77,7 +61,7 @@ public void ParcelInfo(ConsoleWriteLine WriteLine) { WriteLine("Requesting script resources information..."); UUID currectParcel = Client.Parcels.RequestRemoteParcelID(Client.Self.SimPosition, Client.Network.CurrentSim.Handle, Client.Network.CurrentSim.ID); - Client.Parcels.GetParcelResouces(currectParcel, true, (bool success, LandResourcesInfo info) => + Client.Parcels.GetParcelResources(currectParcel, true, (success, info) => { if (!success || info == null) return; @@ -90,13 +74,13 @@ public void ParcelInfo(ConsoleWriteLine WriteLine) if (info.Parcels != null) { - for (int i = 0; i < info.Parcels.Length; i++) + foreach (ParcelResourcesDetail parcelresource in info.Parcels) { sb.AppendLine(); - sb.AppendLine("Detailed usage for parcel " + info.Parcels[i].Name); - for (int j = 0; j < info.Parcels[i].Objects.Length; j++) + sb.AppendLine("Detailed usage for parcel " + parcelresource.Name); + foreach (ObjectResourcesDetail ord in parcelresource.Objects) { - sb.AppendFormat("{0} KB - {1}", info.Parcels[i].Objects[j].Resources["memory"] / 1024, info.Parcels[i].Objects[j].Name); + sb.AppendFormat("{0} KB - {1}", ord.Resources["memory"] / 1024, ord.Name); sb.AppendLine(); } } @@ -107,7 +91,7 @@ public void ParcelInfo(ConsoleWriteLine WriteLine) public void AttachmentInfo(ConsoleWriteLine WriteLine) { - Client.Self.GetAttachmentResources((bool success, AttachmentResourcesMessage info) => + Client.Self.GetAttachmentResources((success, info) => { if (!success || info == null) { @@ -126,10 +110,9 @@ public void AttachmentInfo(ConsoleWriteLine WriteLine) foreach (KeyValuePair kvp in info.Attachments) { sb.AppendLine(); - sb.AppendLine(string.Format("Attached to {0} ", Utils.EnumToText(kvp.Key)) + ":"); - for (int i = 0; i < kvp.Value.Length; i++) + sb.AppendLine($"Attached to {Utils.EnumToText(kvp.Key)} " + ":"); + foreach (var obj in kvp.Value) { - ObjectResourcesDetail obj = kvp.Value[i]; sb.AppendLine(obj.Name + " using " + obj.Resources["memory"] / 1024 + " KB"); } } diff --git a/Radegast/Core/Commands/SimInfoCommand.cs b/Radegast/Core/Commands/SimInfoCommand.cs index 85765eb4f..c1f961a1d 100644 --- a/Radegast/Core/Commands/SimInfoCommand.cs +++ b/Radegast/Core/Commands/SimInfoCommand.cs @@ -1,36 +1,24 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; -using System.Collections.Generic; -using System.Threading; using System.Text; using OpenMetaverse; @@ -50,11 +38,6 @@ public SimInfoCommand(RadegastInstance instance) this.instance = instance; } - public override void Dispose() - { - base.Dispose(); - } - public override void Execute(string name, string[] cmdArgs, ConsoleWriteLine WriteLine) { StringBuilder sb = new StringBuilder(); diff --git a/Radegast/Core/Commands/SitCommand.cs b/Radegast/Core/Commands/SitCommand.cs index 34586ec84..f347079a0 100644 --- a/Radegast/Core/Commands/SitCommand.cs +++ b/Radegast/Core/Commands/SitCommand.cs @@ -1,37 +1,24 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// -using System; +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System.Collections.Generic; -using System.Text; -using System.Text.RegularExpressions; using System.Windows.Forms; using OpenMetaverse; @@ -40,7 +27,7 @@ namespace Radegast.Commands { public class SitCommand : RadegastCommand { - TabsConsole TC { get { return Instance.TabConsole; } } + TabsConsole TC => Instance.TabConsole; ObjectsConsole Objects; ChatConsole Chat; ConsoleWriteLine wl; @@ -106,11 +93,8 @@ public override void Execute(string name, string[] cmdArgs, ConsoleWriteLine Wri Objects = (ObjectsConsole)TC.Tabs["objects"].Control; List prims = Objects.GetObjectList(); - Primitive target = prims.Find((Primitive prim) => - { - return prim.Properties != null - && prim.Properties.Name.ToLower().Contains(cmd.ToLower()); - }); + Primitive target = prims.Find(prim => prim.Properties != null + && prim.Properties.Name.ToLower().Contains(cmd.ToLower())); if (target == null) { diff --git a/Radegast/Core/Commands/StatusCommand.cs b/Radegast/Core/Commands/StatusCommand.cs index 545106777..06a619862 100644 --- a/Radegast/Core/Commands/StatusCommand.cs +++ b/Radegast/Core/Commands/StatusCommand.cs @@ -1,37 +1,26 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections.Generic; using System.Text; -using System.Windows.Forms; using System.Threading; using OpenMetaverse; @@ -53,11 +42,6 @@ public StatusCommand(RadegastInstance instance) args = new List(); } - public override void Dispose() - { - base.Dispose(); - } - bool arg(string a) { return args.Count == 0 || args.Contains(a); @@ -84,7 +68,7 @@ public override void Execute(string name, string[] cmdArgs, ConsoleWriteLine Wri else { ManualResetEvent gotName = new ManualResetEvent(false); - EventHandler handler = (object sender, ObjectPropertiesFamilyEventArgs e) => + EventHandler handler = (sender, e) => { if (e.Properties.ObjectID == seat.ID) gotName.Set(); @@ -94,7 +78,7 @@ public override void Execute(string name, string[] cmdArgs, ConsoleWriteLine Wri Client.Objects.RequestObjectPropertiesFamily(Client.Network.CurrentSim, seat.ID); if (gotName.WaitOne(3000, false)) { - sb.Append(sb.AppendFormat(" on object {0}", seat.Properties.Name)); + sb.Append(sb.AppendFormat(" on object {0}", seat.Properties != null ? seat.Properties.Name : "")); } Client.Objects.ObjectPropertiesFamily -= handler; diff --git a/Radegast/Core/Commands/TPComand.cs b/Radegast/Core/Commands/TPComand.cs index 7f4e1bf4b..ed747d1cf 100644 --- a/Radegast/Core/Commands/TPComand.cs +++ b/Radegast/Core/Commands/TPComand.cs @@ -1,38 +1,26 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections.Generic; using System.Text; -using System.Text.RegularExpressions; -using System.Windows.Forms; using OpenMetaverse; @@ -40,9 +28,9 @@ namespace Radegast.Commands { public class TPCommand : RadegastCommand { - TabsConsole TC { get { return Instance.TabConsole; } } + TabsConsole TC => Instance.TabConsole; public static string FolderName = "Radegast Landmarks"; - Inventory Inv { get { return Client.Inventory.Store; } } + Inventory Inv => Client.Inventory.Store; ConsoleWriteLine wl; public TPCommand(RadegastInstance instance) @@ -54,11 +42,6 @@ public TPCommand(RadegastInstance instance) } - public override void Dispose() - { - base.Dispose(); - } - void PrintUsage() { wl("Wrong arguments for \"tp\" command. For detailed description type: " + CommandsManager.CmdPrefix + "tp help"); @@ -96,7 +79,7 @@ public override void Execute(string name, string[] cmdArgs, ConsoleWriteLine Wri return; } - InventoryFolder folder = (InventoryFolder)Inv.GetContents(Inv.RootFolder).Find((InventoryBase b) => { return b.Name == FolderName && b is InventoryFolder; }); + InventoryFolder folder = (InventoryFolder)Inv.GetContents(Inv.RootFolder).Find(b => b.Name == FolderName && b is InventoryFolder); if (folder == null) { Client.Inventory.CreateFolder(Inv.RootFolder.UUID, FolderName); @@ -106,8 +89,8 @@ public override void Execute(string name, string[] cmdArgs, ConsoleWriteLine Wri List landmarks = new List(); Inv.GetContents(folder) - .FindAll((InventoryBase b) => { return b is InventoryLandmark; }) - .ForEach((InventoryBase l) => { landmarks.Add((InventoryLandmark)l); }); + .FindAll(b => b is InventoryLandmark) + .ForEach(l => { landmarks.Add((InventoryLandmark)l); }); if (landmarks.Count == 0) { @@ -146,17 +129,15 @@ public override void Execute(string name, string[] cmdArgs, ConsoleWriteLine Wri return; } - InventoryLandmark lm = landmarks.Find((InventoryLandmark l) => { return l.Name.ToLower().StartsWith(cmd.ToLower()); }); + InventoryLandmark lm = landmarks.Find(l => l.Name.ToLower().StartsWith(cmd.ToLower())); if (lm == null) { WriteLine("Could not find landmark {0}, try {1}tp list", cmd, CommandsManager.CmdPrefix); - return; } else { WriteLine("Teleporting to {0}", lm.Name); Client.Self.RequestTeleport(lm.AssetUUID); - return; } } diff --git a/Radegast/Core/Commands/ThreadCommand.cs b/Radegast/Core/Commands/ThreadCommand.cs index d361f0366..7130ad718 100644 --- a/Radegast/Core/Commands/ThreadCommand.cs +++ b/Radegast/Core/Commands/ThreadCommand.cs @@ -1,41 +1,25 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections.Generic; -#if (COGBOT_LIBOMV || USE_STHREADS) -using ThreadPoolUtil; -using Thread = ThreadPoolUtil.Thread; -using ThreadPool = ThreadPoolUtil.ThreadPool; -using Monitor = ThreadPoolUtil.Monitor; -#endif using System.Threading; namespace Radegast.Commands @@ -44,22 +28,13 @@ public class ThreadCommand : IRadegastCommand { private List _listed = null; List _commandThreads = new List(); - Queue> _commandQueue { get { return instance.CommandsManager.CommandQueue; } } + Queue> _commandQueue => instance.CommandsManager.CommandQueue; private RadegastInstance instance; - public string Name - { - get { return "thread"; } - } + public string Name => "thread"; - public string Description - { - get { return "Runs a command in a thread"; } - } + public string Description => "Runs a command in a thread"; - public string Usage - { - get { return "thread "; } - } + public string Usage => "thread "; public void StartCommand(RadegastInstance inst) { diff --git a/Radegast/Core/Commands/UnsitCommand.cs b/Radegast/Core/Commands/UnsitCommand.cs index bd4b602fb..38af9711a 100644 --- a/Radegast/Core/Commands/UnsitCommand.cs +++ b/Radegast/Core/Commands/UnsitCommand.cs @@ -1,38 +1,22 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// -using System; -using System.Collections.Generic; -using System.Text; -using System.Text.RegularExpressions; -using System.Windows.Forms; +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ using OpenMetaverse; @@ -48,11 +32,6 @@ public UnsitCommand(RadegastInstance instance) Usage = "unsit"; } - public override void Dispose() - { - base.Dispose(); - } - public override void Execute(string name, string[] cmdArgs, ConsoleWriteLine WriteLine) { Instance.State.SetSitting(false, UUID.Zero); diff --git a/Radegast/Core/Contexts/AvatarProfileAction.cs b/Radegast/Core/Contexts/AvatarProfileAction.cs index 5d0d9da78..96538c646 100644 --- a/Radegast/Core/Contexts/AvatarProfileAction.cs +++ b/Radegast/Core/Contexts/AvatarProfileAction.cs @@ -1,33 +1,23 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id: -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using OpenMetaverse; diff --git a/Radegast/Core/Contexts/ContextAction.cs b/Radegast/Core/Contexts/ContextAction.cs index a3cb7698e..8949d9a37 100644 --- a/Radegast/Core/Contexts/ContextAction.cs +++ b/Radegast/Core/Contexts/ContextAction.cs @@ -1,37 +1,27 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id: -// +/* + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2021, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections.Generic; using System.Drawing; -using System.Threading; +using System.Threading.Tasks; using System.Windows.Forms; using OpenMetaverse; using OpenMetaverse.Assets; @@ -46,7 +36,6 @@ public class ContextAction : IContextAction public EventHandler Handler; protected RadegastInstance instance; public bool ExecAsync = true; - private Thread AsyncThread; public bool Enabled { get; set; } public virtual object DeRef(object o) { @@ -66,31 +55,15 @@ public virtual object DeRef(object o) } return o; } - protected ContextActionsManager ContextActionManager - { - get { return Instance.ContextActionManager; } - } + protected ContextActionsManager ContextActionManager => Instance.ContextActionManager; + public virtual RadegastInstance Instance { - get - { - return instance; - } - set - { - if (instance == value) - return; - instance = value; - } + get => instance; + set => instance = value; } - protected virtual GridClient Client - { - get - { - return Instance.Client; - } - } + protected virtual GridClient Client => Instance.Client; public ContextAction(RadegastInstance inst) { @@ -100,7 +73,7 @@ public ContextAction(RadegastInstance inst) public virtual bool IsEnabled(object target) { - return Enabled && Contributes(target,target!=null?target.GetType():null) || Enabled; + return Enabled && Contributes(target,target?.GetType()) || Enabled; } public virtual string ToolTipText(object target) @@ -124,20 +97,13 @@ public virtual IEnumerable GetToolItems(object target, Type t private void TCI(object sender, EventArgs e, object target) { - if (!this.ExecAsync) + if (!ExecAsync) { TryCatch(() => OnInvoke(sender, e, target)); return; } - if (AsyncThread != null && AsyncThread.IsAlive) - { - AsyncThread.Abort(); - } - AsyncThread = new Thread(() => TryCatch(() => OnInvoke(sender, e, target))) - { - Name = Label + " Async command" - }; - AsyncThread.Start(); + + Task command = Task.Run(() => TryCatch(() => OnInvoke(sender, e, target))); } protected void InvokeSync(MethodInvoker func) @@ -174,13 +140,6 @@ public virtual string LabelFor(object target) return Label; } - public virtual IEnumerable GetControls(object target, Type type) - { - Button button = new Button { Text = LabelFor(target), Enabled = IsEnabled(target) }; - button.Click += (sender, e) => TCI(sender, e, target); - return new List() { button }; - } - public virtual bool TypeContributes(Type o) { if (ExactContextType) return o.IsAssignableFrom(ContextType); @@ -204,7 +163,7 @@ public virtual void OnInvoke(object sender, EventArgs e, object target) { oneOf = GetValue(ContextType, DeRef(oneOf)); } - if (Handler != null) Handler(oneOf, e); + Handler?.Invoke(oneOf, e); } public virtual void IContextAction(RadegastInstance instance) diff --git a/Radegast/Core/Contexts/ContextActionsManager.cs b/Radegast/Core/Contexts/ContextActionsManager.cs index 3a79e5d16..bd5b6e7b5 100644 --- a/Radegast/Core/Contexts/ContextActionsManager.cs +++ b/Radegast/Core/Contexts/ContextActionsManager.cs @@ -1,35 +1,26 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id: -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections.Generic; +using System.Linq; using System.Windows.Forms; using OpenMetaverse; @@ -53,7 +44,7 @@ public ContextActionsManager(RadegastInstance instance) /// /// /// - /// Action + /// Action<object,EventArgs> public void RegisterContextAction(Type libomvType, String label, EventHandler handler) { RegisterContextAction(new ContextAction(instance) @@ -67,7 +58,7 @@ public void RegisterContextAction(Type libomvType, String label, EventHandler ha /// /// Deregister a Context Action - /// DeregisterContextAction(typeof(Object), "Clueless Object!"); + /// DeregisterContextAction(typeof(Object), "Clueless Object!") /// /// /// @@ -75,12 +66,9 @@ public void DeregisterContextAction(Type libomvType, String label) { lock (contextEventHandlers) { - contextEventHandlers.RemoveAll(e => - { - ContextAction ca = e as ContextAction; - return ca != null && ca.Label == label && - libomvType == ca.ContextType; - }); + contextEventHandlers.RemoveAll(e => e is ContextAction ca + && ca.Label == label + && libomvType == ca.ContextType); } } @@ -113,7 +101,7 @@ public void DeregisterContextAction(IContextAction handler) public void AddContributions(ToolStripDropDown strip, Object o) { SetCurrentItem(strip, o); - AddContributions(strip, o != null ? o.GetType() : null, o); + AddContributions(strip, o?.GetType(), o); } /// @@ -128,18 +116,13 @@ public static void AddContributions_Helper(ToolStripDropDown strip, List { string txt = (o.Text ?? "").ToLower().Trim(); - foreach (var i in strip.Items) + if (strip.Items.Cast().Any(item => txt == (item.Text ?? "").ToLower().Trim())) { - ToolStripItem item = (ToolStripItem)i; - if (txt != (item.Text ?? "").ToLower().Trim()) continue; txt = null; - break; } - foreach (var item in items) + if (items.Any(item => txt == (item.Text ?? "").ToLower().Trim())) { - if (txt != (item.Text ?? "").ToLower().Trim()) continue; txt = null; - break; } if (txt != null) items.Add(o); }); @@ -169,24 +152,9 @@ public void AddContributions(ToolStripDropDown strip, Type type, Object obj, par var v = i.GetToolItems(obj, type); if (v != null) { - foreach (ToolStripMenuItem item in v) - { - bool alreadyPresent = false; - foreach (object down in strip.Items) - { - if (down is ToolStripMenuItem) - { - ToolStripMenuItem mi = (ToolStripMenuItem) down; - if ((mi.Text ?? "").ToLower() == (item.Text ?? "").ToLower()) - { - alreadyPresent = true; - break; - } - } - } - if (alreadyPresent) continue; - items.Add(item); - } + items.AddRange(from item in v let alreadyPresent = strip.Items.OfType() + .Any(mi => string.Equals((mi.Text ?? ""), (item.Text ?? ""), StringComparison.CurrentCultureIgnoreCase)) + where !alreadyPresent select item); } } items.Sort(CompareItems); @@ -219,8 +187,7 @@ public void AddContributions(ToolStripDropDown strip, Type type, Object obj, par /// public void SetCurrentItem(ToolStripDropDown strip, object o) { - RadegastContextMenuStrip rmenu = strip as RadegastContextMenuStrip; - if (rmenu != null) rmenu.Selection = o; + if (strip is RadegastContextMenuStrip rmenu) rmenu.Selection = o; } private string ToString(object sender) @@ -229,12 +196,12 @@ private string ToString(object sender) if (sender is Control) { Control control = (Control)sender; - return string.Format("{0}{1} {2} {3}", t, control.Text, control.Name, ToString(control.Tag)); + return $"{t}{control.Text} {control.Name} {ToString(control.Tag)}"; } if (sender is ListViewItem) { ListViewItem control = (ListViewItem)sender; - return string.Format("{0}{1} {2} {3}", t, control.Text, control.Name, ToString(control.Tag)); + return $"{t}{control.Text} {control.Name} {ToString(control.Tag)}"; } return t + sender; } @@ -244,7 +211,7 @@ private string ToString(object sender) /// /// The form's menu /// The type it will target - /// the Target ofbject + /// the Target object /// Control to search for extra contributions (like buttons) public void GleanContributions(ToolStripDropDown strip, Type type, Object obj, params Control[] controls) { @@ -268,7 +235,7 @@ public void GleanContributions(ToolStripDropDown strip, Type type, Object obj, p /// The type it will target /// Parent control that has buttons on it /// Will becvome the button's target when - static public void GleanContributions_Helper(ICollection items, Type type, Control control, Object obj) + public static void GleanContributions_Helper(ICollection items, Type type, Control control, Object obj) { if (control == null) return; if (control is Button) @@ -276,13 +243,12 @@ static public void GleanContributions_Helper(ICollection item Button button = (Button)control; string newVariable = obj.GetType() == type ? type.Name - : string.Format("{0} -> {1}", obj.GetType().Name, type.Name); + : $"{obj.GetType().Name} -> {type.Name}"; items.Add(new ToolStripMenuItem(button.Text, null, (sender, e) => { button.PerformClick(); - Logger.DebugLog(String.Format("Button: {0} {1} {2} {3}", - newVariable, e, sender, obj)); + Logger.DebugLog($"Button: {newVariable} {e} {sender} {obj}"); }) { Enabled = button.Enabled, @@ -300,7 +266,7 @@ static int CompareItems(ToolStripItem i1, ToolStripItem i2) if (i1 == i2) return 0; if (i1 is ToolStripSeparator) return (i2 is ToolStripSeparator) ? 0 : -1; - int i = string.Compare(i1.Text, i2.Text); + int i = String.CompareOrdinal(i1.Text, i2.Text); return i == 0 ? i1.GetHashCode().CompareTo(i2.GetHashCode()) : i; } @@ -341,7 +307,7 @@ public bool LoadType(Type type) c = type.GetConstructor(Type.EmptyTypes); if (c != null) { - IContextAction plug = (IContextAction)c.Invoke(new object[0]); + IContextAction plug = (IContextAction)c.Invoke(Array.Empty()); RegisterContextAction(plug); return true; } @@ -350,7 +316,7 @@ public bool LoadType(Type type) { Logger.Log("ERROR in Radegast Command: " + type + " because " + ex.Message + " " + ex.StackTrace, Helpers.LogLevel.Debug); - throw ex; + throw; } } return false; diff --git a/Radegast/Core/Contexts/DeRezObjectAction.cs b/Radegast/Core/Contexts/DeRezObjectAction.cs index 4dd0b2477..f52ee450d 100644 --- a/Radegast/Core/Contexts/DeRezObjectAction.cs +++ b/Radegast/Core/Contexts/DeRezObjectAction.cs @@ -1,33 +1,23 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id: -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using OpenMetaverse; diff --git a/Radegast/Core/Contexts/IContextAction.cs b/Radegast/Core/Contexts/IContextAction.cs index 91000212b..8c9c749b5 100644 --- a/Radegast/Core/Contexts/IContextAction.cs +++ b/Radegast/Core/Contexts/IContextAction.cs @@ -1,33 +1,23 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id: -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections.Generic; using System.Windows.Forms; @@ -37,6 +27,7 @@ namespace Radegast public interface IContextAction : IDisposable { void IContextAction(RadegastInstance instance); + /// /// Generate a list of ToolStripMenuItems that might be be embeded into a ContextMenuStrip host /// @@ -44,25 +35,21 @@ public interface IContextAction : IDisposable /// the dereferenced type /// List of ToolStripMenuItem that will be appeneded to the current menu IEnumerable GetToolItems(object target, Type type); - /// - /// Get GUI items that one might include on the form to operate this action - /// - /// the context sensitive item - /// the dereferenced type - /// List of Buttons and Other hostable Controls that make sense to appear on the form when this item is selected - IEnumerable GetControls(object target, Type type); + /// /// If the menu item is Enabled /// /// the context sensiive item /// false when the menu Item should be greyed bool IsEnabled(object target); + /// /// The menu Item's text based on target /// /// the context sensiive item /// true if the Action is availble - for instance some Avatar might not even be logged in so "follow" would not even show up string LabelFor(object target); + /// /// If the context menu is usable to the target /// @@ -70,6 +57,7 @@ public interface IContextAction : IDisposable /// the dereferenced type /// The name that is displayed in a menu of options bool Contributes(Object target, Type type); + /// /// The Action code goes here /// diff --git a/Radegast/Core/Contexts/OfferTeleportAction.cs b/Radegast/Core/Contexts/OfferTeleportAction.cs index be8100e9d..84ac7944e 100644 --- a/Radegast/Core/Contexts/OfferTeleportAction.cs +++ b/Radegast/Core/Contexts/OfferTeleportAction.cs @@ -1,33 +1,23 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id: -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using OpenMetaverse; diff --git a/Radegast/Core/Contexts/PointAtAction.cs b/Radegast/Core/Contexts/PointAtAction.cs index eb876e000..f267582fb 100644 --- a/Radegast/Core/Contexts/PointAtAction.cs +++ b/Radegast/Core/Contexts/PointAtAction.cs @@ -1,35 +1,24 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id: -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; -using System.Threading; using OpenMetaverse; namespace Radegast diff --git a/Radegast/Core/Contexts/RequestTeleportAction.cs b/Radegast/Core/Contexts/RequestTeleportAction.cs new file mode 100644 index 000000000..6c5efced7 --- /dev/null +++ b/Radegast/Core/Contexts/RequestTeleportAction.cs @@ -0,0 +1,47 @@ +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + +using System; +using OpenMetaverse; + +namespace Radegast +{ + public class RequestTeleportAction : ContextAction + { + public RequestTeleportAction(RadegastInstance inst) + : base(inst) + { + Label = "Request Teleport"; + ContextType = typeof(Avatar); + } + + public override bool IsEnabled(object target) + { + return true; + } + + public override void OnInvoke(object sender, EventArgs e, object target) + { + UUID id = ToUUID(target); + instance.MainForm.AddNotification(new ntfSendLureRequest(instance, id)); + instance.TabConsole.DisplayNotificationInChat(string.Format("Sent Teleport Request to {0}", id)); + } + } +} diff --git a/Radegast/Core/Contexts/RezInventoryObjectAction.cs b/Radegast/Core/Contexts/RezInventoryObjectAction.cs index 25564c57a..c9cb71b18 100644 --- a/Radegast/Core/Contexts/RezInventoryObjectAction.cs +++ b/Radegast/Core/Contexts/RezInventoryObjectAction.cs @@ -1,33 +1,23 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id: -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using OpenMetaverse; diff --git a/Radegast/Core/Contexts/SitOnGroundAction.cs b/Radegast/Core/Contexts/SitOnGroundAction.cs index cfd469e5c..e2294d9e2 100644 --- a/Radegast/Core/Contexts/SitOnGroundAction.cs +++ b/Radegast/Core/Contexts/SitOnGroundAction.cs @@ -1,35 +1,24 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id: -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; -using System.Threading; using OpenMetaverse; namespace Radegast @@ -68,7 +57,7 @@ public override void OnInvoke(object sender, EventArgs e, object target) Simulator sim = null; Vector3 pos; - if (base.TryFindPos(target, out sim, out pos)) + if (TryFindPos(target, out sim, out pos)) { instance.TabConsole.DisplayNotificationInChat(string.Format("Walking to {0}", pname)); instance.State.MoveTo(sim, pos, false); diff --git a/Radegast/Core/Contexts/TeleportToAction.cs b/Radegast/Core/Contexts/TeleportToAction.cs index 395131c6c..6db02c335 100644 --- a/Radegast/Core/Contexts/TeleportToAction.cs +++ b/Radegast/Core/Contexts/TeleportToAction.cs @@ -1,33 +1,23 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id: -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using OpenMetaverse; @@ -57,7 +47,7 @@ public override void OnInvoke(object sender, EventArgs e, object target) Simulator sim = null; Vector3 pos; - if (base.TryFindPos(target, out sim, out pos)) + if (TryFindPos(target, out sim, out pos)) { instance.TabConsole.DisplayNotificationInChat(string.Format("Teleport to {0}", pname)); instance.State.MoveTo(sim, pos, true); diff --git a/Radegast/Core/Contexts/TurnToAction.cs b/Radegast/Core/Contexts/TurnToAction.cs index 3955f88c1..79eab486f 100644 --- a/Radegast/Core/Contexts/TurnToAction.cs +++ b/Radegast/Core/Contexts/TurnToAction.cs @@ -1,33 +1,23 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id: -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using OpenMetaverse; @@ -57,7 +47,7 @@ public override void OnInvoke(object sender, EventArgs e, object target) Simulator sim = null; Vector3 pos; - if (base.TryFindPos(target, out sim, out pos)) + if (TryFindPos(target, out sim, out pos)) { instance.TabConsole.DisplayNotificationInChat(string.Format("Facing {0}", pname)); Client.Self.Movement.TurnToward(instance.State.ToLocalPosition(sim.Handle, pos)); diff --git a/Radegast/Core/Contexts/WalkToAction.cs b/Radegast/Core/Contexts/WalkToAction.cs index 6ed3a79f1..0ac7fdf18 100644 --- a/Radegast/Core/Contexts/WalkToAction.cs +++ b/Radegast/Core/Contexts/WalkToAction.cs @@ -1,33 +1,23 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id: -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using OpenMetaverse; @@ -57,7 +47,7 @@ public override void OnInvoke(object sender, EventArgs e, object target) Simulator sim = null; Vector3 pos; - if (base.TryFindPos(target, out sim, out pos)) + if (TryFindPos(target, out sim, out pos)) { instance.TabConsole.DisplayNotificationInChat(string.Format("Walking to {0}", pname)); instance.State.MoveTo(sim, pos, false); diff --git a/Radegast/Core/DAEExport.cs b/Radegast/Core/DAEExport.cs index 7010f8f64..5780da1f4 100644 --- a/Radegast/Core/DAEExport.cs +++ b/Radegast/Core/DAEExport.cs @@ -1,31 +1,22 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +/* + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2021, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ using System; using System.Collections.Generic; @@ -33,10 +24,12 @@ using System.Xml; using System.IO; using System.Drawing; +using System.Threading; +using CoreJ2K; using OpenMetaverse; using OpenMetaverse.Rendering; -using OpenMetaverse.Imaging; -using OpenMetaverse.Assets; +using SkiaSharp; +using SkiaSharp.Views.Desktop; namespace Radegast { @@ -64,7 +57,7 @@ public class DAEExport : IDisposable }; RadegastInstance Instance; - GridClient Client { get { return Instance.Client; } } + GridClient Client => Instance.Client; System.Globalization.CultureInfo invariant = System.Globalization.CultureInfo.InvariantCulture; MeshmerizerR Mesher; XmlDocument Doc; @@ -73,10 +66,7 @@ public class DAEExport : IDisposable void OnProgress(string message) { - if (Progress != null) - { - Progress(this, new DAEStatutsEventArgs(message)); - } + Progress?.Invoke(this, new DAEStatutsEventArgs(message)); } public DAEExport(RadegastInstance instance, Primitive requestedPrim) @@ -109,8 +99,7 @@ public void Init(Simulator sim, Primitive requestedPrim) } Prims.Clear(); - Primitive root = new Primitive(RootPrim); - root.Position = Vector3.Zero; + Primitive root = new Primitive(RootPrim) {Position = Vector3.Zero}; Prims.Add(root); sim.ObjectsPrimitives @@ -128,19 +117,18 @@ public void Init(Simulator sim, Primitive requestedPrim) OnProgress("Checking permissions"); ExportablePrims = 0; - for (int i = 0; i < Prims.Count; i++) + foreach (var prim in Prims) { - if (!CanExport(Prims[i])) continue; + if (!CanExport(prim)) continue; ExportablePrims++; - var defaultTexture = Prims[i].Textures.DefaultTexture; + var defaultTexture = prim.Textures.DefaultTexture; if (defaultTexture != null && !Textures.Contains(defaultTexture.TextureID)) { Textures.Add(defaultTexture.TextureID); } - for (int j = 0; j < Prims[i].Textures.FaceTextures.Length; j++) + foreach (var te in prim.Textures.FaceTextures) { - var te = Prims[i].Textures.FaceTextures[j]; if (te == null) continue; UUID id = te.TextureID; if (!Textures.Contains(id)) @@ -165,7 +153,7 @@ public void Init(Simulator sim, Primitive requestedPrim) public void Export(string Filename) { - this.FileName = Filename; + FileName = Filename; MeshedPrims.Clear(); @@ -174,17 +162,17 @@ public void Export(string Filename) return; } - WorkPool.QueueUserWorkItem(sync => + ThreadPool.QueueUserWorkItem(sync => { if (ExportTextures) { SaveTextures(); } - for (int i = 0; i < Prims.Count; i++) + foreach (var prim in Prims) { - if (!CanExport(Prims[i])) continue; + if (!CanExport(prim)) continue; - FacetedMesh mesh = MeshPrim(Prims[i]); + FacetedMesh mesh = MeshPrim(prim); if (mesh == null) continue; for (int j = 0; j < mesh.Faces.Count; j++) @@ -196,14 +184,14 @@ public void Export(string Filename) // Sculpt UV vertically flipped compared to prims. Flip back - if (Prims[i].Sculpt != null && Prims[i].Sculpt.SculptTexture != UUID.Zero && Prims[i].Sculpt.Type != SculptType.Mesh) + if (prim.Sculpt != null && prim.Sculpt.SculptTexture != UUID.Zero && prim.Sculpt.Type != SculptType.Mesh) { teFace = (Primitive.TextureEntryFace)teFace.Clone(); teFace.RepeatV *= -1; } // Texture transform for this face - Mesher.TransformTexCoords(face.Vertices, face.Center, teFace, Prims[i].Scale); + Mesher.TransformTexCoords(face.Vertices, face.Center, teFace, prim.Scale); } MeshedPrims.Add(mesh); @@ -232,7 +220,7 @@ void SaveTextures() var id = Textures[i]; if (TextureNames[i] == null) { - OnProgress("Skipping " + id.ToString() + " due to insufficient permissions"); + OnProgress("Skipping " + id + " due to insufficient permissions"); continue; } @@ -240,19 +228,18 @@ void SaveTextures() OnProgress("Fetching texture" + id); - ManagedImage mImage = null; Image wImage = null; byte[] jpegData = null; try { - System.Threading.AutoResetEvent gotImage = new System.Threading.AutoResetEvent(false); + AutoResetEvent gotImage = new AutoResetEvent(false); Client.Assets.RequestImage(id, ImageType.Normal, (state, asset) => { if (state == TextureRequestState.Finished && asset != null) { jpegData = asset.AssetData; - OpenJPEG.DecodeToImage(jpegData, out mImage, out wImage); + wImage = J2kImage.FromBytes(jpegData).As().ToBitmap(); gotImage.Set(); } else if (state != TextureRequestState.Pending && state != TextureRequestState.Started && state != TextureRequestState.Progress) @@ -280,7 +267,7 @@ void SaveTextures() File.WriteAllBytes(fullFileName, jpegData); break; case "TGA": - File.WriteAllBytes(fullFileName, mImage.ExportTGA()); + //File.WriteAllBytes(fullFileName, mImage.ExportTGA()); break; default: throw new Exception("Unsupported image format"); @@ -295,7 +282,7 @@ void SaveTextures() } catch (Exception ex) { - OnProgress("Failed: " + ex.ToString()); + OnProgress("Failed: " + ex); TextureNames[i] = null; } @@ -376,10 +363,10 @@ FacetedMesh MeshPrim(Primitive prim) } else if (prim.Sculpt.Type != SculptType.Mesh) { - Image img = null; + SKBitmap img = null; if (LoadTexture(prim.Sculpt.SculptTexture, ref img, true)) { - mesh = Mesher.GenerateFacetedSculptMesh(prim, (Bitmap)img, DetailLevel.Highest); + mesh = Mesher.GenerateFacetedSculptMesh(prim, img, DetailLevel.Highest); } } else @@ -400,30 +387,19 @@ FacetedMesh MeshPrim(Primitive prim) return mesh; } - bool LoadTexture(UUID textureID, ref Image texture, bool removeAlpha) + bool LoadTexture(UUID textureID, ref SKBitmap texture, bool removeAlpha) { var gotImage = new System.Threading.ManualResetEvent(false); - Image img = null; + SKBitmap img = null; try { gotImage.Reset(); - byte[] tgaData; - Client.Assets.RequestImage(textureID, (TextureRequestState state, AssetTexture assetTexture) => + Client.Assets.RequestImage(textureID, (state, assetTexture) => { - ManagedImage mi; - if (state == TextureRequestState.Finished && OpenJPEG.DecodeToImage(assetTexture.AssetData, out mi)) + if (state == TextureRequestState.Finished) { - - if (removeAlpha) - { - if ((mi.Channels & ManagedImage.ImageChannels.Alpha) != 0) - { - mi.ConvertChannels(mi.Channels & ~ManagedImage.ImageChannels.Alpha); - } - } - tgaData = mi.ExportTGA(); - img = LoadTGAClass.LoadTGA(new MemoryStream(tgaData)); + img = J2kImage.FromBytes(assetTexture.AssetData).As(); } gotImage.Set(); }); @@ -566,9 +542,8 @@ void AddPolygons(XmlNode mesh, string geomID, string materialID, FacetedMesh obj void GenerateImagesSection(XmlNode images) { - for (int i = 0; i < TextureNames.Length; i++) + foreach (var name in TextureNames) { - string name = TextureNames[i]; if (name == null) continue; string colladaName = name + "_" + ImageFormat.ToLower(); var image = images.AppendChild(Doc.CreateElement("image")); @@ -606,12 +581,12 @@ MaterialInfo GetMaterial(Primitive.TextureEntryFace te) if (ret == null) { - ret = new MaterialInfo() + ret = new MaterialInfo { TextureID = te.TextureID, - Color = te.RGBA + Color = te.RGBA, + Name = $"Material{AllMeterials.Count}" }; - ret.Name = string.Format("Material{0}", AllMeterials.Count); AllMeterials.Add(ret); } @@ -741,11 +716,11 @@ void GenerateCollada() foreach (var obj in MeshedPrims) { int total_num_vertices = 0; - string name = string.Format("prim{0}", prim_nr++); + string name = $"prim{prim_nr++}"; string geomID = name; var geom = geomLib.AppendChild(Doc.CreateElement("geometry")); - geom.Attributes.Append(Doc.CreateAttribute("id")).InnerText = string.Format("{0}-{1}", geomID, "mesh"); + geom.Attributes.Append(Doc.CreateAttribute("id")).InnerText = $"{geomID}-mesh"; var mesh = geom.AppendChild(Doc.CreateElement("mesh")); List position_data = new List(); @@ -759,9 +734,8 @@ void GenerateCollada() var face = obj.Faces[face_num]; total_num_vertices += face.Vertices.Count; - for (int i = 0; i < face.Vertices.Count; i++) + foreach (var v in face.Vertices) { - var v = face.Vertices[i]; position_data.Add(v.Position.X); position_data.Add(v.Position.Y); position_data.Add(v.Position.Z); @@ -775,17 +749,17 @@ void GenerateCollada() } } - AddSource(mesh, string.Format("{0}-{1}", geomID, "positions"), "XYZ", position_data); - AddSource(mesh, string.Format("{0}-{1}", geomID, "normals"), "XYZ", normal_data); - AddSource(mesh, string.Format("{0}-{1}", geomID, "map0"), "ST", uv_data); + AddSource(mesh, $"{geomID}-positions", "XYZ", position_data); + AddSource(mesh, $"{geomID}-normals", "XYZ", normal_data); + AddSource(mesh, $"{geomID}-map0", "ST", uv_data); // Add the element { var verticesNode = mesh.AppendChild(Doc.CreateElement("vertices")); - verticesNode.Attributes.Append(Doc.CreateAttribute("id")).InnerText = string.Format("{0}-{1}", geomID, "vertices"); + verticesNode.Attributes.Append(Doc.CreateAttribute("id")).InnerText = $"{geomID}-vertices"; var verticesInput = verticesNode.AppendChild(Doc.CreateElement("input")); verticesInput.Attributes.Append(Doc.CreateAttribute("semantic")).InnerText = "POSITION"; - verticesInput.Attributes.Append(Doc.CreateAttribute("source")).InnerText = string.Format("#{0}-{1}", geomID, "positions"); + verticesInput.Attributes.Append(Doc.CreateAttribute("source")).InnerText = $"#{geomID}-positions"; } var objMaterials = GetMaterials(obj); @@ -797,38 +771,48 @@ void GenerateCollada() } var node = scene.AppendChild(Doc.CreateElement("node")); - node.Attributes.Append(Doc.CreateAttribute("type")).InnerText = "NODE"; - node.Attributes.Append(Doc.CreateAttribute("id")).InnerText = geomID; - node.Attributes.Append(Doc.CreateAttribute("name")).InnerText = geomID; + if (node.Attributes != null) + { + node.Attributes.Append(Doc.CreateAttribute("type")).InnerText = "NODE"; + node.Attributes.Append(Doc.CreateAttribute("id")).InnerText = geomID; + node.Attributes.Append(Doc.CreateAttribute("name")).InnerText = geomID; - // Set tranform matrix (node position, rotation and scale) - var matrix = node.AppendChild(Doc.CreateElement("matrix")); + // Set tranform matrix (node position, rotation and scale) + var matrix = node.AppendChild(Doc.CreateElement("matrix")); - var srt = Radegast.Rendering.Math3D.CreateSRTMatrix(obj.Prim.Scale, obj.Prim.Rotation, obj.Prim.Position); - string matrixVal = ""; - for (int i = 0; i < 4; i++) - { - for (int j = 0; j < 4; j++) + var srt = Rendering.Math3D.CreateSRTMatrix(obj.Prim.Scale, obj.Prim.Rotation, obj.Prim.Position); + string matrixVal = ""; + for (int i = 0; i < 4; i++) { - matrixVal += srt[j * 4 + i].ToString(invariant) + " "; + for (int j = 0; j < 4; j++) + { + matrixVal += srt[j * 4 + i].ToString(invariant) + " "; + } } - } - matrix.InnerText = matrixVal.TrimEnd(); + matrix.InnerText = matrixVal.TrimEnd(); - // Geometry of the node - var nodeGeometry = node.AppendChild(Doc.CreateElement("instance_geometry")); + // Geometry of the node + var nodeGeometry = node.AppendChild(Doc.CreateElement("instance_geometry")); - // Bind materials - var tq = nodeGeometry.AppendChild(Doc.CreateElement("bind_material")) - .AppendChild(Doc.CreateElement("technique_common")); - foreach (var objMaterial in objMaterials) - { - var instanceMaterial = tq.AppendChild(Doc.CreateElement("instance_material")); - instanceMaterial.Attributes.Append(Doc.CreateAttribute("symbol")).InnerText = string.Format("{0}-{1}", objMaterial.Name, "material"); - instanceMaterial.Attributes.Append(Doc.CreateAttribute("target")).InnerText = string.Format("#{0}-{1}", objMaterial.Name, "material"); - } + // Bind materials + var tq = nodeGeometry.AppendChild(Doc.CreateElement("bind_material")) + .AppendChild(Doc.CreateElement("technique_common")); + foreach (var objMaterial in objMaterials) + { + var instanceMaterial = tq.AppendChild(Doc.CreateElement("instance_material")); + if (instanceMaterial.Attributes != null) + { + instanceMaterial.Attributes.Append(Doc.CreateAttribute("symbol")).InnerText = + $"{objMaterial.Name}-material"; + instanceMaterial.Attributes.Append(Doc.CreateAttribute("target")).InnerText = + $"#{objMaterial.Name}-material"; + } + } - nodeGeometry.Attributes.Append(Doc.CreateAttribute("url")).InnerText = string.Format("#{0}-{1}", geomID, "mesh"); + if (nodeGeometry.Attributes != null) + nodeGeometry.Attributes.Append(Doc.CreateAttribute("url")).InnerText = + $"#{geomID}-mesh"; + } } GenerateEffects(effects); @@ -837,15 +821,21 @@ void GenerateCollada() foreach (var objMaterial in AllMeterials) { var mat = materials.AppendChild(Doc.CreateElement("material")); - mat.Attributes.Append(Doc.CreateAttribute("id")).InnerText = objMaterial.Name + "-material"; - var matEffect = mat.AppendChild(Doc.CreateElement("instance_effect")); - matEffect.Attributes.Append(Doc.CreateAttribute("url")).InnerText = string.Format("#{0}-{1}", objMaterial.Name, "fx"); + if (mat.Attributes != null) + { + mat.Attributes.Append(Doc.CreateAttribute("id")).InnerText = objMaterial.Name + "-material"; + var matEffect = mat.AppendChild(Doc.CreateElement("instance_effect")); + if (matEffect.Attributes != null) + matEffect.Attributes.Append(Doc.CreateAttribute("url")).InnerText = + $"#{objMaterial.Name}-fx"; + } } - root.AppendChild(Doc.CreateElement("scene")) + XmlAttributeCollection xmlAttributeCollection = root.AppendChild(Doc.CreateElement("scene")) .AppendChild(Doc.CreateElement("instance_visual_scene")) - .Attributes.Append(Doc.CreateAttribute("url")).InnerText = "#Scene"; - + .Attributes; + if (xmlAttributeCollection != null) + xmlAttributeCollection.Append(Doc.CreateAttribute("url")).InnerText = "#Scene"; } string DocToString(XmlDocument doc) @@ -854,18 +844,16 @@ string DocToString(XmlDocument doc) try { using (MemoryStream outs = new MemoryStream()) - { - using (XmlTextWriter writter = new XmlTextWriter(outs, Encoding.UTF8)) + using (XmlTextWriter writter = new XmlTextWriter(outs, Encoding.UTF8)) + { + writter.Formatting = Formatting.Indented; + doc.WriteContentTo(writter); + writter.Flush(); + outs.Flush(); + outs.Position = 0; + using (StreamReader sr = new StreamReader(outs)) { - writter.Formatting = Formatting.Indented; - doc.WriteContentTo(writter); - writter.Flush(); - outs.Flush(); - outs.Position = 0; - using (StreamReader sr = new StreamReader(outs)) - { - ret += sr.ReadToEnd(); - } + ret += sr.ReadToEnd(); } } } diff --git a/Radegast/Core/GestureManager.cs b/Radegast/Core/GestureManager.cs new file mode 100644 index 000000000..f1396693e --- /dev/null +++ b/Radegast/Core/GestureManager.cs @@ -0,0 +1,220 @@ +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + +using System; +using System.Collections.Generic; +using System.Text; +using OpenMetaverse; +using OpenMetaverse.Assets; + +namespace Radegast.Core +{ + public class GestureManager + { + private class GestureTrigger + { + public string TriggerLower { get; set; } + public string Replacement { get; set; } + public UUID AssetID { get; set; } + } + + /// Gesture manager instance + public static GestureManager Instance { get; } = new GestureManager(); + + private Dictionary Gestures { get; } = new Dictionary(); + private Random Random { get; } = new Random(); + + /// + /// Begins monitoring for changes in gestures. + /// + public void BeginMonitoring() + { + var client = RadegastInstance.GlobalInstance.Client; + client.Inventory.Store.InventoryObjectAdded += Store_InventoryObjectAdded; + client.Inventory.Store.InventoryObjectUpdated += Store_InventoryObjectUpdated; + + foreach (var item in client.Inventory.Store.Items) + { + var gesture = item.Value.Data as InventoryGesture; + if (gesture == null) + { + continue; + } + + UpdateInventoryGesture(gesture); + } + } + + /// + /// Stops monitoring for changes in gestures. + /// + public void StopMonitoring() + { + var client = RadegastInstance.GlobalInstance.Client; + client.Inventory.Store.InventoryObjectAdded -= Store_InventoryObjectAdded; + client.Inventory.Store.InventoryObjectUpdated -= Store_InventoryObjectUpdated; + } + + /// + /// Processes a chat message and activates a gesture if a gesture trigger is present. + /// + /// Message to process + /// New message after gesture has been triggered and trigger word has been replaced + public string PreProcessChatMessage(string message) + { + var outString = new StringBuilder(message.Length); + var words = message.Split(' '); + var gestureWasTriggered = false; + + foreach (var word in words) + { + if (gestureWasTriggered) + { + outString.Append(word); + outString.Append(' '); + } + else + { + gestureWasTriggered = ProcessWord(word, outString); + } + } + + // Remove trailing space that was added above at the end of our new sentence + if (outString.Length > 0 && outString[outString.Length - 1] == ' ') + { + outString.Remove(outString.Length - 1, 1); + } + + return outString.ToString(); + } + + /// + /// Checks a single word for a gesture trigger and appends the final word to the output + /// + /// Word to check for gesture triggers + /// Where to output the word or replacement word to + /// True if a gesture trigger was executed. + private bool ProcessWord(string word, StringBuilder outString) + { + var possibleTriggers = new List(); + var client = RadegastInstance.GlobalInstance.Client; + var lowerWord = word.ToLower(); + + client.Self.ActiveGestures.ForEach(pair => + { + var activeGestureID = pair.Key; + if (!Gestures.ContainsKey(activeGestureID)) + { + return; + } + var gesture = Gestures[activeGestureID]; + + if (lowerWord != gesture.TriggerLower) + { + return; + } + + possibleTriggers.Add(gesture); + }); + + if (possibleTriggers.Count == 0) + { + outString.Append(word); + outString.Append(' '); + return false; + } + + GestureTrigger gestureToPlay; + if (possibleTriggers.Count > 1) + { + var gestureIndexToPlay = Random.Next(possibleTriggers.Count); + gestureToPlay = possibleTriggers[gestureIndexToPlay]; + } + else + { + gestureToPlay = possibleTriggers[0]; + } + + client.Self.PlayGesture(gestureToPlay.AssetID); + + if (!String.IsNullOrEmpty(gestureToPlay.Replacement)) + { + outString.Append(gestureToPlay.Replacement); + outString.Append(' '); + } + + return true; + } + + /// + /// Handles any addition or update to gesture items in the inventory. + /// + /// Gesture that was added or updated. + private void UpdateInventoryGesture(InventoryGesture gesture) + { + var client = RadegastInstance.GlobalInstance.Client; + + client.Assets.RequestAsset(gesture.AssetUUID, AssetType.Gesture, false, (_, asset) => + { + if (!(asset is AssetGesture assetGesture)) + { + return; + } + + if (!assetGesture.Decode()) + { + return; + } + + if (!Gestures.ContainsKey(gesture.UUID)) + { + Gestures.Add(gesture.UUID, new GestureTrigger()); + } + + if (Gestures.TryGetValue(gesture.UUID, out var existingGestureTrigger)) + { + existingGestureTrigger.TriggerLower = assetGesture.Trigger.ToLower(); + existingGestureTrigger.Replacement = assetGesture.ReplaceWith; + existingGestureTrigger.AssetID = assetGesture.AssetID; + } + }); + } + + private void Store_InventoryObjectUpdated(object sender, InventoryObjectUpdatedEventArgs e) + { + if (!(e.NewObject is InventoryGesture gesture)) + { + return; + } + + UpdateInventoryGesture(gesture); + } + + private void Store_InventoryObjectAdded(object sender, InventoryObjectAddedEventArgs e) + { + if (!(e.Obj is InventoryGesture gesture)) + { + return; + } + + UpdateInventoryGesture(gesture); + } + } +} diff --git a/Radegast/Core/GridManager.cs b/Radegast/Core/GridManager.cs index b18b6d5eb..f95e1f758 100644 --- a/Radegast/Core/GridManager.cs +++ b/Radegast/Core/GridManager.cs @@ -1,37 +1,26 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections.Generic; using System.IO; -using System.Text; using System.Reflection; using OpenMetaverse; using OpenMetaverse.StructuredData; @@ -57,8 +46,8 @@ public Grid() { } public Grid(string ID, string name, string loginURI) { this.ID = ID; - this.Name = name; - this.LoginURI = loginURI; + Name = name; + LoginURI = loginURI; } public override string ToString() @@ -111,20 +100,20 @@ public void LoadGrids() { string sysGridsFile = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "grids.xml"); OSDArray sysGrids = (OSDArray)OSDParser.DeserializeLLSDXml(File.ReadAllText(sysGridsFile)); - for (int i = 0; i < sysGrids.Count; i++) + foreach (var grid in sysGrids) { - RegisterGrid(Grid.FromOSD(sysGrids[i])); + RegisterGrid(Grid.FromOSD(grid)); } } catch (Exception ex) { - Logger.Log(string.Format("Error loading grid information: {0}", ex.Message), Helpers.LogLevel.Warning); + Logger.Log($"Error loading grid information: {ex.Message}", Helpers.LogLevel.Warning); } } public void RegisterGrid(Grid grid) { - int ix = Grids.FindIndex((Grid g) => { return g.ID == grid.ID; }); + int ix = Grids.FindIndex(g => g.ID == grid.ID); if (ix < 0) { Grids.Add(grid); @@ -135,10 +124,7 @@ public void RegisterGrid(Grid grid) } } - public Grid this[int ix] - { - get { return Grids[ix]; } - } + public Grid this[int ix] => Grids[ix]; public Grid this[string gridID] { @@ -161,9 +147,6 @@ public bool KeyExists(string gridID) return false; } - public int Count - { - get { return Grids.Count; } - } + public int Count => Grids.Count; } } diff --git a/Radegast/Core/IMTextManager.cs b/Radegast/Core/IMTextManager.cs index d74c8b1cc..50f1fed4b 100644 --- a/Radegast/Core/IMTextManager.cs +++ b/Radegast/Core/IMTextManager.cs @@ -1,43 +1,33 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections; using System.Drawing; using System.Text; using System.IO; -using Radegast.Netcom; +using Radegast; using OpenMetaverse; using OpenMetaverse.StructuredData; -using System.Web.Script.Serialization; using System.Collections.Generic; +using Newtonsoft.Json; namespace Radegast { @@ -46,25 +36,21 @@ public class IMTextManager public bool DingOnAllIncoming = false; RadegastInstance instance; - RadegastNetcom netcom { get { return instance.Netcom; } } - ITextPrinter textPrinter; + Radegast.Netcom netcom => instance.Netcom; IMTextManagerType Type; - UUID sessionID; string sessionName; bool AutoResponseSent = false; ArrayList textBuffer; - bool showTimestamps; - public static Dictionary fontSettings = new Dictionary(); public IMTextManager(RadegastInstance instance, ITextPrinter textPrinter, IMTextManagerType type, UUID sessionID, string sessionName) { - this.sessionID = sessionID; + SessionID = sessionID; this.sessionName = sessionName; - this.textPrinter = textPrinter; - this.textBuffer = new ArrayList(); - this.Type = type; + TextPrinter = textPrinter; + textBuffer = new ArrayList(); + Type = type; this.instance = instance; PrintLastLog(); @@ -76,7 +62,6 @@ public IMTextManager(RadegastInstance instance, ITextPrinter textPrinter, IMText private void InitializeConfig() { Settings s = instance.GlobalSettings; - var serializer = new JavaScriptSerializer(); if (s["im_timestamps"].Type == OSDType.Unknown) { @@ -86,7 +71,7 @@ private void InitializeConfig() { try { - s["chat_fonts"] = serializer.Serialize(Settings.DefaultFontSettings); + s["chat_fonts"] = JsonConvert.SerializeObject(Settings.DefaultFontSettings); } catch (Exception ex) { @@ -96,31 +81,30 @@ private void InitializeConfig() try { - fontSettings = serializer.Deserialize>(s["chat_fonts"]); + fontSettings = JsonConvert.DeserializeObject>(s["chat_fonts"]); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show("Failed to read chat font settings: " + ex.Message); } - showTimestamps = s["im_timestamps"].AsBoolean(); + ShowTimestamps = s["im_timestamps"].AsBoolean(); - s.OnSettingChanged += new Settings.SettingChangedCallback(s_OnSettingChanged); + s.OnSettingChanged += s_OnSettingChanged; } void s_OnSettingChanged(object sender, SettingsEventArgs e) { if (e.Key == "im_timestamps" && e.Value != null) { - showTimestamps = e.Value.AsBoolean(); + ShowTimestamps = e.Value.AsBoolean(); ReprintAllText(); } else if(e.Key == "chat_fonts") { try { - var serializer = new JavaScriptSerializer(); - fontSettings = serializer.Deserialize>(e.Value); + fontSettings = JsonConvert.DeserializeObject>(e.Value); } catch (Exception ex) { @@ -132,8 +116,8 @@ void s_OnSettingChanged(object sender, SettingsEventArgs e) private void AddNetcomEvents() { - netcom.InstantMessageReceived += new EventHandler(netcom_InstantMessageReceived); - netcom.InstantMessageSent += new EventHandler(netcom_InstantMessageSent); + netcom.InstantMessageReceived += netcom_InstantMessageReceived; + netcom.InstantMessageSent += netcom_InstantMessageSent; } private void RemoveNetcomEvents() @@ -144,7 +128,7 @@ private void RemoveNetcomEvents() private void netcom_InstantMessageSent(object sender, InstantMessageSentEventArgs e) { - if (e.SessionID != sessionID) return; + if (e.SessionID != SessionID) return; textBuffer.Add(e); ProcessIM(e, true); @@ -152,7 +136,7 @@ private void netcom_InstantMessageSent(object sender, InstantMessageSentEventArg private void netcom_InstantMessageReceived(object sender, InstantMessageEventArgs e) { - if (e.IM.IMSessionID != sessionID) return; + if (e.IM.IMSessionID != SessionID) return; if (e.IM.Dialog == InstantMessageDialog.StartTyping || e.IM.Dialog == InstantMessageDialog.StopTyping) return; @@ -169,9 +153,9 @@ private void netcom_InstantMessageReceived(object sender, InstantMessageEventArg public void ProcessIM(object e, bool isNewMessage) { if (e is InstantMessageEventArgs) - this.ProcessIncomingIM((InstantMessageEventArgs)e, isNewMessage); + ProcessIncomingIM((InstantMessageEventArgs)e, isNewMessage); else if (e is InstantMessageSentEventArgs) - this.ProcessOutgoingIM((InstantMessageSentEventArgs)e, isNewMessage); + ProcessOutgoingIM((InstantMessageSentEventArgs)e, isNewMessage); } private void ProcessOutgoingIM(InstantMessageSentEventArgs e, bool isNewMessage) @@ -245,85 +229,85 @@ public void DisplayNotification(string message) return; } - if (showTimestamps) + if (ShowTimestamps) { if(fontSettings.ContainsKey("Timestamp")) { var fontSetting = fontSettings["Timestamp"]; - textPrinter.ForeColor = fontSetting.ForeColor; - textPrinter.BackColor = fontSetting.BackColor; - textPrinter.Font = fontSetting.Font; - textPrinter.PrintText(DateTime.Now.ToString("[HH:mm] ")); + TextPrinter.ForeColor = fontSetting.ForeColor; + TextPrinter.BackColor = fontSetting.BackColor; + TextPrinter.Font = fontSetting.Font; + TextPrinter.PrintText(DateTime.Now.ToString("[HH:mm] ")); } else { - textPrinter.ForeColor = SystemColors.GrayText; - textPrinter.BackColor = Color.Transparent; - textPrinter.Font = Settings.FontSetting.DefaultFont; - textPrinter.PrintText(DateTime.Now.ToString("[HH:mm] ")); + TextPrinter.ForeColor = SystemColors.GrayText; + TextPrinter.BackColor = Color.Transparent; + TextPrinter.Font = Settings.FontSetting.DefaultFont; + TextPrinter.PrintText(DateTime.Now.ToString("[HH:mm] ")); } } if(fontSettings.ContainsKey("Notification")) { var fontSetting = fontSettings["Notification"]; - textPrinter.ForeColor = fontSetting.ForeColor; - textPrinter.BackColor = fontSetting.BackColor; - textPrinter.Font = fontSetting.Font; + TextPrinter.ForeColor = fontSetting.ForeColor; + TextPrinter.BackColor = fontSetting.BackColor; + TextPrinter.Font = fontSetting.Font; } else { - textPrinter.ForeColor = Color.DarkCyan; - textPrinter.BackColor = Color.Transparent; - textPrinter.Font = Settings.FontSetting.DefaultFont; + TextPrinter.ForeColor = Color.DarkCyan; + TextPrinter.BackColor = Color.Transparent; + TextPrinter.Font = Settings.FontSetting.DefaultFont; } instance.LogClientMessage(sessionName + ".txt", message); - textPrinter.PrintTextLine(message); + TextPrinter.PrintTextLine(message); } private void PrintIM(DateTime timestamp, string fromName, UUID fromID, string message, bool isNewMessage) { - if (showTimestamps) + if (ShowTimestamps) { if(fontSettings.ContainsKey("Timestamp")) { var fontSetting = fontSettings["Timestamp"]; - textPrinter.ForeColor = fontSetting.ForeColor; - textPrinter.BackColor = fontSetting.BackColor; - textPrinter.Font = fontSetting.Font; - textPrinter.PrintText(DateTime.Now.ToString("[HH:mm] ")); + TextPrinter.ForeColor = fontSetting.ForeColor; + TextPrinter.BackColor = fontSetting.BackColor; + TextPrinter.Font = fontSetting.Font; + TextPrinter.PrintText(DateTime.Now.ToString("[HH:mm] ")); } else { - textPrinter.ForeColor = SystemColors.GrayText; - textPrinter.BackColor = Color.Transparent; - textPrinter.Font = Settings.FontSetting.DefaultFont; - textPrinter.PrintText(DateTime.Now.ToString("[HH:mm] ")); + TextPrinter.ForeColor = SystemColors.GrayText; + TextPrinter.BackColor = Color.Transparent; + TextPrinter.Font = Settings.FontSetting.DefaultFont; + TextPrinter.PrintText(DateTime.Now.ToString("[HH:mm] ")); } } if(fontSettings.ContainsKey("Name")) { var fontSetting = fontSettings["Name"]; - textPrinter.ForeColor = fontSetting.ForeColor; - textPrinter.BackColor = fontSetting.BackColor; - textPrinter.Font = fontSetting.Font; + TextPrinter.ForeColor = fontSetting.ForeColor; + TextPrinter.BackColor = fontSetting.BackColor; + TextPrinter.Font = fontSetting.Font; } else { - textPrinter.ForeColor = SystemColors.WindowText; - textPrinter.BackColor = Color.Transparent; - textPrinter.Font = Settings.FontSetting.DefaultFont; + TextPrinter.ForeColor = SystemColors.WindowText; + TextPrinter.BackColor = Color.Transparent; + TextPrinter.Font = Settings.FontSetting.DefaultFont; } if (instance.GlobalSettings["av_name_link"]) { - textPrinter.InsertLink(fromName, string.Format("secondlife:///app/agent/{0}/about", fromID)); + TextPrinter.InsertLink(fromName, $"secondlife:///app/agent/{fromID}/about"); } else { - textPrinter.PrintText(fromName); + TextPrinter.PrintText(fromName); } StringBuilder sb = new StringBuilder(); @@ -333,15 +317,15 @@ private void PrintIM(DateTime timestamp, string fromName, UUID fromID, string me if(fontSettings.ContainsKey("Emote")) { var fontSetting = fontSettings["Emote"]; - textPrinter.ForeColor = fontSetting.ForeColor; - textPrinter.BackColor = fontSetting.BackColor; - textPrinter.Font = fontSetting.Font; + TextPrinter.ForeColor = fontSetting.ForeColor; + TextPrinter.BackColor = fontSetting.BackColor; + TextPrinter.Font = fontSetting.Font; } else { - textPrinter.ForeColor = SystemColors.WindowText; - textPrinter.BackColor = Color.Transparent; - textPrinter.Font = Settings.FontSetting.DefaultFont; + TextPrinter.ForeColor = SystemColors.WindowText; + TextPrinter.BackColor = Color.Transparent; + TextPrinter.Font = Settings.FontSetting.DefaultFont; } sb.Append(message.Substring(3)); @@ -353,15 +337,15 @@ private void PrintIM(DateTime timestamp, string fromName, UUID fromID, string me if(fontSettings.ContainsKey("OutgoingIM")) { var fontSetting = fontSettings["OutgoingIM"]; - textPrinter.ForeColor = fontSetting.ForeColor; - textPrinter.BackColor = fontSetting.BackColor; - textPrinter.Font = fontSetting.Font; + TextPrinter.ForeColor = fontSetting.ForeColor; + TextPrinter.BackColor = fontSetting.BackColor; + TextPrinter.Font = fontSetting.Font; } else { - textPrinter.ForeColor = SystemColors.WindowText; - textPrinter.BackColor = Color.Transparent; - textPrinter.Font = Settings.FontSetting.DefaultFont; + TextPrinter.ForeColor = SystemColors.WindowText; + TextPrinter.BackColor = Color.Transparent; + TextPrinter.Font = Settings.FontSetting.DefaultFont; } } else @@ -369,15 +353,15 @@ private void PrintIM(DateTime timestamp, string fromName, UUID fromID, string me if(fontSettings.ContainsKey("IncomingIM")) { var fontSetting = fontSettings["IncomingIM"]; - textPrinter.ForeColor = fontSetting.ForeColor; - textPrinter.BackColor = fontSetting.BackColor; - textPrinter.Font = fontSetting.Font; + TextPrinter.ForeColor = fontSetting.ForeColor; + TextPrinter.BackColor = fontSetting.BackColor; + TextPrinter.Font = fontSetting.Font; } else { - textPrinter.ForeColor = SystemColors.WindowText; - textPrinter.BackColor = Color.Transparent; - textPrinter.Font = Settings.FontSetting.DefaultFont; + TextPrinter.ForeColor = SystemColors.WindowText; + TextPrinter.BackColor = Color.Transparent; + TextPrinter.Font = Settings.FontSetting.DefaultFont; } } @@ -387,10 +371,10 @@ private void PrintIM(DateTime timestamp, string fromName, UUID fromID, string me if(isNewMessage) { - instance.LogClientMessage(sessionName + ".txt", fromName + sb.ToString()); + instance.LogClientMessage(sessionName + ".txt", fromName + sb); } - textPrinter.PrintTextLine(sb.ToString()); + TextPrinter.PrintTextLine(sb.ToString()); } public static string ReadEndTokens(string path, Int64 numberOfTokens, Encoding encoding, string tokenSeparator) @@ -435,7 +419,7 @@ private void PrintLastLog() string last = string.Empty; try { - last = IMTextManager.ReadEndTokens(instance.ChatFileName(sessionName + ".txt"), 20, Encoding.UTF8, Environment.NewLine); + last = ReadEndTokens(instance.ChatFileName(sessionName + ".txt"), 20, Encoding.UTF8, Environment.NewLine); } catch { } @@ -445,47 +429,47 @@ private void PrintLastLog() } string[] lines = last.Split(Environment.NewLine.ToCharArray()); - for (int i = 0; i < lines.Length; i++) + foreach (var line in lines) { - string msg = lines[i].Trim(); + string msg = line.Trim(); if (!string.IsNullOrEmpty(msg)) { if(fontSettings.ContainsKey("History")) { var fontSetting = fontSettings["History"]; - textPrinter.ForeColor = fontSetting.ForeColor; - textPrinter.BackColor = fontSetting.BackColor; - textPrinter.Font = fontSetting.Font; + TextPrinter.ForeColor = fontSetting.ForeColor; + TextPrinter.BackColor = fontSetting.BackColor; + TextPrinter.Font = fontSetting.Font; } else { - textPrinter.ForeColor = SystemColors.GrayText; - textPrinter.BackColor = Color.Transparent; - textPrinter.Font = Settings.FontSetting.DefaultFont; + TextPrinter.ForeColor = SystemColors.GrayText; + TextPrinter.BackColor = Color.Transparent; + TextPrinter.Font = Settings.FontSetting.DefaultFont; } - textPrinter.PrintTextLine(msg); + TextPrinter.PrintTextLine(msg); } } if(fontSettings.ContainsKey("History")) { var fontSetting = fontSettings["History"]; - textPrinter.ForeColor = fontSetting.ForeColor; - textPrinter.BackColor = fontSetting.BackColor; - textPrinter.Font = fontSetting.Font; + TextPrinter.ForeColor = fontSetting.ForeColor; + TextPrinter.BackColor = fontSetting.BackColor; + TextPrinter.Font = fontSetting.Font; } else { - textPrinter.ForeColor = SystemColors.GrayText; - textPrinter.BackColor = Color.Transparent; - textPrinter.Font = Settings.FontSetting.DefaultFont; + TextPrinter.ForeColor = SystemColors.GrayText; + TextPrinter.BackColor = Color.Transparent; + TextPrinter.Font = Settings.FontSetting.DefaultFont; } - textPrinter.PrintTextLine("===="); + TextPrinter.PrintTextLine("===="); } public void ReprintAllText() { - textPrinter.ClearText(); + TextPrinter.ClearText(); PrintLastLog(); foreach (object obj in textBuffer) ProcessIM(obj, false); @@ -503,26 +487,14 @@ public void CleanUp() textBuffer.Clear(); textBuffer = null; - textPrinter = null; + TextPrinter = null; } - public ITextPrinter TextPrinter - { - get { return textPrinter; } - set { textPrinter = value; } - } + public ITextPrinter TextPrinter { get; set; } - public bool ShowTimestamps - { - get { return showTimestamps; } - set { showTimestamps = value; } - } + public bool ShowTimestamps { get; set; } - public UUID SessionID - { - get { return sessionID; } - set { sessionID = value; } - } + public UUID SessionID { get; set; } } public enum IMTextManagerType diff --git a/Radegast/Core/ITextPrinter.cs b/Radegast/Core/ITextPrinter.cs index f08973f46..06613bdee 100644 --- a/Radegast/Core/ITextPrinter.cs +++ b/Radegast/Core/ITextPrinter.cs @@ -1,33 +1,23 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System.Drawing; namespace Radegast diff --git a/Radegast/Core/ImageUploader.cs b/Radegast/Core/ImageUploader.cs index f0036179c..599c2c553 100644 --- a/Radegast/Core/ImageUploader.cs +++ b/Radegast/Core/ImageUploader.cs @@ -1,47 +1,27 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; -using System.Collections.Generic; using System.IO; -#if (COGBOT_LIBOMV || USE_STHREADS) -using ThreadPoolUtil; -using Thread = ThreadPoolUtil.Thread; -using ThreadPool = ThreadPoolUtil.ThreadPool; -using Monitor = ThreadPoolUtil.Monitor; -#endif using System.Threading; -using System.Windows.Forms; using OpenMetaverse; -using OpenMetaverse.StructuredData; -using OpenMetaverse.Assets; namespace Radegast { diff --git a/Radegast/Core/InitialOutfit.cs b/Radegast/Core/InitialOutfit.cs index 7b5104488..05932b24c 100644 --- a/Radegast/Core/InitialOutfit.cs +++ b/Radegast/Core/InitialOutfit.cs @@ -1,37 +1,27 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ using System; using System.Collections.Generic; using System.Threading; using OpenMetaverse; -using OpenMetaverse.StructuredData; namespace Radegast { @@ -39,12 +29,12 @@ public class InitialOutfit { RadegastInstance Instance; - GridClient Client { get { return Instance.Client; }} + GridClient Client => Instance.Client; Inventory Store; public InitialOutfit(RadegastInstance instance) { - this.Instance = instance; + Instance = instance; Store = Client.Inventory.Store; } @@ -72,7 +62,7 @@ public UUID CreateFolder(UUID parent, string name, FolderType type) UUID ret = UUID.Zero; AutoResetEvent folderCreated = new AutoResetEvent(false); - EventHandler handler = (object sender, InventoryObjectAddedEventArgs e) => + EventHandler handler = (sender, e) => { if (e.Obj.Name == name && e.Obj is InventoryFolder && ((InventoryFolder)e.Obj).PreferredType == type) { @@ -103,7 +93,7 @@ List FetchFolder(InventoryFolder folder) AutoResetEvent folderFetched = new AutoResetEvent(false); - EventHandler handler = (object sender, FolderUpdatedEventArgs e) => + EventHandler handler = (sender, e) => { if (e.FolderID == folder.UUID) { @@ -171,16 +161,14 @@ public UUID CopyFolder(InventoryFolder folder, UUID destination) public void SetInitialOutfit(string outfit) { - Thread t = new Thread(() => PerformInit(outfit)); + Thread t = new Thread(() => PerformInit(outfit)) {IsBackground = true, Name = "Initial outfit thread"}; - t.IsBackground = true; - t.Name = "Initial outfit thread"; t.Start(); } void PerformInit(string initialOutfitName) { - Logger.Log("Starting intial outfit thread (first login)", Helpers.LogLevel.Debug); + Logger.Log("Starting initial outfit thread (first login)", Helpers.LogLevel.Debug); var outfitFolder = FindNodeMyName(Store.LibraryRootNode, initialOutfitName); if (outfitFolder == null) diff --git a/Radegast/Core/Keyboard.cs b/Radegast/Core/Keyboard.cs index 9e7e9f8fb..6f962a9b4 100644 --- a/Radegast/Core/Keyboard.cs +++ b/Radegast/Core/Keyboard.cs @@ -1,35 +1,23 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ -using System; using System.Collections.Generic; using System.Windows.Forms; diff --git a/Radegast/Core/LSL/lsl.lexer.cs b/Radegast/Core/LSL/lsl.lexer.cs index 611f6b6ed..3ed6dcbf6 100644 --- a/Radegast/Core/LSL/lsl.lexer.cs +++ b/Radegast/Core/LSL/lsl.lexer.cs @@ -1,656 +1,677 @@ -using System; -using Tools; +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2021, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + +using LibreMetaverse.LslTools; +using System; + namespace Radegast.LSL { //%+STRING_CONSTANT+3 public class STRING_CONSTANT : TOKEN { - public override string yyname { get { return "STRING_CONSTANT"; } } - public override int yynum { get { return 3; } } + public override string yyname => "STRING_CONSTANT"; + public override int yynum => 3; public STRING_CONSTANT(Lexer yyl) : base(yyl) { } } //%INCREMENT+4 public class INCREMENT : TOKEN { - public override string yyname { get { return "INCREMENT"; } } - public override int yynum { get { return 4; } } + public override string yyname => "INCREMENT"; + public override int yynum => 4; public INCREMENT(Lexer yyl) : base(yyl) { } } //%DECREMENT+5 public class DECREMENT : TOKEN { - public override string yyname { get { return "DECREMENT"; } } - public override int yynum { get { return 5; } } + public override string yyname => "DECREMENT"; + public override int yynum => 5; public DECREMENT(Lexer yyl) : base(yyl) { } } //%PLUS_EQUALS+6 public class PLUS_EQUALS : TOKEN { - public override string yyname { get { return "PLUS_EQUALS"; } } - public override int yynum { get { return 6; } } + public override string yyname => "PLUS_EQUALS"; + public override int yynum => 6; public PLUS_EQUALS(Lexer yyl) : base(yyl) { } } //%MINUS_EQUALS+7 public class MINUS_EQUALS : TOKEN { - public override string yyname { get { return "MINUS_EQUALS"; } } - public override int yynum { get { return 7; } } + public override string yyname => "MINUS_EQUALS"; + public override int yynum => 7; public MINUS_EQUALS(Lexer yyl) : base(yyl) { } } //%STAR_EQUALS+8 public class STAR_EQUALS : TOKEN { - public override string yyname { get { return "STAR_EQUALS"; } } - public override int yynum { get { return 8; } } + public override string yyname => "STAR_EQUALS"; + public override int yynum => 8; public STAR_EQUALS(Lexer yyl) : base(yyl) { } } //%SLASH_EQUALS+9 public class SLASH_EQUALS : TOKEN { - public override string yyname { get { return "SLASH_EQUALS"; } } - public override int yynum { get { return 9; } } + public override string yyname => "SLASH_EQUALS"; + public override int yynum => 9; public SLASH_EQUALS(Lexer yyl) : base(yyl) { } } //%PERCENT_EQUALS+10 public class PERCENT_EQUALS : TOKEN { - public override string yyname { get { return "PERCENT_EQUALS"; } } - public override int yynum { get { return 10; } } + public override string yyname => "PERCENT_EQUALS"; + public override int yynum => 10; public PERCENT_EQUALS(Lexer yyl) : base(yyl) { } } //%SEMICOLON+11 public class SEMICOLON : TOKEN { - public override string yyname { get { return "SEMICOLON"; } } - public override int yynum { get { return 11; } } + public override string yyname => "SEMICOLON"; + public override int yynum => 11; public SEMICOLON(Lexer yyl) : base(yyl) { } } //%LEFT_BRACE+12 public class LEFT_BRACE : TOKEN { - public override string yyname { get { return "LEFT_BRACE"; } } - public override int yynum { get { return 12; } } + public override string yyname => "LEFT_BRACE"; + public override int yynum => 12; public LEFT_BRACE(Lexer yyl) : base(yyl) { } } //%RIGHT_BRACE+13 public class RIGHT_BRACE : TOKEN { - public override string yyname { get { return "RIGHT_BRACE"; } } - public override int yynum { get { return 13; } } + public override string yyname => "RIGHT_BRACE"; + public override int yynum => 13; public RIGHT_BRACE(Lexer yyl) : base(yyl) { } } //%COMMA+14 public class COMMA : TOKEN { - public override string yyname { get { return "COMMA"; } } - public override int yynum { get { return 14; } } + public override string yyname => "COMMA"; + public override int yynum => 14; public COMMA(Lexer yyl) : base(yyl) { } } //%EQUALS+15 public class EQUALS : TOKEN { - public override string yyname { get { return "EQUALS"; } } - public override int yynum { get { return 15; } } + public override string yyname => "EQUALS"; + public override int yynum => 15; public EQUALS(Lexer yyl) : base(yyl) { } } //%LEFT_PAREN+16 public class LEFT_PAREN : TOKEN { - public override string yyname { get { return "LEFT_PAREN"; } } - public override int yynum { get { return 16; } } + public override string yyname => "LEFT_PAREN"; + public override int yynum => 16; public LEFT_PAREN(Lexer yyl) : base(yyl) { } } //%RIGHT_PAREN+17 public class RIGHT_PAREN : TOKEN { - public override string yyname { get { return "RIGHT_PAREN"; } } - public override int yynum { get { return 17; } } + public override string yyname => "RIGHT_PAREN"; + public override int yynum => 17; public RIGHT_PAREN(Lexer yyl) : base(yyl) { } } //%PLUS+18 public class PLUS : TOKEN { - public override string yyname { get { return "PLUS"; } } - public override int yynum { get { return 18; } } + public override string yyname => "PLUS"; + public override int yynum => 18; public PLUS(Lexer yyl) : base(yyl) { } } //%MINUS+19 public class MINUS : TOKEN { - public override string yyname { get { return "MINUS"; } } - public override int yynum { get { return 19; } } + public override string yyname => "MINUS"; + public override int yynum => 19; public MINUS(Lexer yyl) : base(yyl) { } } //%STAR+20 public class STAR : TOKEN { - public override string yyname { get { return "STAR"; } } - public override int yynum { get { return 20; } } + public override string yyname => "STAR"; + public override int yynum => 20; public STAR(Lexer yyl) : base(yyl) { } } //%SLASH+21 public class SLASH : TOKEN { - public override string yyname { get { return "SLASH"; } } - public override int yynum { get { return 21; } } + public override string yyname => "SLASH"; + public override int yynum => 21; public SLASH(Lexer yyl) : base(yyl) { } } //%PERCENT+22 public class PERCENT : TOKEN { - public override string yyname { get { return "PERCENT"; } } - public override int yynum { get { return 22; } } + public override string yyname => "PERCENT"; + public override int yynum => 22; public PERCENT(Lexer yyl) : base(yyl) { } } //%AT+23 public class AT : TOKEN { - public override string yyname { get { return "AT"; } } - public override int yynum { get { return 23; } } + public override string yyname => "AT"; + public override int yynum => 23; public AT(Lexer yyl) : base(yyl) { } } //%PERIOD+24 public class PERIOD : TOKEN { - public override string yyname { get { return "PERIOD"; } } - public override int yynum { get { return 24; } } + public override string yyname => "PERIOD"; + public override int yynum => 24; public PERIOD(Lexer yyl) : base(yyl) { } } //%LEFT_ANGLE+25 public class LEFT_ANGLE : TOKEN { - public override string yyname { get { return "LEFT_ANGLE"; } } - public override int yynum { get { return 25; } } + public override string yyname => "LEFT_ANGLE"; + public override int yynum => 25; public LEFT_ANGLE(Lexer yyl) : base(yyl) { } } //%RIGHT_ANGLE+26 public class RIGHT_ANGLE : TOKEN { - public override string yyname { get { return "RIGHT_ANGLE"; } } - public override int yynum { get { return 26; } } + public override string yyname => "RIGHT_ANGLE"; + public override int yynum => 26; public RIGHT_ANGLE(Lexer yyl) : base(yyl) { } } //%LEFT_BRACKET+27 public class LEFT_BRACKET : TOKEN { - public override string yyname { get { return "LEFT_BRACKET"; } } - public override int yynum { get { return 27; } } + public override string yyname => "LEFT_BRACKET"; + public override int yynum => 27; public LEFT_BRACKET(Lexer yyl) : base(yyl) { } } //%RIGHT_BRACKET+28 public class RIGHT_BRACKET : TOKEN { - public override string yyname { get { return "RIGHT_BRACKET"; } } - public override int yynum { get { return 28; } } + public override string yyname => "RIGHT_BRACKET"; + public override int yynum => 28; public RIGHT_BRACKET(Lexer yyl) : base(yyl) { } } //%EQUALS_EQUALS+29 public class EQUALS_EQUALS : TOKEN { - public override string yyname { get { return "EQUALS_EQUALS"; } } - public override int yynum { get { return 29; } } + public override string yyname => "EQUALS_EQUALS"; + public override int yynum => 29; public EQUALS_EQUALS(Lexer yyl) : base(yyl) { } } //%EXCLAMATION_EQUALS+30 public class EXCLAMATION_EQUALS : TOKEN { - public override string yyname { get { return "EXCLAMATION_EQUALS"; } } - public override int yynum { get { return 30; } } + public override string yyname => "EXCLAMATION_EQUALS"; + public override int yynum => 30; public EXCLAMATION_EQUALS(Lexer yyl) : base(yyl) { } } //%LESS_EQUALS+31 public class LESS_EQUALS : TOKEN { - public override string yyname { get { return "LESS_EQUALS"; } } - public override int yynum { get { return 31; } } + public override string yyname => "LESS_EQUALS"; + public override int yynum => 31; public LESS_EQUALS(Lexer yyl) : base(yyl) { } } //%GREATER_EQUALS+32 public class GREATER_EQUALS : TOKEN { - public override string yyname { get { return "GREATER_EQUALS"; } } - public override int yynum { get { return 32; } } + public override string yyname => "GREATER_EQUALS"; + public override int yynum => 32; public GREATER_EQUALS(Lexer yyl) : base(yyl) { } } //%AMP+33 public class AMP : TOKEN { - public override string yyname { get { return "AMP"; } } - public override int yynum { get { return 33; } } + public override string yyname => "AMP"; + public override int yynum => 33; public AMP(Lexer yyl) : base(yyl) { } } //%STROKE+34 public class STROKE : TOKEN { - public override string yyname { get { return "STROKE"; } } - public override int yynum { get { return 34; } } + public override string yyname => "STROKE"; + public override int yynum => 34; public STROKE(Lexer yyl) : base(yyl) { } } //%CARET+35 public class CARET : TOKEN { - public override string yyname { get { return "CARET"; } } - public override int yynum { get { return 35; } } + public override string yyname => "CARET"; + public override int yynum => 35; public CARET(Lexer yyl) : base(yyl) { } } //%TILDE+36 public class TILDE : TOKEN { - public override string yyname { get { return "TILDE"; } } - public override int yynum { get { return 36; } } + public override string yyname => "TILDE"; + public override int yynum => 36; public TILDE(Lexer yyl) : base(yyl) { } } //%EXCLAMATION+37 public class EXCLAMATION : TOKEN { - public override string yyname { get { return "EXCLAMATION"; } } - public override int yynum { get { return 37; } } + public override string yyname => "EXCLAMATION"; + public override int yynum => 37; public EXCLAMATION(Lexer yyl) : base(yyl) { } } //%AMP_AMP+38 public class AMP_AMP : TOKEN { - public override string yyname { get { return "AMP_AMP"; } } - public override int yynum { get { return 38; } } + public override string yyname => "AMP_AMP"; + public override int yynum => 38; public AMP_AMP(Lexer yyl) : base(yyl) { } } //%STROKE_STROKE+39 public class STROKE_STROKE : TOKEN { - public override string yyname { get { return "STROKE_STROKE"; } } - public override int yynum { get { return 39; } } + public override string yyname => "STROKE_STROKE"; + public override int yynum => 39; public STROKE_STROKE(Lexer yyl) : base(yyl) { } } //%LEFT_SHIFT+40 public class LEFT_SHIFT : TOKEN { - public override string yyname { get { return "LEFT_SHIFT"; } } - public override int yynum { get { return 40; } } + public override string yyname => "LEFT_SHIFT"; + public override int yynum => 40; public LEFT_SHIFT(Lexer yyl) : base(yyl) { } } //%RIGHT_SHIFT+41 public class RIGHT_SHIFT : TOKEN { - public override string yyname { get { return "RIGHT_SHIFT"; } } - public override int yynum { get { return 41; } } + public override string yyname => "RIGHT_SHIFT"; + public override int yynum => 41; public RIGHT_SHIFT(Lexer yyl) : base(yyl) { } } //%IF+42 public class IF : TOKEN { - public override string yyname { get { return "IF"; } } - public override int yynum { get { return 42; } } + public override string yyname => "IF"; + public override int yynum => 42; public IF(Lexer yyl) : base(yyl) { } } //%ELSE+43 public class ELSE : TOKEN { - public override string yyname { get { return "ELSE"; } } - public override int yynum { get { return 43; } } + public override string yyname => "ELSE"; + public override int yynum => 43; public ELSE(Lexer yyl) : base(yyl) { } } //%DO+44 public class DO : TOKEN { - public override string yyname { get { return "DO"; } } - public override int yynum { get { return 44; } } + public override string yyname => "DO"; + public override int yynum => 44; public DO(Lexer yyl) : base(yyl) { } } //%WHILE+45 public class WHILE : TOKEN { - public override string yyname { get { return "WHILE"; } } - public override int yynum { get { return 45; } } + public override string yyname => "WHILE"; + public override int yynum => 45; public WHILE(Lexer yyl) : base(yyl) { } } //%FOR+46 public class FOR : TOKEN { - public override string yyname { get { return "FOR"; } } - public override int yynum { get { return 46; } } + public override string yyname => "FOR"; + public override int yynum => 46; public FOR(Lexer yyl) : base(yyl) { } } //%DEFAULT_STATE+47 public class DEFAULT_STATE : TOKEN { - public override string yyname { get { return "DEFAULT_STATE"; } } - public override int yynum { get { return 47; } } + public override string yyname => "DEFAULT_STATE"; + public override int yynum => 47; public DEFAULT_STATE(Lexer yyl) : base(yyl) { } } //%STATE+48 public class STATE : TOKEN { - public override string yyname { get { return "STATE"; } } - public override int yynum { get { return 48; } } + public override string yyname => "STATE"; + public override int yynum => 48; public STATE(Lexer yyl) : base(yyl) { } } //%JUMP+49 public class JUMP : TOKEN { - public override string yyname { get { return "JUMP"; } } - public override int yynum { get { return 49; } } + public override string yyname => "JUMP"; + public override int yynum => 49; public JUMP(Lexer yyl) : base(yyl) { } } //%RETURN+50 public class RETURN : TOKEN { - public override string yyname { get { return "RETURN"; } } - public override int yynum { get { return 50; } } + public override string yyname => "RETURN"; + public override int yynum => 50; public RETURN(Lexer yyl) : base(yyl) { } } //%INTEGER_TYPE+51 public class INTEGER_TYPE : TOKEN { - public override string yyname { get { return "INTEGER_TYPE"; } } - public override int yynum { get { return 51; } } + public override string yyname => "INTEGER_TYPE"; + public override int yynum => 51; public INTEGER_TYPE(Lexer yyl) : base(yyl) { } } //%FLOAT_TYPE+52 public class FLOAT_TYPE : TOKEN { - public override string yyname { get { return "FLOAT_TYPE"; } } - public override int yynum { get { return 52; } } + public override string yyname => "FLOAT_TYPE"; + public override int yynum => 52; public FLOAT_TYPE(Lexer yyl) : base(yyl) { } } //%STRING_TYPE+53 public class STRING_TYPE : TOKEN { - public override string yyname { get { return "STRING_TYPE"; } } - public override int yynum { get { return 53; } } + public override string yyname => "STRING_TYPE"; + public override int yynum => 53; public STRING_TYPE(Lexer yyl) : base(yyl) { } } //%KEY_TYPE+54 public class KEY_TYPE : TOKEN { - public override string yyname { get { return "KEY_TYPE"; } } - public override int yynum { get { return 54; } } + public override string yyname => "KEY_TYPE"; + public override int yynum => 54; public KEY_TYPE(Lexer yyl) : base(yyl) { } } //%VECTOR_TYPE+55 public class VECTOR_TYPE : TOKEN { - public override string yyname { get { return "VECTOR_TYPE"; } } - public override int yynum { get { return 55; } } + public override string yyname => "VECTOR_TYPE"; + public override int yynum => 55; public VECTOR_TYPE(Lexer yyl) : base(yyl) { } } //%ROTATION_TYPE+56 public class ROTATION_TYPE : TOKEN { - public override string yyname { get { return "ROTATION_TYPE"; } } - public override int yynum { get { return 56; } } + public override string yyname => "ROTATION_TYPE"; + public override int yynum => 56; public ROTATION_TYPE(Lexer yyl) : base(yyl) { } } //%LIST_TYPE+57 public class LIST_TYPE : TOKEN { - public override string yyname { get { return "LIST_TYPE"; } } - public override int yynum { get { return 57; } } + public override string yyname => "LIST_TYPE"; + public override int yynum => 57; public LIST_TYPE(Lexer yyl) : base(yyl) { } } //%AT_ROT_TARGET_EVENT+58 public class AT_ROT_TARGET_EVENT : TOKEN { - public override string yyname { get { return "AT_ROT_TARGET_EVENT"; } } - public override int yynum { get { return 58; } } + public override string yyname => "AT_ROT_TARGET_EVENT"; + public override int yynum => 58; public AT_ROT_TARGET_EVENT(Lexer yyl) : base(yyl) { } } //%AT_TARGET_EVENT+59 public class AT_TARGET_EVENT : TOKEN { - public override string yyname { get { return "AT_TARGET_EVENT"; } } - public override int yynum { get { return 59; } } + public override string yyname => "AT_TARGET_EVENT"; + public override int yynum => 59; public AT_TARGET_EVENT(Lexer yyl) : base(yyl) { } } //%ATTACH_EVENT+60 public class ATTACH_EVENT : TOKEN { - public override string yyname { get { return "ATTACH_EVENT"; } } - public override int yynum { get { return 60; } } + public override string yyname => "ATTACH_EVENT"; + public override int yynum => 60; public ATTACH_EVENT(Lexer yyl) : base(yyl) { } } //%CHANGED_EVENT+61 public class CHANGED_EVENT : TOKEN { - public override string yyname { get { return "CHANGED_EVENT"; } } - public override int yynum { get { return 61; } } + public override string yyname => "CHANGED_EVENT"; + public override int yynum => 61; public CHANGED_EVENT(Lexer yyl) : base(yyl) { } } //%COLLISION_EVENT+62 public class COLLISION_EVENT : TOKEN { - public override string yyname { get { return "COLLISION_EVENT"; } } - public override int yynum { get { return 62; } } + public override string yyname => "COLLISION_EVENT"; + public override int yynum => 62; public COLLISION_EVENT(Lexer yyl) : base(yyl) { } } //%COLLISION_END_EVENT+63 public class COLLISION_END_EVENT : TOKEN { - public override string yyname { get { return "COLLISION_END_EVENT"; } } - public override int yynum { get { return 63; } } + public override string yyname => "COLLISION_END_EVENT"; + public override int yynum => 63; public COLLISION_END_EVENT(Lexer yyl) : base(yyl) { } } //%COLLISION_START_EVENT+64 public class COLLISION_START_EVENT : TOKEN { - public override string yyname { get { return "COLLISION_START_EVENT"; } } - public override int yynum { get { return 64; } } + public override string yyname => "COLLISION_START_EVENT"; + public override int yynum => 64; public COLLISION_START_EVENT(Lexer yyl) : base(yyl) { } } //%CONTROL_EVENT+65 public class CONTROL_EVENT : TOKEN { - public override string yyname { get { return "CONTROL_EVENT"; } } - public override int yynum { get { return 65; } } + public override string yyname => "CONTROL_EVENT"; + public override int yynum => 65; public CONTROL_EVENT(Lexer yyl) : base(yyl) { } } //%DATASERVER_EVENT+66 public class DATASERVER_EVENT : TOKEN { - public override string yyname { get { return "DATASERVER_EVENT"; } } - public override int yynum { get { return 66; } } + public override string yyname => "DATASERVER_EVENT"; + public override int yynum => 66; public DATASERVER_EVENT(Lexer yyl) : base(yyl) { } } //%EMAIL_EVENT+67 public class EMAIL_EVENT : TOKEN { - public override string yyname { get { return "EMAIL_EVENT"; } } - public override int yynum { get { return 67; } } + public override string yyname => "EMAIL_EVENT"; + public override int yynum => 67; public EMAIL_EVENT(Lexer yyl) : base(yyl) { } } //%HTTP_RESPONSE_EVENT+68 public class HTTP_RESPONSE_EVENT : TOKEN { - public override string yyname { get { return "HTTP_RESPONSE_EVENT"; } } - public override int yynum { get { return 68; } } + public override string yyname => "HTTP_RESPONSE_EVENT"; + public override int yynum => 68; public HTTP_RESPONSE_EVENT(Lexer yyl) : base(yyl) { } } //%LAND_COLLISION_EVENT+69 public class LAND_COLLISION_EVENT : TOKEN { - public override string yyname { get { return "LAND_COLLISION_EVENT"; } } - public override int yynum { get { return 69; } } + public override string yyname => "LAND_COLLISION_EVENT"; + public override int yynum => 69; public LAND_COLLISION_EVENT(Lexer yyl) : base(yyl) { } } //%LAND_COLLISION_END_EVENT+70 public class LAND_COLLISION_END_EVENT : TOKEN { - public override string yyname { get { return "LAND_COLLISION_END_EVENT"; } } - public override int yynum { get { return 70; } } + public override string yyname => "LAND_COLLISION_END_EVENT"; + public override int yynum => 70; public LAND_COLLISION_END_EVENT(Lexer yyl) : base(yyl) { } } //%LAND_COLLISION_START_EVENT+71 public class LAND_COLLISION_START_EVENT : TOKEN { - public override string yyname { get { return "LAND_COLLISION_START_EVENT"; } } - public override int yynum { get { return 71; } } + public override string yyname => "LAND_COLLISION_START_EVENT"; + public override int yynum => 71; public LAND_COLLISION_START_EVENT(Lexer yyl) : base(yyl) { } } //%LINK_MESSAGE_EVENT+72 public class LINK_MESSAGE_EVENT : TOKEN { - public override string yyname { get { return "LINK_MESSAGE_EVENT"; } } - public override int yynum { get { return 72; } } + public override string yyname => "LINK_MESSAGE_EVENT"; + public override int yynum => 72; public LINK_MESSAGE_EVENT(Lexer yyl) : base(yyl) { } } //%LISTEN_EVENT+73 public class LISTEN_EVENT : TOKEN { - public override string yyname { get { return "LISTEN_EVENT"; } } - public override int yynum { get { return 73; } } + public override string yyname => "LISTEN_EVENT"; + public override int yynum => 73; public LISTEN_EVENT(Lexer yyl) : base(yyl) { } } //%MONEY_EVENT+74 public class MONEY_EVENT : TOKEN { - public override string yyname { get { return "MONEY_EVENT"; } } - public override int yynum { get { return 74; } } + public override string yyname => "MONEY_EVENT"; + public override int yynum => 74; public MONEY_EVENT(Lexer yyl) : base(yyl) { } } //%MOVING_END_EVENT+75 public class MOVING_END_EVENT : TOKEN { - public override string yyname { get { return "MOVING_END_EVENT"; } } - public override int yynum { get { return 75; } } + public override string yyname => "MOVING_END_EVENT"; + public override int yynum => 75; public MOVING_END_EVENT(Lexer yyl) : base(yyl) { } } //%MOVING_START_EVENT+76 public class MOVING_START_EVENT : TOKEN { - public override string yyname { get { return "MOVING_START_EVENT"; } } - public override int yynum { get { return 76; } } + public override string yyname => "MOVING_START_EVENT"; + public override int yynum => 76; public MOVING_START_EVENT(Lexer yyl) : base(yyl) { } } //%NO_SENSOR_EVENT+77 public class NO_SENSOR_EVENT : TOKEN { - public override string yyname { get { return "NO_SENSOR_EVENT"; } } - public override int yynum { get { return 77; } } + public override string yyname => "NO_SENSOR_EVENT"; + public override int yynum => 77; public NO_SENSOR_EVENT(Lexer yyl) : base(yyl) { } } //%NOT_AT_ROT_TARGET_EVENT+78 public class NOT_AT_ROT_TARGET_EVENT : TOKEN { - public override string yyname { get { return "NOT_AT_ROT_TARGET_EVENT"; } } - public override int yynum { get { return 78; } } + public override string yyname => "NOT_AT_ROT_TARGET_EVENT"; + public override int yynum => 78; public NOT_AT_ROT_TARGET_EVENT(Lexer yyl) : base(yyl) { } } //%NOT_AT_TARGET_EVENT+79 public class NOT_AT_TARGET_EVENT : TOKEN { - public override string yyname { get { return "NOT_AT_TARGET_EVENT"; } } - public override int yynum { get { return 79; } } + public override string yyname => "NOT_AT_TARGET_EVENT"; + public override int yynum => 79; public NOT_AT_TARGET_EVENT(Lexer yyl) : base(yyl) { } } //%OBJECT_REZ_EVENT+80 public class OBJECT_REZ_EVENT : TOKEN { - public override string yyname { get { return "OBJECT_REZ_EVENT"; } } - public override int yynum { get { return 80; } } + public override string yyname => "OBJECT_REZ_EVENT"; + public override int yynum => 80; public OBJECT_REZ_EVENT(Lexer yyl) : base(yyl) { } } //%ON_REZ_EVENT+81 public class ON_REZ_EVENT : TOKEN { - public override string yyname { get { return "ON_REZ_EVENT"; } } - public override int yynum { get { return 81; } } + public override string yyname => "ON_REZ_EVENT"; + public override int yynum => 81; public ON_REZ_EVENT(Lexer yyl) : base(yyl) { } } //%REMOTE_DATA_EVENT+82 public class REMOTE_DATA_EVENT : TOKEN { - public override string yyname { get { return "REMOTE_DATA_EVENT"; } } - public override int yynum { get { return 82; } } + public override string yyname => "REMOTE_DATA_EVENT"; + public override int yynum => 82; public REMOTE_DATA_EVENT(Lexer yyl) : base(yyl) { } } //%RUN_TIME_PERMISSIONS_EVENT+83 public class RUN_TIME_PERMISSIONS_EVENT : TOKEN { - public override string yyname { get { return "RUN_TIME_PERMISSIONS_EVENT"; } } - public override int yynum { get { return 83; } } + public override string yyname => "RUN_TIME_PERMISSIONS_EVENT"; + public override int yynum => 83; public RUN_TIME_PERMISSIONS_EVENT(Lexer yyl) : base(yyl) { } } //%SENSOR_EVENT+84 public class SENSOR_EVENT : TOKEN { - public override string yyname { get { return "SENSOR_EVENT"; } } - public override int yynum { get { return 84; } } + public override string yyname => "SENSOR_EVENT"; + public override int yynum => 84; public SENSOR_EVENT(Lexer yyl) : base(yyl) { } } //%STATE_ENTRY_EVENT+85 public class STATE_ENTRY_EVENT : TOKEN { - public override string yyname { get { return "STATE_ENTRY_EVENT"; } } - public override int yynum { get { return 85; } } + public override string yyname => "STATE_ENTRY_EVENT"; + public override int yynum => 85; public STATE_ENTRY_EVENT(Lexer yyl) : base(yyl) { } } //%STATE_EXIT_EVENT+86 public class STATE_EXIT_EVENT : TOKEN { - public override string yyname { get { return "STATE_EXIT_EVENT"; } } - public override int yynum { get { return 86; } } + public override string yyname => "STATE_EXIT_EVENT"; + public override int yynum => 86; public STATE_EXIT_EVENT(Lexer yyl) : base(yyl) { } } //%TIMER_EVENT+87 public class TIMER_EVENT : TOKEN { - public override string yyname { get { return "TIMER_EVENT"; } } - public override int yynum { get { return 87; } } + public override string yyname => "TIMER_EVENT"; + public override int yynum => 87; public TIMER_EVENT(Lexer yyl) : base(yyl) { } } //%TOUCH_EVENT+88 public class TOUCH_EVENT : TOKEN { - public override string yyname { get { return "TOUCH_EVENT"; } } - public override int yynum { get { return 88; } } + public override string yyname => "TOUCH_EVENT"; + public override int yynum => 88; public TOUCH_EVENT(Lexer yyl) : base(yyl) { } } //%TOUCH_START_EVENT+89 public class TOUCH_START_EVENT : TOKEN { - public override string yyname { get { return "TOUCH_START_EVENT"; } } - public override int yynum { get { return 89; } } + public override string yyname => "TOUCH_START_EVENT"; + public override int yynum => 89; public TOUCH_START_EVENT(Lexer yyl) : base(yyl) { } } //%TOUCH_END_EVENT+90 public class TOUCH_END_EVENT : TOKEN { - public override string yyname { get { return "TOUCH_END_EVENT"; } } - public override int yynum { get { return 90; } } + public override string yyname => "TOUCH_END_EVENT"; + public override int yynum => 90; public TOUCH_END_EVENT(Lexer yyl) : base(yyl) { } } //%HTTP_REQUEST_EVENT+91 public class HTTP_REQUEST_EVENT : TOKEN { - public override string yyname { get { return "HTTP_REQUEST_EVENT"; } } - public override int yynum { get { return 91; } } + public override string yyname => "HTTP_REQUEST_EVENT"; + public override int yynum => 91; public HTTP_REQUEST_EVENT(Lexer yyl) : base(yyl) { } } //%IDENT+92 public class IDENT : TOKEN { - public override string yyname { get { return "IDENT"; } } - public override int yynum { get { return 92; } } + public override string yyname => "IDENT"; + public override int yynum => 92; public IDENT(Lexer yyl) : base(yyl) { } } //%INTEGER_CONSTANT+93 public class INTEGER_CONSTANT : TOKEN { - public override string yyname { get { return "INTEGER_CONSTANT"; } } - public override int yynum { get { return 93; } } + public override string yyname => "INTEGER_CONSTANT"; + public override int yynum => 93; public INTEGER_CONSTANT(Lexer yyl) : base(yyl) { } } //%HEX_INTEGER_CONSTANT+94 public class HEX_INTEGER_CONSTANT : TOKEN { - public override string yyname { get { return "HEX_INTEGER_CONSTANT"; } } - public override int yynum { get { return 94; } } + public override string yyname => "HEX_INTEGER_CONSTANT"; + public override int yynum => 94; public HEX_INTEGER_CONSTANT(Lexer yyl) : base(yyl) { } } //%FLOAT_CONSTANT+95 public class FLOAT_CONSTANT : TOKEN { - public override string yyname { get { return "FLOAT_CONSTANT"; } } - public override int yynum { get { return 95; } } + public override string yyname => "FLOAT_CONSTANT"; + public override int yynum => 95; public FLOAT_CONSTANT(Lexer yyl) : base(yyl) { } } //%|LSLTokens @@ -18876,99 +18897,99 @@ public yyLSLTokens(ErrorHandler eh) 775,1,71,449,1486, 10,449,1,65,1487, 5,0,0}; - new Tfactory(this, "MINUS", new TCreator(MINUS_factory)); - new Tfactory(this, "DEFAULT_STATE", new TCreator(DEFAULT_STATE_factory)); - new Tfactory(this, "INTEGER_CONSTANT", new TCreator(INTEGER_CONSTANT_factory)); - new Tfactory(this, "RETURN", new TCreator(RETURN_factory)); - new Tfactory(this, "OBJECT_REZ_EVENT", new TCreator(OBJECT_REZ_EVENT_factory)); - new Tfactory(this, "STRING_TYPE", new TCreator(STRING_TYPE_factory)); - new Tfactory(this, "EXCLAMATION", new TCreator(EXCLAMATION_factory)); - new Tfactory(this, "ELSE", new TCreator(ELSE_factory)); - new Tfactory(this, "INTEGER_TYPE", new TCreator(INTEGER_TYPE_factory)); - new Tfactory(this, "FOR", new TCreator(FOR_factory)); - new Tfactory(this, "LEFT_PAREN", new TCreator(LEFT_PAREN_factory)); - new Tfactory(this, "RIGHT_PAREN", new TCreator(RIGHT_PAREN_factory)); - new Tfactory(this, "HTTP_RESPONSE_EVENT", new TCreator(HTTP_RESPONSE_EVENT_factory)); - new Tfactory(this, "MOVING_END_EVENT", new TCreator(MOVING_END_EVENT_factory)); - new Tfactory(this, "CARET", new TCreator(CARET_factory)); - new Tfactory(this, "STAR", new TCreator(STAR_factory)); - new Tfactory(this, "PLUS_EQUALS", new TCreator(PLUS_EQUALS_factory)); - new Tfactory(this, "PERCENT", new TCreator(PERCENT_factory)); - new Tfactory(this, "SLASH", new TCreator(SLASH_factory)); - new Tfactory(this, "FLOAT_CONSTANT", new TCreator(FLOAT_CONSTANT_factory)); - new Tfactory(this, "TOUCH_EVENT", new TCreator(TOUCH_EVENT_factory)); - new Tfactory(this, "COLLISION_START_EVENT", new TCreator(COLLISION_START_EVENT_factory)); - new Tfactory(this, "JUMP", new TCreator(JUMP_factory)); - new Tfactory(this, "RIGHT_BRACKET", new TCreator(RIGHT_BRACKET_factory)); - new Tfactory(this, "LEFT_ANGLE", new TCreator(LEFT_ANGLE_factory)); - new Tfactory(this, "IF", new TCreator(IF_factory)); - new Tfactory(this, "LAND_COLLISION_EVENT", new TCreator(LAND_COLLISION_EVENT_factory)); - new Tfactory(this, "STATE", new TCreator(STATE_factory)); - new Tfactory(this, "RIGHT_SHIFT", new TCreator(RIGHT_SHIFT_factory)); - new Tfactory(this, "LIST_TYPE", new TCreator(LIST_TYPE_factory)); - new Tfactory(this, "HTTP_REQUEST_EVENT", new TCreator(HTTP_REQUEST_EVENT_factory)); - new Tfactory(this, "INCREMENT", new TCreator(INCREMENT_factory)); - new Tfactory(this, "AT", new TCreator(AT_factory)); - new Tfactory(this, "COLLISION_END_EVENT", new TCreator(COLLISION_END_EVENT_factory)); - new Tfactory(this, "SENSOR_EVENT", new TCreator(SENSOR_EVENT_factory)); - new Tfactory(this, "EQUALS_EQUALS", new TCreator(EQUALS_EQUALS_factory)); - new Tfactory(this, "DECREMENT", new TCreator(DECREMENT_factory)); - new Tfactory(this, "LESS_EQUALS", new TCreator(LESS_EQUALS_factory)); - new Tfactory(this, "FLOAT_TYPE", new TCreator(FLOAT_TYPE_factory)); - new Tfactory(this, "MOVING_START_EVENT", new TCreator(MOVING_START_EVENT_factory)); - new Tfactory(this, "RUN_TIME_PERMISSIONS_EVENT", new TCreator(RUN_TIME_PERMISSIONS_EVENT_factory)); - new Tfactory(this, "ON_REZ_EVENT", new TCreator(ON_REZ_EVENT_factory)); - new Tfactory(this, "NO_SENSOR_EVENT", new TCreator(NO_SENSOR_EVENT_factory)); - new Tfactory(this, "EXCLAMATION_EQUALS", new TCreator(EXCLAMATION_EQUALS_factory)); - new Tfactory(this, "MINUS_EQUALS", new TCreator(MINUS_EQUALS_factory)); - new Tfactory(this, "LISTEN_EVENT", new TCreator(LISTEN_EVENT_factory)); - new Tfactory(this, "PERCENT_EQUALS", new TCreator(PERCENT_EQUALS_factory)); - new Tfactory(this, "LEFT_BRACKET", new TCreator(LEFT_BRACKET_factory)); - new Tfactory(this, "HEX_INTEGER_CONSTANT", new TCreator(HEX_INTEGER_CONSTANT_factory)); - new Tfactory(this, "COMMA", new TCreator(COMMA_factory)); - new Tfactory(this, "PERIOD", new TCreator(PERIOD_factory)); - new Tfactory(this, "KEY_TYPE", new TCreator(KEY_TYPE_factory)); - new Tfactory(this, "SLASH_EQUALS", new TCreator(SLASH_EQUALS_factory)); - new Tfactory(this, "STATE_EXIT_EVENT", new TCreator(STATE_EXIT_EVENT_factory)); - new Tfactory(this, "COLLISION_EVENT", new TCreator(COLLISION_EVENT_factory)); - new Tfactory(this, "STRING_CONSTANT", new TCreator(STRING_CONSTANT_factory)); - new Tfactory(this, "WHILE", new TCreator(WHILE_factory)); - new Tfactory(this, "IDENT", new TCreator(IDENT_factory)); - new Tfactory(this, "DATASERVER_EVENT", new TCreator(DATASERVER_EVENT_factory)); - new Tfactory(this, "ROTATION_TYPE", new TCreator(ROTATION_TYPE_factory)); - new Tfactory(this, "AT_ROT_TARGET_EVENT", new TCreator(AT_ROT_TARGET_EVENT_factory)); - new Tfactory(this, "LEFT_BRACE", new TCreator(LEFT_BRACE_factory)); - new Tfactory(this, "DO", new TCreator(DO_factory)); - new Tfactory(this, "LEFT_SHIFT", new TCreator(LEFT_SHIFT_factory)); - new Tfactory(this, "REMOTE_DATA_EVENT", new TCreator(REMOTE_DATA_EVENT_factory)); - new Tfactory(this, "EMAIL_EVENT", new TCreator(EMAIL_EVENT_factory)); - new Tfactory(this, "NOT_AT_ROT_TARGET_EVENT", new TCreator(NOT_AT_ROT_TARGET_EVENT_factory)); - new Tfactory(this, "TILDE", new TCreator(TILDE_factory)); - new Tfactory(this, "STROKE", new TCreator(STROKE_factory)); - new Tfactory(this, "LAND_COLLISION_END_EVENT", new TCreator(LAND_COLLISION_END_EVENT_factory)); - new Tfactory(this, "TIMER_EVENT", new TCreator(TIMER_EVENT_factory)); - new Tfactory(this, "MONEY_EVENT", new TCreator(MONEY_EVENT_factory)); - new Tfactory(this, "RIGHT_ANGLE", new TCreator(RIGHT_ANGLE_factory)); - new Tfactory(this, "AT_TARGET_EVENT", new TCreator(AT_TARGET_EVENT_factory)); - new Tfactory(this, "AMP", new TCreator(AMP_factory)); - new Tfactory(this, "SEMICOLON", new TCreator(SEMICOLON_factory)); - new Tfactory(this, "AMP_AMP", new TCreator(AMP_AMP_factory)); - new Tfactory(this, "CHANGED_EVENT", new TCreator(CHANGED_EVENT_factory)); - new Tfactory(this, "LINK_MESSAGE_EVENT", new TCreator(LINK_MESSAGE_EVENT_factory)); - new Tfactory(this, "TOUCH_END_EVENT", new TCreator(TOUCH_END_EVENT_factory)); - new Tfactory(this, "EQUALS", new TCreator(EQUALS_factory)); - new Tfactory(this, "NOT_AT_TARGET_EVENT", new TCreator(NOT_AT_TARGET_EVENT_factory)); - new Tfactory(this, "STROKE_STROKE", new TCreator(STROKE_STROKE_factory)); - new Tfactory(this, "GREATER_EQUALS", new TCreator(GREATER_EQUALS_factory)); - new Tfactory(this, "TOUCH_START_EVENT", new TCreator(TOUCH_START_EVENT_factory)); - new Tfactory(this, "ATTACH_EVENT", new TCreator(ATTACH_EVENT_factory)); - new Tfactory(this, "VECTOR_TYPE", new TCreator(VECTOR_TYPE_factory)); - new Tfactory(this, "RIGHT_BRACE", new TCreator(RIGHT_BRACE_factory)); - new Tfactory(this, "STATE_ENTRY_EVENT", new TCreator(STATE_ENTRY_EVENT_factory)); - new Tfactory(this, "PLUS", new TCreator(PLUS_factory)); - new Tfactory(this, "STAR_EQUALS", new TCreator(STAR_EQUALS_factory)); - new Tfactory(this, "LAND_COLLISION_START_EVENT", new TCreator(LAND_COLLISION_START_EVENT_factory)); - new Tfactory(this, "CONTROL_EVENT", new TCreator(CONTROL_EVENT_factory)); + new Tfactory(this, "MINUS", MINUS_factory); + new Tfactory(this, "DEFAULT_STATE", DEFAULT_STATE_factory); + new Tfactory(this, "INTEGER_CONSTANT", INTEGER_CONSTANT_factory); + new Tfactory(this, "RETURN", RETURN_factory); + new Tfactory(this, "OBJECT_REZ_EVENT", OBJECT_REZ_EVENT_factory); + new Tfactory(this, "STRING_TYPE", STRING_TYPE_factory); + new Tfactory(this, "EXCLAMATION", EXCLAMATION_factory); + new Tfactory(this, "ELSE", ELSE_factory); + new Tfactory(this, "INTEGER_TYPE", INTEGER_TYPE_factory); + new Tfactory(this, "FOR", FOR_factory); + new Tfactory(this, "LEFT_PAREN", LEFT_PAREN_factory); + new Tfactory(this, "RIGHT_PAREN", RIGHT_PAREN_factory); + new Tfactory(this, "HTTP_RESPONSE_EVENT", HTTP_RESPONSE_EVENT_factory); + new Tfactory(this, "MOVING_END_EVENT", MOVING_END_EVENT_factory); + new Tfactory(this, "CARET", CARET_factory); + new Tfactory(this, "STAR", STAR_factory); + new Tfactory(this, "PLUS_EQUALS", PLUS_EQUALS_factory); + new Tfactory(this, "PERCENT", PERCENT_factory); + new Tfactory(this, "SLASH", SLASH_factory); + new Tfactory(this, "FLOAT_CONSTANT", FLOAT_CONSTANT_factory); + new Tfactory(this, "TOUCH_EVENT", TOUCH_EVENT_factory); + new Tfactory(this, "COLLISION_START_EVENT", COLLISION_START_EVENT_factory); + new Tfactory(this, "JUMP", JUMP_factory); + new Tfactory(this, "RIGHT_BRACKET", RIGHT_BRACKET_factory); + new Tfactory(this, "LEFT_ANGLE", LEFT_ANGLE_factory); + new Tfactory(this, "IF", IF_factory); + new Tfactory(this, "LAND_COLLISION_EVENT", LAND_COLLISION_EVENT_factory); + new Tfactory(this, "STATE", STATE_factory); + new Tfactory(this, "RIGHT_SHIFT", RIGHT_SHIFT_factory); + new Tfactory(this, "LIST_TYPE", LIST_TYPE_factory); + new Tfactory(this, "HTTP_REQUEST_EVENT", HTTP_REQUEST_EVENT_factory); + new Tfactory(this, "INCREMENT", INCREMENT_factory); + new Tfactory(this, "AT", AT_factory); + new Tfactory(this, "COLLISION_END_EVENT", COLLISION_END_EVENT_factory); + new Tfactory(this, "SENSOR_EVENT", SENSOR_EVENT_factory); + new Tfactory(this, "EQUALS_EQUALS", EQUALS_EQUALS_factory); + new Tfactory(this, "DECREMENT", DECREMENT_factory); + new Tfactory(this, "LESS_EQUALS", LESS_EQUALS_factory); + new Tfactory(this, "FLOAT_TYPE", FLOAT_TYPE_factory); + new Tfactory(this, "MOVING_START_EVENT", MOVING_START_EVENT_factory); + new Tfactory(this, "RUN_TIME_PERMISSIONS_EVENT", RUN_TIME_PERMISSIONS_EVENT_factory); + new Tfactory(this, "ON_REZ_EVENT", ON_REZ_EVENT_factory); + new Tfactory(this, "NO_SENSOR_EVENT", NO_SENSOR_EVENT_factory); + new Tfactory(this, "EXCLAMATION_EQUALS", EXCLAMATION_EQUALS_factory); + new Tfactory(this, "MINUS_EQUALS", MINUS_EQUALS_factory); + new Tfactory(this, "LISTEN_EVENT", LISTEN_EVENT_factory); + new Tfactory(this, "PERCENT_EQUALS", PERCENT_EQUALS_factory); + new Tfactory(this, "LEFT_BRACKET", LEFT_BRACKET_factory); + new Tfactory(this, "HEX_INTEGER_CONSTANT", HEX_INTEGER_CONSTANT_factory); + new Tfactory(this, "COMMA", COMMA_factory); + new Tfactory(this, "PERIOD", PERIOD_factory); + new Tfactory(this, "KEY_TYPE", KEY_TYPE_factory); + new Tfactory(this, "SLASH_EQUALS", SLASH_EQUALS_factory); + new Tfactory(this, "STATE_EXIT_EVENT", STATE_EXIT_EVENT_factory); + new Tfactory(this, "COLLISION_EVENT", COLLISION_EVENT_factory); + new Tfactory(this, "STRING_CONSTANT", STRING_CONSTANT_factory); + new Tfactory(this, "WHILE", WHILE_factory); + new Tfactory(this, "IDENT", IDENT_factory); + new Tfactory(this, "DATASERVER_EVENT", DATASERVER_EVENT_factory); + new Tfactory(this, "ROTATION_TYPE", ROTATION_TYPE_factory); + new Tfactory(this, "AT_ROT_TARGET_EVENT", AT_ROT_TARGET_EVENT_factory); + new Tfactory(this, "LEFT_BRACE", LEFT_BRACE_factory); + new Tfactory(this, "DO", DO_factory); + new Tfactory(this, "LEFT_SHIFT", LEFT_SHIFT_factory); + new Tfactory(this, "REMOTE_DATA_EVENT", REMOTE_DATA_EVENT_factory); + new Tfactory(this, "EMAIL_EVENT", EMAIL_EVENT_factory); + new Tfactory(this, "NOT_AT_ROT_TARGET_EVENT", NOT_AT_ROT_TARGET_EVENT_factory); + new Tfactory(this, "TILDE", TILDE_factory); + new Tfactory(this, "STROKE", STROKE_factory); + new Tfactory(this, "LAND_COLLISION_END_EVENT", LAND_COLLISION_END_EVENT_factory); + new Tfactory(this, "TIMER_EVENT", TIMER_EVENT_factory); + new Tfactory(this, "MONEY_EVENT", MONEY_EVENT_factory); + new Tfactory(this, "RIGHT_ANGLE", RIGHT_ANGLE_factory); + new Tfactory(this, "AT_TARGET_EVENT", AT_TARGET_EVENT_factory); + new Tfactory(this, "AMP", AMP_factory); + new Tfactory(this, "SEMICOLON", SEMICOLON_factory); + new Tfactory(this, "AMP_AMP", AMP_AMP_factory); + new Tfactory(this, "CHANGED_EVENT", CHANGED_EVENT_factory); + new Tfactory(this, "LINK_MESSAGE_EVENT", LINK_MESSAGE_EVENT_factory); + new Tfactory(this, "TOUCH_END_EVENT", TOUCH_END_EVENT_factory); + new Tfactory(this, "EQUALS", EQUALS_factory); + new Tfactory(this, "NOT_AT_TARGET_EVENT", NOT_AT_TARGET_EVENT_factory); + new Tfactory(this, "STROKE_STROKE", STROKE_STROKE_factory); + new Tfactory(this, "GREATER_EQUALS", GREATER_EQUALS_factory); + new Tfactory(this, "TOUCH_START_EVENT", TOUCH_START_EVENT_factory); + new Tfactory(this, "ATTACH_EVENT", ATTACH_EVENT_factory); + new Tfactory(this, "VECTOR_TYPE", VECTOR_TYPE_factory); + new Tfactory(this, "RIGHT_BRACE", RIGHT_BRACE_factory); + new Tfactory(this, "STATE_ENTRY_EVENT", STATE_ENTRY_EVENT_factory); + new Tfactory(this, "PLUS", PLUS_factory); + new Tfactory(this, "STAR_EQUALS", STAR_EQUALS_factory); + new Tfactory(this, "LAND_COLLISION_START_EVENT", LAND_COLLISION_START_EVENT_factory); + new Tfactory(this, "CONTROL_EVENT", CONTROL_EVENT_factory); } public static object MINUS_factory(Lexer yyl) { return new MINUS(yyl); } public static object DEFAULT_STATE_factory(Lexer yyl) { return new DEFAULT_STATE(yyl); } diff --git a/Radegast/Core/LSL/lsl.parser.cs b/Radegast/Core/LSL/lsl.parser.cs index 63bbc1a26..fbb33ae8e 100644 --- a/Radegast/Core/LSL/lsl.parser.cs +++ b/Radegast/Core/LSL/lsl.parser.cs @@ -1,4 +1,25 @@ -using Tools; +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2022, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + +using LibreMetaverse.LslTools; + namespace Radegast.LSL { //%+LSLProgramRoot+96 @@ -18,8 +39,8 @@ public LSLProgramRoot(Parser yyp, GlobalDefinitions gd, States s) while (0 < s.kids.Count) kids.Add(s.kids.Pop()); } - public override string yyname { get { return "LSLProgramRoot"; } } - public override int yynum { get { return 96; } } + public override string yyname => "LSLProgramRoot"; + public override int yynum => 96; public LSLProgramRoot(Parser yyp) : base(yyp) { } } //%+GlobalDefinitions+97 @@ -52,8 +73,8 @@ public GlobalDefinitions(Parser yyp, GlobalDefinitions gd, GlobalFunctionDefinit kids.Add(gfd); } - public override string yyname { get { return "GlobalDefinitions"; } } - public override int yynum { get { return 97; } } + public override string yyname => "GlobalDefinitions"; + public override int yynum => 97; public GlobalDefinitions(Parser yyp) : base(yyp) { } } //%+GlobalVariableDeclaration+98 @@ -72,45 +93,28 @@ public GlobalVariableDeclaration(Parser yyp, Assignment a) kids.Add(a); } - public override string yyname { get { return "GlobalVariableDeclaration"; } } - public override int yynum { get { return 98; } } + public override string yyname => "GlobalVariableDeclaration"; + public override int yynum => 98; public GlobalVariableDeclaration(Parser yyp) : base(yyp) { } } //%+GlobalFunctionDefinition+99 public class GlobalFunctionDefinition : SYMBOL { - private string m_returnType; - private string m_name; public GlobalFunctionDefinition(Parser yyp, string returnType, string name, ArgumentDeclarationList adl, CompoundStatement cs) : base(((LSLSyntax )yyp)) { - m_returnType = returnType; - m_name = name; + ReturnType = returnType; + Name = name; kids.Add(adl); kids.Add(cs); } - public string ReturnType - { - get - { - return m_returnType; - } - set - { - m_returnType = value; - } - } - public string Name - { - get - { - return m_name; - } - } + public string ReturnType { get; set; } - public override string yyname { get { return "GlobalFunctionDefinition"; } } - public override int yynum { get { return 99; } } + public string Name { get; } + + public override string yyname => "GlobalFunctionDefinition"; + public override int yynum => 99; public GlobalFunctionDefinition(Parser yyp) : base(yyp) { } } //%+States+100 @@ -130,35 +134,28 @@ public States(Parser yyp, States s, State us) kids.Add(us); } - public override string yyname { get { return "States"; } } - public override int yynum { get { return 100; } } + public override string yyname => "States"; + public override int yynum => 100; public States(Parser yyp) : base(yyp) { } } //%+State+101 public class State : SYMBOL { - private string m_name; public State(Parser yyp, string name, StateBody sb) : base(((LSLSyntax )yyp)) { - m_name = name; + Name = name; while (0 < sb.kids.Count) kids.Add(sb.kids.Pop()); } public override string ToString() { - return "STATE<" + m_name + ">"; - } - public string Name - { - get - { - return m_name; - } + return "STATE<" + Name + ">"; } + public string Name { get; } - public override string yyname { get { return "State"; } } - public override int yynum { get { return 101; } } + public override string yyname => "State"; + public override int yynum => 101; public State(Parser yyp) : base(yyp) { } } //%+StateBody+102 @@ -178,43 +175,36 @@ public StateBody(Parser yyp, StateEvent se) kids.Add(se); } - public override string yyname { get { return "StateBody"; } } - public override int yynum { get { return 102; } } + public override string yyname => "StateBody"; + public override int yynum => 102; public StateBody(Parser yyp) : base(yyp) { } } //%+StateEvent+103 public class StateEvent : SYMBOL { - private string m_name; public StateEvent(Parser yyp, string name, CompoundStatement cs) : base(((LSLSyntax )yyp)) { - m_name = name; + Name = name; kids.Add(cs); } public StateEvent(Parser yyp, string name, ArgumentDeclarationList dal, CompoundStatement cs) : base(((LSLSyntax )yyp)) { - m_name = name; + Name = name; if (0 < dal.kids.Count) kids.Add(dal); kids.Add(cs); } public override string ToString() { - return "EVENT<" + m_name + ">"; - } - public string Name - { - get - { - return m_name; - } + return "EVENT<" + Name + ">"; } + public string Name { get; } - public override string yyname { get { return "StateEvent"; } } - public override int yynum { get { return 103; } } + public override string yyname => "StateEvent"; + public override int yynum => 103; public StateEvent(Parser yyp) : base(yyp) { } } //%+ArgumentDeclarationList+104 @@ -234,47 +224,30 @@ public ArgumentDeclarationList(Parser yyp, ArgumentDeclarationList adl, Declarat kids.Add(d); } - public override string yyname { get { return "ArgumentDeclarationList"; } } - public override int yynum { get { return 104; } } + public override string yyname => "ArgumentDeclarationList"; + public override int yynum => 104; public ArgumentDeclarationList(Parser yyp) : base(yyp) { } } //%+Declaration+105 public class Declaration : SYMBOL { - private string m_datatype; - private string m_id; public Declaration(Parser yyp, string type, string id) : base(((LSLSyntax )yyp)) { - m_datatype = type; - m_id = id; + Datatype = type; + Id = id; } public override string ToString() { - return "Declaration<" + m_datatype + ":" + m_id + ">"; - } - public string Datatype - { - get - { - return m_datatype; - } - set - { - m_datatype = value; - } - } - public string Id - { - get - { - return m_id; - } + return "Declaration<" + Datatype + ":" + Id + ">"; } + public string Datatype { get; set; } + + public string Id { get; } - public override string yyname { get { return "Declaration"; } } - public override int yynum { get { return 105; } } + public override string yyname => "Declaration"; + public override int yynum => 105; public Declaration(Parser yyp) : base(yyp) { } } //%+Typename+106 @@ -288,8 +261,8 @@ public Typename(Parser yyp, string text) yytext = text; } - public override string yyname { get { return "Typename"; } } - public override int yynum { get { return 106; } } + public override string yyname => "Typename"; + public override int yynum => 106; public Typename(Parser yyp) : base(yyp) { } } //%+Event+107 @@ -303,8 +276,8 @@ public Event(Parser yyp, string text) yytext = text; } - public override string yyname { get { return "Event"; } } - public override int yynum { get { return 107; } } + public override string yyname => "Event"; + public override int yynum => 107; public Event(Parser yyp) : base(yyp) { } } //%+CompoundStatement+108 @@ -320,8 +293,8 @@ public CompoundStatement(Parser yyp, StatementList sl) while (0 < sl.kids.Count) kids.Add(sl.kids.Pop()); } - public override string yyname { get { return "CompoundStatement"; } } - public override int yynum { get { return 108; } } + public override string yyname => "CompoundStatement"; + public override int yynum => 108; } //%+StatementList+109 public class StatementList : SYMBOL @@ -345,8 +318,8 @@ public StatementList(Parser yyp, StatementList sl, Statement s) AddStatement(s); } - public override string yyname { get { return "StatementList"; } } - public override int yynum { get { return 109; } } + public override string yyname => "StatementList"; + public override int yynum => 109; public StatementList(Parser yyp) : base(yyp) { } } //%+Statement+110 @@ -437,8 +410,8 @@ public Statement(Parser yyp, EmptyStatement es) kids.Add(es); } - public override string yyname { get { return "Statement"; } } - public override int yynum { get { return 110; } } + public override string yyname => "Statement"; + public override int yynum => 110; public Statement(Parser yyp) : base(yyp) { } } //%+EmptyStatement+111 @@ -447,13 +420,9 @@ public class EmptyStatement : SYMBOL public EmptyStatement(Parser yyp) : base(((LSLSyntax )yyp)) { } - public override string ToString() - { - return base.ToString(); - } - public override string yyname { get { return "EmptyStatement"; } } - public override int yynum { get { return 111; } } + public override string yyname => "EmptyStatement"; + public override int yynum => 111; } //%+Assignment+112 public class Assignment : SYMBOL @@ -475,20 +444,15 @@ public Assignment(Parser yyp, SimpleAssignment sa) m_assignmentType = sa.AssignmentType; while (0 < sa.kids.Count) kids.Add(sa.kids.Pop()); } - public string AssignmentType - { - get - { - return m_assignmentType; - } - } + public string AssignmentType => m_assignmentType; + public override string ToString() { return base.ToString() + "<" + m_assignmentType + ">"; } - public override string yyname { get { return "Assignment"; } } - public override int yynum { get { return 112; } } + public override string yyname => "Assignment"; + public override int yynum => 112; public Assignment(Parser yyp) : base(yyp) { } } //%+SimpleAssignment+113 @@ -504,8 +468,8 @@ public SimpleAssignment(Parser yyp, SYMBOL lhs, SYMBOL rhs, string assignmentTyp else kids.Add(rhs); } - public override string yyname { get { return "SimpleAssignment"; } } - public override int yynum { get { return 113; } } + public override string yyname => "SimpleAssignment"; + public override int yynum => 113; public SimpleAssignment(Parser yyp) : base(yyp) { } } //%+ReturnStatement+114 @@ -522,81 +486,62 @@ public ReturnStatement(Parser yyp, Expression e) else kids.Add(e); } - public override string yyname { get { return "ReturnStatement"; } } - public override int yynum { get { return 114; } } + public override string yyname => "ReturnStatement"; + public override int yynum => 114; } //%+JumpLabel+115 public class JumpLabel : SYMBOL { - private string m_labelName; public JumpLabel(Parser yyp, string labelName) : base(((LSLSyntax )yyp)) { - m_labelName = labelName; - } - public string LabelName - { - get - { - return m_labelName; - } + LabelName = labelName; } + public string LabelName { get; } + public override string ToString() { - return base.ToString() + "<" + m_labelName + ">"; + return base.ToString() + "<" + LabelName + ">"; } - public override string yyname { get { return "JumpLabel"; } } - public override int yynum { get { return 115; } } + public override string yyname => "JumpLabel"; + public override int yynum => 115; public JumpLabel(Parser yyp) : base(yyp) { } } //%+JumpStatement+116 public class JumpStatement : SYMBOL { - private string m_targetName; public JumpStatement(Parser yyp, string targetName) : base(((LSLSyntax )yyp)) { - m_targetName = targetName; - } - public string TargetName - { - get - { - return m_targetName; - } + TargetName = targetName; } + public string TargetName { get; } + public override string ToString() { - return base.ToString() + "<" + m_targetName + ">"; + return base.ToString() + "<" + TargetName + ">"; } - public override string yyname { get { return "JumpStatement"; } } - public override int yynum { get { return 116; } } + public override string yyname => "JumpStatement"; + public override int yynum => 116; public JumpStatement(Parser yyp) : base(yyp) { } } //%+StateChange+117 public class StateChange : SYMBOL { - private string m_newState; public StateChange(Parser yyp, string newState) : base(((LSLSyntax )yyp)) { - m_newState = newState; - } - public string NewState - { - get - { - return m_newState; - } + NewState = newState; } + public string NewState { get; } - public override string yyname { get { return "StateChange"; } } - public override int yynum { get { return 117; } } + public override string yyname => "StateChange"; + public override int yynum => 117; public StateChange(Parser yyp) : base(yyp) { } } //%+IfStatement+118 @@ -624,8 +569,8 @@ public IfStatement(Parser yyp, SYMBOL s, Statement ifs, Statement es) else AddStatement(es); } - public override string yyname { get { return "IfStatement"; } } - public override int yynum { get { return 118; } } + public override string yyname => "IfStatement"; + public override int yynum => 118; public IfStatement(Parser yyp) : base(yyp) { } } //%+WhileStatement+119 @@ -640,8 +585,8 @@ public WhileStatement(Parser yyp, SYMBOL s, Statement st) else kids.Add(st); } - public override string yyname { get { return "WhileStatement"; } } - public override int yynum { get { return 119; } } + public override string yyname => "WhileStatement"; + public override int yynum => 119; public WhileStatement(Parser yyp) : base(yyp) { } } //%+DoWhileStatement+120 @@ -656,8 +601,8 @@ public DoWhileStatement(Parser yyp, SYMBOL s, Statement st) kids.Add(s); } - public override string yyname { get { return "DoWhileStatement"; } } - public override int yynum { get { return 120; } } + public override string yyname => "DoWhileStatement"; + public override int yynum => 120; public DoWhileStatement(Parser yyp) : base(yyp) { } } //%+ForLoop+121 @@ -674,8 +619,8 @@ public ForLoop(Parser yyp, ForLoopStatement flsa, Expression e, ForLoopStatement else kids.Add(s); } - public override string yyname { get { return "ForLoop"; } } - public override int yynum { get { return 121; } } + public override string yyname => "ForLoop"; + public override int yynum => 121; public ForLoop(Parser yyp) : base(yyp) { } } //%+ForLoopStatement+122 @@ -708,35 +653,28 @@ public ForLoopStatement(Parser yyp, ForLoopStatement fls, SimpleAssignment sa) kids.Add(sa); } - public override string yyname { get { return "ForLoopStatement"; } } - public override int yynum { get { return 122; } } + public override string yyname => "ForLoopStatement"; + public override int yynum => 122; public ForLoopStatement(Parser yyp) : base(yyp) { } } //%+FunctionCall+123 public class FunctionCall : SYMBOL { - private string m_id; public FunctionCall(Parser yyp, string id, ArgumentList al) : base(((LSLSyntax )yyp)) { - m_id = id; + Id = id; kids.Add(al); } public override string ToString() { - return base.ToString() + "<" + m_id + ">"; - } - public string Id - { - get - { - return m_id; - } + return base.ToString() + "<" + Id + ">"; } + public string Id { get; } - public override string yyname { get { return "FunctionCall"; } } - public override int yynum { get { return 123; } } + public override string yyname => "FunctionCall"; + public override int yynum => 123; public FunctionCall(Parser yyp) : base(yyp) { } } //%+ArgumentList+124 @@ -761,15 +699,15 @@ private void AddArgument(Argument a) else kids.Add(a); } - public override string yyname { get { return "ArgumentList"; } } - public override int yynum { get { return 124; } } + public override string yyname => "ArgumentList"; + public override int yynum => 124; public ArgumentList(Parser yyp) : base(yyp) { } } //%+Argument+125 public class Argument : SYMBOL { - public override string yyname { get { return "Argument"; } } - public override int yynum { get { return 125; } } + public override string yyname => "Argument"; + public override int yynum => 125; public Argument(Parser yyp) : base(yyp) { } } //%+ExpressionArgument+126 @@ -783,51 +721,30 @@ public ExpressionArgument(Parser yyp, Expression e) else kids.Add(e); } - public override string yyname { get { return "ExpressionArgument"; } } - public override int yynum { get { return 126; } } + public override string yyname => "ExpressionArgument"; + public override int yynum => 126; public ExpressionArgument(Parser yyp) : base(yyp) { } } //%+Constant+127 public class Constant : SYMBOL { - private string m_type; - private string m_val; public Constant(Parser yyp, string type, string val) : base(((LSLSyntax )yyp)) { - m_type = type; - m_val = val; + Type = type; + Value = val; } public override string ToString() { - return base.ToString() + "<" + m_type + ":" + m_val + ">"; - } - public string Value - { - get - { - return m_val; - } - set - { - m_val = value; - } - } - public string Type - { - get - { - return m_type; - } - set - { - m_type = value; - } + return base.ToString() + "<" + Type + ":" + Value + ">"; } + public string Value { get; set; } + + public string Type { get; set; } - public override string yyname { get { return "Constant"; } } - public override int yynum { get { return 127; } } + public override string yyname => "Constant"; + public override int yynum => 127; public Constant(Parser yyp) : base(yyp) { } } //%+VectorConstant+128 @@ -842,8 +759,8 @@ public VectorConstant(Parser yyp, Expression valX, Expression valY, Expression v kids.Add(valZ); } - public override string yyname { get { return "VectorConstant"; } } - public override int yynum { get { return 128; } } + public override string yyname => "VectorConstant"; + public override int yynum => 128; public VectorConstant(Parser yyp) : base(yyp) { } } //%+RotationConstant+129 @@ -859,8 +776,8 @@ public RotationConstant(Parser yyp, Expression valX, Expression valY, Expression kids.Add(valS); } - public override string yyname { get { return "RotationConstant"; } } - public override int yynum { get { return 129; } } + public override string yyname => "RotationConstant"; + public override int yynum => 129; public RotationConstant(Parser yyp) : base(yyp) { } } //%+ListConstant+130 @@ -873,8 +790,8 @@ public ListConstant(Parser yyp, ArgumentList al) kids.Add(al); } - public override string yyname { get { return "ListConstant"; } } - public override int yynum { get { return 130; } } + public override string yyname => "ListConstant"; + public override int yynum => 130; public ListConstant(Parser yyp) : base(yyp) { } } //%+Expression+131 @@ -886,8 +803,8 @@ protected void AddExpression(Expression e) else kids.Add(e); } - public override string yyname { get { return "Expression"; } } - public override int yynum { get { return 131; } } + public override string yyname => "Expression"; + public override int yynum => 131; public Expression(Parser yyp) : base(yyp) { } } //%+ConstantExpression+132 @@ -900,8 +817,8 @@ public ConstantExpression(Parser yyp, Constant c) kids.Add(c); } - public override string yyname { get { return "ConstantExpression"; } } - public override int yynum { get { return 132; } } + public override string yyname => "ConstantExpression"; + public override int yynum => 132; public ConstantExpression(Parser yyp) : base(yyp) { } } //%+IdentExpression+133 @@ -918,43 +835,30 @@ public override string ToString() { return base.ToString() + "<" + m_name + ">"; } - public string Name - { - get - { - return m_name; - } - } + public string Name => m_name; - public override string yyname { get { return "IdentExpression"; } } - public override int yynum { get { return 133; } } + public override string yyname => "IdentExpression"; + public override int yynum => 133; public IdentExpression(Parser yyp) : base(yyp) { } } //%+IdentDotExpression+134 public class IdentDotExpression : IdentExpression { - private string m_member; public IdentDotExpression(Parser yyp, string name, string member) : base(((LSLSyntax )yyp), name) { - m_member = member; + Member = member; } public override string ToString() { string baseToString = base.ToString(); - return baseToString.Substring(0, baseToString.Length - 1) + "." + m_member + ">"; - } - public string Member - { - get - { - return m_member; - } + return baseToString.Substring(0, baseToString.Length - 1) + "." + Member + ">"; } + public string Member { get; } - public override string yyname { get { return "IdentDotExpression"; } } - public override int yynum { get { return 134; } } + public override string yyname => "IdentDotExpression"; + public override int yynum => 134; public IdentDotExpression(Parser yyp) : base(yyp) { } } //%+FunctionCallExpression+135 @@ -967,90 +871,67 @@ public FunctionCallExpression(Parser yyp, FunctionCall fc) kids.Add(fc); } - public override string yyname { get { return "FunctionCallExpression"; } } - public override int yynum { get { return 135; } } + public override string yyname => "FunctionCallExpression"; + public override int yynum => 135; public FunctionCallExpression(Parser yyp) : base(yyp) { } } //%+BinaryExpression+136 public class BinaryExpression : Expression { - private string m_expressionSymbol; public BinaryExpression(Parser yyp, Expression lhs, Expression rhs, string expressionSymbol) : base(((LSLSyntax )yyp)) { - m_expressionSymbol = expressionSymbol; + ExpressionSymbol = expressionSymbol; AddExpression(lhs); AddExpression(rhs); } - public string ExpressionSymbol - { - get - { - return m_expressionSymbol; - } - } + public string ExpressionSymbol { get; } + public override string ToString() { - return base.ToString() + "<" + m_expressionSymbol + ">"; + return base.ToString() + "<" + ExpressionSymbol + ">"; } - public override string yyname { get { return "BinaryExpression"; } } - public override int yynum { get { return 136; } } + public override string yyname => "BinaryExpression"; + public override int yynum => 136; public BinaryExpression(Parser yyp) : base(yyp) { } } //%+UnaryExpression+137 public class UnaryExpression : Expression { - private string m_unarySymbol; public UnaryExpression(Parser yyp, string unarySymbol, Expression e) : base(((LSLSyntax )yyp)) { - m_unarySymbol = unarySymbol; + UnarySymbol = unarySymbol; AddExpression(e); } - public string UnarySymbol - { - get - { - return m_unarySymbol; - } - } + public string UnarySymbol { get; } + public override string ToString() { - return base.ToString() + "<" + m_unarySymbol + ">"; + return base.ToString() + "<" + UnarySymbol + ">"; } - public override string yyname { get { return "UnaryExpression"; } } - public override int yynum { get { return 137; } } + public override string yyname => "UnaryExpression"; + public override int yynum => 137; public UnaryExpression(Parser yyp) : base(yyp) { } } //%+TypecastExpression+138 public class TypecastExpression : Expression { - private string m_typecastType; public TypecastExpression(Parser yyp, string typecastType, SYMBOL rhs) : base(((LSLSyntax )yyp)) { - m_typecastType = typecastType; + TypecastType = typecastType; kids.Add(rhs); } - public string TypecastType - { - get - { - return m_typecastType; - } - set - { - m_typecastType = value; - } - } + public string TypecastType { get; set; } - public override string yyname { get { return "TypecastExpression"; } } - public override int yynum { get { return 138; } } + public override string yyname => "TypecastExpression"; + public override int yynum => 138; public TypecastExpression(Parser yyp) : base(yyp) { } } //%+ParenthesisExpression+139 @@ -1063,60 +944,41 @@ public ParenthesisExpression(Parser yyp, SYMBOL s) kids.Add(s); } - public override string yyname { get { return "ParenthesisExpression"; } } - public override int yynum { get { return 139; } } + public override string yyname => "ParenthesisExpression"; + public override int yynum => 139; public ParenthesisExpression(Parser yyp) : base(yyp) { } } //%+IncrementDecrementExpression+140 public class IncrementDecrementExpression : Expression { - private string m_name; - private string m_operation; - private bool m_postOperation; public IncrementDecrementExpression(Parser yyp, string name, string operation, bool postOperation) : base(((LSLSyntax )yyp)) { - m_name = name; - m_operation = operation; - m_postOperation = postOperation; + Name = name; + Operation = operation; + PostOperation = postOperation; } public IncrementDecrementExpression(Parser yyp, IdentDotExpression ide, string operation, bool postOperation) : base(((LSLSyntax )yyp)) { - m_operation = operation; - m_postOperation = postOperation; + Operation = operation; + PostOperation = postOperation; kids.Add(ide); } public override string ToString() { - return base.ToString() + "<" + (m_postOperation ? m_name + m_operation : m_operation + m_name) + ">"; - } - public string Name - { - get - { - return m_name; - } - } - public string Operation - { - get - { - return m_operation; - } - } - public bool PostOperation - { - get - { - return m_postOperation; - } + return base.ToString() + "<" + (PostOperation ? Name + Operation : Operation + Name) + ">"; } + public string Name { get; } + + public string Operation { get; } + + public bool PostOperation { get; } - public override string yyname { get { return "IncrementDecrementExpression"; } } - public override int yynum { get { return 140; } } + public override string yyname => "IncrementDecrementExpression"; + public override int yynum => 140; public IncrementDecrementExpression(Parser yyp) : base(yyp) { } } @@ -2958,7 +2820,6 @@ public ArgumentDeclarationList_5(Parser yyq) : base(yyq) { } } public yyLSLSyntax () - : base() { arr = new int[] { 101,4,6,52,0, @@ -11771,237 +11632,237 @@ public yyLSLSyntax 115,0,116,0,95, 0,53,0,1,326, 3945,2,0,0}; - new Sfactory(this, "ExpressionArgument_1", new SCreator(ExpressionArgument_1_factory)); - new Sfactory(this, "SimpleAssignment_8", new SCreator(SimpleAssignment_8_factory)); - new Sfactory(this, "StatementList_1", new SCreator(StatementList_1_factory)); - new Sfactory(this, "StateChange_1", new SCreator(StateChange_1_factory)); - new Sfactory(this, "StateChange_2", new SCreator(StateChange_2_factory)); - new Sfactory(this, "Declaration", new SCreator(Declaration_factory)); - new Sfactory(this, "IdentExpression", new SCreator(IdentExpression_factory)); - new Sfactory(this, "error", new SCreator(error_factory)); - new Sfactory(this, "BinaryExpression_2", new SCreator(BinaryExpression_2_factory)); - new Sfactory(this, "BinaryExpression_3", new SCreator(BinaryExpression_3_factory)); - new Sfactory(this, "BinaryExpression_4", new SCreator(BinaryExpression_4_factory)); - new Sfactory(this, "BinaryExpression_5", new SCreator(BinaryExpression_5_factory)); - new Sfactory(this, "ReturnStatement_2", new SCreator(ReturnStatement_2_factory)); - new Sfactory(this, "SimpleAssignment_19", new SCreator(SimpleAssignment_19_factory)); - new Sfactory(this, "BinaryExpression_9", new SCreator(BinaryExpression_9_factory)); - new Sfactory(this, "VectorConstant_1", new SCreator(VectorConstant_1_factory)); - new Sfactory(this, "ParenthesisExpression", new SCreator(ParenthesisExpression_factory)); - new Sfactory(this, "UnaryExpression", new SCreator(UnaryExpression_factory)); - new Sfactory(this, "IdentDotExpression_1", new SCreator(IdentDotExpression_1_factory)); - new Sfactory(this, "ArgumentList_4", new SCreator(ArgumentList_4_factory)); - new Sfactory(this, "Typename", new SCreator(Typename_factory)); - new Sfactory(this, "IfStatement_1", new SCreator(IfStatement_1_factory)); - new Sfactory(this, "Assignment", new SCreator(Assignment_factory)); - new Sfactory(this, "CompoundStatement_1", new SCreator(CompoundStatement_1_factory)); - new Sfactory(this, "CompoundStatement_2", new SCreator(CompoundStatement_2_factory)); - new Sfactory(this, "BinaryExpression_8", new SCreator(BinaryExpression_8_factory)); - new Sfactory(this, "ReturnStatement_1", new SCreator(ReturnStatement_1_factory)); - new Sfactory(this, "IdentDotExpression", new SCreator(IdentDotExpression_factory)); - new Sfactory(this, "Argument", new SCreator(Argument_factory)); - new Sfactory(this, "State_2", new SCreator(State_2_factory)); - new Sfactory(this, "WhileStatement_1", new SCreator(WhileStatement_1_factory)); - new Sfactory(this, "GlobalDefinitions_3", new SCreator(GlobalDefinitions_3_factory)); - new Sfactory(this, "GlobalDefinitions_4", new SCreator(GlobalDefinitions_4_factory)); - new Sfactory(this, "Event_1", new SCreator(Event_1_factory)); - new Sfactory(this, "ListConstant", new SCreator(ListConstant_factory)); - new Sfactory(this, "Event_3", new SCreator(Event_3_factory)); - new Sfactory(this, "Event_4", new SCreator(Event_4_factory)); - new Sfactory(this, "Event_5", new SCreator(Event_5_factory)); - new Sfactory(this, "SimpleAssignment_5", new SCreator(SimpleAssignment_5_factory)); - new Sfactory(this, "Typename_1", new SCreator(Typename_1_factory)); - new Sfactory(this, "Typename_2", new SCreator(Typename_2_factory)); - new Sfactory(this, "Typename_3", new SCreator(Typename_3_factory)); - new Sfactory(this, "Typename_4", new SCreator(Typename_4_factory)); - new Sfactory(this, "Typename_5", new SCreator(Typename_5_factory)); - new Sfactory(this, "Typename_6", new SCreator(Typename_6_factory)); - new Sfactory(this, "Typename_7", new SCreator(Typename_7_factory)); - new Sfactory(this, "ArgumentDeclarationList", new SCreator(ArgumentDeclarationList_factory)); - new Sfactory(this, "ConstantExpression", new SCreator(ConstantExpression_factory)); - new Sfactory(this, "LSLProgramRoot_1", new SCreator(LSLProgramRoot_1_factory)); - new Sfactory(this, "LSLProgramRoot_2", new SCreator(LSLProgramRoot_2_factory)); - new Sfactory(this, "States_1", new SCreator(States_1_factory)); - new Sfactory(this, "States_2", new SCreator(States_2_factory)); - new Sfactory(this, "FunctionCallExpression_1", new SCreator(FunctionCallExpression_1_factory)); - new Sfactory(this, "ForLoopStatement", new SCreator(ForLoopStatement_factory)); - new Sfactory(this, "DoWhileStatement_1", new SCreator(DoWhileStatement_1_factory)); - new Sfactory(this, "DoWhileStatement_2", new SCreator(DoWhileStatement_2_factory)); - new Sfactory(this, "ForLoopStatement_4", new SCreator(ForLoopStatement_4_factory)); - new Sfactory(this, "SimpleAssignment_11", new SCreator(SimpleAssignment_11_factory)); - new Sfactory(this, "SimpleAssignment_12", new SCreator(SimpleAssignment_12_factory)); - new Sfactory(this, "SimpleAssignment_13", new SCreator(SimpleAssignment_13_factory)); - new Sfactory(this, "JumpLabel", new SCreator(JumpLabel_factory)); - new Sfactory(this, "SimpleAssignment_15", new SCreator(SimpleAssignment_15_factory)); - new Sfactory(this, "SimpleAssignment_17", new SCreator(SimpleAssignment_17_factory)); - new Sfactory(this, "SimpleAssignment_18", new SCreator(SimpleAssignment_18_factory)); - new Sfactory(this, "JumpStatement_1", new SCreator(JumpStatement_1_factory)); - new Sfactory(this, "GlobalDefinitions", new SCreator(GlobalDefinitions_factory)); - new Sfactory(this, "FunctionCall_1", new SCreator(FunctionCall_1_factory)); - new Sfactory(this, "ArgumentList_3", new SCreator(ArgumentList_3_factory)); - new Sfactory(this, "Assignment_2", new SCreator(Assignment_2_factory)); - new Sfactory(this, "TypecastExpression_1", new SCreator(TypecastExpression_1_factory)); - new Sfactory(this, "SimpleAssignment_21", new SCreator(SimpleAssignment_21_factory)); - new Sfactory(this, "SimpleAssignment_22", new SCreator(SimpleAssignment_22_factory)); - new Sfactory(this, "SimpleAssignment_23", new SCreator(SimpleAssignment_23_factory)); - new Sfactory(this, "TypecastExpression_9", new SCreator(TypecastExpression_9_factory)); - new Sfactory(this, "ArgumentDeclarationList_1", new SCreator(ArgumentDeclarationList_1_factory)); - new Sfactory(this, "ArgumentDeclarationList_2", new SCreator(ArgumentDeclarationList_2_factory)); - new Sfactory(this, "ArgumentDeclarationList_3", new SCreator(ArgumentDeclarationList_3_factory)); - new Sfactory(this, "GlobalDefinitions_1", new SCreator(GlobalDefinitions_1_factory)); - new Sfactory(this, "GlobalDefinitions_2", new SCreator(GlobalDefinitions_2_factory)); - new Sfactory(this, "IncrementDecrementExpression", new SCreator(IncrementDecrementExpression_factory)); - new Sfactory(this, "GlobalVariableDeclaration", new SCreator(GlobalVariableDeclaration_factory)); - new Sfactory(this, "Event_11", new SCreator(Event_11_factory)); - new Sfactory(this, "TypecastExpression_2", new SCreator(TypecastExpression_2_factory)); - new Sfactory(this, "TypecastExpression_3", new SCreator(TypecastExpression_3_factory)); - new Sfactory(this, "TypecastExpression_5", new SCreator(TypecastExpression_5_factory)); - new Sfactory(this, "TypecastExpression_8", new SCreator(TypecastExpression_8_factory)); - new Sfactory(this, "Constant_1", new SCreator(Constant_1_factory)); - new Sfactory(this, "Expression", new SCreator(Expression_factory)); - new Sfactory(this, "Constant_3", new SCreator(Constant_3_factory)); - new Sfactory(this, "Constant_4", new SCreator(Constant_4_factory)); - new Sfactory(this, "BinaryExpression_1", new SCreator(BinaryExpression_1_factory)); - new Sfactory(this, "IfStatement_2", new SCreator(IfStatement_2_factory)); - new Sfactory(this, "IfStatement_3", new SCreator(IfStatement_3_factory)); - new Sfactory(this, "IfStatement_4", new SCreator(IfStatement_4_factory)); - new Sfactory(this, "ReturnStatement", new SCreator(ReturnStatement_factory)); - new Sfactory(this, "Event_2", new SCreator(Event_2_factory)); - new Sfactory(this, "RotationConstant", new SCreator(RotationConstant_factory)); - new Sfactory(this, "Statement_12", new SCreator(Statement_12_factory)); - new Sfactory(this, "UnaryExpression_1", new SCreator(UnaryExpression_1_factory)); - new Sfactory(this, "UnaryExpression_2", new SCreator(UnaryExpression_2_factory)); - new Sfactory(this, "UnaryExpression_3", new SCreator(UnaryExpression_3_factory)); - new Sfactory(this, "ArgumentList_1", new SCreator(ArgumentList_1_factory)); - new Sfactory(this, "ArgumentList_2", new SCreator(ArgumentList_2_factory)); - new Sfactory(this, "Constant", new SCreator(Constant_factory)); - new Sfactory(this, "State", new SCreator(State_factory)); - new Sfactory(this, "Event_13", new SCreator(Event_13_factory)); - new Sfactory(this, "LSLProgramRoot", new SCreator(LSLProgramRoot_factory)); - new Sfactory(this, "StateChange", new SCreator(StateChange_factory)); - new Sfactory(this, "IncrementDecrementExpression_2", new SCreator(IncrementDecrementExpression_2_factory)); - new Sfactory(this, "GlobalVariableDeclaration_1", new SCreator(GlobalVariableDeclaration_1_factory)); - new Sfactory(this, "GlobalVariableDeclaration_2", new SCreator(GlobalVariableDeclaration_2_factory)); - new Sfactory(this, "IncrementDecrementExpression_5", new SCreator(IncrementDecrementExpression_5_factory)); - new Sfactory(this, "GlobalFunctionDefinition_2", new SCreator(GlobalFunctionDefinition_2_factory)); - new Sfactory(this, "IncrementDecrementExpression_7", new SCreator(IncrementDecrementExpression_7_factory)); - new Sfactory(this, "IncrementDecrementExpression_8", new SCreator(IncrementDecrementExpression_8_factory)); - new Sfactory(this, "Assignment_1", new SCreator(Assignment_1_factory)); - new Sfactory(this, "Event_21", new SCreator(Event_21_factory)); - new Sfactory(this, "Event_22", new SCreator(Event_22_factory)); - new Sfactory(this, "CompoundStatement", new SCreator(CompoundStatement_factory)); - new Sfactory(this, "RotationConstant_1", new SCreator(RotationConstant_1_factory)); - new Sfactory(this, "TypecastExpression", new SCreator(TypecastExpression_factory)); - new Sfactory(this, "SimpleAssignment_3", new SCreator(SimpleAssignment_3_factory)); - new Sfactory(this, "SimpleAssignment_4", new SCreator(SimpleAssignment_4_factory)); - new Sfactory(this, "Statement_1", new SCreator(Statement_1_factory)); - new Sfactory(this, "Statement_2", new SCreator(Statement_2_factory)); - new Sfactory(this, "Statement_3", new SCreator(Statement_3_factory)); - new Sfactory(this, "Statement_4", new SCreator(Statement_4_factory)); - new Sfactory(this, "Statement_5", new SCreator(Statement_5_factory)); - new Sfactory(this, "Statement_6", new SCreator(Statement_6_factory)); - new Sfactory(this, "Statement_7", new SCreator(Statement_7_factory)); - new Sfactory(this, "Statement_8", new SCreator(Statement_8_factory)); - new Sfactory(this, "Statement_9", new SCreator(Statement_9_factory)); - new Sfactory(this, "ExpressionArgument", new SCreator(ExpressionArgument_factory)); - new Sfactory(this, "GlobalFunctionDefinition", new SCreator(GlobalFunctionDefinition_factory)); - new Sfactory(this, "State_1", new SCreator(State_1_factory)); - new Sfactory(this, "DoWhileStatement", new SCreator(DoWhileStatement_factory)); - new Sfactory(this, "ParenthesisExpression_1", new SCreator(ParenthesisExpression_1_factory)); - new Sfactory(this, "ParenthesisExpression_2", new SCreator(ParenthesisExpression_2_factory)); - new Sfactory(this, "StateBody", new SCreator(StateBody_factory)); - new Sfactory(this, "Event_7", new SCreator(Event_7_factory)); - new Sfactory(this, "Event_8", new SCreator(Event_8_factory)); - new Sfactory(this, "IncrementDecrementExpression_1", new SCreator(IncrementDecrementExpression_1_factory)); - new Sfactory(this, "IncrementDecrementExpression_3", new SCreator(IncrementDecrementExpression_3_factory)); - new Sfactory(this, "IncrementDecrementExpression_4", new SCreator(IncrementDecrementExpression_4_factory)); - new Sfactory(this, "IncrementDecrementExpression_6", new SCreator(IncrementDecrementExpression_6_factory)); - new Sfactory(this, "StateEvent", new SCreator(StateEvent_factory)); - new Sfactory(this, "Event_20", new SCreator(Event_20_factory)); - new Sfactory(this, "Event_23", new SCreator(Event_23_factory)); - new Sfactory(this, "Event_24", new SCreator(Event_24_factory)); - new Sfactory(this, "Event_26", new SCreator(Event_26_factory)); - new Sfactory(this, "SimpleAssignment_10", new SCreator(SimpleAssignment_10_factory)); - new Sfactory(this, "Event", new SCreator(Event_factory)); - new Sfactory(this, "SimpleAssignment_14", new SCreator(SimpleAssignment_14_factory)); - new Sfactory(this, "SimpleAssignment_16", new SCreator(SimpleAssignment_16_factory)); - new Sfactory(this, "Statement_10", new SCreator(Statement_10_factory)); - new Sfactory(this, "Statement_11", new SCreator(Statement_11_factory)); - new Sfactory(this, "SimpleAssignment", new SCreator(SimpleAssignment_factory)); - new Sfactory(this, "Statement_13", new SCreator(Statement_13_factory)); - new Sfactory(this, "Event_15", new SCreator(Event_15_factory)); - new Sfactory(this, "Event_16", new SCreator(Event_16_factory)); - new Sfactory(this, "Event_32", new SCreator(Event_32_factory)); - new Sfactory(this, "Event_34", new SCreator(Event_34_factory)); - new Sfactory(this, "SimpleAssignment_20", new SCreator(SimpleAssignment_20_factory)); - new Sfactory(this, "SimpleAssignment_24", new SCreator(SimpleAssignment_24_factory)); - new Sfactory(this, "SimpleAssignment_1", new SCreator(SimpleAssignment_1_factory)); - new Sfactory(this, "SimpleAssignment_2", new SCreator(SimpleAssignment_2_factory)); - new Sfactory(this, "BinaryExpression", new SCreator(BinaryExpression_factory)); - new Sfactory(this, "FunctionCallExpression", new SCreator(FunctionCallExpression_factory)); - new Sfactory(this, "SimpleAssignment_6", new SCreator(SimpleAssignment_6_factory)); - new Sfactory(this, "StateBody_1", new SCreator(StateBody_1_factory)); - new Sfactory(this, "StatementList_2", new SCreator(StatementList_2_factory)); - new Sfactory(this, "SimpleAssignment_9", new SCreator(SimpleAssignment_9_factory)); - new Sfactory(this, "BinaryExpression_15", new SCreator(BinaryExpression_15_factory)); - new Sfactory(this, "BinaryExpression_16", new SCreator(BinaryExpression_16_factory)); - new Sfactory(this, "BinaryExpression_17", new SCreator(BinaryExpression_17_factory)); - new Sfactory(this, "BinaryExpression_18", new SCreator(BinaryExpression_18_factory)); - new Sfactory(this, "Event_25", new SCreator(Event_25_factory)); - new Sfactory(this, "Event_9", new SCreator(Event_9_factory)); - new Sfactory(this, "Statement", new SCreator(Statement_factory)); - new Sfactory(this, "JumpStatement", new SCreator(JumpStatement_factory)); - new Sfactory(this, "BinaryExpression_11", new SCreator(BinaryExpression_11_factory)); - new Sfactory(this, "BinaryExpression_12", new SCreator(BinaryExpression_12_factory)); - new Sfactory(this, "BinaryExpression_13", new SCreator(BinaryExpression_13_factory)); - new Sfactory(this, "BinaryExpression_14", new SCreator(BinaryExpression_14_factory)); - new Sfactory(this, "BinaryExpression_6", new SCreator(BinaryExpression_6_factory)); - new Sfactory(this, "BinaryExpression_7", new SCreator(BinaryExpression_7_factory)); - new Sfactory(this, "ArgumentList", new SCreator(ArgumentList_factory)); - new Sfactory(this, "Event_10", new SCreator(Event_10_factory)); - new Sfactory(this, "ConstantExpression_1", new SCreator(ConstantExpression_1_factory)); - new Sfactory(this, "Event_12", new SCreator(Event_12_factory)); - new Sfactory(this, "Event_14", new SCreator(Event_14_factory)); - new Sfactory(this, "Event_17", new SCreator(Event_17_factory)); - new Sfactory(this, "Event_18", new SCreator(Event_18_factory)); - new Sfactory(this, "Event_19", new SCreator(Event_19_factory)); - new Sfactory(this, "BinaryExpression_10", new SCreator(BinaryExpression_10_factory)); - new Sfactory(this, "StateEvent_1", new SCreator(StateEvent_1_factory)); - new Sfactory(this, "VectorConstant", new SCreator(VectorConstant_factory)); - new Sfactory(this, "EmptyStatement_1", new SCreator(EmptyStatement_1_factory)); - new Sfactory(this, "TypecastExpression_4", new SCreator(TypecastExpression_4_factory)); - new Sfactory(this, "TypecastExpression_6", new SCreator(TypecastExpression_6_factory)); - new Sfactory(this, "TypecastExpression_7", new SCreator(TypecastExpression_7_factory)); - new Sfactory(this, "FunctionCall", new SCreator(FunctionCall_factory)); - new Sfactory(this, "Event_27", new SCreator(Event_27_factory)); - new Sfactory(this, "Event_28", new SCreator(Event_28_factory)); - new Sfactory(this, "Event_29", new SCreator(Event_29_factory)); - new Sfactory(this, "ListConstant_1", new SCreator(ListConstant_1_factory)); - new Sfactory(this, "Event_6", new SCreator(Event_6_factory)); - new Sfactory(this, "Declaration_1", new SCreator(Declaration_1_factory)); - new Sfactory(this, "SimpleAssignment_7", new SCreator(SimpleAssignment_7_factory)); - new Sfactory(this, "ForLoop", new SCreator(ForLoop_factory)); - new Sfactory(this, "ForLoop_2", new SCreator(ForLoop_2_factory)); - new Sfactory(this, "Event_30", new SCreator(Event_30_factory)); - new Sfactory(this, "Event_31", new SCreator(Event_31_factory)); - new Sfactory(this, "Event_33", new SCreator(Event_33_factory)); - new Sfactory(this, "GlobalFunctionDefinition_1", new SCreator(GlobalFunctionDefinition_1_factory)); - new Sfactory(this, "JumpLabel_1", new SCreator(JumpLabel_1_factory)); - new Sfactory(this, "IfStatement", new SCreator(IfStatement_factory)); - new Sfactory(this, "ForLoopStatement_1", new SCreator(ForLoopStatement_1_factory)); - new Sfactory(this, "ForLoopStatement_2", new SCreator(ForLoopStatement_2_factory)); - new Sfactory(this, "ForLoopStatement_3", new SCreator(ForLoopStatement_3_factory)); - new Sfactory(this, "ArgumentDeclarationList_4", new SCreator(ArgumentDeclarationList_4_factory)); - new Sfactory(this, "ArgumentDeclarationList_5", new SCreator(ArgumentDeclarationList_5_factory)); - new Sfactory(this, "EmptyStatement", new SCreator(EmptyStatement_factory)); - new Sfactory(this, "WhileStatement", new SCreator(WhileStatement_factory)); - new Sfactory(this, "ForLoop_1", new SCreator(ForLoop_1_factory)); - new Sfactory(this, "Constant_2", new SCreator(Constant_2_factory)); - new Sfactory(this, "StatementList", new SCreator(StatementList_factory)); - new Sfactory(this, "StateBody_2", new SCreator(StateBody_2_factory)); - new Sfactory(this, "WhileStatement_2", new SCreator(WhileStatement_2_factory)); - new Sfactory(this, "IdentExpression_1", new SCreator(IdentExpression_1_factory)); - new Sfactory(this, "States", new SCreator(States_factory)); + new Sfactory(this, "ExpressionArgument_1", ExpressionArgument_1_factory); + new Sfactory(this, "SimpleAssignment_8", SimpleAssignment_8_factory); + new Sfactory(this, "StatementList_1", StatementList_1_factory); + new Sfactory(this, "StateChange_1", StateChange_1_factory); + new Sfactory(this, "StateChange_2", StateChange_2_factory); + new Sfactory(this, "Declaration", Declaration_factory); + new Sfactory(this, "IdentExpression", IdentExpression_factory); + new Sfactory(this, "error", error_factory); + new Sfactory(this, "BinaryExpression_2", BinaryExpression_2_factory); + new Sfactory(this, "BinaryExpression_3", BinaryExpression_3_factory); + new Sfactory(this, "BinaryExpression_4", BinaryExpression_4_factory); + new Sfactory(this, "BinaryExpression_5", BinaryExpression_5_factory); + new Sfactory(this, "ReturnStatement_2", ReturnStatement_2_factory); + new Sfactory(this, "SimpleAssignment_19", SimpleAssignment_19_factory); + new Sfactory(this, "BinaryExpression_9", BinaryExpression_9_factory); + new Sfactory(this, "VectorConstant_1", VectorConstant_1_factory); + new Sfactory(this, "ParenthesisExpression", ParenthesisExpression_factory); + new Sfactory(this, "UnaryExpression", UnaryExpression_factory); + new Sfactory(this, "IdentDotExpression_1", IdentDotExpression_1_factory); + new Sfactory(this, "ArgumentList_4", ArgumentList_4_factory); + new Sfactory(this, "Typename", Typename_factory); + new Sfactory(this, "IfStatement_1", IfStatement_1_factory); + new Sfactory(this, "Assignment", Assignment_factory); + new Sfactory(this, "CompoundStatement_1", CompoundStatement_1_factory); + new Sfactory(this, "CompoundStatement_2", CompoundStatement_2_factory); + new Sfactory(this, "BinaryExpression_8", BinaryExpression_8_factory); + new Sfactory(this, "ReturnStatement_1", ReturnStatement_1_factory); + new Sfactory(this, "IdentDotExpression", IdentDotExpression_factory); + new Sfactory(this, "Argument", Argument_factory); + new Sfactory(this, "State_2", State_2_factory); + new Sfactory(this, "WhileStatement_1", WhileStatement_1_factory); + new Sfactory(this, "GlobalDefinitions_3", GlobalDefinitions_3_factory); + new Sfactory(this, "GlobalDefinitions_4", GlobalDefinitions_4_factory); + new Sfactory(this, "Event_1", Event_1_factory); + new Sfactory(this, "ListConstant", ListConstant_factory); + new Sfactory(this, "Event_3", Event_3_factory); + new Sfactory(this, "Event_4", Event_4_factory); + new Sfactory(this, "Event_5", Event_5_factory); + new Sfactory(this, "SimpleAssignment_5", SimpleAssignment_5_factory); + new Sfactory(this, "Typename_1", Typename_1_factory); + new Sfactory(this, "Typename_2", Typename_2_factory); + new Sfactory(this, "Typename_3", Typename_3_factory); + new Sfactory(this, "Typename_4", Typename_4_factory); + new Sfactory(this, "Typename_5", Typename_5_factory); + new Sfactory(this, "Typename_6", Typename_6_factory); + new Sfactory(this, "Typename_7", Typename_7_factory); + new Sfactory(this, "ArgumentDeclarationList", ArgumentDeclarationList_factory); + new Sfactory(this, "ConstantExpression", ConstantExpression_factory); + new Sfactory(this, "LSLProgramRoot_1", LSLProgramRoot_1_factory); + new Sfactory(this, "LSLProgramRoot_2", LSLProgramRoot_2_factory); + new Sfactory(this, "States_1", States_1_factory); + new Sfactory(this, "States_2", States_2_factory); + new Sfactory(this, "FunctionCallExpression_1", FunctionCallExpression_1_factory); + new Sfactory(this, "ForLoopStatement", ForLoopStatement_factory); + new Sfactory(this, "DoWhileStatement_1", DoWhileStatement_1_factory); + new Sfactory(this, "DoWhileStatement_2", DoWhileStatement_2_factory); + new Sfactory(this, "ForLoopStatement_4", ForLoopStatement_4_factory); + new Sfactory(this, "SimpleAssignment_11", SimpleAssignment_11_factory); + new Sfactory(this, "SimpleAssignment_12", SimpleAssignment_12_factory); + new Sfactory(this, "SimpleAssignment_13", SimpleAssignment_13_factory); + new Sfactory(this, "JumpLabel", JumpLabel_factory); + new Sfactory(this, "SimpleAssignment_15", SimpleAssignment_15_factory); + new Sfactory(this, "SimpleAssignment_17", SimpleAssignment_17_factory); + new Sfactory(this, "SimpleAssignment_18", SimpleAssignment_18_factory); + new Sfactory(this, "JumpStatement_1", JumpStatement_1_factory); + new Sfactory(this, "GlobalDefinitions", GlobalDefinitions_factory); + new Sfactory(this, "FunctionCall_1", FunctionCall_1_factory); + new Sfactory(this, "ArgumentList_3", ArgumentList_3_factory); + new Sfactory(this, "Assignment_2", Assignment_2_factory); + new Sfactory(this, "TypecastExpression_1", TypecastExpression_1_factory); + new Sfactory(this, "SimpleAssignment_21", SimpleAssignment_21_factory); + new Sfactory(this, "SimpleAssignment_22", SimpleAssignment_22_factory); + new Sfactory(this, "SimpleAssignment_23", SimpleAssignment_23_factory); + new Sfactory(this, "TypecastExpression_9", TypecastExpression_9_factory); + new Sfactory(this, "ArgumentDeclarationList_1", ArgumentDeclarationList_1_factory); + new Sfactory(this, "ArgumentDeclarationList_2", ArgumentDeclarationList_2_factory); + new Sfactory(this, "ArgumentDeclarationList_3", ArgumentDeclarationList_3_factory); + new Sfactory(this, "GlobalDefinitions_1", GlobalDefinitions_1_factory); + new Sfactory(this, "GlobalDefinitions_2", GlobalDefinitions_2_factory); + new Sfactory(this, "IncrementDecrementExpression", IncrementDecrementExpression_factory); + new Sfactory(this, "GlobalVariableDeclaration", GlobalVariableDeclaration_factory); + new Sfactory(this, "Event_11", Event_11_factory); + new Sfactory(this, "TypecastExpression_2", TypecastExpression_2_factory); + new Sfactory(this, "TypecastExpression_3", TypecastExpression_3_factory); + new Sfactory(this, "TypecastExpression_5", TypecastExpression_5_factory); + new Sfactory(this, "TypecastExpression_8", TypecastExpression_8_factory); + new Sfactory(this, "Constant_1", Constant_1_factory); + new Sfactory(this, "Expression", Expression_factory); + new Sfactory(this, "Constant_3", Constant_3_factory); + new Sfactory(this, "Constant_4", Constant_4_factory); + new Sfactory(this, "BinaryExpression_1", BinaryExpression_1_factory); + new Sfactory(this, "IfStatement_2", IfStatement_2_factory); + new Sfactory(this, "IfStatement_3", IfStatement_3_factory); + new Sfactory(this, "IfStatement_4", IfStatement_4_factory); + new Sfactory(this, "ReturnStatement", ReturnStatement_factory); + new Sfactory(this, "Event_2", Event_2_factory); + new Sfactory(this, "RotationConstant", RotationConstant_factory); + new Sfactory(this, "Statement_12", Statement_12_factory); + new Sfactory(this, "UnaryExpression_1", UnaryExpression_1_factory); + new Sfactory(this, "UnaryExpression_2", UnaryExpression_2_factory); + new Sfactory(this, "UnaryExpression_3", UnaryExpression_3_factory); + new Sfactory(this, "ArgumentList_1", ArgumentList_1_factory); + new Sfactory(this, "ArgumentList_2", ArgumentList_2_factory); + new Sfactory(this, "Constant", Constant_factory); + new Sfactory(this, "State", State_factory); + new Sfactory(this, "Event_13", Event_13_factory); + new Sfactory(this, "LSLProgramRoot", LSLProgramRoot_factory); + new Sfactory(this, "StateChange", StateChange_factory); + new Sfactory(this, "IncrementDecrementExpression_2", IncrementDecrementExpression_2_factory); + new Sfactory(this, "GlobalVariableDeclaration_1", GlobalVariableDeclaration_1_factory); + new Sfactory(this, "GlobalVariableDeclaration_2", GlobalVariableDeclaration_2_factory); + new Sfactory(this, "IncrementDecrementExpression_5", IncrementDecrementExpression_5_factory); + new Sfactory(this, "GlobalFunctionDefinition_2", GlobalFunctionDefinition_2_factory); + new Sfactory(this, "IncrementDecrementExpression_7", IncrementDecrementExpression_7_factory); + new Sfactory(this, "IncrementDecrementExpression_8", IncrementDecrementExpression_8_factory); + new Sfactory(this, "Assignment_1", Assignment_1_factory); + new Sfactory(this, "Event_21", Event_21_factory); + new Sfactory(this, "Event_22", Event_22_factory); + new Sfactory(this, "CompoundStatement", CompoundStatement_factory); + new Sfactory(this, "RotationConstant_1", RotationConstant_1_factory); + new Sfactory(this, "TypecastExpression", TypecastExpression_factory); + new Sfactory(this, "SimpleAssignment_3", SimpleAssignment_3_factory); + new Sfactory(this, "SimpleAssignment_4", SimpleAssignment_4_factory); + new Sfactory(this, "Statement_1", Statement_1_factory); + new Sfactory(this, "Statement_2", Statement_2_factory); + new Sfactory(this, "Statement_3", Statement_3_factory); + new Sfactory(this, "Statement_4", Statement_4_factory); + new Sfactory(this, "Statement_5", Statement_5_factory); + new Sfactory(this, "Statement_6", Statement_6_factory); + new Sfactory(this, "Statement_7", Statement_7_factory); + new Sfactory(this, "Statement_8", Statement_8_factory); + new Sfactory(this, "Statement_9", Statement_9_factory); + new Sfactory(this, "ExpressionArgument", ExpressionArgument_factory); + new Sfactory(this, "GlobalFunctionDefinition", GlobalFunctionDefinition_factory); + new Sfactory(this, "State_1", State_1_factory); + new Sfactory(this, "DoWhileStatement", DoWhileStatement_factory); + new Sfactory(this, "ParenthesisExpression_1", ParenthesisExpression_1_factory); + new Sfactory(this, "ParenthesisExpression_2", ParenthesisExpression_2_factory); + new Sfactory(this, "StateBody", StateBody_factory); + new Sfactory(this, "Event_7", Event_7_factory); + new Sfactory(this, "Event_8", Event_8_factory); + new Sfactory(this, "IncrementDecrementExpression_1", IncrementDecrementExpression_1_factory); + new Sfactory(this, "IncrementDecrementExpression_3", IncrementDecrementExpression_3_factory); + new Sfactory(this, "IncrementDecrementExpression_4", IncrementDecrementExpression_4_factory); + new Sfactory(this, "IncrementDecrementExpression_6", IncrementDecrementExpression_6_factory); + new Sfactory(this, "StateEvent", StateEvent_factory); + new Sfactory(this, "Event_20", Event_20_factory); + new Sfactory(this, "Event_23", Event_23_factory); + new Sfactory(this, "Event_24", Event_24_factory); + new Sfactory(this, "Event_26", Event_26_factory); + new Sfactory(this, "SimpleAssignment_10", SimpleAssignment_10_factory); + new Sfactory(this, "Event", Event_factory); + new Sfactory(this, "SimpleAssignment_14", SimpleAssignment_14_factory); + new Sfactory(this, "SimpleAssignment_16", SimpleAssignment_16_factory); + new Sfactory(this, "Statement_10", Statement_10_factory); + new Sfactory(this, "Statement_11", Statement_11_factory); + new Sfactory(this, "SimpleAssignment", SimpleAssignment_factory); + new Sfactory(this, "Statement_13", Statement_13_factory); + new Sfactory(this, "Event_15", Event_15_factory); + new Sfactory(this, "Event_16", Event_16_factory); + new Sfactory(this, "Event_32", Event_32_factory); + new Sfactory(this, "Event_34", Event_34_factory); + new Sfactory(this, "SimpleAssignment_20", SimpleAssignment_20_factory); + new Sfactory(this, "SimpleAssignment_24", SimpleAssignment_24_factory); + new Sfactory(this, "SimpleAssignment_1", SimpleAssignment_1_factory); + new Sfactory(this, "SimpleAssignment_2", SimpleAssignment_2_factory); + new Sfactory(this, "BinaryExpression", BinaryExpression_factory); + new Sfactory(this, "FunctionCallExpression", FunctionCallExpression_factory); + new Sfactory(this, "SimpleAssignment_6", SimpleAssignment_6_factory); + new Sfactory(this, "StateBody_1", StateBody_1_factory); + new Sfactory(this, "StatementList_2", StatementList_2_factory); + new Sfactory(this, "SimpleAssignment_9", SimpleAssignment_9_factory); + new Sfactory(this, "BinaryExpression_15", BinaryExpression_15_factory); + new Sfactory(this, "BinaryExpression_16", BinaryExpression_16_factory); + new Sfactory(this, "BinaryExpression_17", BinaryExpression_17_factory); + new Sfactory(this, "BinaryExpression_18", BinaryExpression_18_factory); + new Sfactory(this, "Event_25", Event_25_factory); + new Sfactory(this, "Event_9", Event_9_factory); + new Sfactory(this, "Statement", Statement_factory); + new Sfactory(this, "JumpStatement", JumpStatement_factory); + new Sfactory(this, "BinaryExpression_11", BinaryExpression_11_factory); + new Sfactory(this, "BinaryExpression_12", BinaryExpression_12_factory); + new Sfactory(this, "BinaryExpression_13", BinaryExpression_13_factory); + new Sfactory(this, "BinaryExpression_14", BinaryExpression_14_factory); + new Sfactory(this, "BinaryExpression_6", BinaryExpression_6_factory); + new Sfactory(this, "BinaryExpression_7", BinaryExpression_7_factory); + new Sfactory(this, "ArgumentList", ArgumentList_factory); + new Sfactory(this, "Event_10", Event_10_factory); + new Sfactory(this, "ConstantExpression_1", ConstantExpression_1_factory); + new Sfactory(this, "Event_12", Event_12_factory); + new Sfactory(this, "Event_14", Event_14_factory); + new Sfactory(this, "Event_17", Event_17_factory); + new Sfactory(this, "Event_18", Event_18_factory); + new Sfactory(this, "Event_19", Event_19_factory); + new Sfactory(this, "BinaryExpression_10", BinaryExpression_10_factory); + new Sfactory(this, "StateEvent_1", StateEvent_1_factory); + new Sfactory(this, "VectorConstant", VectorConstant_factory); + new Sfactory(this, "EmptyStatement_1", EmptyStatement_1_factory); + new Sfactory(this, "TypecastExpression_4", TypecastExpression_4_factory); + new Sfactory(this, "TypecastExpression_6", TypecastExpression_6_factory); + new Sfactory(this, "TypecastExpression_7", TypecastExpression_7_factory); + new Sfactory(this, "FunctionCall", FunctionCall_factory); + new Sfactory(this, "Event_27", Event_27_factory); + new Sfactory(this, "Event_28", Event_28_factory); + new Sfactory(this, "Event_29", Event_29_factory); + new Sfactory(this, "ListConstant_1", ListConstant_1_factory); + new Sfactory(this, "Event_6", Event_6_factory); + new Sfactory(this, "Declaration_1", Declaration_1_factory); + new Sfactory(this, "SimpleAssignment_7", SimpleAssignment_7_factory); + new Sfactory(this, "ForLoop", ForLoop_factory); + new Sfactory(this, "ForLoop_2", ForLoop_2_factory); + new Sfactory(this, "Event_30", Event_30_factory); + new Sfactory(this, "Event_31", Event_31_factory); + new Sfactory(this, "Event_33", Event_33_factory); + new Sfactory(this, "GlobalFunctionDefinition_1", GlobalFunctionDefinition_1_factory); + new Sfactory(this, "JumpLabel_1", JumpLabel_1_factory); + new Sfactory(this, "IfStatement", IfStatement_factory); + new Sfactory(this, "ForLoopStatement_1", ForLoopStatement_1_factory); + new Sfactory(this, "ForLoopStatement_2", ForLoopStatement_2_factory); + new Sfactory(this, "ForLoopStatement_3", ForLoopStatement_3_factory); + new Sfactory(this, "ArgumentDeclarationList_4", ArgumentDeclarationList_4_factory); + new Sfactory(this, "ArgumentDeclarationList_5", ArgumentDeclarationList_5_factory); + new Sfactory(this, "EmptyStatement", EmptyStatement_factory); + new Sfactory(this, "WhileStatement", WhileStatement_factory); + new Sfactory(this, "ForLoop_1", ForLoop_1_factory); + new Sfactory(this, "Constant_2", Constant_2_factory); + new Sfactory(this, "StatementList", StatementList_factory); + new Sfactory(this, "StateBody_2", StateBody_2_factory); + new Sfactory(this, "WhileStatement_2", WhileStatement_2_factory); + new Sfactory(this, "IdentExpression_1", IdentExpression_1_factory); + new Sfactory(this, "States", States_factory); } public static object ExpressionArgument_1_factory(Parser yyp) { return new ExpressionArgument_1(yyp); } public static object SimpleAssignment_8_factory(Parser yyp) { return new SimpleAssignment_8(yyp); } @@ -12010,7 +11871,7 @@ public yyLSLSyntax public static object StateChange_2_factory(Parser yyp) { return new StateChange_2(yyp); } public static object Declaration_factory(Parser yyp) { return new Declaration(yyp); } public static object IdentExpression_factory(Parser yyp) { return new IdentExpression(yyp); } - public static object error_factory(Parser yyp) { return new error(yyp); } + public static object error_factory(Parser yyp) { return new Error(yyp); } public static object BinaryExpression_2_factory(Parser yyp) { return new BinaryExpression_2(yyp); } public static object BinaryExpression_3_factory(Parser yyp) { return new BinaryExpression_3(yyp); } public static object BinaryExpression_4_factory(Parser yyp) { return new BinaryExpression_4(yyp); } diff --git a/Radegast/Core/LSLKeywordParser.cs b/Radegast/Core/LSLKeywordParser.cs index 6232192de..8d3e29ef3 100644 --- a/Radegast/Core/LSLKeywordParser.cs +++ b/Radegast/Core/LSLKeywordParser.cs @@ -1,33 +1,23 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections.Generic; using System.Drawing; @@ -108,16 +98,17 @@ public static Dictionary Parse() if ((m = keyWordRegex.Match(l)).Success) { - LSLKeyWord kw = new LSLKeyWord(); - kw.KeyWord = m.Groups[1].Value; - kw.ToolTip = m.Groups[3].Value.Replace(@"\n", "\n"); - kw.Color = currentColor; + LSLKeyWord kw = new LSLKeyWord + { + KeyWord = m.Groups[1].Value, + ToolTip = m.Groups[3].Value.Replace(@"\n", "\n"), + Color = currentColor + }; if (valid) { ret.Add(kw.KeyWord, kw); } - continue; } } return ret; diff --git a/Radegast/Core/Media/BufferSound.cs b/Radegast/Core/Media/BufferSound.cs index ca4579bb1..0b0e1571c 100644 --- a/Radegast/Core/Media/BufferSound.cs +++ b/Radegast/Core/Media/BufferSound.cs @@ -1,33 +1,23 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id: Sound.cs 502 2010-03-14 23:13:46Z latifer $ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + // Uncomment this to get lots more logging //#define TRACE_SOUND using System; @@ -45,10 +35,10 @@ public class BufferSound : MediaObject { private UUID Id; private UUID ContainerId; - private Boolean prefetchOnly = false; - private FMOD.MODE mode; - public Sound Sound { get { return sound; } } - private Boolean loopSound = false; + private bool prefetchOnly = false; + private MODE mode; + public Sound Sound => sound; + private bool loopSound = false; /// /// The individual volume setting for THIS object /// @@ -57,15 +47,12 @@ public class BufferSound : MediaObject /// /// Creates a new sound object /// - /// Sound system public BufferSound(UUID objectId, UUID soundId, bool loop, bool global, Vector3 worldpos, float vol) - : base() { InitBuffer(objectId, soundId, loop, global, worldpos, vol); } public BufferSound(UUID objectId, UUID soundId, bool loop, bool global, Vector3d worldpos, float vol) - : base() { InitBuffer(objectId, soundId, loop, global, new Vector3(worldpos), vol); } @@ -84,35 +71,29 @@ private void InitBuffer(UUID objectId, UUID soundId, bool loop, bool global, Vec volumeSetting = vol; loopSound = loop; - Logger.Log( - String.Format( - "Playing sound at <{0:0.0},{1:0.0},{2:0.0}> ID {3}", - position.x, - position.y, - position.z, - Id.ToString()), + Logger.Log($"Playing sound at <{position.x:0.0},{position.y:0.0},{position.z:0.0}> ID {Id}", Helpers.LogLevel.Debug); // Set flags to determine how it will be played. - mode = FMOD.MODE.SOFTWARE | // Need software processing for all the features - FMOD.MODE._3D | // Need 3D effects for placement - FMOD.MODE.OPENMEMORY; // Use sound data in memory + mode = MODE.DEFAULT | + MODE._3D | // Need 3D effects for placement + MODE.OPENMEMORY; // Use sound data in memory // Set coordinate space interpretation. if (global) - mode |= FMOD.MODE._3D_WORLDRELATIVE; + mode |= MODE._3D_WORLDRELATIVE; else - mode |= FMOD.MODE._3D_HEADRELATIVE; + mode |= MODE._3D_HEADRELATIVE; if (loopSound) - mode |= FMOD.MODE.LOOP_NORMAL; + mode |= MODE.LOOP_NORMAL; // Fetch the sound data. manager.Instance.Client.Assets.RequestAsset( Id, AssetType.Sound, false, - new AssetManager.AssetReceivedCallback(Assets_OnSoundReceived)); + Assets_OnSoundReceived); } public static void Kill(UUID id) @@ -131,18 +112,17 @@ public static void KillAll() { // Make a list from the dictionary so we do not get a deadlock // on it when removing entries. - List list = new List(allBuffers.Values); + var list = new List(allBuffers.Values); - foreach (BufferSound s in list) + foreach (var s in list) { s.StopSound(); } - List objs = new List(allChannels.Values); - foreach (MediaObject obj in objs) + var objs = new List(allChannels.Values); + foreach (var obj in objs) { - if (obj is BufferSound) - ((BufferSound)obj).StopSound(); + (obj as BufferSound)?.StopSound(); } } @@ -152,9 +132,9 @@ public static void KillAll() public static void AdjustVolumes() { // Make a list from the dictionary so we do not get a deadlock - List list = new List(allBuffers.Values); + var list = new List(allBuffers.Values); - foreach (BufferSound s in list) + foreach (var s in list) { s.AdjustVolume(); } @@ -170,7 +150,6 @@ private void AdjustVolume() // A simpler constructor used by PreFetchSound. public BufferSound(UUID soundId) - : base() { prefetchOnly = true; ContainerId = UUID.Zero; @@ -180,15 +159,7 @@ public BufferSound(UUID soundId) Id, AssetType.Sound, false, - new AssetManager.AssetReceivedCallback(Assets_OnSoundReceived)); - } - - /// - /// Releases resources of this sound object - /// - public override void Dispose() - { - base.Dispose(); + Assets_OnSoundReceived); } /** @@ -207,15 +178,16 @@ void Assets_OnSoundReceived(AssetDownload transfer, Asset asset) // Logger.Log("Opening sound " + Id.ToString(), Helpers.LogLevel.Debug); // Decode the Ogg Vorbis buffer. - AssetSound s = asset as AssetSound; + if (!(asset is AssetSound s)) return; + s.Decode(); - byte[] data = s.AssetData; + var data = s.AssetData; // Describe the data to FMOD extraInfo.length = (uint)data.Length; extraInfo.cbsize = Marshal.SizeOf(extraInfo); - invoke(new SoundDelegate(delegate + invoke(delegate { try { @@ -224,7 +196,7 @@ void Assets_OnSoundReceived(AssetDownload transfer, Asset asset) data, mode, ref extraInfo, - ref sound)); + out sound)); // Register for callbacks. RegisterSound(sound); @@ -234,13 +206,15 @@ void Assets_OnSoundReceived(AssetDownload transfer, Asset asset) if (loopSound) { uint soundlen = 0; - FMODExec(sound.getLength(ref soundlen, TIMEUNIT.PCM)); + FMODExec(sound.getLength(out soundlen, TIMEUNIT.PCM)); FMODExec(sound.setLoopPoints(0, TIMEUNIT.PCM, soundlen - 1, TIMEUNIT.PCM)); FMODExec(sound.setLoopCount(-1)); } // Allocate a channel and set initial volume. Initially paused. - FMODExec(system.playSound(CHANNELINDEX.FREE, sound, true, ref channel)); + ChannelGroup masterChannelGroup; + system.getMasterChannelGroup(out masterChannelGroup); + FMODExec(system.playSound(sound, masterChannelGroup, true, out channel)); #if TRACE_SOUND Logger.Log( String.Format("Channel {0} for {1} assigned to {2}", @@ -258,8 +232,8 @@ void Assets_OnSoundReceived(AssetDownload transfer, Asset asset) // Set attenuation limits. FMODExec(sound.set3DMinMaxDistance( - 1.2f, // Any closer than this gets no louder - 100.0f)); // Further than this gets no softer. + 1.2f, // Any closer than this gets no louder + 100.0f)); // Further than this gets no softer. // Set the sound point of origin. This is in SIM coordinates. FMODExec(channel.set3DAttributes(ref position, ref ZeroVector)); @@ -271,11 +245,11 @@ void Assets_OnSoundReceived(AssetDownload transfer, Asset asset) { Logger.Log("Error playing sound: ", Helpers.LogLevel.Error, ex); } - })); + }); } else { - Logger.Log("Failed to download sound: " + transfer.Status.ToString(), + Logger.Log("Failed to download sound: " + transfer.Status, Helpers.LogLevel.Error); } } @@ -303,26 +277,26 @@ protected void StopSound(bool blocking) finished = true; - invoke(new SoundDelegate(delegate + invoke(delegate { string chanStr = "none"; string soundStr = "none"; // Release the buffer to avoid a big memory leak. - if (channel != null) + if (channel.hasHandle()) { lock (allChannels) - allChannels.Remove(channel.getRaw()); - chanStr = channel.getRaw().ToString("X"); + allChannels.Remove(channel.handle); + chanStr = channel.handle.ToString("X"); channel.stop(); - channel = null; + channel.clearHandle(); } - if (sound != null) + if (sound.hasHandle()) { - soundStr = sound.getRaw().ToString("X"); + soundStr = sound.handle.ToString("X"); sound.release(); - sound = null; + sound.clearHandle(); } #if TRACE_SOUND Logger.Log(String.Format("Removing channel {0} sound {1} ID {2}", @@ -335,8 +309,8 @@ protected void StopSound(bool blocking) allBuffers.Remove(ContainerId); if (blocking) - stopped.Set(); - })); + stopped?.Set(); + }); if (blocking) stopped.WaitOne(); diff --git a/Radegast/Core/Media/MediaManager.cs b/Radegast/Core/Media/MediaManager.cs index d78996d35..c67aa9375 100644 --- a/Radegast/Core/Media/MediaManager.cs +++ b/Radegast/Core/Media/MediaManager.cs @@ -1,91 +1,69 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections.Generic; -using System.Text; using FMOD; using System.Threading; using OpenMetaverse; -using OpenMetaverse.Assets; -#if (COGBOT_LIBOMV || USE_STHREADS) -using ThreadPoolUtil; -using Thread = ThreadPoolUtil.Thread; -using ThreadPool = ThreadPoolUtil.ThreadPool; -using Monitor = ThreadPoolUtil.Monitor; -#endif +using System.Threading.Tasks; namespace Radegast.Media { public class MediaManager : MediaObject { /// - /// Indicated wheather spund sytem is ready for use + /// Indicated wheather sound sytem is ready for use /// - public bool SoundSystemAvailable { get { return soundSystemAvailable; } } - private bool soundSystemAvailable = false; - private Thread soundThread; - private Thread listenerThread; + public bool SoundSystemAvailable { get; private set; } = false; public RadegastInstance Instance; + private CancellationTokenSource soundCancelToken; + private List sounds = new List(); ManualResetEvent initDone = new ManualResetEvent(false); public MediaManager(RadegastInstance instance) - : base() { - this.Instance = instance; + Instance = instance; manager = this; - if (MainProgram.CommandLine.DisableSound) + if (MainProgram.s_CommandLineOpts.DisableSound) { - soundSystemAvailable = false; + SoundSystemAvailable = false; return; } - endCallback = new FMOD.CHANNEL_CALLBACK(DispatchEndCallback); + endCallback = DispatchEndCallback; allBuffers = new Dictionary(); - // Start the background thread that does all the FMOD calls. - soundThread = new Thread(new ThreadStart(CommandLoop)); - soundThread.IsBackground = true; - soundThread.Name = "SoundThread"; - soundThread.Start(); + soundCancelToken = new CancellationTokenSource(); + // Start the background thread that does the audio calls. + Task soundTask = Task.Factory.StartNew(CommandLoop, + soundCancelToken.Token, TaskCreationOptions.LongRunning, TaskScheduler.Default); // Start the background thread that updates listerner position. - listenerThread = new Thread(new ThreadStart(ListenerUpdate)); - listenerThread.IsBackground = true; - listenerThread.Name = "ListenerThread"; - listenerThread.Start(); + Task listenerTask = Task.Factory.StartNew(ListenerUpdate, + soundCancelToken.Token, TaskCreationOptions.LongRunning, TaskScheduler.Default); - Instance.ClientChanged += new EventHandler(Instance_ClientChanged); + Instance.ClientChanged += Instance_ClientChanged; // Wait for init to complete initDone.WaitOne(); @@ -101,24 +79,24 @@ void Instance_ClientChanged(object sender, ClientChangedEventArgs e) void RegisterClientEvents(GridClient client) { - client.Sound.SoundTrigger += new EventHandler(Sound_SoundTrigger); - client.Sound.AttachedSound += new EventHandler(Sound_AttachedSound); - client.Sound.PreloadSound += new EventHandler(Sound_PreloadSound); - client.Objects.ObjectUpdate += new EventHandler(Objects_ObjectUpdate); - client.Objects.KillObject += new EventHandler(Objects_KillObject); - client.Network.SimChanged += new EventHandler(Network_SimChanged); - client.Self.ChatFromSimulator += new EventHandler(Self_ChatFromSimulator); + client.Sound.SoundTrigger += Sound_SoundTrigger; + client.Sound.AttachedSound += Sound_AttachedSound; + client.Sound.PreloadSound += Sound_PreloadSound; + client.Objects.ObjectUpdate += Objects_ObjectUpdate; + client.Objects.KillObject += Objects_KillObject; + client.Network.SimChanged += Network_SimChanged; + client.Self.ChatFromSimulator += Self_ChatFromSimulator; } void UnregisterClientEvents(GridClient client) { - client.Sound.SoundTrigger -= new EventHandler(Sound_SoundTrigger); - client.Sound.AttachedSound -= new EventHandler(Sound_AttachedSound); - client.Sound.PreloadSound -= new EventHandler(Sound_PreloadSound); - client.Objects.ObjectUpdate -= new EventHandler(Objects_ObjectUpdate); - client.Objects.KillObject -= new EventHandler(Objects_KillObject); - client.Network.SimChanged -= new EventHandler(Network_SimChanged); - client.Self.ChatFromSimulator -= new EventHandler(Self_ChatFromSimulator); + client.Sound.SoundTrigger -= Sound_SoundTrigger; + client.Sound.AttachedSound -= Sound_AttachedSound; + client.Sound.PreloadSound -= Sound_PreloadSound; + client.Objects.ObjectUpdate -= Objects_ObjectUpdate; + client.Objects.KillObject -= Objects_KillObject; + client.Network.SimChanged -= Network_SimChanged; + client.Self.ChatFromSimulator -= Self_ChatFromSimulator; } /// @@ -126,8 +104,6 @@ void UnregisterClientEvents(GridClient client) /// private void CommandLoop() { - SoundDelegate action = null; - // Initialze a bunch of static values UpVector.x = 0.0f; UpVector.y = 1.0f; @@ -145,10 +121,16 @@ private void CommandLoop() // Initialize the FMOD sound package InitFMOD(); initDone.Set(); - if (!this.soundSystemAvailable) return; + if (!SoundSystemAvailable) return; + + SoundDelegate action = null; while (true) { + if (soundCancelToken.IsCancellationRequested) + { + break; + } // Wait for something to show up in the queue. lock (queue) { @@ -159,6 +141,10 @@ private void CommandLoop() action = queue.Dequeue(); } + if (soundCancelToken.IsCancellationRequested) + { + break; + } // We have an action, so call it. try { @@ -180,25 +166,21 @@ private void InitFMOD() { try { - FMODExec(FMOD.Factory.System_Create(ref system)); + FMODExec(Factory.System_Create(out system)); uint version = 0; - FMODExec(system.getVersion(ref version)); + FMODExec(system.getVersion(out version)); - if (version < FMOD.VERSION.number) + if (version < VERSION.number) throw new MediaException("You are using an old version of FMOD " + version.ToString("X") + ". This program requires " + - FMOD.VERSION.number.ToString("X") + "."); - - // Assume no special hardware capabilities except 5.1 surround sound. - FMOD.CAPS caps = FMOD.CAPS.NONE; - FMOD.SPEAKERMODE speakermode = FMOD.SPEAKERMODE._5POINT1; + VERSION.number.ToString("X") + "."); // Try to detect soud system used - if (System.Environment.OSVersion.Platform == PlatformID.Unix || System.Environment.OSVersion.Platform == PlatformID.MacOSX) + if (Environment.OSVersion.Platform == PlatformID.Unix || Environment.OSVersion.Platform == PlatformID.MacOSX) { bool audioOK = false; - var res = system.setOutput(FMOD.OUTPUTTYPE.COREAUDIO); + var res = system.setOutput(OUTPUTTYPE.COREAUDIO); if (res == RESULT.OK) { audioOK = true; @@ -206,7 +188,7 @@ private void InitFMOD() if (!audioOK) { - res = system.setOutput(FMOD.OUTPUTTYPE.PULSEAUDIO); + res = system.setOutput(OUTPUTTYPE.PULSEAUDIO); if (res == RESULT.OK) { audioOK = true; @@ -215,7 +197,7 @@ private void InitFMOD() if (!audioOK) { - res = system.setOutput(FMOD.OUTPUTTYPE.ALSA); + res = system.setOutput(OUTPUTTYPE.ALSA); if (res == RESULT.OK) { audioOK = true; @@ -224,16 +206,7 @@ private void InitFMOD() if (!audioOK) { - res = system.setOutput(FMOD.OUTPUTTYPE.OSS); - if (res == RESULT.OK) - { - audioOK = true; - } - } - - if (!audioOK) - { - res = system.setOutput(FMOD.OUTPUTTYPE.AUTODETECT); + res = system.setOutput(OUTPUTTYPE.AUTODETECT); if (res == RESULT.OK) { audioOK = true; @@ -242,22 +215,11 @@ private void InitFMOD() } - FMOD.OUTPUTTYPE outputType = OUTPUTTYPE.UNKNOWN; - FMODExec(system.getOutput(ref outputType)); - - // Fancy param checking on Linux can cause init to fail - try - { - // Get the capabilities of the driver. - int outputRate = 0; - FMODExec(system.getDriverCaps(0, ref caps, - ref outputRate, - ref speakermode)); - // Set FMOD speaker mode to what the driver supports. - FMODExec(system.setSpeakerMode(speakermode)); - } - catch {} + OUTPUTTYPE outputType = OUTPUTTYPE.UNKNOWN; + FMODExec(system.getOutput(out outputType)); +// *TODO: Investigate if this all is still needed under FMODStudio +#if false // The user has the 'Acceleration' slider set to off, which // is really bad for latency. At 48khz, the latency between // issuing an fmod command and hearing it will now be about 213ms. @@ -268,10 +230,10 @@ private void InitFMOD() try { - StringBuilder name = new StringBuilder(128); + StringBuilder name = new StringBuilder(128); // Get driver information so we can check for a wierd one. - FMOD.GUID guid = new FMOD.GUID(); - FMODExec(system.getDriverInfo(0, name, 128, ref guid)); + Guid guid = new Guid(); + FMODExec(system.getDriverInfo(0, name, 128, out guid)); // Sigmatel sound devices crackle for some reason if the format is pcm 16bit. // pcm floating point output seems to solve it. @@ -286,22 +248,12 @@ private void InitFMOD() } } catch {} - +#endif + // FMODExec(system.setDSPBufferSize(1024, 10)); + // Try to initialize with all those settings, and Max 32 channels. - FMOD.RESULT result = system.init(32, FMOD.INITFLAGS.NORMAL, (IntPtr)null); - if (result == FMOD.RESULT.ERR_OUTPUT_CREATEBUFFER) - { - // Can not handle surround sound - back to Stereo. - FMODExec(system.setSpeakerMode(FMOD.SPEAKERMODE.STEREO)); - - // And init again. - FMODExec(system.init( - 32, - FMOD.INITFLAGS.NORMAL, - (IntPtr)null) - ); - } - else if (result != FMOD.RESULT.OK) + RESULT result = system.init(32, INITFLAGS.NORMAL, (IntPtr)null); + if (result != RESULT.OK) { throw(new Exception(result.ToString())); } @@ -313,12 +265,12 @@ private void InitFMOD() 1.0f) // Rolloff factor ); - soundSystemAvailable = true; - Logger.Log("Initialized FMOD Ex: " + outputType.ToString(), Helpers.LogLevel.Debug); + SoundSystemAvailable = true; + Logger.Log("Initialized FMOD interface: " + outputType, Helpers.LogLevel.Info); } catch (Exception ex) { - Logger.Log("Failed to initialize the sound system: " + ex.ToString(), Helpers.LogLevel.Warning); + Logger.Log("Failed to initialize the sound system: " + ex, Helpers.LogLevel.Warning); } } @@ -329,36 +281,25 @@ public override void Dispose() lock (sounds) { - for (int i = 0; i < sounds.Count; i++) + foreach (var s in sounds) { - if (!sounds[i].Disposed) - sounds[i].Dispose(); + if (!s.Disposed) + s.Dispose(); } sounds.Clear(); } sounds = null; - if (system != null) + if (system.hasHandle()) { Logger.Log("FMOD interface stopping", Helpers.LogLevel.Info); system.release(); - system = null; + system.clearHandle(); } - if (listenerThread != null) - { - if (listenerThread.IsAlive) - listenerThread.Abort(); - listenerThread = null; - } - - if (soundThread != null) - { - if (soundThread.IsAlive) - soundThread.Abort(); - soundThread = null; - } + soundCancelToken.Cancel(); + soundCancelToken.Dispose(); base.Dispose(); } @@ -375,12 +316,16 @@ private void ListenerUpdate() while (true) { + if (soundCancelToken.IsCancellationRequested) + { + break; + } // Two updates per second. - Thread.Sleep(500); + System.Threading.Thread.Sleep(500); - if (system == null) continue; + if (!system.hasHandle()) continue; - AgentManager my = Instance.Client.Self; + var my = Instance.Client.Self; Vector3 newPosition = new Vector3(my.SimPosition); float newFace = my.SimRotation.W; @@ -394,10 +339,10 @@ private void ListenerUpdate() if (newPosition.ApproxEquals(lastpos, 0.5f) && Math.Abs(newFace - lastface) < 0.2) { - invoke(new SoundDelegate(delegate + invoke(delegate { FMODExec(system.update()); - })); + }); continue; } @@ -406,7 +351,7 @@ private void ListenerUpdate() lastface = newFace; // Convert coordinate spaces. - FMOD.VECTOR listenerpos = FromOMVSpace(newPosition); + VECTOR listenerpos = FromOMVSpace(newPosition); // Get azimuth from the facing Quaternion. Note we assume the // avatar is standing upright. Avatars in unusual positions @@ -417,10 +362,14 @@ private void ListenerUpdate() // Construct facing unit vector in FMOD coordinates. // Z is East, X is South, Y is up. - FMOD.VECTOR forward = new FMOD.VECTOR(); - forward.x = (float)Math.Sin(angle); // South - forward.y = 0.0f; - forward.z = (float)Math.Cos(angle); // East + VECTOR forward = new VECTOR + { + x = (float) Math.Sin(angle), + y = 0.0f, + z = (float) Math.Cos(angle) + }; + // South + // East //Logger.Log( // String.Format( @@ -432,7 +381,7 @@ private void ListenerUpdate() // Helpers.LogLevel.Debug); // Tell FMOD the new orientation. - invoke(new SoundDelegate(delegate + invoke(delegate { FMODExec(system.set3DListenerAttributes( 0, @@ -442,7 +391,7 @@ private void ListenerUpdate() ref UpVector)); // Top of head FMODExec(system.update()); - })); + }); } } @@ -455,8 +404,7 @@ private void Sound_SoundTrigger(object sender, SoundTriggerEventArgs e) { if (e.SoundID == UUID.Zero) return; - Logger.Log("Trigger sound " + e.SoundID.ToString() + - " in object " + e.ObjectID.ToString(), + Logger.Log("Trigger sound " + e.SoundID +" in object " + e.ObjectID, Helpers.LogLevel.Debug); new BufferSound( @@ -478,7 +426,7 @@ private void Sound_AttachedSound(object sender, AttachedSoundEventArgs e) // This event tells us the Object ID, but not the Prim info directly. // So we look it up in our internal Object memory. Simulator sim = e.Simulator; - Primitive p = sim.ObjectsPrimitives.Find((Primitive p2) => { return p2.ID == e.ObjectID; }); + Primitive p = sim.ObjectsPrimitives.Find(p2 => p2.ID == e.ObjectID); if (p == null) return; // Only one attached sound per prim, so we kill any previous @@ -621,7 +569,7 @@ public float ObjectVolume AllObjectVolume = value; BufferSound.AdjustVolumes(); } - get { return AllObjectVolume; } + get => AllObjectVolume; } /// @@ -654,7 +602,7 @@ public bool ObjectEnable m_objectEnabled = value; } - get { return m_objectEnabled; } + get => m_objectEnabled; } void Self_ChatFromSimulator(object sender, ChatEventArgs e) @@ -687,7 +635,7 @@ void Network_SimChanged(object sender, SimChangedEventArgs e) /// UUID of the sound to play public void PlayUISound(UUID sound) { - if (!soundSystemAvailable) return; + if (!SoundSystemAvailable) return; new BufferSound( UUID.Random(), diff --git a/Radegast/Core/Media/MediaObject.cs b/Radegast/Core/Media/MediaObject.cs index 5836d0822..272c28882 100644 --- a/Radegast/Core/Media/MediaObject.cs +++ b/Radegast/Core/Media/MediaObject.cs @@ -1,36 +1,25 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections.Generic; -using System.Text; using System.Threading; using System.Runtime.InteropServices; using FMOD; @@ -38,14 +27,14 @@ namespace Radegast.Media { - public abstract class MediaObject : Object, IDisposable + public abstract class MediaObject : object, IDisposable { /// /// Indicates if this object's resources have already been disposed /// - public bool Disposed { get { return disposed; } } - private bool disposed = false; - protected Boolean finished = false; + public bool Disposed { get; private set; } = false; + + protected bool finished = false; /// All commands are made through queued delegate calls, so they /// are guaranteed to take place in the same thread. FMOD requires this. @@ -59,48 +48,49 @@ public abstract class MediaObject : Object, IDisposable // A SOUND represents the data (buffer or stream) - public FMOD.Sound FMODSound { get { return sound; } } - protected FMOD.Sound sound = null; + public Sound FMODSound => sound; + protected Sound sound; // A CHANNEL represents a playback instance of a sound. - public Channel FMODChannel { get { return channel; } } - protected Channel channel = null; + public Channel FMODChannel => channel; + protected Channel channel; // Additional info for callbacks goes here. - protected FMOD.CREATESOUNDEXINFO extraInfo; - protected static FMOD.CHANNEL_CALLBACK endCallback; + protected CREATESOUNDEXINFO extraInfo; + protected static CHANNELCONTROL_CALLBACK endCallback; // Vectors used for orienting spatial axes. - protected static FMOD.VECTOR UpVector; - protected static FMOD.VECTOR ZeroVector; + protected static VECTOR UpVector; + protected static VECTOR ZeroVector; /// /// Base FMOD system object, of which there is only one. /// - protected static FMOD.System system = null; - public FMOD.System FMODSystem { get { return system; } } + protected static FMOD.System system; + public FMOD.System FMODSystem => system; protected static float AllObjectVolume = 0.8f; - public MediaObject() + + protected MediaObject() { // Zero out the extra info structure. - extraInfo = new FMOD.CREATESOUNDEXINFO(); + extraInfo = new CREATESOUNDEXINFO(); extraInfo.cbsize = Marshal.SizeOf(extraInfo); } protected bool Cloned = false; public virtual void Dispose() { - if (!Cloned && sound != null) + if (!Cloned && sound.hasHandle()) { sound.release(); - sound = null; + sound.clearHandle(); } - disposed = true; + Disposed = true; } - public bool Active { get { return (sound != null); } } + public bool Active => (sound.hasHandle()); /// /// Put a delegate call on the command queue. These will be executed on @@ -127,16 +117,13 @@ protected void invoke(SoundDelegate action) protected float volume = 0.8f; public float Volume { - get - { - return volume; - } + get => volume; set { volume = value; - if (channel == null) return; + if (!channel.hasHandle()) return; - invoke(new SoundDelegate(delegate + invoke(delegate { try { @@ -145,59 +132,52 @@ public float Volume catch (Exception ex) { Logger.Log( - String.Format("Error on volume change on channel {0} sound {1} finished {2}", - channel.getRaw().ToString("X"), - sound.getRaw().ToString("X"), - finished), - Helpers.LogLevel.Error, - ex); + $"Error on volume change on channel {channel.handle.ToString("X")} sound {sound.handle.ToString("X")} finished {finished}", + Helpers.LogLevel.Error, + ex); } - })); + }); } } /// /// Update the 3D position of a sound source. /// - protected FMOD.VECTOR position = new FMOD.VECTOR(); - public OpenMetaverse.Vector3 Position + protected VECTOR position = new VECTOR(); + public Vector3 Position { set { position = FromOMVSpace(value); - if (channel == null) return; + if (!channel.hasHandle()) return; - invoke(new SoundDelegate(delegate + invoke(delegate + { + try + { + FMODExec(channel.set3DAttributes( + ref position, + ref ZeroVector)); + } + catch (Exception ex) { - try - { - FMODExec(channel.set3DAttributes( - ref position, - ref ZeroVector)); - } - catch (Exception ex) - { - Logger.Log( - String.Format("Error on position change on channel {0} sound {1} finished {2}", - channel.getRaw().ToString("X"), - sound.getRaw().ToString("X"), - finished), - Helpers.LogLevel.Error, - ex); - } - })); + Logger.Log( + $"Error on position change on channel {channel.handle.ToString("X")} sound {sound.handle.ToString("X")} finished {finished}", + Helpers.LogLevel.Error, ex); + } + }); } } public void Stop() { - if (channel != null) + if (channel.hasHandle()) { - invoke(new SoundDelegate(delegate + invoke(delegate { - MediaManager.FMODExec(channel.stop()); - })); + FMODExec(channel.stop()); + }); } } @@ -206,37 +186,38 @@ public void Stop() /// /// /// - protected FMOD.VECTOR FromOMVSpace(OpenMetaverse.Vector3 omvV) + protected VECTOR FromOMVSpace(Vector3 omvV) { // OMV X is forward/East, Y is left/North, Z is up. // FMOD Z is forward/East, X is right/South, Y is up. - FMOD.VECTOR v = new FMOD.VECTOR(); - v.x = -omvV.Y; - v.y = omvV.Z; - v.z = omvV.X; + VECTOR v = new VECTOR + { + x = -omvV.Y, + y = omvV.Z, + z = omvV.X + }; return v; } protected static Dictionary allSounds; protected static Dictionary allChannels; - protected void RegisterSound(FMOD.Sound sound) + protected void RegisterSound(Sound sound) { - IntPtr raw = sound.getRaw(); + IntPtr raw = sound.handle; if (allSounds.ContainsKey(raw)) allSounds.Remove(raw); allSounds.Add(raw, this); } - protected void RegisterChannel(FMOD.Channel channel) + protected void RegisterChannel(Channel channel) { - IntPtr raw = channel.getRaw(); + IntPtr raw = channel.handle; if (allChannels.ContainsKey(raw)) allChannels.Remove(raw); allChannels.Add(raw, this); } protected void UnRegisterSound() { - if (sound == null) return; - IntPtr raw = sound.getRaw(); + IntPtr raw = sound.handle; if (allSounds.ContainsKey( raw )) { allSounds.Remove( raw ); @@ -244,8 +225,7 @@ protected void UnRegisterSound() } protected void UnRegisterChannel() { - if (channel == null) return; - IntPtr raw = channel.getRaw(); + IntPtr raw = channel.handle; if (allChannels.ContainsKey(raw)) { allChannels.Remove(raw); @@ -258,51 +238,51 @@ protected void UnRegisterChannel() /// // Subclasses override these methods to handle callbacks. - protected virtual FMOD.RESULT EndCallbackHandler() { return RESULT.OK; } + protected virtual RESULT EndCallbackHandler() { return RESULT.OK; } /// /// Main handler for playback-end callback. /// /// + /// /// /// /// /// protected RESULT DispatchEndCallback( IntPtr channelraw, - CHANNEL_CALLBACKTYPE type, + CHANNELCONTROL_TYPE controltype, + CHANNELCONTROL_CALLBACK_TYPE type, IntPtr commanddata1, IntPtr commanddata2) { // There are several callback types - switch (type) + if (type == CHANNELCONTROL_CALLBACK_TYPE.END) { - case CHANNEL_CALLBACKTYPE.END: - if (allChannels.ContainsKey(channelraw)) - { - MediaObject sndobj = allChannels[channelraw]; - return sndobj.EndCallbackHandler(); - } - break; + if (allChannels.ContainsKey(channelraw)) + { + MediaObject sndobj = allChannels[channelraw]; + return sndobj.EndCallbackHandler(); + } } return RESULT.OK; } - protected static void FMODExec(FMOD.RESULT result) + protected static void FMODExec(RESULT result) { - if (result != FMOD.RESULT.OK) + if (result != RESULT.OK) { - throw new MediaException("FMOD error! " + result + " - " + FMOD.Error.String(result)); + throw new MediaException($"FMOD error! {result} - {Error.String(result)}"); } } - protected static void FMODExec(FMOD.RESULT result, string trace) + protected static void FMODExec(RESULT result, string trace) { - Logger.Log("FMOD call " + trace + " returned " + result.ToString(), Helpers.LogLevel.Info); - if (result != FMOD.RESULT.OK) + Logger.Log($"FMOD call {trace} returned {result}", Helpers.LogLevel.Info); + if (result != RESULT.OK) { - throw new MediaException("FMOD error! " + result + " - " + FMOD.Error.String(result)); + throw new MediaException($"FMOD error! {result} - {Error.String(result)}"); } } diff --git a/Radegast/Core/Media/Speech.cs b/Radegast/Core/Media/Speech.cs index d5ed8ea8c..6c03bac7c 100644 --- a/Radegast/Core/Media/Speech.cs +++ b/Radegast/Core/Media/Speech.cs @@ -1,35 +1,24 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id: Sound.cs 502 2010-03-14 23:13:46Z latifer $ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; -using System.Runtime.InteropServices; using FMOD; using OpenMetaverse; @@ -47,35 +36,17 @@ public class Speech : MediaObject /// Fired when a stream meta data is received /// public event SpeechDoneCallback OnSpeechDone; - private String filename; + private string filename; private Vector3 speakerPos; - /// - /// If true, decrease distance falloff effect in volume. - /// - private static Boolean compress = true; - public static Boolean Compress - { - set { compress = value; } - get { return compress; } - } + public static bool Compress { set; get; } = true; - /// - /// If truee use FMODEx 3D sound - /// - private static bool surround = false; - public static bool Surround - { - set { surround = value; } - get { return surround; } - } + public static bool Surround { set; get; } = false; /// /// Creates a new sound object /// - /// Sound system public Speech() - : base() { extraInfo.format = SOUND_FORMAT.PCM16; } @@ -86,10 +57,10 @@ public Speech() /// public override void Dispose() { - if (sound != null) + if (sound.hasHandle()) { sound.release(); - sound = null; + sound.clearHandle(); } base.Dispose(); } @@ -97,8 +68,9 @@ public override void Dispose() /// /// Plays audio from a file, as created by an external speech synthesizer. /// - /// Name of a WAV file + /// Name of a WAV file /// + /// /// Length of the sound in ms public uint Play(string speakfile, bool global, Vector3 pos) { @@ -108,91 +80,86 @@ public uint Play(string speakfile, bool global, Vector3 pos) filename = speakfile; // Set flags to determine how it will be played. - FMOD.MODE mode = FMOD.MODE.SOFTWARE; + MODE mode = MODE.DEFAULT; if (Surround) { - mode |= FMOD.MODE._3D; + mode |= MODE._3D; // Set coordinate space interpretation. if (global) - mode |= FMOD.MODE._3D_WORLDRELATIVE; + mode |= MODE._3D_WORLDRELATIVE; else - mode |= FMOD.MODE._3D_HEADRELATIVE; + mode |= MODE._3D_HEADRELATIVE; } System.Threading.AutoResetEvent done = new System.Threading.AutoResetEvent(false); - invoke(new SoundDelegate( - delegate + invoke(delegate + { + try { - try - { - FMODExec( + FMODExec( system.createSound(filename, - mode, - ref extraInfo, - ref sound)); - - // Register for callbacks. - RegisterSound(sound); - - // Find out how long the sound should play - FMODExec(sound.getLength(ref len, TIMEUNIT.MS)); - - // Allocate a channel, initially paused. - FMODExec(system.playSound(CHANNELINDEX.FREE, sound, true, ref channel)); - - // Set general Speech volume. - //TODO Set this in the GUI - volume = 1.0f; - FMODExec(channel.setVolume(volume)); - - if (Surround) - { - // Set attenuation limits so distant people get a little softer, - // but not TOO soft - if (compress) - FMODExec(sound.set3DMinMaxDistance( - 2f, // Any closer than this gets no louder - 3.5f)); // Further than this gets no softer. - else - FMODExec(sound.set3DMinMaxDistance( - 2f, // Any closer than this gets no louder - 10f)); // Further than this gets no softer. - - // Set speaker position. - position = FromOMVSpace(speakerPos); - FMODExec(channel.set3DAttributes( - ref position, - ref ZeroVector)); - - Logger.Log( - String.Format( - "Speech at <{0:0.0},{1:0.0},{2:0.0}>", - position.x, - position.y, - position.z), - Helpers.LogLevel.Debug); - } - - // SET a handler for when it finishes. - FMODExec(channel.setCallback(endCallback)); - RegisterChannel(channel); - - // Un-pause the sound. - FMODExec(channel.setPaused(false)); - } - catch (Exception ex) - { - Logger.Log("Error playing speech: ", Helpers.LogLevel.Error, ex); - } - finally + mode, + ref extraInfo, + out sound)); + + // Register for callbacks. + RegisterSound(sound); + + // Find out how long the sound should play + FMODExec(sound.getLength(out len, TIMEUNIT.MS)); + + // Allocate a channel, initially paused. + ChannelGroup masterChannelGroup; + system.getMasterChannelGroup(out masterChannelGroup); + FMODExec(system.playSound(sound, masterChannelGroup, true, out channel)); + + // Set general Speech volume. + //TODO Set this in the GUI + volume = 1.0f; + FMODExec(channel.setVolume(volume)); + + if (Surround) { - done.Set(); + // Set attenuation limits so distant people get a little softer, + // but not TOO soft + if (Compress) + FMODExec(sound.set3DMinMaxDistance( + 2f, // Any closer than this gets no louder + 3.5f)); // Further than this gets no softer. + else + FMODExec(sound.set3DMinMaxDistance( + 2f, // Any closer than this gets no louder + 10f)); // Further than this gets no softer. + + // Set speaker position. + position = FromOMVSpace(speakerPos); + FMODExec(channel.set3DAttributes( + ref position, + ref ZeroVector)); + + Logger.Log($"Speech at <{position.x:0.0},{position.y:0.0},{position.z:0.0}>", Helpers.LogLevel.Debug); } - })); + + // SET a handler for when it finishes. + FMODExec(channel.setCallback(endCallback)); + RegisterChannel(channel); + + // Un-pause the sound. + FMODExec(channel.setPaused(false)); + } + catch (Exception ex) + { + Logger.Log("Error playing speech: ", Helpers.LogLevel.Error, ex); + } + finally + { + done.Set(); + } + }); done.WaitOne(30 * 1000, false); return len; @@ -204,26 +171,25 @@ public uint Play(string speakfile, bool global, Vector3 pos) /// protected override RESULT EndCallbackHandler() { - invoke(new SoundDelegate( - delegate - { - UnRegisterChannel(); - channel = null; - UnRegisterSound(); - FMODExec(sound.release()); - sound = null; - - // Tell speech control the file has been played. Note - // the event is dispatched on FMOD's thread, to make sure - // the event handler does not start a new sound before the - // old one is cleaned up. - if (OnSpeechDone != null) - try - { - OnSpeechDone(this, new EventArgs()); - } - catch (Exception) { } - })); + invoke(delegate + { + UnRegisterChannel(); + channel.clearHandle(); + UnRegisterSound(); + FMODExec(sound.release()); + sound.clearHandle(); + + // Tell speech control the file has been played. Note + // the event is dispatched on FMOD's thread, to make sure + // the event handler does not start a new sound before the + // old one is cleaned up. + if (OnSpeechDone != null) + try + { + OnSpeechDone(this, new EventArgs()); + } + catch (Exception) { } + }); return RESULT.OK; diff --git a/Radegast/Core/Media/Stream.cs b/Radegast/Core/Media/Stream.cs index 5bd0d5e65..f91905993 100644 --- a/Radegast/Core/Media/Stream.cs +++ b/Radegast/Core/Media/Stream.cs @@ -1,33 +1,23 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id: Sound.cs 502 2010-03-14 23:13:46Z latifer $ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Runtime.InteropServices; using System.Threading; @@ -64,14 +54,6 @@ public class Stream : MediaObject Timer updateTimer = null; uint updateIntervl = 500; - /// - /// Creates a new sound object - /// - /// Sound system - public Stream() - : base() - { - } /// /// Releases resources of this sound object @@ -90,25 +72,22 @@ public void StopStream() updateTimer = null; } - if (channel != null) + if (!channel.hasHandle()) return; + ManualResetEvent stopped = new ManualResetEvent(false); + invoke(delegate { - ManualResetEvent stopped = new ManualResetEvent(false); - invoke(new SoundDelegate( - delegate - { - try - { - FMODExec(channel.stop()); - channel = null; - UnRegisterSound(); - FMODExec(sound.release()); - sound = null; - } - catch { } - stopped.Set(); - })); - stopped.WaitOne(); - } + try + { + FMODExec(channel.stop()); + channel.clearHandle(); + UnRegisterSound(); + FMODExec(sound.release()); + sound.clearHandle(); + } + catch { } + stopped.Set(); + }); + stopped.WaitOne(); } /// @@ -122,90 +101,85 @@ public void PlayStream(string url) extraInfo.format = SOUND_FORMAT.PCM16; - invoke(new SoundDelegate( - delegate + invoke(delegate + { + try { - try - { - FMODExec( - system.setStreamBufferSize(4 * 128 * 128, TIMEUNIT.RAWBYTES)); + FMODExec( + system.setStreamBufferSize(4 * 128 * 128, TIMEUNIT.RAWBYTES)); - FMODExec( - system.createSound(url, - (MODE.HARDWARE | MODE._2D | MODE.CREATESTREAM), + FMODExec( + system.createSound(url, + (MODE._2D | MODE.CREATESTREAM), ref extraInfo, - ref sound), "Stream load"); - // Register for callbacks. - RegisterSound(sound); - - // Allocate a channel and set initial volume. - FMODExec(system.playSound( - CHANNELINDEX.FREE, - sound, - false, - ref channel), "Stream channel"); - FMODExec(channel.setVolume(volume), "Stream volume"); - - if (updateTimer == null) - { - updateTimer = new Timer(Update); - } - updateTimer.Change(0, updateIntervl); - } - catch (Exception ex) + out sound), "Stream load"); + // Register for callbacks. + RegisterSound(sound); + + // Allocate a channel and set initial volume. + ChannelGroup masterChannelGroup; + system.getMasterChannelGroup(out masterChannelGroup); + FMODExec(system.playSound(sound, masterChannelGroup, false, + out channel), "Stream channel"); + FMODExec(channel.setVolume(volume), "Stream volume"); + + if (updateTimer == null) { - Logger.Log("Error playing stream: " + ex.ToString(), Helpers.LogLevel.Debug); + updateTimer = new Timer(Update); } - })); + updateTimer.Change(0, updateIntervl); + } + catch (Exception ex) + { + Logger.Log("Error playing stream: " + ex, Helpers.LogLevel.Debug); + } + }); } private void Update(object sender) { - if (sound == null) return; + if (!sound.hasHandle()) return; - invoke(new SoundDelegate(() => + invoke(() => { try { FMODExec(system.update()); TAG tag = new TAG(); - int numTags = 0; - int numTagsUpdated = 0; + var numTags = 0; + var numTagsUpdated = 0; - var res = sound.getNumTags(ref numTags, ref numTagsUpdated); + var res = sound.getNumTags(out numTags, out numTagsUpdated); - if (res == RESULT.OK && numTagsUpdated > 0) + if (res != RESULT.OK || numTagsUpdated <= 0) return; + for (var i=0; i < numTags; i++) { - for (int i=0; i < numTags; i++) + if (sound.getTag(null, i, out tag) != RESULT.OK) + { + continue; + } + + if (tag.type == TAGTYPE.FMOD && tag.name == "Sample Rate Change") { - if (sound.getTag(null, i, ref tag) != RESULT.OK) - { - continue; - } - - if (tag.type == TAGTYPE.FMOD && tag.name == "Sample Rate Change") - { - float newfreq = (float)Marshal.PtrToStructure(tag.data, typeof(float)); - Logger.DebugLog("New stream frequency: " + newfreq.ToString("F" + 0)); - channel.setFrequency(newfreq); - } - - if (tag.datatype != TAGDATATYPE.STRING) continue; - - // Tell listeners about the Stream tag. This can be - // displayed to the user. - if (OnStreamInfo != null) - OnStreamInfo(this, new StreamInfoArgs(tag.name.ToLower(), Marshal.PtrToStringAnsi(tag.data))); + float newfreq = (float)Marshal.PtrToStructure(tag.data, typeof(float)); + Logger.DebugLog("New stream frequency: " + newfreq.ToString("F" + 0)); + channel.setFrequency(newfreq); } + + if (tag.datatype != TAGDATATYPE.STRING) continue; + + // Tell listeners about the Stream tag. This can be + // displayed to the user. + OnStreamInfo?.Invoke(this, new StreamInfoArgs(tag.name.ToString().ToLower(), Marshal.PtrToStringAnsi(tag.data))); } } catch (Exception ex) { Logger.DebugLog("Error getting stream tags: " + ex.Message); } - })); + }); } } } diff --git a/Radegast/Core/Media/UISounds.cs b/Radegast/Core/Media/UISounds.cs index a4632acb1..a4a9d38d0 100644 --- a/Radegast/Core/Media/UISounds.cs +++ b/Radegast/Core/Media/UISounds.cs @@ -1,33 +1,22 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ using OpenMetaverse; @@ -39,15 +28,39 @@ namespace Radegast /// public static class UISounds { + /// Alert + public static UUID Alert = new UUID("ed124764-705d-d497-167a-182cd9fa2e6c"); + + /// Click + public static UUID Click = new UUID("4c8c3c77-de8d-bde2-b9b8-32635e0fd4a6"); + + /// Error + public static UUID Error = new UUID("cb58f920-5b52-8a49-b81c-e532adbbe6f1"); + + /// Health Reduction (Female) + public static UUID HealthReductionFemale = new UUID("219c5d93-6c09-31c5-fb3f-c5fe7495c115"); + + /// Health Reduction (Male) + public static UUID HealthReductionMale = new UUID("e057c244-5768-1056-c37e-1537454eeb62"); + /// Sound of incoming IM public static UUID IM = new UUID("67cc2844-00f3-2b3c-b991-6418d01e1bb7"); - /// Typing sound - public static UUID Typing = new UUID("5e191c7b-8996-9ced-a177-b2ac32bfea06"); - /// When user opens new IM window public static UUID IMWindow = new UUID("c825dfbc-9827-7e02-6507-3713d18916c1"); + /// Invalid Operation + public static UUID InvalidOperation = new UUID("4174f859-0d3d-c517-c424-72923dc21f65"); + + /// Invalid Keystrole + public static UUID InvalidKeystroke = new UUID("2ca849ba-2885-4bc3-90ef-d4987a5b983a"); + + /// Keyboard Loop + public static UUID KeyboardLoop = new UUID("5e191c7b-8996-9ced-a177-b2ac32bfea06"); + + /// Pie Appear + public static UUID PieAppear = new UUID("8eaed61f-92ff-6485-de83-4dcc938a478e"); + /// When money balance is increased public static UUID MoneyIn = new UUID("104974e3-dfda-428b-99ee-b0d4e748d3a3"); @@ -63,5 +76,25 @@ public static class UISounds /// Object deleted public static UUID ObjectDelete = new UUID("0cb7b00a-4c10-6948-84de-a93c09af2ba9"); + /// Snapshot sound + public static UUID Snapshot = new UUID("3d09f582-3851-c0e0-f5ba-277ac5c73fb4"); + + /// Teleport + public static UUID Teleport = new UUID("d7a9a565-a013-2a69-797d-5332baa1a947"); + + /// + public static UUID Thunder = new UUID("e95c96a5-293c-bb7a-57ad-ce2e785ad85f"); + + /// Window Close + public static UUID WindowClose = new UUID("2c346eda-b60c-ab33-1119-b8941916a499"); + + /// + public static UUID WindowOpen = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); + + /// Typing sound + public static UUID Typing = new UUID("5e191c7b-8996-9ced-a177-b2ac32bfea06"); + + /// Warning + public static UUID Warning = new UUID("449bc80c-91b6-6365-8fd1-95bd91016624"); } } diff --git a/Radegast/Core/NameManager.cs b/Radegast/Core/NameManager.cs index 04dc6ebc8..ac38981e4 100644 --- a/Radegast/Core/NameManager.cs +++ b/Radegast/Core/NameManager.cs @@ -1,44 +1,25 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/* + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2021, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -#if (COGBOT_LIBOMV || USE_STHREADS) -using ThreadPoolUtil; -using Thread = ThreadPoolUtil.Thread; -using ThreadPool = ThreadPoolUtil.ThreadPool; -using Monitor = ThreadPoolUtil.Monitor; -#endif using System.Threading; using System.IO; using OpenMetaverse; @@ -50,7 +31,7 @@ namespace Radegast /// /// Enum representing different modes of handling display names /// - public enum NameMode : int + public enum NameMode { /// No display names Standard, @@ -73,46 +54,37 @@ public class NameManager : IDisposable public NameMode Mode { - get - { - if (!client.Avatars.DisplayNamesAvailable()) - return NameMode.Standard; - - return (NameMode)instance.GlobalSettings["display_name_mode"].AsInteger(); - } + get => !client.Avatars.DisplayNamesAvailable() + ? NameMode.Standard + : (NameMode)instance.GlobalSettings["display_name_mode"].AsInteger(); - set - { - instance.GlobalSettings["display_name_mode"] = (int)value; - } + set => instance.GlobalSettings["display_name_mode"] = (int)value; } #endregion public fields and properties #region private fields and properties - RadegastInstance instance; - GridClient client { get { return instance.Client; } } - Timer requestTimer; - Timer cacheTimer; - string cacheFileName; - Queue requests = new Queue(); + private readonly RadegastInstance instance; + private GridClient client => instance.Client; + private Timer requestTimer; + private Timer cacheTimer; + private string cacheFileName; + + private readonly Queue requests = new Queue(); - int MaxNameRequests = 80; + private readonly int MaxNameRequests = 80; - // Queue up name request for this many ms, and send a batch requst - const int REQUEST_DELAY = 100; + // Queue up name request for this many ms, and send a batch request + private const int REQUEST_DELAY = 100; // Save name cache after change to names after this many ms - const int CACHE_DELAY = 30000; + private const int CACHE_DELAY = 30000; // Consider request failed after this many ms - const int MAX_REQ_AGE = 15000; + private const int MAX_REQ_AGE = 15000; - Dictionary names = new Dictionary(); - Dictionary activeRequests = new Dictionary(); + private readonly DateTime UUIDNameOnly = new DateTime(1970, 9, 4, 10, 0, 0, DateTimeKind.Utc); - BlockingQueue> PendingLookups; - Thread requestThread = null; - Semaphore lookupGate; - bool useRequestThread; + private readonly Dictionary names = new Dictionary(); + private readonly Dictionary activeRequests = new Dictionary(); #endregion private fields and properties @@ -125,21 +97,8 @@ public NameManager(RadegastInstance instance) cacheTimer = new Timer(SaveCache, null, Timeout.Infinite, Timeout.Infinite); cacheFileName = Path.Combine(instance.UserDir, "name.cache"); LoadCachedNames(); - instance.ClientChanged += new EventHandler(instance_ClientChanged); + instance.ClientChanged += instance_ClientChanged; RegisterEvents(client); - - // Mono HTTPWebRequest sucks balls - useRequestThread = instance.MonoRuntime; - - if (useRequestThread) - { - PendingLookups = new BlockingQueue>(); - lookupGate = new Semaphore(4, 4); - requestThread = new Thread(new ThreadStart(RequestThread)); - requestThread.IsBackground = true; - requestThread.Name = "Display Name Request Thread"; - requestThread.Start(); - } } public void Dispose() @@ -162,65 +121,23 @@ public void Dispose() cacheTimer.Dispose(); cacheTimer = null; } - - try - { - if (useRequestThread) - { - PendingLookups.Close(); - if (requestThread != null) - { - if (!requestThread.Join(5 * 1000)) - { - requestThread.Abort(); - } - requestThread = null; - } - } - } - catch { } } #endregion construction and disposal #region private methods - public void RequestThread() - { - PendingLookups.Open(); - - while (true) - { - List req = null; - if (!PendingLookups.Dequeue(Timeout.Infinite, ref req)) break; - lookupGate.WaitOne(90 * 1000); - client.Avatars.GetDisplayNames(req, (bool success, AgentDisplayName[] names, UUID[] badIDs) => - { - if (success) - { - ProcessDisplayNames(names); - } - else - { - Logger.Log("Failed fetching display names", Helpers.LogLevel.Warning, client); - } - lookupGate.Release(1); - }); - } - } void RegisterEvents(GridClient c) { - c.Avatars.UUIDNameReply += new EventHandler(Avatars_UUIDNameReply); - c.Avatars.DisplayNameUpdate += new EventHandler(Avatars_DisplayNameUpdate); + c.Avatars.UUIDNameReply += Avatars_UUIDNameReply; + c.Avatars.DisplayNameUpdate += Avatars_DisplayNameUpdate; } void DeregisterEvents(GridClient c) { - c.Avatars.UUIDNameReply -= new EventHandler(Avatars_UUIDNameReply); - c.Avatars.DisplayNameUpdate -= new EventHandler(Avatars_DisplayNameUpdate); + c.Avatars.UUIDNameReply -= Avatars_UUIDNameReply; + c.Avatars.DisplayNameUpdate -= Avatars_DisplayNameUpdate; } - DateTime UUIDNameOnly = new DateTime(1970, 9, 4, 10, 0, 0, DateTimeKind.Utc); - void instance_ClientChanged(object sender, ClientChangedEventArgs e) { DeregisterEvents(e.OldClient); @@ -234,16 +151,17 @@ void Avatars_DisplayNameUpdate(object sender, DisplayNameUpdateEventArgs e) e.DisplayName.Updated = DateTime.Now; names[e.DisplayName.ID] = e.DisplayName; } - Dictionary ret = new Dictionary(); - ret.Add(e.DisplayName.ID, FormatName(e.DisplayName)); + + var ret = new Dictionary + { {e.DisplayName.ID, FormatName(e.DisplayName)}}; TriggerEvent(ret); } void Avatars_UUIDNameReply(object sender, UUIDNameReplyEventArgs e) { - Dictionary ret = new Dictionary(); + var ret = new Dictionary(); - foreach (KeyValuePair kvp in e.Names) + foreach (var kvp in e.Names) { // Remove from the list of active requests if in UUID only (standard mode) if (Mode == NameMode.Standard) @@ -258,35 +176,30 @@ void Avatars_UUIDNameReply(object sender, UUIDNameReplyEventArgs e) { if (!names.ContainsKey(kvp.Key)) { - names[kvp.Key] = new AgentDisplayName(); - names[kvp.Key].ID = kvp.Key; - names[kvp.Key].NextUpdate = UUIDNameOnly; - names[kvp.Key].IsDefaultDisplayName = true; + names[kvp.Key] = new AgentDisplayName + { + ID = kvp.Key, + NextUpdate = UUIDNameOnly, + IsDefaultDisplayName = true + }; } names[kvp.Key].Updated = DateTime.Now; - string[] parts = kvp.Value.Trim().Split(' '); - if (parts.Length == 2) + var parts = kvp.Value.Trim().Split(' '); + if (parts.Length != 2) continue; + if (InvalidName(names[kvp.Key].DisplayName)) { - if (InvalidName(names[kvp.Key].DisplayName)) - { - names[kvp.Key].DisplayName = string.Format("{0} {1}", parts[0], parts[1]); - } + names[kvp.Key].DisplayName = $"{parts[0]} {parts[1]}"; + } - names[kvp.Key].LegacyFirstName = parts[0]; - names[kvp.Key].LegacyLastName = parts[1]; - if (names[kvp.Key].LegacyLastName == "Resident") - { - names[kvp.Key].UserName = names[kvp.Key].LegacyFirstName.ToLower(); - } - else - { - names[kvp.Key].UserName = string.Format("{0}.{1}", parts[0], parts[1]).ToLower(); - } + names[kvp.Key].LegacyFirstName = parts[0]; + names[kvp.Key].LegacyLastName = parts[1]; + names[kvp.Key].UserName = names[kvp.Key].LegacyLastName == "Resident" + ? names[kvp.Key].LegacyFirstName.ToLower() + : $"{parts[0]}.{parts[1]}".ToLower(); - ret.Add(kvp.Key, FormatName(names[kvp.Key])); - } + ret.Add(kvp.Key, FormatName(names[kvp.Key])); } } @@ -302,14 +215,12 @@ string FormatName(AgentDisplayName n) return n.DisplayName; case NameMode.Smart: - if (n.IsDefaultDisplayName) - return n.DisplayName; - else - return string.Format("{0} ({1})", n.DisplayName, n.UserName); + return n.IsDefaultDisplayName ? n.DisplayName : $"{n.DisplayName} ({n.UserName})"; case NameMode.DisplayNameAndUserName: - return string.Format("{0} ({1})", n.DisplayName, n.UserName); + return $"{n.DisplayName} ({n.UserName})"; + case NameMode.Standard: default: return n.LegacyFullName; } @@ -317,18 +228,14 @@ string FormatName(AgentDisplayName n) bool InvalidName(string displayName) { - if (string.IsNullOrEmpty(displayName) || - displayName == "???" || - displayName == RadegastInstance.INCOMPLETE_NAME) - { - return true; - } - return false; + return string.IsNullOrEmpty(displayName) || + displayName == "???" || + displayName == RadegastInstance.INCOMPLETE_NAME; } void ProcessDisplayNames(AgentDisplayName[] names) { - Dictionary ret = new Dictionary(); + var ret = new Dictionary(); foreach (var name in names) { @@ -355,7 +262,7 @@ void ProcessDisplayNames(AgentDisplayName[] names) void MakeRequest(object sync) { - List req = new List(); + var req = new List(); lock (requests) { while (requests.Count > 0) @@ -363,39 +270,30 @@ void MakeRequest(object sync) } - if (req.Count > 0) + if (req.Count <= 0) { return; } + if (Mode == NameMode.Standard || (!client.Avatars.DisplayNamesAvailable())) { - if (Mode == NameMode.Standard || (!client.Avatars.DisplayNamesAvailable())) - { - client.Avatars.RequestAvatarNames(req); - } - else // Use display names + client.Avatars.RequestAvatarNames(req); + } + else // Use display names + { + client.Avatars.GetDisplayNames(req, (success, names, badIDs) => { - if (useRequestThread) + if (success) { - PendingLookups.Enqueue(new List(req)); + ProcessDisplayNames(names); } else { - client.Avatars.GetDisplayNames(req, (bool success, AgentDisplayName[] names, UUID[] badIDs) => - { - if (success) - { - ProcessDisplayNames(names); - } - else - { - Logger.Log("Failed fetching display names", Helpers.LogLevel.Warning, client); - } - }); + Logger.Log("Failed fetching display names", Helpers.LogLevel.Warning, client); } - } + }); } } void SaveCache(object sync) { - WorkPool.QueueUserWorkItem(syncx => + ThreadPool.QueueUserWorkItem(syncx => { OSDArray namesOSD = new OSDArray(names.Count); lock (names) @@ -406,10 +304,9 @@ void SaveCache(object sync) } } - OSDMap cache = new OSDMap(1); - cache["names"] = namesOSD; + OSDMap cache = new OSDMap(1) {["names"] = namesOSD}; byte[] data = OSDParser.SerializeLLSDBinary(cache, false); - Logger.DebugLog(string.Format("Caching {0} avatar names to {1}", namesOSD.Count, cacheFileName)); + Logger.DebugLog($"Caching {namesOSD.Count} avatar names to {cacheFileName}"); try { @@ -424,7 +321,7 @@ void SaveCache(object sync) void LoadCachedNames() { - WorkPool.QueueUserWorkItem(syncx => + ThreadPool.QueueUserWorkItem(syncx => { try { @@ -437,9 +334,9 @@ void LoadCachedNames() lock (names) { - for (int i = 0; i < namesOSD.Count; i++) + foreach (var osdname in namesOSD) { - AgentDisplayName name = AgentDisplayName.FromOSD(namesOSD[i]); + AgentDisplayName name = AgentDisplayName.FromOSD(osdname); if (mode == NameMode.Standard || ((now - name.Updated) < maxAge)) { names[name.ID] = name; @@ -447,11 +344,11 @@ void LoadCachedNames() } } - Logger.DebugLog(string.Format("Restored {0} names from the avatar name cache", names.Count)); + Logger.DebugLog($"Restored {names.Count} names from the avatar name cache"); } catch (Exception ex) { - Logger.Log("Failed loading cached avatar names: ", Helpers.LogLevel.Warning, client, ex); + Logger.Log("Failed to load avatar name cache: " + ex.Message, Helpers.LogLevel.Warning, client); } }); } @@ -472,18 +369,12 @@ void TriggerEvent(Dictionary ret) void TriggerNameRequest() { - if (requestTimer != null) - { - requestTimer.Change(REQUEST_DELAY, Timeout.Infinite); - } + requestTimer?.Change(REQUEST_DELAY, Timeout.Infinite); } void TriggerCacheSave() { - if (cacheTimer != null) - { - cacheTimer.Change(CACHE_DELAY, Timeout.Infinite); - } + cacheTimer?.Change(CACHE_DELAY, Timeout.Infinite); } void QueueNameRequest(UUID agentID) @@ -493,20 +384,10 @@ void QueueNameRequest(UUID agentID) { if (activeRequests.ContainsKey(agentID)) { - // Logger.Log("Exiting is active " + agentID.ToString(), Helpers.LogLevel.Error); if (Environment.TickCount - activeRequests[agentID] < MAX_REQ_AGE) // Not timeout yet { - // Logger.Log("Exiting is active " + agentID.ToString(), Helpers.LogLevel.Error); return; } - else - { - // Logger.Log("Continuing, present but expired " + agentID.ToString(), Helpers.LogLevel.Error); - } - } - else - { - // Logger.Log("Not present " + agentID.ToString(), Helpers.LogLevel.Error); } // Record time of when we're making this request @@ -516,20 +397,18 @@ void QueueNameRequest(UUID agentID) lock (requests) { - if (!requests.Contains(agentID)) - { - // Logger.Log("Enqueueing " + agentID.ToString(), Helpers.LogLevel.Error); - requests.Enqueue(agentID); + if (requests.Contains(agentID)) { return; } + + requests.Enqueue(agentID); - if (requests.Count >= MaxNameRequests && Mode != NameMode.Standard) - { - requestTimer.Change(Timeout.Infinite, Timeout.Infinite); - MakeRequest(this); - } - else - { - TriggerNameRequest(); - } + if (requests.Count >= MaxNameRequests && Mode != NameMode.Standard) + { + requestTimer.Change(Timeout.Infinite, Timeout.Infinite); + MakeRequest(this); + } + else + { + TriggerNameRequest(); } } } @@ -559,7 +438,7 @@ public void CleanCache() /// public string GetLegacyName(UUID agentID) { - if (agentID == UUID.Zero) return "(???) (???)"; + if (agentID == UUID.Zero) { return "(???) (???)"; } lock (names) { @@ -580,7 +459,7 @@ public string GetLegacyName(UUID agentID) /// public string GetUserName(UUID agentID) { - if (agentID == UUID.Zero) return "(???) (???)"; + if (agentID == UUID.Zero) { return "(???) (???)"; } lock (names) { @@ -601,7 +480,7 @@ public string GetUserName(UUID agentID) /// public string GetDisplayName(UUID agentID) { - if (agentID == UUID.Zero) return "(???) (???)"; + if (agentID == UUID.Zero) { return "(???) (???)"; } lock (names) { @@ -622,29 +501,35 @@ public string GetDisplayName(UUID agentID) /// Avatar display name or "Loading..." if not in cache public string Get(UUID agentID) { - if (agentID == UUID.Zero) return "(???) (???)"; + if (agentID == UUID.Zero) { return "(???) (???)"; } + + string name = null; + bool requestName = true; lock (names) { if (names.ContainsKey(agentID)) { - if (Mode != NameMode.Standard && names[agentID].NextUpdate == UUIDNameOnly) + if (Mode == NameMode.Standard || names[agentID].NextUpdate != UUIDNameOnly) { - QueueNameRequest(agentID); + requestName = false; } - return FormatName(names[agentID]); + name = FormatName(names[agentID]); } } - QueueNameRequest(agentID); - return RadegastInstance.INCOMPLETE_NAME; + if (requestName) + { + QueueNameRequest(agentID); + } + return string.IsNullOrEmpty(name) ? RadegastInstance.INCOMPLETE_NAME : name; } /// /// Get avatar display name, or queue fetching of the name /// /// UUID of avatar to lookup - /// If true, wait until name is recieved, otherwise return immediately + /// If true, wait until name is received, otherwise return immediately /// Avatar display name or "Loading..." if not in cache public string Get(UUID agentID, bool blocking) { @@ -656,7 +541,7 @@ public string Get(UUID agentID, bool blocking) using (ManualResetEvent gotName = new ManualResetEvent(false)) { - EventHandler handler = (object sender, UUIDNameReplyEventArgs e) => + EventHandler handler = (sender, e) => { if (e.Names.ContainsKey(agentID)) { @@ -690,10 +575,7 @@ public string Get(UUID agentID, string defaultValue) return defaultValue; string name = Get(agentID); - if (name == RadegastInstance.INCOMPLETE_NAME) - return defaultValue; - - return name; + return name == RadegastInstance.INCOMPLETE_NAME ? defaultValue : name; } /// @@ -709,11 +591,7 @@ public string Get(UUID agentID, bool blocking, string defaultValue) return defaultValue; string name = Get(agentID, blocking); - if (name == RadegastInstance.INCOMPLETE_NAME) - return defaultValue; - - return name; - + return name == RadegastInstance.INCOMPLETE_NAME ? defaultValue : name; } #endregion public methods diff --git a/Radegast/Core/NativeMethods.cs b/Radegast/Core/NativeMethods.cs new file mode 100644 index 000000000..5ae7af22b --- /dev/null +++ b/Radegast/Core/NativeMethods.cs @@ -0,0 +1,51 @@ +/** + * Radegast Metaverse Client + * Copyright(c) 2021, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + +using System.Runtime.InteropServices; + +namespace Radegast.Core +{ + internal sealed class NativeMethods + { + #region Fields + + public const CallingConvention CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl; + + private static readonly WindowsLibraryLoader WindowsLibraryLoader = new WindowsLibraryLoader(); + + #endregion + + #region Constructors + + static NativeMethods() + { + WindowsLibraryLoader.LoadLibraries(new[] + { + "fmod" + }); + } + + public static void Init() + { + + } + + #endregion + } +} diff --git a/Radegast/Core/PluginInterface/IRadegastPlugin.cs b/Radegast/Core/PluginInterface/IRadegastPlugin.cs index 74845bc9f..38c3c21bd 100644 --- a/Radegast/Core/PluginInterface/IRadegastPlugin.cs +++ b/Radegast/Core/PluginInterface/IRadegastPlugin.cs @@ -1,33 +1,23 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + namespace Radegast { /// diff --git a/Radegast/Core/PluginInterface/PluginAttribute.cs b/Radegast/Core/PluginInterface/PluginAttribute.cs index 71f98a93d..37d220027 100644 --- a/Radegast/Core/PluginInterface/PluginAttribute.cs +++ b/Radegast/Core/PluginInterface/PluginAttribute.cs @@ -1,33 +1,23 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; namespace Radegast diff --git a/Radegast/Core/PluginInterface/PluginInfo.cs b/Radegast/Core/PluginInterface/PluginInfo.cs new file mode 100644 index 000000000..63fdbc73b --- /dev/null +++ b/Radegast/Core/PluginInterface/PluginInfo.cs @@ -0,0 +1,110 @@ +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + +using System; +using System.Linq; + +namespace Radegast +{ + /// + /// Information about loaded plugin + /// + public class PluginInfo + { + /// File name from which the plugin was loaded, cannot load plugin twice from the same file + public string FileName { get; } + + /// Display name + public string DisplayName { get; set; } + + /// Is plugin started + public bool IsStarted { get; private set; } + + /// Plugin attributes + public PluginAttribute Attribures { get; } + + /// Plugin instance + private IRadegastPlugin PluginInstance { get; } + + public override string ToString() => DisplayName; + + /// + /// Constructs a new PluginInfo + /// + /// Path to the plugin. + /// Valid plugin instance. Must not be null. + /// is + public PluginInfo(string filename, IRadegastPlugin plugin) + { + PluginInstance = plugin ?? throw new ArgumentNullException(nameof(plugin)); + FileName = filename; + DisplayName = PluginInstance.GetType().Name; + + PluginAttribute pluginAttributes = null; + try + { + var customAttributes = Attribute.GetCustomAttributes(PluginInstance.GetType()); + pluginAttributes = customAttributes.First(attribute => attribute is PluginAttribute) as PluginAttribute; + } + catch + { + // Suppress + } + + Attribures = pluginAttributes ?? new PluginAttribute {Name = PluginInstance.GetType().FullName}; + } + + /// + /// Starts the plugin. Attempts to start a plugin that has already been started will result in an exception. + /// + /// Radegast instance + /// On failure + public void Start(RadegastInstance instance) + { + if (!IsStarted) + { + PluginInstance.StartPlugin(instance); + IsStarted = true; + } + else + { + throw new Exception("Attempting to start a plugin that is already in the running state."); + } + } + + /// + /// Stops the plugin. Attempts to stop a plugin that has already been stopped will result in an exception. + /// + /// Radegast instance + /// On failure + public void Stop(RadegastInstance instance) + { + if (IsStarted) + { + PluginInstance.StopPlugin(instance); + IsStarted = false; + } + else + { + throw new Exception("Attempting to stop a plugin that is already in the stopped state."); + } + } + } +} diff --git a/Radegast/Core/PluginInterface/PluginManager.cs b/Radegast/Core/PluginInterface/PluginManager.cs index d7b681f35..05a35892a 100644 --- a/Radegast/Core/PluginInterface/PluginManager.cs +++ b/Radegast/Core/PluginInterface/PluginManager.cs @@ -1,126 +1,112 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections.Generic; using System.IO; using System.Reflection; using System.CodeDom.Compiler; -using System.Windows.Forms; +using System.Linq; +using System.Text; using OpenMetaverse; using Microsoft.CSharp; namespace Radegast { - /// - /// Information about loaded plugin - /// - public class PluginInfo - { - /// File name from which the plugin was loaded, cannot load plugin twice from the same file - public string FileName { get; set; } - /// Plugin class - public IRadegastPlugin Plugin { get; set; } - /// Is plugin started - public bool Started { get; set; } - /// Plugin class - public PluginAttribute Attribures - { - get - { - if (Plugin == null) return null; - return PluginManager.GetAttributes(Plugin); - } - } - - public AppDomain Domain; - } - /// /// Handles loading Radegast plugins /// public class PluginManager : IDisposable { /// List of files that should not be scanned for plugins - public static readonly List PluginBlackList = new List(new string[] - { - "AIMLbot.dll", - "CommandLine.dll", - "Meebey.SmartIrc4net.dll", - "Monobjc.Cocoa.dll", - "Monobjc.dll", - "OpenMetaverse.Rendering.Meshmerizer.dll", - "OpenMetaverse.StructuredData.dll", - "OpenMetaverse.dll", - "OpenMetaverseTypes.dll", - "PrimMesher.dll", - "RadSpeechLin.dll", - "RadSpeechMac.dll", - "RadSpeechWin.dll", - "Tao.OpenGl.dll", - "Tao.Platform.Windows.dll", - "Tools.dll", - "XMLRPC.dll", - "fmodex-dotnet.dll", - "fmodex.dll", - "log4net.dll", - "openjpeg-dotnet-x86_64.dll", - "openjpeg-dotnet.dll", - "OpenCyc.dll", - "IKVM.", - "OpenTK", - "zlib.net.dll", - "SmartThreadPool", - }); + private static readonly List PluginBlackList = new List(new string[] + { + "AIMLbot.dll", + "Binaron.Serializer.dll", + "C5.dll", + "CommandLine.dll", + "DbgHelp.dll", + "fmod.dll", + "IKVM.dll", + "log4net.dll", + "Meebey.SmartIrc4net.dll", + "Monobjc.Cocoa.dll", + "Monobjc.dll", + "NSec.Cryptography.dll", + "nvdacontrollerClient32.dll", + "nvdacontrollerClient64.dll", + "OpenCyc.dll", + "openjpeg-dotnet.dll", + "OpenJpegDotNetNative.dll", + "OpenTK", + "OpenTK.GLControl.dll", + "ortp.dll", + "PrimMesher.dll", + "protobuf-net.dll", + "RadSpeechLin.dll", + "RadSpeechMac.dll", + "RadSpeechWin.dll", + "SmartThreadPool", + "SLVoice.exe", + "Tao.OpenGl.dll", + "Tao.Platform.Windows.dll", + "UniversalSpeech.dll", + "vivoxsdk.dll", + "XmlRpcCore.dll", + "zlib.net.dll", + "zlib1.dll", + // Blacklist all of these + "OpenMetaverse.", + "LibreMetaverse.", + "System.", + }); + + /// Collection of assemblies that are referenced when compiling scripts. + private static readonly string[] ReferencedAssemblies = new string[] + { + "LibreMetaverse.StructuredData.dll", + "LibreMetaverse.Types.dll", + "LibreMetaverse.dll", + "Radegast.exe", + "System.dll", + "System.ComponentModel.Composition.dll", + "System.Core.dll", + "System.Xml.dll", + "System.Drawing.dll", + "System.Drawing.Common.dll", + "System.Threading.Channels.dll", + "System.Windows.Forms.dll", + }; /// List of file extensions that could potentially hold plugins - public static readonly List AllowedPluginExtensions = new List(new string[] - { - ".cs", - ".dll", - ".exe" - }); + private static readonly List AllowedPluginExtensions = new List(new string[] + { + ".cs", + ".dll", + ".exe" + }); - List PluginsLoaded = new List(); - RadegastInstance instance; + private RadegastInstance Instance { get; } - /// - /// Gets the list of currently loaded plugins - /// - public List Plugins - { - get - { - return PluginsLoaded; - } - } + /// Collection of all of the loaded plugins + public List Plugins { get; } = new List(); /// /// Creates new PluginManager @@ -128,7 +114,7 @@ public List Plugins /// Radegast instance PluginManager is associated with public PluginManager(RadegastInstance instance) { - this.instance = instance; + Instance = instance; } /// @@ -136,367 +122,315 @@ public PluginManager(RadegastInstance instance) /// public void Dispose() { - lock (PluginsLoaded) + lock (Plugins) { - List unload = new List(PluginsLoaded); - unload.ForEach(plug => + // Make a copy so we can have something to iterate over while removing items from the original list. + var pluginsToRemove = Plugins.ToList(); + foreach (var plugin in pluginsToRemove) { - UnloadPlugin(plug); - }); + try + { + UnloadPlugin(plugin); + } + catch (Exception ex) + { + Logger.Log($"ERROR unloading plugin: {plugin} because {ex}", Helpers.LogLevel.Warning, ex); + } + } } } /// /// Unloads a plugin /// - /// Plugin to unload - public void UnloadPlugin(PluginInfo plug) + /// Plugin to unload + public void UnloadPlugin(PluginInfo plugin) { - lock (PluginsLoaded) + lock (Plugins) { - var pluginInfos = PluginsLoaded.FindAll(info => { return info.Plugin == plug.Plugin; }); - - foreach (var info in pluginInfos) + var pluginsToUnload = Plugins.FindAll(loadedPlugin => plugin.FileName == loadedPlugin.FileName); + foreach (var pluginToUnload in pluginsToUnload) { - AppDomain domain = info.Domain; - try { info.Plugin.StopPlugin(instance); } - catch (Exception ex) { Logger.Log("ERROR in unloading plugin: " + info.Plugin.GetType().Name + " because " + ex, Helpers.LogLevel.Debug, ex); } - PluginsLoaded.Remove(info); - - if (domain != null && PluginsLoaded.Find(dinfo => { return dinfo.Domain == domain; }) == null) + try + { + pluginToUnload.Stop(Instance); + } + catch (Exception ex) { - try { AppDomain.Unload(domain); } - catch (Exception ex) { Logger.Log("ERROR unloading application domain for : " + plug.FileName + "\n" + ex.Message, Helpers.LogLevel.Debug); } + Logger.Log($"ERROR stopping plugin: {pluginToUnload} because {ex}", Helpers.LogLevel.Warning, ex); } + Plugins.Remove(pluginToUnload); } } } /// - /// Gets extended atributes for plugin + /// Loads and starts all plugins in the specified directory. /// - /// Plugin to lookup extra attributes - /// Extended atributes for plugin - public static PluginAttribute GetAttributes(IRadegastPlugin plug) + /// On failure + public void LoadPluginsInDirectory(string pluginDirectory) { - PluginAttribute a = null; + if (string.IsNullOrEmpty(pluginDirectory)) + { + return; + } - foreach (Attribute attr in Attribute.GetCustomAttributes(plug.GetType())) + foreach (var pluginPath in Directory.GetFiles(pluginDirectory)) { - if (attr is PluginAttribute) - a = (PluginAttribute)attr; + LoadPlugin(pluginPath); } + } - if (a == null) + /// + /// Loads and starts the specified plugin. + /// + /// On failure + public void LoadPlugin(string pluginPath) + { + var newPlugins = new List(); + + try + { + var foundPlugins = LoadPluginFile(pluginPath); + newPlugins.AddRange(foundPlugins); + } + catch (Exception ex) { - a = new PluginAttribute(); - a.Name = plug.GetType().FullName; + Logger.Log($"ERROR unable to load plugin: {pluginPath} because {ex}", Helpers.LogLevel.Warning); } - return a; + StartPlugins(newPlugins); } /// - /// Starts all loaded plugins + /// Starts the specified plugins. /// - public void StartPlugins() + /// Plugins to start. + /// On failure + private void StartPlugins(IEnumerable pluginsToStart) { - lock (PluginsLoaded) + lock (Plugins) { - foreach (PluginInfo plug in PluginsLoaded) + foreach (var newPlugin in pluginsToStart) { - Logger.DebugLog("Starting " + plug.Plugin.GetType().FullName); + Logger.DebugLog($"Starting {newPlugin}"); try { - plug.Plugin.StartPlugin(instance); - plug.Started = true; + newPlugin.Start(Instance); } catch (Exception ex) { - Logger.Log("ERROR in Starting Radegast Plugin: " + plug + " because " + ex, Helpers.LogLevel.Debug); + Logger.Log($"ERROR in Starting Radegast Plugin: {newPlugin} because {ex}", Helpers.LogLevel.Warning); } + Plugins.Add(newPlugin); } } } /// - /// Loads a plugin for a precompiled assembly or source file + /// Loads plugins from the specified assembly or script. /// - /// File to load - /// Start plugins that are found in the assembly - public void LoadPluginFile(string loadFileName, bool stratPlugins) + /// Path to an assembly or script file containing plugins. + /// List of plugins that were successfully loaded. + /// On failure + private List LoadPluginFile(string path) { - string ext = Path.GetExtension(loadFileName).ToLower(); - if (ext == ".cs") + if (IsBlacklisted(path)) { - LoadCSharpScriptFile(loadFileName, stratPlugins); + return new List(); } - else if (ext == ".dll" || ext == ".exe") + + if (IsPluginLoaded(path)) { - try - { - LoadAssembly(loadFileName, stratPlugins); - } - catch (BadImageFormatException) - { - // non .NET .dlls - } - catch (ReflectionTypeLoadException) - { - // Out of date or dlls missing sub dependencies - } - catch (TypeLoadException) - { - // Another version of: Out of date or dlls missing sub dependencies - } - catch (Exception ex) - { - Logger.Log("ERROR in Radegast Plugin: " + loadFileName + " because " + ex, Helpers.LogLevel.Debug); - } + Instance.TabConsole.DisplayNotificationInChat($"Plugin already loaded, skipping: {path}"); + return new List(); } - } - - /// - /// Scans and load plugins from Radegast application folder without starting them - /// - public void ScanAndLoadPlugins() - { - string dirName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); - - if (!Directory.Exists(dirName)) return; - foreach (string loadFileName in Directory.GetFiles(dirName)) + var extension = Path.GetExtension(path)?.ToLower(); + switch (extension) { - if (IsUnusedFile(loadFileName)) - { - continue; - } - - LoadPluginFile(loadFileName, false); + case ".cs": + return LoadScript(path); + case ".dll": + case ".exe": + return LoadAssembly(path); } + + return new List(); } - private static bool IsUnusedFile(string loadFileName) + /// + /// Determines if the specified file path is blacklisted and should not be loaded. + /// + /// File path to check. + /// True if the file path is blacklisted and should not be loaded. + private static bool IsBlacklisted(string path) { - if (!AllowedPluginExtensions.Contains(Path.GetExtension(loadFileName).ToLower())) return true; - loadFileName = Path.GetFileName(loadFileName).ToLower(); + var extension = Path.GetExtension(path)?.ToLower(); + if (string.IsNullOrEmpty(extension)) { return true; } + if (!AllowedPluginExtensions.Contains(extension)) { return true; } - foreach (string blackList in PluginBlackList) - { - if (loadFileName.StartsWith(blackList.ToLower())) - { - return true; - } - } - return false; + var filename = Path.GetFileName(path).ToLower(); + if (string.IsNullOrEmpty(filename)) { return true; } + if (filename.StartsWith("System.")) { return true; } + + return PluginBlackList.Any(blackListItem => filename.StartsWith(blackListItem.ToLower())); } /// - /// Loads and compiles a plugin from a C# source file + /// Determines if the plugin at the specified path has already been loaded. /// - /// Load plugin from this filename - /// Start plugins found in the assembly after complilation - public void LoadCSharpScriptFile(string fileName, bool startPlugins) + /// Path to the plugin to check. + /// True if the plugin has already been loaded. + private bool IsPluginLoaded(string pluginPath) { - try { LoadCSharpScript(fileName, File.ReadAllText(fileName), startPlugins); } - catch (Exception ex) + lock (Plugins) { - Logger.Log("Failed loading C# script " + fileName + ": ", Helpers.LogLevel.Warning, ex); + return Plugins.Find(plugin => plugin.FileName == pluginPath) != null; } } /// - /// Compiles plugin from string source code + /// Compiles and loads plugins from a script /// - /// File name from which source was loaded - /// Source code - /// Start plugins found in the assembly after complilation - public void LoadCSharpScript(string fileName, string code, bool startPlugins) + /// Path to the script to compile and load plugins from. + /// List of plugins that were successfully loaded. + /// On failure + private List LoadScript(string scriptPath) { - try + // *** Generate dynamic compiler + var compilerOptions = new Dictionary { - // *** Generate dynamic compiler - Dictionary loCompilerOptions = new Dictionary(); - loCompilerOptions.Add("CompilerVersion", "v3.5"); - CSharpCodeProvider loCompiler = new CSharpCodeProvider(loCompilerOptions); - CompilerParameters loParameters = new CompilerParameters(); - - // *** Start by adding any referenced assemblies - loParameters.ReferencedAssemblies.Add("OpenMetaverse.StructuredData.dll"); - loParameters.ReferencedAssemblies.Add("OpenMetaverseTypes.dll"); - loParameters.ReferencedAssemblies.Add("OpenMetaverse.dll"); - loParameters.ReferencedAssemblies.Add("Radegast.exe"); - loParameters.ReferencedAssemblies.Add("System.dll"); - loParameters.ReferencedAssemblies.Add("System.Core.dll"); - loParameters.ReferencedAssemblies.Add("System.Xml.dll"); - loParameters.ReferencedAssemblies.Add("System.Drawing.dll"); - loParameters.ReferencedAssemblies.Add("System.Windows.Forms.dll"); - - // *** Load the resulting assembly into memory - loParameters.GenerateInMemory = true; - loParameters.GenerateExecutable = false; - - // *** Now compile the whole thing - CompilerResults loCompiled = - loCompiler.CompileAssemblyFromSource(loParameters, code); - - // *** Check for compilation erros - if (loCompiled.Errors.HasErrors) - { - string lcErrorMsg = ""; - lcErrorMsg = "Compilation failed: " + loCompiled.Errors.Count.ToString() + " errors:"; + {"CompilerVersion", "v4.0"} + }; + var compiler = new CSharpCodeProvider(compilerOptions); + var compilerParameters = new CompilerParameters(); - for (int x = 0; x < loCompiled.Errors.Count; x++) - lcErrorMsg += "\r\nLine: " + - loCompiled.Errors[x].Line.ToString() + " - " + - loCompiled.Errors[x].ErrorText; + // *** Start by adding any referenced assemblies + compilerParameters.ReferencedAssemblies.AddRange(ReferencedAssemblies); - instance.TabConsole.DisplayNotificationInChat(lcErrorMsg, ChatBufferTextStyle.Alert); - return; - } + // *** Load the resulting assembly into memory + compilerParameters.GenerateInMemory = true; + compilerParameters.GenerateExecutable = false; - instance.TabConsole.DisplayNotificationInChat("Compilation successful."); - Assembly loAssembly = loCompiled.CompiledAssembly; - LoadAssembly(fileName, loAssembly, startPlugins); - } - catch (Exception ex) + // *** Now compile the whole thing + var source = File.ReadAllText(scriptPath); + var compilerResults = compiler.CompileAssemblyFromSource(compilerParameters, source); + + // *** Check for compilation erros + if (compilerResults.Errors.HasErrors) { - Logger.Log("Failed loading C# script: ", Helpers.LogLevel.Warning, ex); + var errorMessage = new StringBuilder(); + + errorMessage.AppendLine($"Compilation failed: {compilerResults.Errors.Count} errors:"); + for (var i = 0; i < compilerResults.Errors.Count; i++) + { + errorMessage.AppendLine($"Line: {compilerResults.Errors[i].Line} - {compilerResults.Errors[i].ErrorText}"); + } + + Instance.TabConsole.DisplayNotificationInChat(errorMessage.ToString(), ChatBufferTextStyle.Alert); + return new List(); } + + Instance.TabConsole.DisplayNotificationInChat("Compilation successful."); + return LoadPluginsFromAssembly(scriptPath, compilerResults.CompiledAssembly); } /// - /// Scans assembly for supported types + /// Loads all plugins from the specified assembly path. /// - /// File name from which assembly was loaded - /// Assembly to scan for supported types - /// Start plugins found in the assembly after complilation - public void LoadAssembly(string loadfilename, bool startPlugins) + /// Path to the assembly to load plugins from. + /// List of plugins that were successfully loaded. + /// On failure + private List LoadAssembly(string assemblyPath) { - LoadAssembly(loadfilename, null, startPlugins); - } + Assembly pluginAssembly = null; + // We may try to load plugins from the currently running process. The assembly is already loaded. + var currentProcessPath = Assembly.GetEntryAssembly()?.Location; + pluginAssembly = Path.GetFileName(currentProcessPath) == Path.GetFileName(assemblyPath) + ? Assembly.GetEntryAssembly() : Assembly.LoadFile(assemblyPath); + return LoadPluginsFromAssembly(assemblyPath, pluginAssembly); + } /// - /// Scans assembly for supported types and loads it into it's own domain + /// Loads all plugins from the specified assembly. /// - /// File name from which assembly was loaded - /// Start plugins found in the assembly after complilation - public void LoadAssembly(string loadfilename, Assembly assembly, bool startPlugins) + /// Path the assembly was loaded from. + /// Assembly to load plugins from. + /// List of plugins that were successfully loaded. + /// On failure. + /// is + private List LoadPluginsFromAssembly(string assemblyPath, Assembly pluginAssembly) { - if (null != PluginsLoaded.Find((PluginInfo info) => { return info.FileName == loadfilename; })) + if (pluginAssembly == null) { - Logger.Log("Plugin already loaded, skipping: " + loadfilename, Helpers.LogLevel.Info); - if (startPlugins) - { - instance.TabConsole.DisplayNotificationInChat("Plugin already loaded, skipping: " + loadfilename); - } - return; + throw new ArgumentNullException(nameof(pluginAssembly)); } - AppDomain domain = null; + var loadedPlugins = new List(); - if (assembly == null) - { - // Don't load ourselves into a domain - if (Path.GetFileName(Assembly.GetEntryAssembly().Location) == Path.GetFileName(loadfilename)) - { - assembly = Assembly.GetEntryAssembly(); - } - else - { - assembly = Assembly.LoadFile(loadfilename); - - /* Disable creation of domains for now - domain = AppDomain.CreateDomain("Domain for: " + loadfilename); - var loader = (RemoteLoader)domain.CreateInstanceAndUnwrap("Radegast", "Radegast.RemoteLoader"); - assembly = loader.Load(loadfilename); - */ - } - } - - bool loadedTypesFromAssembly = false; - - foreach (Type type in assembly.GetTypes()) + foreach (var type in pluginAssembly.GetTypes()) { if (typeof(IRadegastPlugin).IsAssignableFrom(type)) { - if (type.IsInterface) continue; + if (type.IsInterface) + { + continue; + } + try { - IRadegastPlugin plug = null; - ConstructorInfo constructorInfo = type.GetConstructor(new Type[] { typeof(RadegastInstance) }); - if (constructorInfo != null) - { - plug = (IRadegastPlugin)constructorInfo.Invoke(new[] { instance }); - } - else - { - constructorInfo = type.GetConstructor(new Type[] { }); - if (constructorInfo != null) - { - plug = (IRadegastPlugin)constructorInfo.Invoke(new object[0]); - } - else - { - Logger.Log("ERROR Constructing Radegast Plugin: " + loadfilename + " because " + type + " has no usable constructor.", Helpers.LogLevel.Debug); - continue; - } - } - - loadedTypesFromAssembly = true; - - PluginInfo info = new PluginInfo() - { - FileName = loadfilename, - Plugin = plug, - Started = false, - Domain = domain - }; - - lock (PluginsLoaded) PluginsLoaded.Add(info); - if (startPlugins && plug != null) - { - try { plug.StartPlugin(instance); info.Started = true; } - catch (Exception ex) { Logger.Log(string.Format("Failed starting plugin {0}:", type), Helpers.LogLevel.Error, ex); } - } + var newPlugin = LoadPluginFromType(assemblyPath, type); + loadedPlugins.Add(newPlugin); } catch (Exception ex) { - Logger.Log("ERROR Constructing Radegast Plugin: " + loadfilename + " because " + ex, - Helpers.LogLevel.Debug); + Logger.Log($"Cannot load {type.Name} from {pluginAssembly.FullName} because: {ex}", Helpers.LogLevel.Warning); } } else { - try - { - loadedTypesFromAssembly |= instance.CommandsManager.LoadType(type); - loadedTypesFromAssembly |= instance.ContextActionManager.LoadType(type); - } - catch (Exception ex) - { - Logger.Log("ERROR in Radegast Plugin: " + loadfilename + " Command: " + type + - " because " + ex.Message + " " + ex.StackTrace, Helpers.LogLevel.Debug); - } + Instance.CommandsManager.LoadType(type); + Instance.ContextActionManager.LoadType(type); } } - if (domain != null && !loadedTypesFromAssembly) - { - AppDomain.Unload(domain); - } - - + return loadedPlugins; } - } - public class RemoteLoader : MarshalByRefObject - { - public Assembly Load(string loadfilename) + /// + /// Instantiates a new plugin from the specified type. + /// + /// Path to the plugin or script. + /// Type to instantiate a new plugin from. + /// Plugin that was loaded from the specified type. + /// On failure. + private PluginInfo LoadPluginFromType(string pluginPath, Type pluginType) { - return AppDomain.CurrentDomain.Load(File.ReadAllBytes(loadfilename)); + IRadegastPlugin pluginInstance; + + // Does the assembly have a constructor that has a RadegastInstance parameter? + var constructorInfo = pluginType.GetConstructor(new Type[] { typeof(RadegastInstance) }); + if (constructorInfo != null) + { + pluginInstance = (IRadegastPlugin) constructorInfo.Invoke(new object[] {Instance}); + } + else + { + // Does the assembly have a constructor? + constructorInfo = pluginType.GetConstructor(Type.EmptyTypes); + if (constructorInfo != null) + { + pluginInstance = (IRadegastPlugin) constructorInfo.Invoke(null); + } + else + { + throw new Exception($"No suitable constructor found in {pluginType.Name}."); + } + } + + return new PluginInfo(pluginPath, pluginInstance); } } - } diff --git a/Radegast/Core/PrimDeserializer.cs b/Radegast/Core/PrimDeserializer.cs index e33ec2549..63cb75b7a 100644 --- a/Radegast/Core/PrimDeserializer.cs +++ b/Radegast/Core/PrimDeserializer.cs @@ -1,41 +1,25 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections.Generic; -#if (COGBOT_LIBOMV || USE_STHREADS) -using ThreadPoolUtil; -using Thread = ThreadPoolUtil.Thread; -using ThreadPool = ThreadPoolUtil.ThreadPool; -using Monitor = ThreadPoolUtil.Monitor; -#endif using System.Threading; using System.Windows.Forms; using OpenMetaverse; @@ -48,17 +32,20 @@ public class PrimDeserializer { public static void ImportFromFile(GridClient client) { - WindowWrapper mainWindow = new WindowWrapper(frmMain.ActiveForm.Handle); - System.Windows.Forms.OpenFileDialog dlg = new OpenFileDialog(); - dlg.Title = "Open object file"; - dlg.Filter = "XML file (*.xml)|*.xml"; - dlg.Multiselect = false; + if (Form.ActiveForm == null) return; + WindowWrapper mainWindow = new WindowWrapper(Form.ActiveForm.Handle); + OpenFileDialog dlg = new OpenFileDialog + { + Title = "Open object file", + Filter = "XML file (*.xml)|*.xml", + Multiselect = false + }; DialogResult res = dlg.ShowDialog(); if (res == DialogResult.OK) { - Thread t = new Thread(new System.Threading.ThreadStart(delegate() + Thread t = new Thread(delegate() { try { @@ -67,15 +54,16 @@ public static void ImportFromFile(GridClient client) d.CreateObjectFromXml(primsXmls); d.CleanUp(); d = null; - MessageBox.Show(mainWindow, "Successfully imported " + dlg.FileName, "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); + MessageBox.Show(mainWindow, $"Successfully imported {dlg.FileName}", "Success", + MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception excp) { - MessageBox.Show(mainWindow, excp.Message, "Saving failed", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show(mainWindow, excp.Message, "Saving failed", MessageBoxButtons.OK, + MessageBoxIcon.Error); } - })); + }) {IsBackground = true}; - t.IsBackground = true; t.Start(); } @@ -117,12 +105,12 @@ public Linkset(Primitive rootPrim) public PrimDeserializer(GridClient c) { Client = c; - Client.Objects.ObjectUpdate += new EventHandler(Objects_ObjectUpdate); + Client.Objects.ObjectUpdate += Objects_ObjectUpdate; } public void CleanUp() { - Client.Objects.ObjectUpdate -= new EventHandler(Objects_ObjectUpdate); + Client.Objects.ObjectUpdate -= Objects_ObjectUpdate; } public bool CreateObjectFromXml(string xml) @@ -135,10 +123,8 @@ public bool CreateObject(List prims) { // Build an organized structure from the imported prims Dictionary linksets = new Dictionary(); - for (int i = 0; i < prims.Count; i++) + foreach (var prim in prims) { - Primitive prim = prims[i]; - if (prim.ParentID == 0) { if (linksets.ContainsKey(prim.LocalID)) @@ -205,8 +191,8 @@ public bool CreateObject(List prims) if (linkset.Children.Count != 0) { // Create a list of the local IDs of the newly created prims - List primIDs = new List(primsCreated.Count); - primIDs.Add(rootLocalID); // Root prim is first in list. + List primIDs = new List(primsCreated.Count) {rootLocalID}; + // Root prim is first in list. foreach (Primitive prim in primsCreated) { if (prim.LocalID != rootLocalID) @@ -222,7 +208,7 @@ public bool CreateObject(List prims) if (!primDone.WaitOne(5000, false)) { - Logger.Log(String.Format("Warning: Failed to link {0} prims", linkQueue.Count), Helpers.LogLevel.Warning); + Logger.Log($"Warning: Failed to link {linkQueue.Count} prims", Helpers.LogLevel.Warning); } Client.Objects.SetPermissions(Client.Network.CurrentSim, primIDs, @@ -231,8 +217,7 @@ public bool CreateObject(List prims) } else { - List primsForPerms = new List(); - primsForPerms.Add(rootLocalID); + List primsForPerms = new List {rootLocalID}; Client.Objects.SetRotation(Client.Network.CurrentSim, rootLocalID, rootRotation); Client.Objects.SetPermissions(Client.Network.CurrentSim, primsForPerms, PermissionWho.NextOwner, diff --git a/Radegast/Core/PrimExporter.cs b/Radegast/Core/PrimExporter.cs index 3731fa20b..64bfb74ca 100644 --- a/Radegast/Core/PrimExporter.cs +++ b/Radegast/Core/PrimExporter.cs @@ -1,44 +1,28 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections.Generic; using System.IO; -#if (COGBOT_LIBOMV || USE_STHREADS) -using ThreadPoolUtil; -using Thread = ThreadPoolUtil.Thread; -using ThreadPool = ThreadPoolUtil.ThreadPool; -using Monitor = ThreadPoolUtil.Monitor; -#endif +using System.Linq; using System.Threading; -using System.Windows.Forms; using OpenMetaverse; using OpenMetaverse.StructuredData; using OpenMetaverse.Assets; @@ -67,34 +51,30 @@ public class PrimExporter public PrimExporter(GridClient client) { Client = client; - Client.Objects.ObjectPropertiesFamily += new EventHandler(Objects_OnObjectPropertiesFamily); - Client.Objects.ObjectProperties += new EventHandler(Objects_OnObjectProperties); + Client.Objects.ObjectPropertiesFamily += Objects_OnObjectPropertiesFamily; + Client.Objects.ObjectProperties += Objects_OnObjectProperties; } public void CleanUp() { - Client.Objects.ObjectPropertiesFamily -= new EventHandler(Objects_OnObjectPropertiesFamily); - Client.Objects.ObjectProperties += new EventHandler(Objects_OnObjectProperties); + Client.Objects.ObjectPropertiesFamily -= Objects_OnObjectPropertiesFamily; + Client.Objects.ObjectProperties += Objects_OnObjectProperties; } public void ExportToFile(string filename, uint localID) { - Primitive exportPrim; - uint localid; + uint localid; ExportDirectory = Path.Combine(Path.GetDirectoryName(filename),Path.GetFileNameWithoutExtension(filename)); Directory.CreateDirectory(ExportDirectory); - exportPrim = Client.Network.CurrentSim.ObjectsPrimitives.Find( - delegate(Primitive prim) { return prim.LocalID == localID; } + var exportPrim = Client.Network.CurrentSim.ObjectsPrimitives.Find( + prim => prim.LocalID == localID ); if (exportPrim != null) { - if (exportPrim.ParentID != 0) - localid = exportPrim.ParentID; - else - localid = exportPrim.LocalID; + localid = exportPrim.ParentID != 0 ? exportPrim.ParentID : exportPrim.LocalID; uLocalID = localid; // Check for export permission first @@ -118,11 +98,8 @@ public void ExportToFile(string filename, uint localID) } List prims = Client.Network.CurrentSim.ObjectsPrimitives.FindAll( - delegate(Primitive prim) - { - return (prim.LocalID == localid || prim.ParentID == localid); - } - ); + prim => (prim.LocalID == localid || prim.ParentID == localid) + ); bool complete = RequestObjectProperties(prims, 250); @@ -133,42 +110,40 @@ public void ExportToFile(string filename, uint localID) lock(Textures) { - for (int i = 0; i < prims.Count; i++) - { - Primitive prim = prims[i]; - UUID texture; + foreach (var prim in prims) + { + UUID texture; - if (prim.Textures.DefaultTexture.TextureID != Primitive.TextureEntry.WHITE_TEXTURE && - !Textures.Contains(prim.Textures.DefaultTexture.TextureID)) - { - texture = new UUID(prim.Textures.DefaultTexture.TextureID); - Textures.Add(texture); - } + if (prim.Textures.DefaultTexture.TextureID != Primitive.TextureEntry.WHITE_TEXTURE && + !Textures.Contains(prim.Textures.DefaultTexture.TextureID)) + { + texture = new UUID(prim.Textures.DefaultTexture.TextureID); + Textures.Add(texture); + } - for (int j = 0; j < prim.Textures.FaceTextures.Length; j++) - { - if (prim.Textures.FaceTextures[j] != null && - prim.Textures.FaceTextures[j].TextureID != Primitive.TextureEntry.WHITE_TEXTURE && - !Textures.Contains(prim.Textures.FaceTextures[j].TextureID)) - { - texture = new UUID(prim.Textures.FaceTextures[j].TextureID); - Textures.Add(texture); - } - } + foreach (var tex in prim.Textures.FaceTextures) + { + if (tex != null && + tex.TextureID != Primitive.TextureEntry.WHITE_TEXTURE && + !Textures.Contains(tex.TextureID)) + { + texture = new UUID(tex.TextureID); + Textures.Add(texture); + } + } - if (prim.Sculpt != null && prim.Sculpt.SculptTexture != UUID.Zero && !Textures.Contains(prim.Sculpt.SculptTexture)) - { - texture = new UUID(prim.Sculpt.SculptTexture); - Textures.Add(texture); - } - } + if (prim.Sculpt != null && prim.Sculpt.SculptTexture != UUID.Zero && !Textures.Contains(prim.Sculpt.SculptTexture)) + { + texture = new UUID(prim.Sculpt.SculptTexture); + Textures.Add(texture); + } + } FindImagesInInventory(); - - for (int i = 0; i < Textures.Count; i++) - textureRequests.Add(new ImageRequest(Textures[i], ImageType.Normal, 1013000.0f, 0)); - - foreach (ImageRequest request in textureRequests) + + textureRequests.AddRange(Textures.Select(t => new ImageRequest(t, ImageType.Normal, 1013000.0f, 0))); + + foreach (ImageRequest request in textureRequests) { Client.Assets.RequestImage(request.ImageID, request.Type, Assets_OnImageReceived); } @@ -177,7 +152,7 @@ public void ExportToFile(string filename, uint localID) } else { - throw new Exception("Couldn't find id " + localID.ToString() + " in the " + + throw new Exception("Couldn't find id " + localID + " in the " + Client.Network.CurrentSim.ObjectsPrimitives.Count + " objects currently indexed in the current simulator."); } @@ -294,24 +269,17 @@ void Assets_OnImageReceived(TextureRequestState state, AssetTexture asset) { lock (Textures) Textures.Remove(asset.AssetID); - - if (state == TextureRequestState.Finished) - { - try - { - File.WriteAllBytes(Path.Combine(ExportDirectory,asset.AssetID + ".jp2"), asset.AssetData); - LogMessage("Successfully downloaded texture {0}",asset.AssetID.ToString()); - } - catch (Exception ex) - { - LogMessage("Failed to download texture {0}\r\nReason: {1}",asset.AssetID.ToString(),ex.Message); - } - } - else - { - LogMessage("Failed to download texture {0}\r\nReason: {1}",asset.AssetID.ToString(),state); - } - lock (Textures) + + try + { + File.WriteAllBytes(Path.Combine(ExportDirectory,asset.AssetID + ".jp2"), asset.AssetData); + LogMessage("Successfully downloaded texture {0}",asset.AssetID.ToString()); + } + catch (Exception ex) + { + LogMessage("Failed to download texture {0}\r\nReason: {1}",asset.AssetID.ToString(),ex.Message); + } + lock (Textures) { if (Textures.Count == 0) LogMessage("Texture Download complete!"); diff --git a/Radegast/Core/PrimImporter.cs b/Radegast/Core/PrimImporter.cs index 28f216f68..ae528842a 100644 --- a/Radegast/Core/PrimImporter.cs +++ b/Radegast/Core/PrimImporter.cs @@ -1,43 +1,26 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections.Generic; -#if (COGBOT_LIBOMV || USE_STHREADS) -using ThreadPoolUtil; -using Thread = ThreadPoolUtil.Thread; -using ThreadPool = ThreadPoolUtil.ThreadPool; -using Monitor = ThreadPoolUtil.Monitor; -#endif using System.Threading; -using System.Windows.Forms; using System.IO; using OpenMetaverse; using OpenMetaverse.StructuredData; @@ -103,43 +86,37 @@ public PrimImporter(GridClient client) { Client = client; Textures = new Dictionary(); - Client.Objects.ObjectUpdate += new EventHandler(Objects_OnNewPrim); + Client.Objects.ObjectUpdate += Objects_OnNewPrim; } public void CleanUp() { - Client.Objects.ObjectUpdate -= new EventHandler(Objects_OnNewPrim); + Client.Objects.ObjectUpdate -= Objects_OnNewPrim; } public void ImportFromFile(string filename) { ImportDirectory = Path.GetDirectoryName(filename); - string xml; - List prims; - - xml = File.ReadAllText(filename); - - prims = Helpers.OSDToPrimList(OSDParser.DeserializeLLSDXml(xml)); + var xml = File.ReadAllText(filename); + var prims = Helpers.OSDToPrimList(OSDParser.DeserializeLLSDXml(xml)); Dictionary linksets = new Dictionary(); - for (int i = 0; i < prims.Count; i++) + foreach (Primitive prim in prims) { - Primitive prim = prims[i]; - - if (prim.ParentID == 0) - { - if (linksets.ContainsKey(prim.LocalID)) - linksets[prim.LocalID].RootPrim = prim; - else - linksets[prim.LocalID] = new Linkset(prim); - } - else - { - if (!linksets.ContainsKey(prim.ParentID)) - linksets[prim.ParentID] = new Linkset(); + if (prim.ParentID == 0) + { + if (linksets.ContainsKey(prim.LocalID)) + linksets[prim.LocalID].RootPrim = prim; + else + linksets[prim.LocalID] = new Linkset(prim); + } + else + { + if (!linksets.ContainsKey(prim.ParentID)) + linksets[prim.ParentID] = new Linkset(); - linksets[prim.ParentID].Children.Add(prim); - } + linksets[prim.ParentID].Children.Add(prim); + } } primsCreated = new List(); @@ -182,10 +159,10 @@ public void ImportFromFile(string filename) } // Create a list of the local IDs of the newly created prims - List primIDs = new List(primsCreated.Count); - primIDs.Add(rootLocalID); // Root prim is first in list. - - if (linkset.Children.Count != 0) + List primIDs = new List(primsCreated.Count) {rootLocalID}; + + + if (linkset.Children.Count != 0) { // Add the rest of the prims to the list of local IDs) foreach (Primitive prim in primsCreated) diff --git a/Radegast/Core/PrimSerializer.cs b/Radegast/Core/PrimSerializer.cs index 226ef2ee7..ed6bf86be 100644 --- a/Radegast/Core/PrimSerializer.cs +++ b/Radegast/Core/PrimSerializer.cs @@ -1,33 +1,23 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System.Collections.Generic; using System.Threading; using OpenMetaverse; @@ -49,30 +39,24 @@ public class PrimSerializer public PrimSerializer(GridClient c) { Client = c; - Client.Objects.ObjectProperties += new System.EventHandler(Objects_ObjectProperties); + Client.Objects.ObjectProperties += Objects_ObjectProperties; } public void CleanUp() { - Client.Objects.ObjectProperties -= new System.EventHandler(Objects_ObjectProperties); + Client.Objects.ObjectProperties -= Objects_ObjectProperties; } public string GetSerializedAttachmentPrims(Simulator sim, uint localID) { List prims = sim.ObjectsPrimitives.FindAll( - delegate(Primitive prim) - { - return (prim.LocalID == localID || prim.ParentID == localID); - } + prim => (prim.LocalID == localID || prim.ParentID == localID) ); RequestObjectProperties(prims, 500); int i = prims.FindIndex( - delegate(Primitive prim) - { - return (prim.LocalID == localID); - } + prim => (prim.LocalID == localID) ); if (i >= 0) { @@ -94,10 +78,7 @@ public string GetSerializedPrims(Simulator sim, uint localID) uint rootPrim = p.ParentID == 0 ? p.LocalID : p.ParentID; List prims = sim.ObjectsPrimitives.FindAll( - delegate(Primitive prim) - { - return (prim.LocalID == rootPrim || prim.ParentID == rootPrim); - } + prim => (prim.LocalID == rootPrim || prim.ParentID == rootPrim) ); RequestObjectProperties(prims, 500); diff --git a/Radegast/Core/RLV/RLVEventArgs.cs b/Radegast/Core/RLV/RLVEventArgs.cs index ac3a2f707..3bedc1acd 100644 --- a/Radegast/Core/RLV/RLVEventArgs.cs +++ b/Radegast/Core/RLV/RLVEventArgs.cs @@ -1,37 +1,24 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; namespace Radegast { diff --git a/Radegast/Core/RLV/RLVManager.cs b/Radegast/Core/RLV/RLVManager.cs index 4d66527f4..8a9bf0df7 100644 --- a/Radegast/Core/RLV/RLVManager.cs +++ b/Radegast/Core/RLV/RLVManager.cs @@ -1,36 +1,27 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections.Generic; using System.Linq; +using System.Reflection; using System.Text; using System.Text.RegularExpressions; using OpenMetaverse; @@ -52,8 +43,7 @@ protected virtual void OnRLVRuleChanged(RLVEventArgs e) EventHandler handler = m_RLVRuleChanged; try { - if (handler != null) - handler(this, e); + handler?.Invoke(this, e); } catch (Exception) { } @@ -90,92 +80,36 @@ public struct RLVAttachment static RLVManager() { - RLVWearables = new List(16); - RLVWearables.Add(new RLVWearable() { Name = "gloves", Type = WearableType.Gloves }); - RLVWearables.Add(new RLVWearable() { Name = "jacket", Type = WearableType.Jacket }); - RLVWearables.Add(new RLVWearable() { Name = "pants", Type = WearableType.Pants }); - RLVWearables.Add(new RLVWearable() { Name = "shirt", Type = WearableType.Shirt }); - RLVWearables.Add(new RLVWearable() { Name = "shoes", Type = WearableType.Shoes }); - RLVWearables.Add(new RLVWearable() { Name = "skirt", Type = WearableType.Skirt }); - RLVWearables.Add(new RLVWearable() { Name = "socks", Type = WearableType.Socks }); - RLVWearables.Add(new RLVWearable() { Name = "underpants", Type = WearableType.Underpants }); - RLVWearables.Add(new RLVWearable() { Name = "undershirt", Type = WearableType.Undershirt }); - RLVWearables.Add(new RLVWearable() { Name = "skin", Type = WearableType.Skin }); - RLVWearables.Add(new RLVWearable() { Name = "eyes", Type = WearableType.Eyes }); - RLVWearables.Add(new RLVWearable() { Name = "hair", Type = WearableType.Hair }); - RLVWearables.Add(new RLVWearable() { Name = "shape", Type = WearableType.Shape }); - RLVWearables.Add(new RLVWearable() { Name = "alpha", Type = WearableType.Alpha }); - RLVWearables.Add(new RLVWearable() { Name = "tattoo", Type = WearableType.Tattoo }); - RLVWearables.Add(new RLVWearable() { Name = "physics", Type = WearableType.Physics }); - - RLVAttachments = new List(); - RLVAttachments.Add(new RLVAttachment() { Name = "none", Point = AttachmentPoint.Default }); - RLVAttachments.Add(new RLVAttachment() { Name = "chest", Point = AttachmentPoint.Chest }); - RLVAttachments.Add(new RLVAttachment() { Name = "skull", Point = AttachmentPoint.Skull }); - RLVAttachments.Add(new RLVAttachment() { Name = "left shoulder", Point = AttachmentPoint.LeftShoulder }); - RLVAttachments.Add(new RLVAttachment() { Name = "right shoulder", Point = AttachmentPoint.RightShoulder }); - RLVAttachments.Add(new RLVAttachment() { Name = "left hand", Point = AttachmentPoint.LeftHand }); - RLVAttachments.Add(new RLVAttachment() { Name = "right hand", Point = AttachmentPoint.RightHand }); - RLVAttachments.Add(new RLVAttachment() { Name = "left foot", Point = AttachmentPoint.LeftFoot }); - RLVAttachments.Add(new RLVAttachment() { Name = "right foot", Point = AttachmentPoint.RightFoot }); - RLVAttachments.Add(new RLVAttachment() { Name = "spine", Point = AttachmentPoint.Spine }); - RLVAttachments.Add(new RLVAttachment() { Name = "pelvis", Point = AttachmentPoint.Pelvis }); - RLVAttachments.Add(new RLVAttachment() { Name = "mouth", Point = AttachmentPoint.Mouth }); - RLVAttachments.Add(new RLVAttachment() { Name = "chin", Point = AttachmentPoint.Chin }); - RLVAttachments.Add(new RLVAttachment() { Name = "left ear", Point = AttachmentPoint.LeftEar }); - RLVAttachments.Add(new RLVAttachment() { Name = "right ear", Point = AttachmentPoint.RightEar }); - RLVAttachments.Add(new RLVAttachment() { Name = "left eyeball", Point = AttachmentPoint.LeftEyeball }); - RLVAttachments.Add(new RLVAttachment() { Name = "right eyeball", Point = AttachmentPoint.RightEyeball }); - RLVAttachments.Add(new RLVAttachment() { Name = "nose", Point = AttachmentPoint.Nose }); - RLVAttachments.Add(new RLVAttachment() { Name = "r upper arm", Point = AttachmentPoint.RightUpperArm }); - RLVAttachments.Add(new RLVAttachment() { Name = "r forearm", Point = AttachmentPoint.RightForearm }); - RLVAttachments.Add(new RLVAttachment() { Name = "l upper arm", Point = AttachmentPoint.LeftUpperArm }); - RLVAttachments.Add(new RLVAttachment() { Name = "l forearm", Point = AttachmentPoint.LeftForearm }); - RLVAttachments.Add(new RLVAttachment() { Name = "right hip", Point = AttachmentPoint.RightHip }); - RLVAttachments.Add(new RLVAttachment() { Name = "r upper leg", Point = AttachmentPoint.RightUpperLeg }); - RLVAttachments.Add(new RLVAttachment() { Name = "r lower leg", Point = AttachmentPoint.RightLowerLeg }); - RLVAttachments.Add(new RLVAttachment() { Name = "left hip", Point = AttachmentPoint.LeftHip }); - RLVAttachments.Add(new RLVAttachment() { Name = "l upper leg", Point = AttachmentPoint.LeftUpperLeg }); - RLVAttachments.Add(new RLVAttachment() { Name = "l lower leg", Point = AttachmentPoint.LeftLowerLeg }); - RLVAttachments.Add(new RLVAttachment() { Name = "stomach", Point = AttachmentPoint.Stomach }); - RLVAttachments.Add(new RLVAttachment() { Name = "left pec", Point = AttachmentPoint.LeftPec }); - RLVAttachments.Add(new RLVAttachment() { Name = "right pec", Point = AttachmentPoint.RightPec }); - RLVAttachments.Add(new RLVAttachment() { Name = "center 2", Point = AttachmentPoint.HUDCenter2 }); - RLVAttachments.Add(new RLVAttachment() { Name = "top right", Point = AttachmentPoint.HUDTopRight }); - RLVAttachments.Add(new RLVAttachment() { Name = "top", Point = AttachmentPoint.HUDTop }); - RLVAttachments.Add(new RLVAttachment() { Name = "top left", Point = AttachmentPoint.HUDTopLeft }); - RLVAttachments.Add(new RLVAttachment() { Name = "center", Point = AttachmentPoint.HUDCenter }); - RLVAttachments.Add(new RLVAttachment() { Name = "bottom left", Point = AttachmentPoint.HUDBottomLeft }); - RLVAttachments.Add(new RLVAttachment() { Name = "bottom", Point = AttachmentPoint.HUDBottom }); - RLVAttachments.Add(new RLVAttachment() { Name = "bottom right", Point = AttachmentPoint.HUDBottomRight }); - RLVAttachments.Add(new RLVAttachment() { Name = "neck", Point = AttachmentPoint.Neck }); - RLVAttachments.Add(new RLVAttachment() { Name = "root", Point = AttachmentPoint.Root }); + RLVWearables = new List(); + foreach (WearableType wear in Enum.GetValues(typeof(WearableType))) + { + if (wear.Equals(WearableType.Invalid)) continue; + string wearstr = Utils.EnumToText(wear); + RLVWearables.Add(new RLVWearable() {Name = wearstr.ToLower(), Type = wear}); + } + + RLVAttachments = new List + { + new RLVAttachment() {Name = "none", Point = AttachmentPoint.Default} + }; + foreach (AttachmentPoint pt in Enum.GetValues(typeof(AttachmentPoint))) + { + string ptstr = Utils.EnumToText(pt); + if (pt.Equals(AttachmentPoint.Default) || ptstr.StartsWith("HUD")) continue; + RLVAttachments.Add(new RLVAttachment {Name = ptstr.ToLower(), Point = pt}); + } } public static WearableType WearableFromString(string type) { var found = RLVWearables.FindAll(w => w.Name == type); - if (found.Count == 1) - { - return found[0].Type; - } - else - { - return WearableType.Invalid; - } + return found.Count == 1 ? found[0].Type : WearableType.Invalid; } public static AttachmentPoint AttachmentPointFromString(string point) { var found = RLVAttachments.FindAll(a => a.Name == point); - if (found.Count == 1) - { - return found[0].Point; - } - else - { - return AttachmentPoint.Default; - } + return found.Count == 1 ? found[0].Point : AttachmentPoint.Default; } #endregion Helper classes, structs and enums @@ -228,10 +162,10 @@ public bool EnabledDebugCommands } } - RadegastInstance instance; - GridClient client { get { return instance.Client; } } - Regex rlv_regex = new Regex(@"(?[^:=]+)(:(? public virtual void OnRadegastFormCreated(RadegastForm radForm) { - if (RadegastFormCreated != null) RadegastFormCreated(radForm); + RadegastFormCreated?.Invoke(radForm); } #endregion - private GridClient client; - private RadegastNetcom netcom; - - private StateManager state; - - private frmMain mainForm; - // Singleton, there can be only one instance private static RadegastInstance globalInstance = null; - public static RadegastInstance GlobalInstance - { - get - { - if (globalInstance == null) - { - globalInstance = new RadegastInstance(new GridClient()); - } - return globalInstance; - } - } + public static RadegastInstance GlobalInstance => globalInstance ?? (globalInstance = new RadegastInstance(new GridClient())); /// /// Manages retrieving avatar names /// - public NameManager Names { get { return names; } } - private NameManager names; + public NameManager Names { get; private set; } /// /// When was Radegast started (UTC) @@ -91,84 +63,60 @@ public static RadegastInstance GlobalInstance /// public TimeZoneInfo WordTimeZone; - private string userDir; /// /// System (not grid!) user's dir /// - public string UserDir { get { return userDir; } } + public string UserDir { get; private set; } /// /// Grid client's user dir for settings and logs /// - public string ClientDir - { - get - { - if (client != null && client.Self != null && !string.IsNullOrEmpty(client.Self.Name)) - { - return Path.Combine(userDir, client.Self.Name); - } - else - { - return Environment.CurrentDirectory; - } - } - } + public string ClientDir => !string.IsNullOrEmpty(Client?.Self?.Name) ? Path.Combine(UserDir, Client.Self.Name) : Environment.CurrentDirectory; - public string InventoryCacheFileName { get { return Path.Combine(ClientDir, "inventory.cache"); } } + public string InventoryCacheFileName => Path.Combine(ClientDir, "inventory.cache"); - private string globalLogFile; - public string GlobalLogFile { get { return globalLogFile; } } + public string GlobalLogFile { get; private set; } - private bool monoRuntime; - public bool MonoRuntime { get { return monoRuntime; } } + public bool MonoRuntime { get; } - private Dictionary groups = new Dictionary(); - public Dictionary Groups { get { return groups; } } + public Dictionary Groups { get; private set; } = new Dictionary(); - private Settings globalSettings; /// /// Global settings for the entire application /// - public Settings GlobalSettings { get { return globalSettings; } } + public Settings GlobalSettings { get; private set; } - private Settings clientSettings; /// /// Per client settings /// - public Settings ClientSettings { get { return clientSettings; } } + public Settings ClientSettings { get; private set; } public const string INCOMPLETE_NAME = "Loading..."; public readonly bool advancedDebugging = false; - private PluginManager pluginManager; /// Handles loading plugins and scripts - public PluginManager PluginManager { get { return pluginManager; } } + public PluginManager PluginManager { get; private set; } - private MediaManager mediaManager; /// /// Radegast media manager for playing streams and in world sounds /// - public MediaManager MediaManager { get { return mediaManager; } } - + public MediaManager MediaManager { get; private set; } - private CommandsManager commandsManager; /// /// Radegast command manager for executing textual console commands /// - public CommandsManager CommandsManager { get { return commandsManager; } } + public CommandsManager CommandsManager { get; private set; } /// /// Radegast ContextAction manager for context sensitive actions /// public ContextActionsManager ContextActionManager { get; private set; } - private RadegastMovement movement; /// /// Allows key emulation for moving avatar around /// - public RadegastMovement Movement { get { return movement; } } + public RadegastMovement Movement { get; private set; } private InventoryClipboard inventoryClipboard; /// @@ -178,7 +126,7 @@ public string ClientDir /// public InventoryClipboard InventoryClipboard { - get { return inventoryClipboard; } + get => inventoryClipboard; set { inventoryClipboard = value; @@ -186,16 +134,13 @@ public InventoryClipboard InventoryClipboard } } - private RLVManager rlv; - /// /// Manager for RLV functionality /// - public RLVManager RLV { get { return rlv; } } + public RLVManager RLV { get; private set; } - private GridManager gridManager; /// Manages default params for different grids - public GridManager GridManger { get { return gridManager; } } + public GridManager GridManger { get; private set; } /// /// Is system using plain color theme, with white background and dark text @@ -206,9 +151,7 @@ public bool PlainColors { // If windows background is whiteish, declare as standard color scheme var c = System.Drawing.SystemColors.Window; - if (c.R > 240 && c.G > 240 && c.B > 240) - return true; - return false; + return c.R > 240 && c.G > 240 && c.B > 240; } } @@ -227,13 +170,7 @@ public bool PlainColors /// public bool ReportedCrash = false; - private string CrashMarkerFileName - { - get - { - return Path.Combine(UserDir, "crash_marker"); - } - } + private string CrashMarkerFileName => Path.Combine(UserDir, "crash_marker"); #region Events @@ -247,8 +184,7 @@ private string CrashMarkerFileName protected virtual void OnClientChanged(ClientChangedEventArgs e) { EventHandler handler = m_ClientChanged; - if (handler != null) - handler(this, e); + handler?.Invoke(this, e); } /// Thread sync lock object @@ -272,8 +208,7 @@ public event EventHandler ClientChanged protected virtual void OnInventoryClipboardUpdated(EventArgs e) { EventHandler handler = m_InventoryClipboardUpdated; - if (handler != null) - handler(this, e); + handler?.Invoke(this, e); } /// Thread sync lock object @@ -287,7 +222,6 @@ public event EventHandler InventoryClipboardUpdated } #endregion InventoryClipboardUpdated event - #endregion Events public RadegastInstance(GridClient client0) @@ -301,42 +235,41 @@ public RadegastInstance(GridClient client0) Application.ThreadException += HandleThreadException; } - client = client0; + Client = client0; // Initialize current time zone, and mark when we started GetWorldTimeZone(); StartupTimeUTC = DateTime.UtcNow; // Are we running mono? - monoRuntime = Type.GetType("Mono.Runtime") != null; + MonoRuntime = Type.GetType("Mono.Runtime") != null; Keyboard = new Keyboard(); Application.AddMessageFilter(Keyboard); - netcom = new RadegastNetcom(this); - state = new StateManager(this); - mediaManager = new MediaManager(this); - commandsManager = new CommandsManager(this); + Netcom = new Netcom(this); + State = new StateManager(this); + MediaManager = new MediaManager(this); + CommandsManager = new CommandsManager(this); ContextActionManager = new ContextActionsManager(this); RegisterContextActions(); - movement = new RadegastMovement(this); + Movement = new RadegastMovement(this); InitializeLoggingAndConfig(); - InitializeClient(client); + InitializeClient(Client); - rlv = new RLVManager(this); - gridManager = new GridManager(); - gridManager.LoadGrids(); + RLV = new RLVManager(this); + GridManger = new GridManager(); + GridManger.LoadGrids(); - names = new NameManager(this); + Names = new NameManager(this); COF = new CurrentOutfitFolder(this); - mainForm = new frmMain(this); - mainForm.InitializeControls(); + MainForm = new frmMain(this); + MainForm.InitializeControls(); - mainForm.Load += new EventHandler(mainForm_Load); - pluginManager = new PluginManager(this); - pluginManager.ScanAndLoadPlugins(); + MainForm.Load += mainForm_Load; + PluginManager = new PluginManager(this); } private void InitializeClient(GridClient client) @@ -348,13 +281,12 @@ private void InitializeClient(GridClient client) client.Settings.ALWAYS_DECODE_OBJECTS = true; client.Settings.OBJECT_TRACKING = true; client.Settings.ENABLE_SIMSTATS = true; - client.Settings.FETCH_MISSING_INVENTORY = true; client.Settings.SEND_AGENT_THROTTLE = true; client.Settings.SEND_AGENT_UPDATES = true; client.Settings.STORE_LAND_PATCHES = true; client.Settings.USE_ASSET_CACHE = true; - client.Settings.ASSET_CACHE_DIR = Path.Combine(userDir, "cache"); + client.Settings.ASSET_CACHE_DIR = Path.Combine(UserDir, "cache"); client.Assets.Cache.AutoPruneEnabled = false; client.Assets.Cache.ComputeAssetCacheFilename = ComputeCacheName; @@ -368,7 +300,6 @@ private void InitializeClient(GridClient client) client.Self.Movement.UpdateInterval = 250; RegisterClientEvents(client); - SetClientTag(); } public string ComputeCacheName(string cacheDir, UUID assetID) @@ -393,37 +324,26 @@ public string ComputeCacheName(string cacheDir, UUID assetID) private void RegisterClientEvents(GridClient client) { - client.Groups.CurrentGroups += new EventHandler(Groups_CurrentGroups); - client.Groups.GroupLeaveReply += new EventHandler(Groups_GroupsChanged); - client.Groups.GroupDropped += new EventHandler(Groups_GroupsChanged); - client.Groups.GroupJoinedReply += new EventHandler(Groups_GroupsChanged); - if (netcom != null) - netcom.ClientConnected += new EventHandler(netcom_ClientConnected); - client.Network.LoginProgress += new EventHandler(Network_LoginProgress); + client.Groups.CurrentGroups += Groups_CurrentGroups; + client.Groups.GroupLeaveReply += Groups_GroupsChanged; + client.Groups.GroupDropped += Groups_GroupsChanged; + client.Groups.GroupJoinedReply += Groups_GroupsChanged; + if (Netcom != null) + Netcom.ClientConnected += netcom_ClientConnected; + client.Network.LoginProgress += Network_LoginProgress; } private void UnregisterClientEvents(GridClient client) { - client.Groups.CurrentGroups -= new EventHandler(Groups_CurrentGroups); - client.Groups.GroupLeaveReply -= new EventHandler(Groups_GroupsChanged); - client.Groups.GroupDropped -= new EventHandler(Groups_GroupsChanged); - client.Groups.GroupJoinedReply -= new EventHandler(Groups_GroupsChanged); - if (netcom != null) - netcom.ClientConnected -= new EventHandler(netcom_ClientConnected); - client.Network.LoginProgress -= new EventHandler(Network_LoginProgress); + client.Groups.CurrentGroups -= Groups_CurrentGroups; + client.Groups.GroupLeaveReply -= Groups_GroupsChanged; + client.Groups.GroupDropped -= Groups_GroupsChanged; + client.Groups.GroupJoinedReply -= Groups_GroupsChanged; + if (Netcom != null) + Netcom.ClientConnected -= netcom_ClientConnected; + client.Network.LoginProgress -= Network_LoginProgress; } - public void SetClientTag() - { - if (GlobalSettings["send_rad_client_tag"]) - { - client.Settings.CLIENT_IDENTIFICATION_TAG = new UUID("b748af88-58e2-995b-cf26-9486dea8e830"); - } - else - { - client.Settings.CLIENT_IDENTIFICATION_TAG = UUID.Zero; - } - } private void GetWorldTimeZone() { try @@ -446,10 +366,7 @@ public DateTime GetWorldTime() try { - if (WordTimeZone != null) - now = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, WordTimeZone); - else - now = DateTime.UtcNow.AddHours(-7); + now = WordTimeZone != null ? TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, WordTimeZone) : DateTime.UtcNow.AddHours(-7); } catch (Exception) { @@ -463,13 +380,13 @@ public DateTime GetWorldTime() public void Reconnect() { TabConsole.DisplayNotificationInChat("Attempting to reconnect...", ChatBufferTextStyle.StatusDarkBlue); - Logger.Log("Attemting to reconnect", Helpers.LogLevel.Info, client); - GridClient oldClient = client; - client = new GridClient(); + Logger.Log("Attempting to reconnect", Helpers.LogLevel.Info, Client); + GridClient oldClient = Client; + Client = new GridClient(); UnregisterClientEvents(oldClient); - InitializeClient(client); - OnClientChanged(new ClientChangedEventArgs(oldClient, client)); - netcom.Login(); + InitializeClient(Client); + OnClientChanged(new ClientChangedEventArgs(oldClient, Client)); + Netcom.Login(); } public void CleanUp() @@ -482,102 +399,107 @@ public void CleanUp() COF = null; } - if (names != null) + if (Names != null) { - names.Dispose(); - names = null; + Names.Dispose(); + Names = null; } - if (gridManager != null) + if (GridManger != null) { - gridManager.Dispose(); - gridManager = null; + GridManger.Dispose(); + GridManger = null; } - if (rlv != null) + if (RLV != null) { - rlv.Dispose(); - rlv = null; + RLV.Dispose(); + RLV = null; } - if (client != null) + if (Client != null) { - UnregisterClientEvents(client); + UnregisterClientEvents(Client); } - if (pluginManager != null) + if (PluginManager != null) { - pluginManager.Dispose(); - pluginManager = null; + PluginManager.Dispose(); + PluginManager = null; } - if (movement != null) + if (Movement != null) { - movement.Dispose(); - movement = null; + Movement.Dispose(); + Movement = null; } - if (commandsManager != null) + if (CommandsManager != null) { - commandsManager.Dispose(); - commandsManager = null; + CommandsManager.Dispose(); + CommandsManager = null; } if (ContextActionManager != null) { ContextActionManager.Dispose(); ContextActionManager = null; } - if (mediaManager != null) + if (MediaManager != null) { - mediaManager.Dispose(); - mediaManager = null; + MediaManager.Dispose(); + MediaManager = null; } - if (state != null) + if (State != null) { - state.Dispose(); - state = null; + State.Dispose(); + State = null; } - if (netcom != null) + if (Netcom != null) { - netcom.Dispose(); - netcom = null; + Netcom.Dispose(); + Netcom = null; } - if (mainForm != null) + if (MainForm != null) { - mainForm.Load -= new EventHandler(mainForm_Load); + MainForm.Load -= mainForm_Load; } Logger.Log("RadegastInstance finished cleaning up.", Helpers.LogLevel.Debug); } void mainForm_Load(object sender, EventArgs e) { - pluginManager.StartPlugins(); + try + { + var pluginDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + PluginManager.LoadPluginsInDirectory(pluginDirectory); + } + catch (Exception ex) + { + Logger.Log($"ERROR scanning and loading plugins: {ex}", Helpers.LogLevel.Warning); + } } void netcom_ClientConnected(object sender, EventArgs e) { - client.Self.RequestMuteList(); + Client.Self.RequestMuteList(); } void Network_LoginProgress(object sender, LoginProgressEventArgs e) { - if (e.Status == LoginStatus.ConnectingToSim) + if (e.Status != LoginStatus.ConnectingToSim) return; + try { - try - { - if (!Directory.Exists(ClientDir)) - { - Directory.CreateDirectory(ClientDir); - } - clientSettings = new Settings(Path.Combine(ClientDir, "client_settings.xml")); - } - catch (Exception ex) + if (!Directory.Exists(ClientDir)) { - Logger.Log("Failed to create client directory", Helpers.LogLevel.Warning, ex); + Directory.CreateDirectory(ClientDir); } + ClientSettings = new Settings(Path.Combine(ClientDir, "client_settings.xml")); + } + catch (Exception ex) + { + Logger.Log("Failed to create client directory", Helpers.LogLevel.Warning, ex); } } - /// /// Fetches avatar name /// @@ -603,41 +525,34 @@ public string getAvatarName(UUID key) void Groups_GroupsChanged(object sender, EventArgs e) { - client.Groups.RequestCurrentGroups(); + Client.Groups.RequestCurrentGroups(); } public static string SafeFileName(string fileName) { - foreach (char lDisallowed in Path.GetInvalidFileNameChars()) - { - fileName = fileName.Replace(lDisallowed.ToString(), "_"); - } - - return fileName; + return Path.GetInvalidFileNameChars().Aggregate(fileName, (current, lDisallowed) => current.Replace(lDisallowed.ToString(), "_")); } public string ChatFileName(string session) { - string fileName = session; - - foreach (char lDisallowed in System.IO.Path.GetInvalidFileNameChars()) - { - fileName = fileName.Replace(lDisallowed.ToString(), "_"); - } - - return Path.Combine(ClientDir, fileName); + string dir = GlobalSettings["chat_log_dir"] && !string.IsNullOrWhiteSpace(GlobalSettings["chat_log_dir"].AsString()) + ? Path.Combine(GlobalSettings["chat_log_dir"].AsString(), !string.IsNullOrEmpty(Client?.Self?.Name) + ? Path.Combine(UserDir, Client.Self.Name) : Environment.CurrentDirectory) + : ClientDir; + string fileName = SafeFileName(session); + return Path.Combine(dir, fileName); } - public void LogClientMessage(string sessioName, string message) + public void LogClientMessage(string sessionName, string message) { - if (globalSettings["disable_chat_im_log"]) return; + if (GlobalSettings["disable_chat_im_log"]) return; - lock (this) + lock (_lockChatLog) { try { - File.AppendAllText(ChatFileName(sessioName), - DateTime.Now.ToString("yyyy-MM-dd [HH:mm:ss] ") + message + Environment.NewLine); + File.AppendAllText(ChatFileName(sessionName), + DateTime.Now.ToString("[yyyy/MM/dd HH:mm:ss] ") + message + Environment.NewLine); } catch (Exception) { } } @@ -645,53 +560,34 @@ public void LogClientMessage(string sessioName, string message) void Groups_CurrentGroups(object sender, CurrentGroupsEventArgs e) { - this.groups = e.Groups; + Groups = e.Groups; } private void InitializeLoggingAndConfig() { try { - userDir = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData), Properties.Resources.ProgramName); - if (!Directory.Exists(userDir)) + UserDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), Properties.Resources.ProgramName); + if (!Directory.Exists(UserDir)) { - Directory.CreateDirectory(userDir); + Directory.CreateDirectory(UserDir); } } catch (Exception) { - userDir = System.Environment.CurrentDirectory; - }; - - globalLogFile = Path.Combine(userDir, Properties.Resources.ProgramName + ".log"); - globalSettings = new Settings(Path.Combine(userDir, "settings.xml")); - frmSettings.InitSettigs(globalSettings, monoRuntime); - } - - public GridClient Client - { - get { return client; } - } - - public RadegastNetcom Netcom - { - get { return netcom; } - } + UserDir = Environment.CurrentDirectory; + } - public StateManager State - { - get { return state; } + GlobalLogFile = Path.Combine(UserDir, Properties.Resources.ProgramName + ".log"); + GlobalSettings = new Settings(Path.Combine(UserDir, "settings.xml")); + frmSettings.InitSettings(GlobalSettings); } - public frmMain MainForm - { - get { return mainForm; } - } - - public TabsConsole TabConsole - { - get { return mainForm.TabConsole; } - } + public GridClient Client { get; private set; } + public Netcom Netcom { get; private set; } + public StateManager State { get; private set; } + public frmMain MainForm { get; } + public TabsConsole TabConsole => MainForm.TabConsole; public void HandleThreadException(object sender, ThreadExceptionEventArgs e) { @@ -699,31 +595,32 @@ public void HandleThreadException(object sender, ThreadExceptionEventArgs e) + e.Exception.Message + Environment.NewLine + e.Exception.StackTrace + Environment.NewLine, Helpers.LogLevel.Error, - client); + Client); } #region Crash reporting FileStream MarkerLock = null; + private readonly object _lockChatLog = new object(); public bool AnotherInstanceRunning() { // We have successfuly obtained lock - if (MarkerLock != null && MarkerLock.CanWrite) + if (MarkerLock?.CanWrite == true) { Logger.Log("No other instances detected, marker file already locked", Helpers.LogLevel.Debug); - return false || MonoRuntime; + return MonoRuntime; } try { MarkerLock = new FileStream(CrashMarkerFileName, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); - Logger.Log(string.Format("Successfully created and locked marker file {0}", CrashMarkerFileName), Helpers.LogLevel.Debug); - return false || MonoRuntime; + Logger.Log($"Successfully created and locked marker file {CrashMarkerFileName}", Helpers.LogLevel.Debug); + return MonoRuntime; } catch { MarkerLock = null; - Logger.Log(string.Format("Another instance detected, marker fils {0} locked", CrashMarkerFileName), Helpers.LogLevel.Debug); + Logger.Log($"Another instance detected, marker fils {CrashMarkerFileName} locked", Helpers.LogLevel.Debug); return true; } } @@ -733,19 +630,19 @@ public LastExecStatus GetLastExecStatus() // Crash marker file found and is not locked by us if (File.Exists(CrashMarkerFileName) && MarkerLock == null) { - Logger.Log(string.Format("Found crash marker file {0}", CrashMarkerFileName), Helpers.LogLevel.Debug); + Logger.Log($"Found crash marker file {CrashMarkerFileName}", Helpers.LogLevel.Debug); return LastExecStatus.OtherCrash; } else { - Logger.Log(string.Format("No crash marker file {0} found", CrashMarkerFileName), Helpers.LogLevel.Debug); + Logger.Log($"No crash marker file {CrashMarkerFileName} found", Helpers.LogLevel.Debug); return LastExecStatus.Normal; } } public void MarkStartExecution() { - Logger.Log(string.Format("Marking start of execution run, creating file: {0}", CrashMarkerFileName), Helpers.LogLevel.Debug); + Logger.Log($"Marking start of execution run, creating file: {CrashMarkerFileName}", Helpers.LogLevel.Debug); try { File.Create(CrashMarkerFileName).Dispose(); @@ -755,7 +652,7 @@ public void MarkStartExecution() public void MarkEndExecution() { - Logger.Log(string.Format("Marking end of execution run, deleting file: {0}", CrashMarkerFileName), Helpers.LogLevel.Debug); + Logger.Log($"Marking end of execution run, deleting file: {CrashMarkerFileName}", Helpers.LogLevel.Debug); try { if (MarkerLock != null) @@ -792,11 +689,11 @@ void ExportDAEHander(object sender, EventArgs e) void CopyObjectUUIDHandler(object sender, EventArgs e) { - if (mainForm.InvokeRequired) + if (MainForm.InvokeRequired) { - if (mainForm.IsHandleCreated || !MonoRuntime) + if (MainForm.IsHandleCreated || !MonoRuntime) { - mainForm.Invoke(new MethodInvoker(() => CopyObjectUUIDHandler(sender, e))); + MainForm.Invoke(new MethodInvoker(() => CopyObjectUUIDHandler(sender, e))); } return; } @@ -811,16 +708,13 @@ void CopyObjectUUIDHandler(object sender, EventArgs e) #region Event classes public class ClientChangedEventArgs : EventArgs { - private GridClient m_OldClient; - private GridClient m_Client; - - public GridClient OldClient { get { return m_OldClient; } } - public GridClient Client { get { return m_Client; } } + public GridClient OldClient { get; } + public GridClient Client { get; } public ClientChangedEventArgs(GridClient OldClient, GridClient Client) { - m_OldClient = OldClient; - m_Client = Client; + this.OldClient = OldClient; + this.Client = Client; } } #endregion Event classes diff --git a/Radegast/Core/RadegastLogger.cs b/Radegast/Core/RadegastLogger.cs index 7c430592d..07b586c47 100644 --- a/Radegast/Core/RadegastLogger.cs +++ b/Radegast/Core/RadegastLogger.cs @@ -1,33 +1,23 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.IO; using log4net.Appender; @@ -68,7 +58,7 @@ protected override void Append(LoggingEvent le) if (m_Log != null) OnLog(this, new LogEventArgs(le)); - Console.Write("{0} [", le.TimeStamp.ToString("HH:mm:ss")); + Console.Write("{0:HH:mm:ss} [", le.TimeStamp); WriteColorText(DeriveColor(le.Level.Name), le.Level.Name); Console.Write("]: - "); diff --git a/Radegast/Core/RadegastMisc.cs b/Radegast/Core/RadegastMisc.cs index 2dfb643bc..3b3a33d7d 100644 --- a/Radegast/Core/RadegastMisc.cs +++ b/Radegast/Core/RadegastMisc.cs @@ -1,33 +1,23 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System.Collections.Generic; namespace Radegast diff --git a/Radegast/Core/RadegastMovement.cs b/Radegast/Core/RadegastMovement.cs index afdf709b4..64e908955 100644 --- a/Radegast/Core/RadegastMovement.cs +++ b/Radegast/Core/RadegastMovement.cs @@ -1,33 +1,23 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Timers; using OpenMetaverse; @@ -37,19 +27,21 @@ namespace Radegast public class RadegastMovement : IDisposable { private RadegastInstance instance; - private GridClient client { get { return instance.Client; } } + private GridClient client => instance.Client; private Timer timer; private Vector3 forward = new Vector3(1, 0, 0); private bool turningLeft = false; private bool turningRight = false; private bool movingForward = false; private bool movingBackward = false; + private bool crouching = false; + private bool flying = false; + private bool jumping = false; + private bool running = false; public bool TurningLeft { - get { - return turningLeft; - } + get => turningLeft; set { turningLeft = value; if (value) { @@ -65,10 +57,7 @@ public bool TurningLeft public bool TurningRight { - get - { - return turningRight; - } + get => turningRight; set { turningRight = value; @@ -85,10 +74,7 @@ public bool TurningRight public bool MovingForward { - get - { - return movingForward; - } + get => movingForward; set { movingForward = value; @@ -104,10 +90,7 @@ public bool MovingForward public bool MovingBackward { - get - { - return movingBackward; - } + get => movingBackward; set { movingBackward = value; @@ -122,11 +105,63 @@ public bool MovingBackward } } + public bool Jump + { + get => jumping; + set + { + jumping = value; + client.Self.Jump(value); + } + } + + public bool Crouch + { + get => crouching; + set + { + crouching = value; + client.Self.Crouch(value); + } + } + + public bool Fly + { + get => flying; + set + { + flying = value; + client.Self.Fly(value); + } + } + + public bool AlwaysRun + { + get => running; + set + { + running = value; + client.Self.Movement.AlwaysRun = value; + } + } + + public bool ToggleFlight() + { + Fly = !Fly; + return Fly; + } + + public bool ToggleAlwaysRun() + { + AlwaysRun = !AlwaysRun; + return AlwaysRun; + } + public RadegastMovement(RadegastInstance instance) { this.instance = instance; - timer = new System.Timers.Timer(100); - timer.Elapsed +=new ElapsedEventHandler(timer_Elapsed); + timer = new Timer(100); + timer.Elapsed +=timer_Elapsed; timer.Enabled = false; } diff --git a/Radegast/Core/RichTextBoxPrinter.cs b/Radegast/Core/RichTextBoxPrinter.cs index 77b880bc1..cfc64c019 100644 --- a/Radegast/Core/RichTextBoxPrinter.cs +++ b/Radegast/Core/RichTextBoxPrinter.cs @@ -1,35 +1,24 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; -using System.Text; using System.Text.RegularExpressions; using System.Drawing; using System.Windows.Forms; @@ -74,7 +63,6 @@ public void InsertLink(string text, string hyperlink) private void FindURLs(string text) { - StringBuilder sb = new StringBuilder(); string[] lineParts = urlRegex.Split(text); int linePartIndex; @@ -151,50 +139,26 @@ public void ClearText() public string Content { - get - { - return rtb.Text; - } - set - { - rtb.Text = value; - } + get => rtb.Text; + set => rtb.Text = value; } - public System.Drawing.Color ForeColor + public Color ForeColor { - get - { - return rtb.SelectionColor; - } - set - { - rtb.SelectionColor = value; - } + get => rtb.SelectionColor; + set => rtb.SelectionColor = value; } - public System.Drawing.Color BackColor + public Color BackColor { - get - { - return rtb.SelectionBackColor; - } - set - { - rtb.SelectionBackColor = value; - } + get => rtb.SelectionBackColor; + set => rtb.SelectionBackColor = value; } - public System.Drawing.Font Font + public Font Font { - get - { - return rtb.SelectionFont; - } - set - { - rtb.SelectionFont = value; - } + get => rtb.SelectionFont; + set => rtb.SelectionFont = value; } #endregion diff --git a/Radegast/Core/Settings.cs b/Radegast/Core/Settings.cs index e86c8da19..29e36bae2 100644 --- a/Radegast/Core/Settings.cs +++ b/Radegast/Core/Settings.cs @@ -1,33 +1,23 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2023, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections.Generic; using System.Collections; @@ -36,8 +26,8 @@ using OpenMetaverse; using OpenMetaverse.StructuredData; using System.Drawing; -using System.Web.Script.Serialization; using System.ComponentModel; +using System.Runtime.Serialization; namespace Radegast { @@ -151,16 +141,16 @@ public class Settings : IDictionary public class FontSetting { - [ScriptIgnoreAttribute] + [IgnoreDataMember] public static readonly Font DefaultFont = new Font(FontFamily.GenericSansSerif, 8.0f); - [ScriptIgnoreAttribute] + [IgnoreDataMember] public Font Font; - [ScriptIgnoreAttribute] + [IgnoreDataMember] public Color ForeColor; - [ScriptIgnoreAttribute] + [IgnoreDataMember] public Color BackColor; @@ -168,66 +158,37 @@ public class FontSetting public string ForeColorString { - get - { - if (ForeColor != null) - { - return ColorTranslator.ToHtml(ForeColor); - } - else - { - return ColorTranslator.ToHtml(SystemColors.ControlText); - } - } - set - { - ForeColor = ColorTranslator.FromHtml(value); - } + get => ColorTranslator.ToHtml(ForeColor); + set => ForeColor = ColorTranslator.FromHtml(value); } public string BackColorString { - get - { - if (BackColor != null) - { - return ColorTranslator.ToHtml(BackColor); - } - else - { - return ColorTranslator.ToHtml(SystemColors.ControlText); - } - } - set - { - BackColor = ColorTranslator.FromHtml(value); - } + get => ColorTranslator.ToHtml(BackColor); + set => BackColor = ColorTranslator.FromHtml(value); } public string FontString { get { - if (this.Font != null) + if (Font != null) { TypeConverter converter = TypeDescriptor.GetConverter(typeof(Font)); - return converter.ConvertToString(this.Font); - } - else - { - return null; + return converter.ConvertToString(Font); } + return null; } set { try { TypeConverter converter = TypeDescriptor.GetConverter(typeof(Font)); - this.Font = converter.ConvertFromString(value) as Font; + Font = converter.ConvertFromString(value) as Font; } catch (Exception) { - this.Font = DefaultFont; + Font = DefaultFont; } } @@ -250,7 +211,7 @@ public Settings(string fileName) } catch { - Logger.DebugLog("Failed openning setting file: " + fileName); + Logger.DebugLog("Failed opening Settings file: " + fileName); SettingsData = new OSDMap(); Save(); } @@ -264,7 +225,7 @@ public void Save() } catch (Exception ex) { - Logger.Log("Failed saving settings", Helpers.LogLevel.Warning, ex); + Logger.Log("Failed to save settings", Helpers.LogLevel.Warning, ex); } } @@ -300,21 +261,19 @@ private void FireEvent(string key, OSD val) #region IDictionary Implementation - public int Count { get { return SettingsData.Count; } } - public bool IsReadOnly { get { return false; } } - public ICollection Keys { get { return SettingsData.Keys; } } - public ICollection Values { get { return SettingsData.Values; } } + public int Count => SettingsData.Count; + public bool IsReadOnly => false; + public ICollection Keys => SettingsData.Keys; + public ICollection Values => SettingsData.Values; + public OSD this[string key] { - get - { - return SettingsData[key]; - } + get => SettingsData[key]; set { if (string.IsNullOrEmpty(key)) { - Logger.DebugLog("Warning: trying to set an emprty setting: " + Environment.StackTrace.ToString()); + Logger.DebugLog("Warning: trying to set an emprty setting: " + Environment.StackTrace); } else { @@ -383,7 +342,7 @@ public bool Remove(KeyValuePair kvp) return ret; } - public System.Collections.IDictionaryEnumerator GetEnumerator() + public IDictionaryEnumerator GetEnumerator() { return SettingsData.GetEnumerator(); } @@ -404,8 +363,8 @@ IEnumerator IEnumerable.GetEnumerator() public class SettingsEventArgs : EventArgs { - public string Key = string.Empty; - public OSD Value = new OSD(); + public string Key; + public OSD Value; public SettingsEventArgs(string key, OSD val) { diff --git a/Radegast/Core/SlUriParser.cs b/Radegast/Core/SlUriParser.cs index 425c9e307..2b339edda 100644 --- a/Radegast/Core/SlUriParser.cs +++ b/Radegast/Core/SlUriParser.cs @@ -1,3 +1,23 @@ +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Text.RegularExpressions; using System.Threading; @@ -247,7 +267,7 @@ private string GetAgentName(UUID agentID, ResolveType nameType) using (ManualResetEvent gotName = new ManualResetEvent(false)) { - EventHandler handler = (object sender, UUIDNameReplyEventArgs e) => + EventHandler handler = (sender, e) => { if (e.Names.ContainsKey(agentID)) { @@ -303,7 +323,7 @@ private string GetGroupName(UUID groupID) using (ManualResetEvent gotName = new ManualResetEvent(false)) { - EventHandler handler = (object sender, GroupNamesEventArgs e) => + EventHandler handler = (sender, e) => { if (e.GroupNames.ContainsKey(groupID)) { @@ -341,7 +361,7 @@ private string GetParcelName(UUID parcelID) using (ManualResetEvent gotName = new ManualResetEvent(false)) { - EventHandler handler = (object sender, ParcelInfoReplyEventArgs e) => + EventHandler handler = (sender, e) => { if (e.Parcel.ID == parcelID) { diff --git a/Radegast/Core/StateManager.cs b/Radegast/Core/StateManager.cs index 4387a5791..5e4c7f37b 100644 --- a/Radegast/Core/StateManager.cs +++ b/Radegast/Core/StateManager.cs @@ -1,33 +1,23 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections.Generic; using System.Timers; @@ -36,7 +26,7 @@ using OpenMetaverse; using Radegast.Automation; -using Radegast.Netcom; +using Radegast; namespace Radegast { @@ -48,9 +38,9 @@ public class KnownHeading public KnownHeading(string id, string name, Quaternion heading) { - this.ID = id; - this.Name = name; - this.Heading = heading; + ID = id; + Name = name; + Heading = heading; } public override string ToString() @@ -64,25 +54,17 @@ public class StateManager : IDisposable public Parcel Parcel { get; set; } private RadegastInstance instance; - private GridClient client { get { return instance.Client; } } - private RadegastNetcom netcom { get { return instance.Netcom; } } + private GridClient Client => instance.Client; + private Radegast.Netcom Netcom => instance.Netcom; - private bool typing = false; private bool away = false; - private bool busy = false; private bool flying = false; private bool alwaysrun = false; private bool sitting = false; - private bool following = false; - private string followName = string.Empty; - private float followDistance = 3.0f; private UUID followID; private bool displayEndWalk = false; - private UUID awayAnimationID = new UUID("fd037134-85d4-f241-72c6-4f42164fedee"); - private UUID busyAnimationID = new UUID("efcf670c2d188128973a034ebc806b67"); - private UUID typingAnimationID = new UUID("c541c47f-e0c0-058b-ad1a-d6ae3a4584d9"); internal static Random rnd = new Random(); private System.Threading.Timer lookAtTimer; @@ -105,33 +87,33 @@ public class StateManager : IDisposable public event EventHandler SitStateChanged; static List m_Headings; - public static List KnownHeadings - { - get - { - if (m_Headings == null) - { - m_Headings = new List(16); - m_Headings.Add(new KnownHeading("E", "East", new Quaternion(0.00000f, 0.00000f, 0.00000f, 1.00000f))); - m_Headings.Add(new KnownHeading("ENE", "East by Northeast", new Quaternion(0.00000f, 0.00000f, 0.19509f, 0.98079f))); - m_Headings.Add(new KnownHeading("NE", "Northeast", new Quaternion(0.00000f, 0.00000f, 0.38268f, 0.92388f))); - m_Headings.Add(new KnownHeading("NNE", "North by Northeast", new Quaternion(0.00000f, 0.00000f, 0.55557f, 0.83147f))); - m_Headings.Add(new KnownHeading("N", "North", new Quaternion(0.00000f, 0.00000f, 0.70711f, 0.70711f))); - m_Headings.Add(new KnownHeading("NNW", "North by Northwest", new Quaternion(0.00000f, 0.00000f, 0.83147f, 0.55557f))); - m_Headings.Add(new KnownHeading("NW", "Nortwest", new Quaternion(0.00000f, 0.00000f, 0.92388f, 0.38268f))); - m_Headings.Add(new KnownHeading("WNW", "West by Northwest", new Quaternion(0.00000f, 0.00000f, 0.98079f, 0.19509f))); - m_Headings.Add(new KnownHeading("W", "West", new Quaternion(0.00000f, 0.00000f, 1.00000f, -0.00000f))); - m_Headings.Add(new KnownHeading("WSW", "West by Southwest", new Quaternion(0.00000f, 0.00000f, 0.98078f, -0.19509f))); - m_Headings.Add(new KnownHeading("SW", "Southwest", new Quaternion(0.00000f, 0.00000f, 0.92388f, -0.38268f))); - m_Headings.Add(new KnownHeading("SSW", "South by Southwest", new Quaternion(0.00000f, 0.00000f, 0.83147f, -0.55557f))); - m_Headings.Add(new KnownHeading("S", "South", new Quaternion(0.00000f, 0.00000f, 0.70711f, -0.70711f))); - m_Headings.Add(new KnownHeading("SSE", "South by Southeast", new Quaternion(0.00000f, 0.00000f, 0.55557f, -0.83147f))); - m_Headings.Add(new KnownHeading("SE", "Southeast", new Quaternion(0.00000f, 0.00000f, 0.38268f, -0.92388f))); - m_Headings.Add(new KnownHeading("ESE", "East by Southeast", new Quaternion(0.00000f, 0.00000f, 0.19509f, -0.98078f))); - } - return m_Headings; - } - } + public static List KnownHeadings => m_Headings ?? (m_Headings = new List(16) + { + new KnownHeading("E", "East", new Quaternion(0.00000f, 0.00000f, 0.00000f, 1.00000f)), + new KnownHeading("ENE", "East by Northeast", + new Quaternion(0.00000f, 0.00000f, 0.19509f, 0.98079f)), + new KnownHeading("NE", "Northeast", new Quaternion(0.00000f, 0.00000f, 0.38268f, 0.92388f)), + new KnownHeading("NNE", "North by Northeast", + new Quaternion(0.00000f, 0.00000f, 0.55557f, 0.83147f)), + new KnownHeading("N", "North", new Quaternion(0.00000f, 0.00000f, 0.70711f, 0.70711f)), + new KnownHeading("NNW", "North by Northwest", + new Quaternion(0.00000f, 0.00000f, 0.83147f, 0.55557f)), + new KnownHeading("NW", "Nortwest", new Quaternion(0.00000f, 0.00000f, 0.92388f, 0.38268f)), + new KnownHeading("WNW", "West by Northwest", + new Quaternion(0.00000f, 0.00000f, 0.98079f, 0.19509f)), + new KnownHeading("W", "West", new Quaternion(0.00000f, 0.00000f, 1.00000f, -0.00000f)), + new KnownHeading("WSW", "West by Southwest", + new Quaternion(0.00000f, 0.00000f, 0.98078f, -0.19509f)), + new KnownHeading("SW", "Southwest", new Quaternion(0.00000f, 0.00000f, 0.92388f, -0.38268f)), + new KnownHeading("SSW", "South by Southwest", + new Quaternion(0.00000f, 0.00000f, 0.83147f, -0.55557f)), + new KnownHeading("S", "South", new Quaternion(0.00000f, 0.00000f, 0.70711f, -0.70711f)), + new KnownHeading("SSE", "South by Southeast", + new Quaternion(0.00000f, 0.00000f, 0.55557f, -0.83147f)), + new KnownHeading("SE", "Southeast", new Quaternion(0.00000f, 0.00000f, 0.38268f, -0.92388f)), + new KnownHeading("ESE", "East by Southeast", + new Quaternion(0.00000f, 0.00000f, 0.19509f, -0.98078f)) + }); public static Vector3 RotToEuler(Quaternion r) { @@ -192,52 +174,51 @@ public static KnownHeading ClosestKnownHeading(int degrees) public StateManager(RadegastInstance instance) { this.instance = instance; - this.instance.ClientChanged += new EventHandler(instance_ClientChanged); + this.instance.ClientChanged += Instance_ClientChanged; KnownAnimations = Animations.ToDictionary(); - autosit = new AutoSit(this.instance); - pseudohome = new PseudoHome(this.instance); - lslHelper = new LSLHelper(this.instance); + AutoSit = new AutoSit(this.instance); + PseudoHome = new PseudoHome(this.instance); + LSLHelper = new LSLHelper(this.instance); - beamTimer = new System.Timers.Timer(); - beamTimer.Enabled = false; - beamTimer.Elapsed += new ElapsedEventHandler(beamTimer_Elapsed); + beamTimer = new System.Timers.Timer {Enabled = false}; + beamTimer.Elapsed += BeamTimer_Elapsed; // Callbacks - netcom.ClientConnected += new EventHandler(netcom_ClientConnected); - netcom.ClientDisconnected += new EventHandler(netcom_ClientDisconnected); - netcom.ChatReceived += new EventHandler(netcom_ChatReceived); - RegisterClientEvents(client); + Netcom.ClientConnected += Netcom_ClientConnected; + Netcom.ClientDisconnected += Netcom_ClientDisconnected; + Netcom.ChatReceived += Netcom_ChatReceived; + RegisterClientEvents(Client); } private void RegisterClientEvents(GridClient client) { - client.Objects.AvatarUpdate += new EventHandler(Objects_AvatarUpdate); - client.Objects.TerseObjectUpdate += new EventHandler(Objects_TerseObjectUpdate); - client.Objects.AvatarSitChanged += new EventHandler(Objects_AvatarSitChanged); - client.Self.AlertMessage += new EventHandler(Self_AlertMessage); - client.Self.TeleportProgress += new EventHandler(Self_TeleportProgress); - client.Network.EventQueueRunning += new EventHandler(Network_EventQueueRunning); - client.Network.SimChanged += new EventHandler(Network_SimChanged); + client.Objects.AvatarUpdate += Objects_AvatarUpdate; + client.Objects.TerseObjectUpdate += Objects_TerseObjectUpdate; + client.Objects.AvatarSitChanged += Objects_AvatarSitChanged; + client.Self.AlertMessage += Self_AlertMessage; + client.Self.TeleportProgress += Self_TeleportProgress; + client.Network.EventQueueRunning += Network_EventQueueRunning; + client.Network.SimChanged += Network_SimChanged; } private void UnregisterClientEvents(GridClient client) { - client.Objects.AvatarUpdate -= new EventHandler(Objects_AvatarUpdate); - client.Objects.TerseObjectUpdate -= new EventHandler(Objects_TerseObjectUpdate); - client.Objects.AvatarSitChanged -= new EventHandler(Objects_AvatarSitChanged); - client.Self.AlertMessage -= new EventHandler(Self_AlertMessage); - client.Self.TeleportProgress -= new EventHandler(Self_TeleportProgress); - client.Network.EventQueueRunning -= new EventHandler(Network_EventQueueRunning); - client.Network.SimChanged -= new EventHandler(Network_SimChanged); + client.Objects.AvatarUpdate -= Objects_AvatarUpdate; + client.Objects.TerseObjectUpdate -= Objects_TerseObjectUpdate; + client.Objects.AvatarSitChanged -= Objects_AvatarSitChanged; + client.Self.AlertMessage -= Self_AlertMessage; + client.Self.TeleportProgress -= Self_TeleportProgress; + client.Network.EventQueueRunning -= Network_EventQueueRunning; + client.Network.SimChanged -= Network_SimChanged; } public void Dispose() { - netcom.ClientConnected -= new EventHandler(netcom_ClientConnected); - netcom.ClientDisconnected -= new EventHandler(netcom_ClientDisconnected); - netcom.ChatReceived -= new EventHandler(netcom_ChatReceived); - UnregisterClientEvents(client); + Netcom.ClientConnected -= Netcom_ClientConnected; + Netcom.ClientDisconnected -= Netcom_ClientDisconnected; + Netcom.ChatReceived -= Netcom_ChatReceived; + UnregisterClientEvents(Client); beamTimer.Dispose(); beamTimer = null; @@ -253,40 +234,37 @@ public void Dispose() walkTimer = null; } - if (autosit != null) + if (AutoSit != null) { - autosit.Dispose(); - autosit = null; + AutoSit.Dispose(); + AutoSit = null; } - if (lslHelper == null) + if (LSLHelper != null) { - lslHelper.Dispose(); - lslHelper = null; + LSLHelper.Dispose(); + LSLHelper = null; } } - void instance_ClientChanged(object sender, ClientChangedEventArgs e) + void Instance_ClientChanged(object sender, ClientChangedEventArgs e) { UnregisterClientEvents(e.OldClient); - RegisterClientEvents(client); + RegisterClientEvents(Client); } void Objects_AvatarSitChanged(object sender, AvatarSitChangedEventArgs e) { - if (e.Avatar.LocalID != client.Self.LocalID) return; + if (e.Avatar.LocalID != Client.Self.LocalID) return; sitting = e.SittingOn != 0; - if (client.Self.SittingOn != 0 && !client.Network.CurrentSim.ObjectsPrimitives.ContainsKey(client.Self.SittingOn)) + if (Client.Self.SittingOn != 0 && !Client.Network.CurrentSim.ObjectsPrimitives.ContainsKey(Client.Self.SittingOn)) { - client.Objects.RequestObject(client.Network.CurrentSim, client.Self.SittingOn); + Client.Objects.RequestObject(Client.Network.CurrentSim, Client.Self.SittingOn); } - if (SitStateChanged != null) - { - SitStateChanged(this, new SitEventArgs(this.sitting)); - } + SitStateChanged?.Invoke(this, new SitEventArgs(sitting)); } /// @@ -300,14 +278,14 @@ public bool TryFindAvatar(UUID person, out Vector3 position) Simulator sim; if (!TryFindAvatar(person, out sim, out position)) return false; // same sim? - if (sim == client.Network.CurrentSim) return true; + if (sim == Client.Network.CurrentSim) return true; position = ToLocalPosition(sim.Handle, position); return true; } public Vector3 ToLocalPosition(ulong handle, Vector3 position) { - Vector3d diff = ToVector3D(handle, position) - client.Self.GlobalPosition; + Vector3d diff = ToVector3D(handle, position) - Client.Self.GlobalPosition; position = new Vector3((float) diff.X, (float) diff.Y, (float) diff.Z) - position; return position; } @@ -334,12 +312,13 @@ public bool TryFindAvatar(UUID person, out Simulator sim, out Vector3 position) { return TryFindPrim(person, out sim, out position, true); } + public bool TryFindPrim(UUID person, out Simulator sim, out Vector3 position, bool onlyAvatars) { Simulator[] Simulators = null; - lock (client.Network.Simulators) + lock (Client.Network.Simulators) { - Simulators = client.Network.Simulators.ToArray(); + Simulators = Client.Network.Simulators.ToArray(); } sim = null; position = Vector3.Zero; @@ -349,7 +328,7 @@ public bool TryFindPrim(UUID person, out Simulator sim, out Vector3 position, bo // First try the object tracker foreach (var s in Simulators) { - avi = s.ObjectsAvatars.Find((Avatar av) => { return av.ID == person; }); + avi = s.ObjectsAvatars.Find(av => av.ID == person); if (avi != null) { sim = s; @@ -360,7 +339,7 @@ public bool TryFindPrim(UUID person, out Simulator sim, out Vector3 position, bo { foreach (var s in Simulators) { - avi = s.ObjectsPrimitives.Find((Primitive av) => { return av.ID == person; }); + avi = s.ObjectsPrimitives.Find(av => av.ID == person); if (avi != null) { sim = s; @@ -396,21 +375,18 @@ public bool TryFindPrim(UUID person, out Simulator sim, out Vector3 position, bo } } - if (position.Z > 0.1f) - return true; - else - return false; + return position.Z > 0.1f; } public bool TryLocatePrim(Primitive avi, out Simulator sim, out Vector3 position) { Simulator[] Simulators = null; - lock (client.Network.Simulators) + lock (Client.Network.Simulators) { - Simulators = client.Network.Simulators.ToArray(); + Simulators = Client.Network.Simulators.ToArray(); } - sim = client.Network.CurrentSim; + sim = Client.Network.CurrentSim; position = Vector3.Zero; { foreach (var s in Simulators) @@ -437,10 +413,7 @@ public bool TryLocatePrim(Primitive avi, out Simulator sim, out Vector3 position } } } - if (position.Z > 0.1f) - return true; - else - return false; + return position.Z > 0.1f; } /// @@ -450,7 +423,7 @@ public bool TryLocatePrim(Primitive avi, out Simulator sim, out Vector3 position /// Move using teleport public void MoveTo(Vector3 target, bool useTP) { - MoveTo(client.Network.CurrentSim, target, useTP); + MoveTo(Client.Network.CurrentSim, target, useTP); } /// @@ -465,12 +438,12 @@ public void MoveTo(Simulator sim, Vector3 target, bool useTP) if (useTP) { - client.Self.RequestTeleport(sim.Handle, target); + Client.Self.RequestTeleport(sim.Handle, target); } else { displayEndWalk = true; - client.Self.Movement.TurnToward(target); + Client.Self.Movement.TurnToward(target); WalkTo(GlobalPosition(sim, target)); } } @@ -478,13 +451,13 @@ public void MoveTo(Simulator sim, Vector3 target, bool useTP) public void SetRandomHeading() { - client.Self.Movement.UpdateFromHeading(Utils.TWO_PI * rnd.NextDouble(), true); + Client.Self.Movement.UpdateFromHeading(Utils.TWO_PI * rnd.NextDouble(), true); LookInFront(); } void Network_EventQueueRunning(object sender, EventQueueRunningEventArgs e) { - if (e.Simulator == client.Network.CurrentSim) + if (e.Simulator == Client.Network.CurrentSim) { SetRandomHeading(); } @@ -492,41 +465,41 @@ void Network_EventQueueRunning(object sender, EventQueueRunningEventArgs e) void Network_SimChanged(object sender, SimChangedEventArgs e) { - WorkPool.QueueUserWorkItem(sync => + ThreadPool.QueueUserWorkItem(sync => { Thread.Sleep(15 * 1000); - autosit.TrySit(); - pseudohome.ETGoHome(); + AutoSit.TrySit(); + PseudoHome.ETGoHome(); }); - client.Self.Movement.SetFOVVerticalAngle(FOVVerticalAngle); + Client.Self.Movement.SetFOVVerticalAngle(FOVVerticalAngle); } private UUID teleportEffect = UUID.Random(); void Self_TeleportProgress(object sender, TeleportEventArgs e) { - if (!client.Network.Connected) return; - - if (e.Status == TeleportStatus.Progress) - { - client.Self.SphereEffect(client.Self.GlobalPosition, Color4.White, 4f, teleportEffect); - } - - if (e.Status == TeleportStatus.Finished) - { - client.Self.SphereEffect(Vector3d.Zero, Color4.White, 0f, teleportEffect); - SetRandomHeading(); - } + if (!Client.Network.Connected) return; - if (e.Status == TeleportStatus.Failed) + switch (e.Status) { - client.Self.SphereEffect(Vector3d.Zero, Color4.White, 0f, teleportEffect); + case TeleportStatus.Progress: + instance.MediaManager.PlayUISound(UISounds.Teleport); + Client.Self.SphereEffect(Client.Self.GlobalPosition, Color4.White, 4f, teleportEffect); + break; + case TeleportStatus.Finished: + Client.Self.SphereEffect(Vector3d.Zero, Color4.White, 0f, teleportEffect); + SetRandomHeading(); + break; + case TeleportStatus.Failed: + instance.MediaManager.PlayUISound(UISounds.Error); + Client.Self.SphereEffect(Vector3d.Zero, Color4.White, 0f, teleportEffect); + break; } } - void netcom_ClientDisconnected(object sender, DisconnectedEventArgs e) + void Netcom_ClientDisconnected(object sender, DisconnectedEventArgs e) { - typing = away = busy = walking = false; + IsTyping = away = IsBusy = IsWalking = false; if (lookAtTimer != null) { @@ -536,24 +509,24 @@ void netcom_ClientDisconnected(object sender, DisconnectedEventArgs e) } - void netcom_ClientConnected(object sender, EventArgs e) + void Netcom_ClientConnected(object sender, EventArgs e) { if (!instance.GlobalSettings.ContainsKey("draw_distance")) { instance.GlobalSettings["draw_distance"] = 48; } - client.Self.Movement.Camera.Far = instance.GlobalSettings["draw_distance"]; + Client.Self.Movement.Camera.Far = instance.GlobalSettings["draw_distance"]; if (lookAtTimer == null) { - lookAtTimer = new System.Threading.Timer(new TimerCallback(lookAtTimerTick), null, Timeout.Infinite, Timeout.Infinite); + lookAtTimer = new System.Threading.Timer(LookAtTimerTick, null, Timeout.Infinite, Timeout.Infinite); } } void Objects_AvatarUpdate(object sender, AvatarUpdateEventArgs e) { - if (e.Avatar.LocalID == client.Self.LocalID) + if (e.Avatar.LocalID == Client.Self.LocalID) { SetDefaultCamera(); } @@ -563,20 +536,20 @@ void Objects_TerseObjectUpdate(object sender, TerseObjectUpdateEventArgs e) { if (!e.Update.Avatar) return; - if (e.Prim.LocalID == client.Self.LocalID) + if (e.Prim.LocalID == Client.Self.LocalID) { SetDefaultCamera(); } - if (!following) return; + if (!IsFollowing) return; Avatar av; - client.Network.CurrentSim.ObjectsAvatars.TryGetValue(e.Update.LocalID, out av); + Client.Network.CurrentSim.ObjectsAvatars.TryGetValue(e.Update.LocalID, out av); if (av == null) return; if (av.ID == followID) { - Vector3 pos = AvatarPosition(client.Network.CurrentSim, av); + Vector3 pos = AvatarPosition(Client.Network.CurrentSim, av); FollowUpdate(pos); } @@ -584,17 +557,17 @@ void Objects_TerseObjectUpdate(object sender, TerseObjectUpdateEventArgs e) void FollowUpdate(Vector3 pos) { - if (Vector3.Distance(pos, client.Self.SimPosition) > followDistance) + if (Vector3.Distance(pos, Client.Self.SimPosition) > FollowDistance) { - Vector3 target = pos + Vector3.Normalize(client.Self.SimPosition - pos) * (followDistance - 1f); - client.Self.AutoPilotCancel(); - Vector3d glb = GlobalPosition(client.Network.CurrentSim, target); - client.Self.AutoPilot(glb.X, glb.Y, glb.Z); + Vector3 target = pos + Vector3.Normalize(Client.Self.SimPosition - pos) * (FollowDistance - 1f); + Client.Self.AutoPilotCancel(); + Vector3d glb = GlobalPosition(Client.Network.CurrentSim, target); + Client.Self.AutoPilot(glb.X, glb.Y, glb.Z); } else { - client.Self.AutoPilotCancel(); - client.Self.Movement.TurnToward(pos); + Client.Self.AutoPilotCancel(); + Client.Self.Movement.TurnToward(pos); } } @@ -602,7 +575,7 @@ public void SetDefaultCamera() { if (CameraTracksOwnAvatar) { - if (client.Self.SittingOn != 0 && !client.Network.CurrentSim.ObjectsPrimitives.ContainsKey(client.Self.SittingOn)) + if (Client.Self.SittingOn != 0 && !Client.Network.CurrentSim.ObjectsPrimitives.ContainsKey(Client.Self.SittingOn)) { // We are sitting but don't have the information about the object we are sitting on // Sim seems to ignore RequestMutlipleObjects message @@ -610,11 +583,10 @@ public void SetDefaultCamera() } else { - Vector3 pos = client.Self.SimPosition + DefaultCameraOffset * client.Self.Movement.BodyRotation; + Vector3 pos = Client.Self.SimPosition + DefaultCameraOffset * Client.Self.Movement.BodyRotation; //Logger.Log("Setting camera position to " + pos.ToString(), Helpers.LogLevel.Debug); - client.Self.Movement.Camera.LookAt( - pos, - client.Self.SimPosition + Client.Self.Movement.Camera.LookAt( + pos, Client.Self.SimPosition ); } } @@ -623,7 +595,7 @@ public void SetDefaultCamera() public Quaternion AvatarRotation(Simulator sim, UUID avID) { Quaternion rot = Quaternion.Identity; - Avatar av = sim.ObjectsAvatars.Find((Avatar a) => { return a.ID == avID; }); + Avatar av = sim.ObjectsAvatars.Find(a => a.ID == avID); if (av == null) return rot; @@ -648,7 +620,7 @@ public Quaternion AvatarRotation(Simulator sim, UUID avID) public Vector3 AvatarPosition(Simulator sim, UUID avID) { Vector3 pos = Vector3.Zero; - Avatar av = sim.ObjectsAvatars.Find((Avatar a) => { return a.ID == avID; }); + Avatar av = sim.ObjectsAvatars.Find(a => a.ID == avID); if (av != null) { return AvatarPosition(sim, av); @@ -687,18 +659,18 @@ public Vector3 AvatarPosition(Simulator sim, Avatar av) public void Follow(string name, UUID id) { - followName = name; + FollowName = name; followID = id; - following = followID != UUID.Zero; + IsFollowing = followID != UUID.Zero; - if (following) + if (IsFollowing) { - walking = false; + IsWalking = false; - Vector3 target = AvatarPosition(client.Network.CurrentSim, id); + Vector3 target = AvatarPosition(Client.Network.CurrentSim, id); if (Vector3.Zero != target) { - client.Self.Movement.TurnToward(target); + Client.Self.Movement.TurnToward(target); FollowUpdate(target); } @@ -707,8 +679,8 @@ public void Follow(string name, UUID id) public void StopFollowing() { - following = false; - followName = string.Empty; + IsFollowing = false; + FollowName = string.Empty; followID = UUID.Zero; } @@ -721,43 +693,40 @@ public void StopFollowing() /// public void LookInFront() { - if (!client.Network.Connected || instance.GlobalSettings["disable_look_at"]) return; + if (!Client.Network.Connected || instance.GlobalSettings["disable_look_at"]) return; - client.Self.LookAtEffect(client.Self.AgentID, client.Self.AgentID, + Client.Self.LookAtEffect(Client.Self.AgentID, Client.Self.AgentID, new Vector3d(new Vector3(3, 0, 0) * Quaternion.Identity), LookAtType.Idle, lookAtEffect); } - void lookAtTimerTick(object state) + void LookAtTimerTick(object state) { LookInFront(); } - void netcom_ChatReceived(object sender, ChatEventArgs e) + void Netcom_ChatReceived(object sender, ChatEventArgs e) { //somehow it can be too early (when Radegast is loaded from running bot) if (instance.GlobalSettings==null) return; if (!instance.GlobalSettings["disable_look_at"] - && e.SourceID != client.Self.AgentID + && e.SourceID != Client.Self.AgentID && (e.SourceType == ChatSourceType.Agent || e.Type == ChatType.StartTyping)) { // change focus max every 4 seconds if (Environment.TickCount - lastLookAtEffect > 4000) { lastLookAtEffect = Environment.TickCount; - client.Self.LookAtEffect(client.Self.AgentID, e.SourceID, Vector3d.Zero, LookAtType.Respond, lookAtEffect); + Client.Self.LookAtEffect(Client.Self.AgentID, e.SourceID, Vector3d.Zero, LookAtType.Respond, lookAtEffect); // keep looking at the speaker for 10 seconds - if (lookAtTimer != null) - { - lookAtTimer.Change(10000, Timeout.Infinite); - } + lookAtTimer?.Change(10000, Timeout.Infinite); } } } #endregion Look at effect #region Walking (move to) - private bool walking = false; + private System.Threading.Timer walkTimer; private int walkChekInterval = 500; private Vector3d walkToTarget; @@ -774,11 +743,11 @@ public double WaitUntilPosition(Vector3d pos, TimeSpan maxWait, double howClose) DateTime until = DateTime.Now + maxWait; while (until > DateTime.Now) { - double dist = Vector3d.Distance(client.Self.GlobalPosition, pos); + double dist = Vector3d.Distance(Client.Self.GlobalPosition, pos); if (howClose >= dist) return dist; Thread.Sleep(250); } - return Vector3d.Distance(client.Self.GlobalPosition, pos); + return Vector3d.Distance(Client.Self.GlobalPosition, pos); } @@ -786,28 +755,28 @@ public void WalkTo(Vector3d globalPos) { walkToTarget = globalPos; - if (following) + if (IsFollowing) { - following = false; - followName = string.Empty; + IsFollowing = false; + FollowName = string.Empty; } if (walkTimer == null) { - walkTimer = new System.Threading.Timer(new TimerCallback(walkTimerElapsed), null, walkChekInterval, Timeout.Infinite); + walkTimer = new System.Threading.Timer(WalkTimerElapsed, null, walkChekInterval, Timeout.Infinite); } - lastDistanceChanged = System.Environment.TickCount; - client.Self.AutoPilotCancel(); - walking = true; - client.Self.AutoPilot(walkToTarget.X, walkToTarget.Y, walkToTarget.Z); + lastDistanceChanged = Environment.TickCount; + Client.Self.AutoPilotCancel(); + IsWalking = true; + Client.Self.AutoPilot(walkToTarget.X, walkToTarget.Y, walkToTarget.Z); FireWalkStateCanged(); } - void walkTimerElapsed(object sender) + void WalkTimerElapsed(object sender) { - double distance = Vector3d.Distance(client.Self.GlobalPosition, walkToTarget); + double distance = Vector3d.Distance(Client.Self.GlobalPosition, walkToTarget); if (distance < 2d) { @@ -818,24 +787,24 @@ void walkTimerElapsed(object sender) { if (lastDistance != (int)distance) { - lastDistanceChanged = System.Environment.TickCount; + lastDistanceChanged = Environment.TickCount; lastDistance = (int)distance; } - else if ((System.Environment.TickCount - lastDistanceChanged) > 10000) + else if ((Environment.TickCount - lastDistanceChanged) > 10000) { // Our distance to the target has not changed in 10s, give up EndWalking(); return; } - if (walkTimer != null) walkTimer.Change(walkChekInterval, Timeout.Infinite); + walkTimer?.Change(walkChekInterval, Timeout.Infinite); } } void Self_AlertMessage(object sender, AlertMessageEventArgs e) { - if (e.Message.Contains("Autopilot cancel")) + if (e.NotificationId == "AutopilotCanceled") { - if (walking) + if (IsWalking) { EndWalking(); } @@ -846,20 +815,20 @@ void FireWalkStateCanged() { if (OnWalkStateCanged != null) { - try { OnWalkStateCanged(walking); } + try { OnWalkStateCanged(IsWalking); } catch (Exception) { } } } public void EndWalking() { - if (walking) + if (IsWalking) { - walking = false; - Logger.Log("Finished walking.", Helpers.LogLevel.Debug, client); + IsWalking = false; + Logger.Log("Finished walking.", Helpers.LogLevel.Debug, Client); walkTimer.Dispose(); walkTimer = null; - client.Self.AutoPilotCancel(); + Client.Self.AutoPilotCancel(); if (displayEndWalk) { @@ -868,8 +837,8 @@ public void EndWalking() if (walkToTarget != Vector3d.Zero) { - System.Threading.Thread.Sleep(1000); - msg += string.Format(" {0:0} meters from destination", Vector3d.Distance(client.Self.GlobalPosition, walkToTarget)); + Thread.Sleep(1000); + msg += $" {Vector3d.Distance(Client.Self.GlobalPosition, walkToTarget):0} meters from destination"; walkToTarget = Vector3d.Zero; } @@ -883,79 +852,64 @@ public void EndWalking() public void SetTyping(bool typing) { - if (!client.Network.Connected) return; - - Dictionary typingAnim = new Dictionary(); - typingAnim.Add(typingAnimationID, typing); - - client.Self.Animate(typingAnim, false); - - if (typing) - client.Self.Chat(string.Empty, 0, ChatType.StartTyping); - else - client.Self.Chat(string.Empty, 0, ChatType.StopTyping); - - this.typing = typing; + if (!Client.Network.Connected) return; + var typingAnim = new Dictionary {{TypingAnimationID, typing}}; + Client.Self.Animate(typingAnim, false); + Client.Self.Chat(string.Empty, 0, typing ? ChatType.StartTyping : ChatType.StopTyping); + IsTyping = typing; } public void SetAway(bool away) { - Dictionary awayAnim = new Dictionary(); - awayAnim.Add(awayAnimationID, away); - - client.Self.Animate(awayAnim, true); - if (UseMoveControl) client.Self.Movement.Away = away; + var awayAnim = new Dictionary {{AwayAnimationID, away}}; + Client.Self.Animate(awayAnim, true); + if (UseMoveControl) Client.Self.Movement.Away = away; this.away = away; } public void SetBusy(bool busy) { - Dictionary busyAnim = new Dictionary(); - busyAnim.Add(busyAnimationID, busy); - - client.Self.Animate(busyAnim, true); - this.busy = busy; + var busyAnim = new Dictionary {{BusyAnimationID, busy}}; + Client.Self.Animate(busyAnim, true); + IsBusy = busy; } - public void SetFlying(bool flying) + public void SetFlying(bool fly) { - this.flying = client.Self.Movement.Fly = flying; + flying = Client.Self.Movement.Fly = fly; } - public void SetAlwaysRun(bool alwaysrun) + public void SetAlwaysRun(bool always_run) { - this.alwaysrun = client.Self.Movement.AlwaysRun = alwaysrun; + alwaysrun = Client.Self.Movement.AlwaysRun = always_run; } - public void SetSitting(bool sitting, UUID target) + public void SetSitting(bool sit, UUID target) { - this.sitting = sitting; + sitting = sit; - if (sitting) - { - client.Self.RequestSit(target, Vector3.Zero); - client.Self.Sit(); - } - else + if (!instance.RLV.RestictionActive("unsit")) { - if (!instance.RLV.RestictionActive("unsit")) + if (sitting) { - client.Self.Stand(); + Client.Self.RequestSit(target, Vector3.Zero); + Client.Self.Sit(); } else { - instance.TabConsole.DisplayNotificationInChat("Unsit prevented by RLV"); - this.sitting = true; - return; + Client.Self.Stand(); } } - - if (SitStateChanged != null) + else { - SitStateChanged(this, new SitEventArgs(this.sitting)); + instance.TabConsole.DisplayNotificationInChat("Unsit prevented by RLV"); + sitting = true; + return; } - if (!this.sitting) + SitStateChanged?.Invoke(this, new SitEventArgs(sitting)); + + if (!sitting) { StopAllAnimations(); } @@ -963,9 +917,9 @@ public void SetSitting(bool sitting, UUID target) public void StopAllAnimations() { - Dictionary stop = new Dictionary(); + var stop = new Dictionary(); - client.Self.SignaledAnimations.ForEach((UUID anim) => + Client.Self.SignaledAnimations.ForEach(anim => { if (!KnownAnimations.ContainsKey(anim)) { @@ -975,11 +929,11 @@ public void StopAllAnimations() if (stop.Count > 0) { - client.Self.Animate(stop, true); + Client.Self.Animate(stop, true); } } - static public Vector3d GlobalPosition(Simulator sim, Vector3 pos) + public static Vector3d GlobalPosition(Simulator sim, Vector3 pos) { uint globalX, globalY; Utils.LongToUInts(sim.Handle, out globalX, out globalY); @@ -992,7 +946,7 @@ static public Vector3d GlobalPosition(Simulator sim, Vector3 pos) public Vector3d GlobalPosition(Primitive prim) { - return GlobalPosition(client.Network.CurrentSim, prim.Position); + return GlobalPosition(Client.Network.CurrentSim, prim.Position); } private System.Timers.Timer beamTimer; @@ -1002,7 +956,7 @@ public Vector3d GlobalPosition(Primitive prim) private UUID sphereID; private List beamID; private int numBeans; - private Color4[] beamColors = new Color4[3] { new Color4(0, 255, 0, 255), new Color4(255, 0, 0, 255), new Color4(0, 0, 255, 255) }; + private Color4[] beamColors = new Color4[] { new Color4(0, 255, 0, 255), new Color4(255, 0, 0, 255), new Color4(0, 0, 255, 255) }; private Primitive targetPrim; public void UnSetPointing() @@ -1010,7 +964,7 @@ public void UnSetPointing() beamTimer.Enabled = false; if (pointID != UUID.Zero) { - client.Self.PointAtEffect(client.Self.AgentID, UUID.Zero, Vector3d.Zero, PointAtType.None, pointID); + Client.Self.PointAtEffect(Client.Self.AgentID, UUID.Zero, Vector3d.Zero, PointAtType.None, pointID); pointID = UUID.Zero; } @@ -1018,30 +972,29 @@ public void UnSetPointing() { foreach (UUID id in beamID) { - client.Self.BeamEffect(UUID.Zero, UUID.Zero, Vector3d.Zero, new Color4(255, 255, 255, 255), 0, id); + Client.Self.BeamEffect(UUID.Zero, UUID.Zero, Vector3d.Zero, new Color4(255, 255, 255, 255), 0, id); } beamID = null; } if (sphereID != UUID.Zero) { - client.Self.SphereEffect(Vector3d.Zero, Color4.White, 0, sphereID); + Client.Self.SphereEffect(Vector3d.Zero, Color4.White, 0, sphereID); sphereID = UUID.Zero; } } - void beamTimer_Elapsed(object sender, EventArgs e) + void BeamTimer_Elapsed(object sender, EventArgs e) { if (beamID == null) return; try { - client.Self.SphereEffect(GlobalPosition(targetPrim), beamColors[beamRandom.Next(0, 3)], 0.85f, sphereID); + Client.Self.SphereEffect(GlobalPosition(targetPrim), beamColors[beamRandom.Next(0, 3)], 0.85f, sphereID); int i = 0; for (i = 0; i < numBeans; i++) { - UUID newBeam = UUID.Random(); Vector3d scatter; if (i == 0) @@ -1050,41 +1003,39 @@ void beamTimer_Elapsed(object sender, EventArgs e) } else { - Vector3d direction = client.Self.GlobalPosition - GlobalPosition(targetPrim); + Vector3d direction = Client.Self.GlobalPosition - GlobalPosition(targetPrim); Vector3d cross = direction % new Vector3d(0, 0, 1); cross.Normalize(); scatter = GlobalPosition(targetPrim) + cross * (i * 0.2d) * (i % 2 == 0 ? 1 : -1); } - client.Self.BeamEffect(client.Self.AgentID, UUID.Zero, scatter, beamColors[beamRandom.Next(0, 3)], 1.0f, beamID[i]); + Client.Self.BeamEffect(Client.Self.AgentID, UUID.Zero, scatter, beamColors[beamRandom.Next(0, 3)], 1.0f, beamID[i]); } for (int j = 1; j < numBeans; j++) { - UUID newBeam = UUID.Random(); - Vector3d scatter; Vector3d cross = new Vector3d(0, 0, 1); cross.Normalize(); - scatter = GlobalPosition(targetPrim) + cross * (j * 0.2d) * (j % 2 == 0 ? 1 : -1); + var scatter = GlobalPosition(targetPrim) + cross * (j * 0.2d) * (j % 2 == 0 ? 1 : -1); - client.Self.BeamEffect(client.Self.AgentID, UUID.Zero, scatter, beamColors[beamRandom.Next(0, 3)], 1.0f, beamID[j + i - 1]); + Client.Self.BeamEffect(Client.Self.AgentID, UUID.Zero, scatter, beamColors[beamRandom.Next(0, 3)], 1.0f, beamID[j + i - 1]); } } - catch (Exception) { }; + catch (Exception) { } } - public void SetPointing(Primitive prim, int numBeans) + public void SetPointing(Primitive prim, int num_beans) { UnSetPointing(); - client.Self.Movement.TurnToward(prim.Position); + Client.Self.Movement.TurnToward(prim.Position); pointID = UUID.Random(); sphereID = UUID.Random(); beamID = new List(); beamTarget = new List(); targetPrim = prim; - this.numBeans = numBeans; + numBeans = num_beans; - client.Self.PointAtEffect(client.Self.AgentID, prim.ID, Vector3d.Zero, PointAtType.Select, pointID); + Client.Self.PointAtEffect(Client.Self.AgentID, prim.ID, Vector3d.Zero, PointAtType.Select, pointID); for (int i = 0; i < numBeans; i++) { @@ -1104,53 +1055,18 @@ public void SetPointing(Primitive prim, int numBeans) beamTimer.Enabled = true; } - public UUID TypingAnimationID - { - get { return typingAnimationID; } - set { typingAnimationID = value; } - } - - public UUID AwayAnimationID - { - get { return awayAnimationID; } - set { awayAnimationID = value; } - } - - public UUID BusyAnimationID - { - get { return busyAnimationID; } - set { busyAnimationID = value; } - } - - public bool IsTyping - { - get { return typing; } - } - - public bool IsAway - { - get - { - if (UseMoveControl) return client.Self.Movement.Away; - return away; - } - } - - public bool IsBusy - { - get { return busy; } - } - - public bool IsFlying - { - get { return client.Self.Movement.Fly; } - } - + public UUID TypingAnimationID { get; set; } = new UUID("c541c47f-e0c0-058b-ad1a-d6ae3a4584d9"); + public UUID AwayAnimationID { get; set; } = new UUID("fd037134-85d4-f241-72c6-4f42164fedee"); + public UUID BusyAnimationID { get; set; } = new UUID("efcf670c2d188128973a034ebc806b67"); + public bool IsTyping { get; private set; } = false; + public bool IsAway => UseMoveControl ? Client.Self.Movement.Away : away; + public bool IsBusy { get; private set; } = false; + public bool IsFlying => Client.Self.Movement.Fly; public bool IsSitting { get { - if (client.Self.Movement.SitOnGround || client.Self.SittingOn != 0) return true; + if (Client.Self.Movement.SitOnGround || Client.Self.SittingOn != 0) return true; if (sitting) { Logger.Log("out of sync sitting", Helpers.LogLevel.Debug); sitting = false; @@ -1159,56 +1075,19 @@ public bool IsSitting } } - public bool IsPointing - { - get { return pointID != UUID.Zero; } - } - - public bool IsFollowing - { - get { return following; } - } - - public string FollowName - { - get { return followName; } - set { followName = value; } - } - - public float FollowDistance - { - get { return followDistance; } - set { followDistance = value; } - } - - public bool IsWalking - { - get { return walking; } - } - - private AutoSit autosit; - public AutoSit AutoSit - { - get { return autosit; } - } - - private LSLHelper lslHelper; - public LSLHelper LSLHelper - { - get { return lslHelper; } - } - - private PseudoHome pseudohome; + public bool IsPointing => pointID != UUID.Zero; + public bool IsFollowing { get; private set; } = false; + public string FollowName { get; set; } = string.Empty; + public float FollowDistance { get; set; } = 3.0f; + public bool IsWalking { get; private set; } = false; + public AutoSit AutoSit { get; private set; } + public LSLHelper LSLHelper { get; private set; } + public PseudoHome PseudoHome { get; } /// /// Experimental Option that sometimes the Client has more authority than state mananger /// public static bool UseMoveControl; - - public PseudoHome PseudoHome - { - get { return pseudohome; } - } } public class SitEventArgs : EventArgs @@ -1217,7 +1096,7 @@ public class SitEventArgs : EventArgs public SitEventArgs(bool sitting) { - this.Sitting = sitting; + Sitting = sitting; } } } diff --git a/Radegast/Core/Tabs/IRadegastTabControl.cs b/Radegast/Core/Tabs/IRadegastTabControl.cs deleted file mode 100644 index e2018064b..000000000 --- a/Radegast/Core/Tabs/IRadegastTabControl.cs +++ /dev/null @@ -1,38 +0,0 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// - -namespace Radegast -{ - public interface IRadegastTabControl - { - void RegisterTab(RadegastTab tab); - } -} diff --git a/Radegast/Core/Tabs/RadegastTab.cs b/Radegast/Core/Tabs/RadegastTab.cs deleted file mode 100644 index da468d52c..000000000 --- a/Radegast/Core/Tabs/RadegastTab.cs +++ /dev/null @@ -1,405 +0,0 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// -using System; -using System.Drawing; -using System.Windows.Forms; - -namespace Radegast -{ - public partial class RadegastTab - { - public bool Floater = false; - public bool CloseOnDetachedClose = false; - - private RadegastInstance instance; - private ToolStripButton button; - private Control control; - - private Button defaultControlButton; - private string name; - private string label; - private RadegastTab mergedTab; - private Form owner; - private string originalLabel; - - private bool allowMerge = true; - private bool allowDetach = true; - private bool allowClose = true; - private bool allowHide = true; - - private bool partialHighlighted = false; - private bool highlighted = false; - private bool selected = false; - private bool detached = false; - private bool merged = false; - private bool hidden = false; - - public RadegastTab(RadegastInstance instance, ToolStripButton button, Control control, string name, string label) - { - this.instance = instance; - this.button = button; - this.control = control; - this.name = name; - this.label = label; - } - - public void Close() - { - if (!allowClose) return; - - if (control != null) - { - if (control.Parent != null && control.Parent is Form) - { - control.Parent.Dispose(); - } - - if (instance.TabConsole.toolStripContainer1.ContentPanel.Contains(control)) - { - instance.TabConsole.toolStripContainer1.ContentPanel.Controls.Remove(control); - } - control.Dispose(); - control = null; - } - - if (button != null) - { - if (instance.TabConsole.tstTabs.Items.Contains(button)) - { - instance.TabConsole.tstTabs.Items.Remove(button); - } - button.Dispose(); - button = null; - } - - - OnTabClosed(EventArgs.Empty); - } - - public void Select() - { - if (detached) return; - - if (hidden) - { - hidden = false; - } - - control.Visible = true; - control.BringToFront(); - - if (!partialHighlighted) Unhighlight(); - button.Visible = true; - button.Checked = true; - selected = true; - - OnTabSelected(EventArgs.Empty); - } - - public void Deselect() - { - if (detached) return; - - if (control != null) control.Visible = false; - if (button != null) button.Checked = false; - - selected = false; - - OnTabDeselected(EventArgs.Empty); - } - - public void Hide() - { - if (!allowHide || detached) return; - - if (control != null) control.Visible = false; - if (button != null) button.Visible = false; - - hidden = true; - - OnTabHidden(EventArgs.Empty); - } - - public void Show() - { - if (detached) return; - - if (button != null) button.Visible = true; - Select(); - - hidden = false; - - OnTabShown(EventArgs.Empty); - } - - public void PartialHighlight() - { - if (detached) - { - //do nothing?! - } - else - { - button.Image = null; - button.ForeColor = Color.Blue; - } - - partialHighlighted = true; - OnTabPartiallyHighlighted(EventArgs.Empty); - } - - public void Highlight() - { - if (instance.GlobalSettings["taskbar_highlight"]) - { - if ((Control is ChatConsole && instance.GlobalSettings["highlight_on_chat"]) || - (Control is IMTabWindow && instance.GlobalSettings["highlight_on_im"]) || - (Control is GroupIMTabWindow && instance.GlobalSettings["highlight_on_group_chat"]) || - (Control is ConferenceIMTabWindow && instance.GlobalSettings["highlight_on_group_chat"])) - { - FormFlash.StartFlash(control.FindForm()); - } - } - - if (selected) return; - - if (!detached) - { - button.Image = Properties.Resources.arrow_forward_16; - button.ForeColor = Color.Red; - } - - highlighted = true; - OnTabHighlighted(EventArgs.Empty); - } - - public void Unhighlight() - { - FormFlash.StopFlash(instance.MainForm); - - if (!detached) - { - button.Image = null; - button.ForeColor = Color.FromKnownColor(KnownColor.ControlText); - } - - highlighted = partialHighlighted = false; - OnTabUnhighlighted(EventArgs.Empty); - } - - public void AttachTo(ToolStrip strip, Panel container) - { - if (!allowDetach) return; - if (!detached) return; - - button.Visible = true; - foreach (Control c in container.Controls) - c.Hide(); - container.Controls.Add(control); - - owner = null; - detached = false; - OnTabAttached(EventArgs.Empty); - } - - public void Detach(RadegastInstance instance) - { - if (!allowDetach) return; - if (detached) return; - button.Visible = false; - owner = new frmDetachedTab(instance, this); - owner.Show(); - owner.Focus(); - detached = true; - OnTabDetached(EventArgs.Empty); - } - - public void MergeWith(RadegastTab tab) - { - if (!allowMerge) return; - if (merged) return; - - SplitContainer container = new SplitContainer(); - container.Dock = DockStyle.Fill; - container.BorderStyle = BorderStyle.Fixed3D; - container.SplitterDistance = container.Width / 2; - container.Panel1.Controls.Add(control); - container.Panel2.Controls.Add(tab.Control); - - control.Visible = true; - tab.Control.Visible = true; - - control = container; - tab.Control = container; - - mergedTab = tab; - tab.mergedTab = this; - - originalLabel = label; - tab.originalLabel = tab.label; - this.Label = label + "+" + tab.Label; - - merged = tab.merged = true; - - OnTabMerged(EventArgs.Empty); - } - - public RadegastTab Split() - { - if (!allowMerge) return null; - if (!merged) return null; - - RadegastTab returnTab = mergedTab; - mergedTab = null; - returnTab.mergedTab = null; - - SplitContainer container = (SplitContainer)control; - control = container.Panel1.Controls[0]; - returnTab.Control = container.Panel2.Controls[0]; - merged = returnTab.merged = false; - - this.Label = originalLabel; - OnTabSplit(EventArgs.Empty); - - return returnTab; - } - - public ToolStripButton Button - { - get { return button; } - set { button = value; } - } - - public Control Control - { - get { return control; } - set { control = value; } - } - - public Button DefaultControlButton - { - get { return defaultControlButton; } - set { defaultControlButton = value; } - } - - public string Name - { - get { return name; } - } - - public string Label - { - get { return label; } - set { label = button.Text = value; } - } - - public RadegastTab MergedTab - { - get { return mergedTab; } - } - - public Form Owner - { - get { return owner; } - } - - public bool AllowMerge - { - get { return allowMerge; } - set { allowMerge = value; } - } - - public bool AllowDetach - { - get { return allowDetach; } - set { allowDetach = value; } - } - - public bool AllowClose - { - get { return allowClose; } - set { allowClose = value; } - } - - public bool PartiallyHighlighted - { - get { return partialHighlighted; } - } - - public bool Highlighted - { - get { return highlighted; } - } - - public bool Selected - { - get { return selected; } - } - - public bool Detached - { - get { return detached; } - } - - public bool Merged - { - get { return merged; } - } - - public bool AllowHide - { - get { return allowHide; } - set { allowHide = value; } - } - - public bool Hidden - { - get { return hidden; } - } - - public bool Visible - { - get { return !hidden; } - - set - { - if (value) - { - Show(); - } - else if (allowHide) - { - Hide(); - } - } - } - } -} diff --git a/Radegast/Core/Tabs/RadegastTabEvents.cs b/Radegast/Core/Tabs/RadegastTabEvents.cs deleted file mode 100644 index c34aa52bb..000000000 --- a/Radegast/Core/Tabs/RadegastTabEvents.cs +++ /dev/null @@ -1,110 +0,0 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// -using System; - -namespace Radegast -{ - public partial class RadegastTab - { - public event EventHandler TabSelected; - public event EventHandler TabDeselected; - public event EventHandler TabHighlighted; - public event EventHandler TabUnhighlighted; - public event EventHandler TabPartiallyHighlighted; - public event EventHandler TabMerged; - public event EventHandler TabSplit; - public event EventHandler TabDetached; - public event EventHandler TabAttached; - public event EventHandler TabClosed; - public event EventHandler TabHidden; - public event EventHandler TabShown; - - protected virtual void OnTabSelected(EventArgs e) - { - if (TabSelected != null) TabSelected(this, e); - } - - protected virtual void OnTabDeselected(EventArgs e) - { - if (TabDeselected != null) TabDeselected(this, e); - } - - protected virtual void OnTabHighlighted(EventArgs e) - { - if (TabHighlighted != null) TabHighlighted(this, e); - } - - protected virtual void OnTabUnhighlighted(EventArgs e) - { - if (TabUnhighlighted != null) TabUnhighlighted(this, e); - } - - protected virtual void OnTabPartiallyHighlighted(EventArgs e) - { - if (TabPartiallyHighlighted != null) TabPartiallyHighlighted(this, e); - } - - protected virtual void OnTabMerged(EventArgs e) - { - if (TabMerged != null) TabMerged(this, e); - } - - protected virtual void OnTabSplit(EventArgs e) - { - if (TabSplit != null) TabSplit(this, e); - } - - protected virtual void OnTabDetached(EventArgs e) - { - if (TabDetached != null) TabDetached(this, e); - } - - protected virtual void OnTabAttached(EventArgs e) - { - if (TabAttached != null) TabAttached(this, e); - } - - protected virtual void OnTabClosed(EventArgs e) - { - if (TabClosed != null) TabClosed(this, e); - } - - protected virtual void OnTabHidden(EventArgs e) - { - if (TabHidden != null) TabHidden(this, e); - } - - protected virtual void OnTabShown(EventArgs e) - { - if (TabShown != null) TabShown(this, e); - } - } -} diff --git a/Radegast/Core/Types/AgentNameTextBox.cs b/Radegast/Core/Types/AgentNameTextBox.cs deleted file mode 100644 index 61a2db8ce..000000000 --- a/Radegast/Core/Types/AgentNameTextBox.cs +++ /dev/null @@ -1,109 +0,0 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// -using System; -using System.Collections.Generic; -using System.Windows.Forms; -using System.ComponentModel; -using OpenMetaverse; - -namespace Radegast -{ - public class AgentNameTextBox : System.Windows.Forms.TextBox - { - private UUID agentID; - private GridClient client { get { return RadegastInstance.GlobalInstance.Client; } } - private RadegastInstance instance { get { return RadegastInstance.GlobalInstance; } } - - [Browsable(false)] - public UUID AgentID - { - get { return agentID; } - - set - { - if (agentID == value) return; - - agentID = value; - - if (agentID == UUID.Zero) - { - SetName(string.Empty); - } - else - { - SetupHandlers(); - string name = instance.Names.Get(agentID); - SetName(name); - } - } - } - - public AgentNameTextBox() - : base() - { - SetStyle(ControlStyles.SupportsTransparentBackColor, true); - Disposed += new EventHandler(CleanupHandlers); - } - - void SetupHandlers() - { - if (instance == null || instance.Names == null) return; - instance.Names.NameUpdated += new EventHandler(Names_NameUpdated); - } - - void CleanupHandlers(object sender, EventArgs e) - { - if (instance != null && instance.Names != null) - { - instance.Names.NameUpdated -= new EventHandler(Names_NameUpdated); - } - } - - void Names_NameUpdated(object sender, UUIDNameReplyEventArgs e) - { - if (e.Names.ContainsKey(agentID)) - { - SetName(e.Names[agentID]); - } - } - - void SetName(string name) - { - if (InvokeRequired) - { - BeginInvoke(new MethodInvoker(delegate() { SetName(name); })); - return; - } - - base.Text = name; - } - } -} diff --git a/Radegast/Core/Types/ChatInputBox.cs b/Radegast/Core/Types/ChatInputBox.cs deleted file mode 100644 index e0f5eb21b..000000000 --- a/Radegast/Core/Types/ChatInputBox.cs +++ /dev/null @@ -1,71 +0,0 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id: IMTabWindow.Designer.cs 323 2009-10-07 01:08:34Z latifer@gmail.com $ -// -using System; -using System.Windows.Forms; - -namespace Radegast -{ - public class ChatInputBox : TextBox - { - public static readonly string NewlineMarker = new string('\u00b6', 1); - - public ChatInputBox() - : base() - { - } - - protected override void WndProc(ref Message m) - { - switch (m.Msg) - { - case 0x302: //WM_PASTE - Paste(); - break; - - default: - base.WndProc(ref m); - break; - } - } - - public new void Paste() - { - Paste(Clipboard.GetText()); - } - - public new void Paste(string text) - { - base.Paste(text.Replace(Environment.NewLine, NewlineMarker)); - } - - - } -} diff --git a/Radegast/Core/Types/CircularList.cs b/Radegast/Core/Types/CircularList.cs deleted file mode 100644 index 34fc8b701..000000000 --- a/Radegast/Core/Types/CircularList.cs +++ /dev/null @@ -1,104 +0,0 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// -using System.Collections.Generic; - -namespace Radegast -{ - /// - /// A list which acts like the List class, but with more of a java - /// influence. This allows you to set - /// a looping variable to true, and creates - /// a circular list. Also it utilizes the java iterator pattern of - /// Next and HasNext. - /// - /// Author: Wesley Tansey - /// - /// The type of item that - /// will be stored in the list - - public class CircularList : List - { - #region Member Variables - private bool loop = true; - private int index; - #endregion - - #region Properties - - /// - /// If true, the list will loop to the beginning when Next - /// is called after the last element has been accessed. - /// - public bool Loop - { - get { return loop; } - set { loop = value; } - } - - /// - /// The next element in the list. The user is responsible for - /// making sure that HasNext is true - /// before getting the next element. - /// - - public T Next - { - get - { - if (index >= Count) - { - if (!loop) - { - return default(T); - } - index = 0; - } - return this[index++]; - } - } - - /// - /// Tells whether there is another element in the list - /// - public bool HasNext - { - get - { - if (Count == 0 || (!loop && index >= Count)) - { - return false; - } - return true; - } - } - #endregion - } -} diff --git a/Radegast/Core/Types/ListBoxCustomSort.cs b/Radegast/Core/Types/ListBoxCustomSort.cs deleted file mode 100644 index 7516d667c..000000000 --- a/Radegast/Core/Types/ListBoxCustomSort.cs +++ /dev/null @@ -1,87 +0,0 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id: ListBoxCustomSort.cs 300 2009-10-05 09:29:46Z latifer@gmail.com $ -// -using System; -using System.Collections.Generic; -using System.Windows.Forms; - -namespace Radegast -{ - public class ListBoxCustomSort : ListBox - { - public ListBoxCustomSort() - : base() - { - } - - public void PerformSort() - { - QuickSort(0, Items.Count - 1); - } - - private void QuickSort(int left, int right) - { - if (right > left) - { - int pivotIndex = left; - int pivotNewIndex = QuickSortPartition(left, right, pivotIndex); - - QuickSort(left, pivotNewIndex - 1); - QuickSort(pivotNewIndex + 1, right); - } - } - - private int QuickSortPartition(int left, int right, int pivot) - { - var pivotValue = (IComparable)Items[pivot]; - Swap(pivot, right); - - int storeIndex = left; - for (int i = left; i < right; ++i) - { - if (pivotValue.CompareTo(Items[i]) >= 0) - { - Swap(i, storeIndex); - ++storeIndex; - } - } - - Swap(storeIndex, right); - return storeIndex; - } - - private void Swap(int left, int right) - { - var temp = Items[left]; - Items[left] = Items[right]; - Items[right] = temp; - } - } -} diff --git a/Radegast/Core/Types/ListViewNoFlicker.cs b/Radegast/Core/Types/ListViewNoFlicker.cs deleted file mode 100644 index b838dbacf..000000000 --- a/Radegast/Core/Types/ListViewNoFlicker.cs +++ /dev/null @@ -1,58 +0,0 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// - -using System.Windows.Forms; - -namespace Radegast -{ - public class ListViewNoFlicker : ListView - { - public ListViewNoFlicker() - { - - //Activate double buffering - this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true); - - //Enable the OnNotifyMessage event so we get a chance to filter out - // Windows messages before they get to the form's WndProc - this.SetStyle(ControlStyles.EnableNotifyMessage, true); - } - - protected override void OnNotifyMessage(Message m) - { - //Filter out the WM_ERASEBKGND message - if (m.Msg != 0x14) - { - base.OnNotifyMessage(m); - } - } - } -} diff --git a/Radegast/Core/Types/RadegastTabControl.cs b/Radegast/Core/Types/RadegastTabControl.cs deleted file mode 100644 index aa6012e75..000000000 --- a/Radegast/Core/Types/RadegastTabControl.cs +++ /dev/null @@ -1,53 +0,0 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// -using System; -using System.Collections.Generic; -using System.Windows.Forms; -using OpenMetaverse; - -namespace Radegast -{ - public class RadegastTabControl : UserControl - { - public RadegastTab RadegastTab { get; set; } - - protected RadegastInstance instance; - protected GridClient client { get { return instance.Client; } } - - public RadegastTabControl() { } - - public RadegastTabControl(RadegastInstance instance) - : base() - { - this.instance = instance; - } - } -} diff --git a/Radegast/Core/Types/ToolStripCheckBox.cs b/Radegast/Core/Types/ToolStripCheckBox.cs deleted file mode 100644 index 3132e16c5..000000000 --- a/Radegast/Core/Types/ToolStripCheckBox.cs +++ /dev/null @@ -1,152 +0,0 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// -using System; -using System.Windows.Forms; -using System.Windows.Forms.Design; -using System.ComponentModel; - -namespace Radegast -{ - [ToolStripItemDesignerAvailability( - ToolStripItemDesignerAvailability.ToolStrip)] - public partial class ToolStripCheckBox - : ToolStripControlHost - { - public CheckBox CheckBoxControl - { - get - { - return Control as CheckBox; - } - } - - /// - /// Is check box ticked - /// - [Category("Appearance")] - public bool Checked - { - get - { - return CheckBoxControl.Checked; - } - set - { - CheckBoxControl.Checked = value; - } - } - - /// - /// Checked state - /// - [Category("Appearance")] - public CheckState CheckState - { - get - { - return CheckBoxControl.CheckState; - } - set - { - CheckBoxControl.CheckState = value; - } - } - - /// - /// Label text - /// - [Category("Appearance")] - public override string Text - { - get - { - return CheckBoxControl.Text; - } - set - { - CheckBoxControl.Text = value; - } - } - - /// - /// Occurs when check property is changed - /// - [Category("Misc")] - public event EventHandler CheckedChanged; - - /// - /// Occurs when check state of the control changes - /// - [Category("Misc")] - public event EventHandler CheckStateChanged; - - public ToolStripCheckBox() - : base(new CheckBox()) - { - CheckBoxControl.MouseHover += new EventHandler(chk_MouseHover); - } - - void chk_MouseHover(object sender, EventArgs e) - { - this.OnMouseHover(e); - } - - protected override void OnSubscribeControlEvents(Control c) - { - base.OnSubscribeControlEvents(c); - ((CheckBox)c).CheckedChanged += new EventHandler(ToolStripCheckBox_CheckedChanged); - ((CheckBox)c).CheckStateChanged += new EventHandler(ToolStripCheckBox_CheckStateChanged); - } - - protected override void OnUnsubscribeControlEvents(Control c) - { - base.OnUnsubscribeControlEvents(c); - ((CheckBox)c).CheckedChanged -= new EventHandler(ToolStripCheckBox_CheckedChanged); - ((CheckBox)c).CheckStateChanged -= new EventHandler(ToolStripCheckBox_CheckStateChanged); - } - - void ToolStripCheckBox_CheckedChanged(object sender, EventArgs e) - { - if (CheckedChanged != null) - { - CheckedChanged(this, e); - } - } - - void ToolStripCheckBox_CheckStateChanged(object sender, EventArgs e) - { - if (CheckStateChanged != null) - { - CheckStateChanged(this, e); - } - } - } -} \ No newline at end of file diff --git a/Radegast/Core/Types/TransparentButton.cs b/Radegast/Core/Types/TransparentButton.cs deleted file mode 100644 index 9d6736bb6..000000000 --- a/Radegast/Core/Types/TransparentButton.cs +++ /dev/null @@ -1,58 +0,0 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// -using System.Drawing; -using System.Windows.Forms; - -namespace Radegast -{ - class TransparentButton : Button - { - public TransparentButton() : base() - { - this.SetStyle(ControlStyles.SupportsTransparentBackColor, true); - this.BackColor = Color.Transparent; - } - - protected override CreateParams CreateParams - { - get - { - CreateParams cp = base.CreateParams; - cp.ExStyle |= 0x20; - return cp; - } - } - - protected override void OnPaintBackground(PaintEventArgs pevent) - { - } - } -} diff --git a/Radegast/Core/Updater/ErrorReporter.cs b/Radegast/Core/Updater/ErrorReporter.cs deleted file mode 100644 index 3e3e849fe..000000000 --- a/Radegast/Core/Updater/ErrorReporter.cs +++ /dev/null @@ -1,116 +0,0 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.IO; -using System.Net; -using OpenMetaverse; - -namespace Radegast -{ - public class ErrorReporter - { - string url; - StringBuilder postString; - - public ErrorReporter(string url) - { - this.url = url; - } - - void AddStacktrace(ref StringBuilder report, Exception ex) - { - if (ex == null) return; - - report.AppendFormat("{0}: ", ex.ToString()); - report.AppendLine(ex.Message); - report.AppendLine(ex.StackTrace); - report.AppendLine(); - if (ex.InnerException != null && ex.InnerException != ex) - { - AddStacktrace(ref report, ex.InnerException); - } - } - - public void SendExceptionReport(Exception ex) - { - try - { - // Build the params we want to send - postString = new StringBuilder(); - StringBuilder report = new StringBuilder(); - AddStacktrace(ref report, ex); - AddPostField("report", report.ToString()); - AddPostField("version", RadegastBuild.VersionString); - AddPostField("build", RadegastBuild.BuildName); - - // Send the request - WebRequest request = WebRequest.Create(url); - request.Method = "POST"; - byte[] postData = Encoding.UTF8.GetBytes(postString.ToString()); - request.ContentLength = postData.Length; - request.ContentType = "application/x-www-form-urlencoded"; - Stream dataStream = request.GetRequestStream(); - dataStream.Write(postData, 0, postData.Length); - dataStream.Close(); - - // Read the response - WebResponse response = request.GetResponse(); - dataStream = response.GetResponseStream(); - StreamReader reader = new StreamReader(dataStream); - string responseFromServer = reader.ReadToEnd(); - reader.Close(); - dataStream.Close(); - response.Close(); - Logger.Log("Error reporting server said: " + responseFromServer, Helpers.LogLevel.Info); - } - catch (Exception e) - { - Logger.Log("Failed to send error report: " + e.Message, Helpers.LogLevel.Error, e); - } - } - - void AddPostField(string name, string value) - { - if (postString.Length > 0) - { - postString.Append("&"); - } - - postString.Append(name); - postString.Append("="); - postString.Append(System.Web.HttpUtility.UrlEncode(value)); - } - - } -} diff --git a/Radegast/Core/Updater/UpdateChecker.cs b/Radegast/Core/Updater/UpdateChecker.cs deleted file mode 100644 index d76acda97..000000000 --- a/Radegast/Core/Updater/UpdateChecker.cs +++ /dev/null @@ -1,148 +0,0 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id: RadegastInstance.cs 234 2009-09-13 12:45:52Z logicmoo $ -// -using System; -using System.Collections.Generic; -using System.Text; -using System.Reflection; -using System.Net; -using OpenMetaverse; -using OpenMetaverse.StructuredData; -#if (COGBOT_LIBOMV || USE_STHREADS) -using ThreadPoolUtil; -using Thread = ThreadPoolUtil.Thread; -using ThreadPool = ThreadPoolUtil.ThreadPool; -using Monitor = ThreadPoolUtil.Monitor; -#endif -using System.Threading; - - -namespace Radegast -{ - public class UpdateChecker : IDisposable - { - public AssemblyName MyAssembly; - - public delegate void UpdateInfoCallback(object sender, UpdateCheckerArgs e); - - public event UpdateInfoCallback OnUpdateInfoReceived; - - private WebClient client; - - public UpdateChecker() - { - MyAssembly = Assembly.GetExecutingAssembly().GetName(); - } - - public void Dispose() - { - if (client != null) - { - client.Dispose(); - client = null; - } - } - - public void StartCheck() - { - if (client == null) - { - client = new WebClient(); - client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(OnDownloadStringCompleted); - } - - WorkPool.QueueUserWorkItem((object state) => - { - client.DownloadStringAsync(new Uri(Properties.Resources.UpdateCheckUri)); - } - ); - } - - private void OnDownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) - { - if (e.Error != null) - { - Logger.Log("Failed fetching updatede information: ", Helpers.LogLevel.Warning, e.Error); - FireCallback(new UpdateCheckerArgs() { Success = false }); - } - else - { - try - { - OSDMap upd = OSDParser.DeserializeJson(e.Result) as OSDMap; - UpdateInfo inf = new UpdateInfo() - { - Error = upd["Error"].AsBoolean(), - ErrMessage = upd["ErrMessage"].AsString(), - CurrentVersion = upd["CurrentVersion"].AsString(), - DownloadSite = upd["DownloadSite"].AsString(), - DisplayMOTD = upd["DisplayMOTD"].AsBoolean(), - MOTD = upd["MOTD"].AsString(), - UpdateAvailable = MyAssembly.Version < new Version(upd["CurrentVersion"].AsString()) - }; - - FireCallback(new UpdateCheckerArgs() { Success = !inf.Error, Info = inf }); - } - catch (Exception ex) - { - Logger.Log("Failed decoding updatede information: ", Helpers.LogLevel.Warning, ex); - FireCallback(new UpdateCheckerArgs() { Success = false }); - } - } - } - - private void FireCallback(UpdateCheckerArgs e) - { - if (OnUpdateInfoReceived != null) - { - try { OnUpdateInfoReceived(this, e); } - catch { } - } - } - } - - public class UpdateInfo - { - public bool Error { get; set; } - public string ErrMessage { get; set; } - public string CurrentVersion { get; set; } - public string DownloadSite { get; set; } - public bool DisplayMOTD { get; set; } - public string MOTD { get; set; } - public bool UpdateAvailable { get; set; } - } - - public class UpdateCheckerArgs : EventArgs - { - public bool Success { get; set; } - public UpdateInfo Info { get; set; } - } - -} diff --git a/Radegast/Core/WindowsLibraryLoader.cs b/Radegast/Core/WindowsLibraryLoader.cs new file mode 100644 index 000000000..db4eb63d6 --- /dev/null +++ b/Radegast/Core/WindowsLibraryLoader.cs @@ -0,0 +1,310 @@ +/** + * Radegast Metaverse Client + * Copyright(c) 2021, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.IO; +using System.Reflection; +using System.Runtime.InteropServices; +using System.Text; + +namespace Radegast.Core +{ + internal sealed class WindowsLibraryLoader + { + + #region Fields + + private const string ProcessorArchitecture = "PROCESSOR_ARCHITECTURE"; + + private const string DllFileExtension = ".dll"; + + private const string DllDirectory = "dll"; + + private readonly Dictionary _ProcessorArchitectureAddressWidthPlatforms = + new Dictionary(StringComparer.OrdinalIgnoreCase) + { + {"x86", 4}, + {"AMD64", 8}, + {"IA64", 8}, + {"ARM", 4} + }; + + private readonly Dictionary _ProcessorArchitecturePlatforms = + new Dictionary(StringComparer.OrdinalIgnoreCase) + { + {"x86", "x86"}, + {"AMD64", "x64"}, + {"IA64", "Itanium"}, + {"ARM", "WinCE"} + }; + + private readonly object _SyncLock = new object(); + + private static readonly IDictionary LoadedLibraries = new Dictionary(); + + [DllImport("kernel32", EntryPoint = "LoadLibrary", CallingConvention = CallingConvention.Winapi, + SetLastError = true, BestFitMapping = false, ThrowOnUnmappableChar = true)] + private static extern IntPtr Win32LoadLibrary(string dllPath); + + #endregion + + #region Properties + + public static bool IsCurrentPlatformSupported() + { + return RuntimeInformation.IsOSPlatform(OSPlatform.Windows); + } + + public static bool IsWindows() + { + return Environment.OSVersion.Platform == PlatformID.Win32NT || + Environment.OSVersion.Platform == PlatformID.Win32S || + Environment.OSVersion.Platform == PlatformID.Win32Windows || + Environment.OSVersion.Platform == PlatformID.WinCE; + } + + #endregion + + #region Methods + + #region Helpers + + private static string FixUpDllFileName(string fileName) + { + if (string.IsNullOrEmpty(fileName)) + return fileName; + + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + return fileName; + + if (!fileName.EndsWith(DllFileExtension, StringComparison.OrdinalIgnoreCase)) + return $"{fileName}{DllFileExtension}"; + + return fileName; + } + + private ProcessArchitectureInfo GetProcessArchitecture() + { + // BUG: Will this always be reliable? + var processArchitecture = Environment.GetEnvironmentVariable(ProcessorArchitecture); + var processInfo = new ProcessArchitectureInfo(); + if (!string.IsNullOrEmpty(processArchitecture)) + { + // Sanity check + processInfo.Architecture = processArchitecture; + } + else + { + processInfo.AddWarning("Failed to detect processor architecture, falling back to x86."); + processInfo.Architecture = (IntPtr.Size == 8) ? "x64" : "x86"; + } + + var addressWidth = this._ProcessorArchitectureAddressWidthPlatforms[processInfo.Architecture]; + if (addressWidth != IntPtr.Size) + { + if (String.Equals(processInfo.Architecture, "AMD64", StringComparison.OrdinalIgnoreCase) && IntPtr.Size == 4) + { + // fall back to x86 if detected x64 but has an address width of 32 bits. + processInfo.Architecture = "x86"; + processInfo.AddWarning("Expected the detected processing architecture of {0} to have an address width of {1} Bytes but was {2} Bytes, falling back to x86.", processInfo.Architecture, addressWidth, IntPtr.Size); + } + else + { + // no fallback possible + processInfo.AddWarning("Expected the detected processing architecture of {0} to have an address width of {1} Bytes but was {2} Bytes.", processInfo.Architecture, addressWidth, IntPtr.Size); + + } + } + + return processInfo; + } + + private string GetPlatformName(string processorArchitecture) + { + if (String.IsNullOrEmpty(processorArchitecture)) + return null; + + string platformName; + if (this._ProcessorArchitecturePlatforms.TryGetValue(processorArchitecture, out platformName)) + { + return platformName; + } + + return null; + } + + public void LoadLibraries(IEnumerable dlls) + { + if (!IsWindows()) + return; + + foreach (var dll in dlls) + LoadLibrary(dll); + } + + private void LoadLibrary(string dllName) + { + if (!IsCurrentPlatformSupported()) + return; + + try + { + lock (this._SyncLock) + { + if (LoadedLibraries.ContainsKey(dllName)) + return; + + var processArch = GetProcessArchitecture(); + IntPtr dllHandle; + + // Try loading from executing assembly domain + var executingAssembly = GetType().GetTypeInfo().Assembly; + var baseDirectory = Path.GetDirectoryName(executingAssembly.Location); + dllHandle = LoadLibraryInternal(dllName, baseDirectory, processArch); + if (dllHandle != IntPtr.Zero) return; + + // Gets the pathname of the base directory that the assembly resolver uses to probe for assemblies. + // https://github.com/dotnet/corefx/issues/2221 + baseDirectory = AppContext.BaseDirectory; + dllHandle = LoadLibraryInternal(dllName, baseDirectory, processArch); + if (dllHandle != IntPtr.Zero) return; + + // Finally try the working directory + baseDirectory = Path.GetFullPath(Directory.GetCurrentDirectory()); + dllHandle = LoadLibraryInternal(dllName, baseDirectory, processArch); + if (dllHandle != IntPtr.Zero) return; + + var errorMessage = new StringBuilder(); + errorMessage.Append($"Failed to find dll \"{dllName}\", for processor architecture {processArch.Architecture}."); + if (processArch.HasWarnings) + { + // include process detection warnings + errorMessage.Append($"\r\nWarnings: \r\n{processArch.WarningText()}"); + } + + throw new Exception(errorMessage.ToString()); + } + } + catch (Exception e) + { + Debug.WriteLine(e.Message); + } + } + + private IntPtr LoadLibraryInternal(string dllName, string baseDirectory, ProcessArchitectureInfo processArchInfo) + { + var platformName = GetPlatformName(processArchInfo.Architecture); + var expectedDllDirectory = Path.Combine( + Path.Combine(baseDirectory, DllDirectory), platformName); + return this.LoadLibraryRaw(dllName, expectedDllDirectory); + } + + private IntPtr LoadLibraryRaw(string dllName, string baseDirectory) + { + var libraryHandle = IntPtr.Zero; + var fileName = FixUpDllFileName(Path.Combine(baseDirectory, dllName)); + + // Show where we're trying to load the file from + Debug.WriteLine($"Trying to load native library \"{fileName}\"..."); + + if (File.Exists(fileName)) + { + // Attempt to load dll + try + { + libraryHandle = Win32LoadLibrary(fileName); + if (libraryHandle != IntPtr.Zero) + { + // library has been loaded + Debug.WriteLine($"Successfully loaded native library \"{fileName}\"."); + LoadedLibraries.Add(dllName, libraryHandle); + } + else + { + Debug.WriteLine($"Failed to load native library \"{fileName}\".\r\nCheck windows event log."); + } + } + catch (Exception e) + { + var lastError = Marshal.GetLastWin32Error(); + Debug.WriteLine($"Failed to load native library \"{fileName}\".\r\nLast Error:{lastError}\r\nCheck inner exception and\\or windows event log.\r\nInner Exception: {e}"); + } + } + else + { + Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "The native library \"{0}\" does not exist.", fileName)); + } + + return libraryHandle; + } + + #endregion + + #endregion + + private class ProcessArchitectureInfo + { + + #region Constructors + + public ProcessArchitectureInfo() + { + this.Warnings = new List(); + } + + #endregion + + #region Properties + + public string Architecture + { + get; set; + } + + private List Warnings + { + get; + } + + #endregion + + #region Methods + + public void AddWarning(string format, params object[] args) + { + Warnings.Add(String.Format(format, args)); + } + + public bool HasWarnings => Warnings.Count > 0; + + public string WarningText() + { + return string.Join("\r\n", Warnings.ToArray()); + } + + #endregion + + } + + } + +} diff --git a/Radegast/FMOD/fmod.cs b/Radegast/FMOD/fmod.cs new file mode 100644 index 000000000..06ac47073 --- /dev/null +++ b/Radegast/FMOD/fmod.cs @@ -0,0 +1,3948 @@ +/* ======================================================================================== */ +/* FMOD Core API - C# wrapper. */ +/* Copyright (c), Firelight Technologies Pty, Ltd. 2004-2021. */ +/* */ +/* For more detail visit: */ +/* https://fmod.com/resources/documentation-api?version=2.0&page=core-api.html */ +/* ======================================================================================== */ + +using System; +using System.Text; +using System.Runtime.InteropServices; +using System.Collections.Generic; + +namespace FMOD +{ + /* + FMOD version number. Check this against FMOD::System::getVersion / System_GetVersion + 0xaaaabbcc -> aaaa = major version number. bb = minor version number. cc = development version number. + */ + public partial class VERSION + { + public const int number = 0x00020110; + public const string dll = "fmod"; + } + + public class CONSTANTS + { + public const int MAX_CHANNEL_WIDTH = 32; + public const int MAX_LISTENERS = 8; + public const int REVERB_MAXINSTANCES = 4; + public const int MAX_SYSTEMS = 8; + } + + /* + FMOD core types + */ + public enum RESULT : int + { + OK, + ERR_BADCOMMAND, + ERR_CHANNEL_ALLOC, + ERR_CHANNEL_STOLEN, + ERR_DMA, + ERR_DSP_CONNECTION, + ERR_DSP_DONTPROCESS, + ERR_DSP_FORMAT, + ERR_DSP_INUSE, + ERR_DSP_NOTFOUND, + ERR_DSP_RESERVED, + ERR_DSP_SILENCE, + ERR_DSP_TYPE, + ERR_FILE_BAD, + ERR_FILE_COULDNOTSEEK, + ERR_FILE_DISKEJECTED, + ERR_FILE_EOF, + ERR_FILE_ENDOFDATA, + ERR_FILE_NOTFOUND, + ERR_FORMAT, + ERR_HEADER_MISMATCH, + ERR_HTTP, + ERR_HTTP_ACCESS, + ERR_HTTP_PROXY_AUTH, + ERR_HTTP_SERVER_ERROR, + ERR_HTTP_TIMEOUT, + ERR_INITIALIZATION, + ERR_INITIALIZED, + ERR_INTERNAL, + ERR_INVALID_FLOAT, + ERR_INVALID_HANDLE, + ERR_INVALID_PARAM, + ERR_INVALID_POSITION, + ERR_INVALID_SPEAKER, + ERR_INVALID_SYNCPOINT, + ERR_INVALID_THREAD, + ERR_INVALID_VECTOR, + ERR_MAXAUDIBLE, + ERR_MEMORY, + ERR_MEMORY_CANTPOINT, + ERR_NEEDS3D, + ERR_NEEDSHARDWARE, + ERR_NET_CONNECT, + ERR_NET_SOCKET_ERROR, + ERR_NET_URL, + ERR_NET_WOULD_BLOCK, + ERR_NOTREADY, + ERR_OUTPUT_ALLOCATED, + ERR_OUTPUT_CREATEBUFFER, + ERR_OUTPUT_DRIVERCALL, + ERR_OUTPUT_FORMAT, + ERR_OUTPUT_INIT, + ERR_OUTPUT_NODRIVERS, + ERR_PLUGIN, + ERR_PLUGIN_MISSING, + ERR_PLUGIN_RESOURCE, + ERR_PLUGIN_VERSION, + ERR_RECORD, + ERR_REVERB_CHANNELGROUP, + ERR_REVERB_INSTANCE, + ERR_SUBSOUNDS, + ERR_SUBSOUND_ALLOCATED, + ERR_SUBSOUND_CANTMOVE, + ERR_TAGNOTFOUND, + ERR_TOOMANYCHANNELS, + ERR_TRUNCATED, + ERR_UNIMPLEMENTED, + ERR_UNINITIALIZED, + ERR_UNSUPPORTED, + ERR_VERSION, + ERR_EVENT_ALREADY_LOADED, + ERR_EVENT_LIVEUPDATE_BUSY, + ERR_EVENT_LIVEUPDATE_MISMATCH, + ERR_EVENT_LIVEUPDATE_TIMEOUT, + ERR_EVENT_NOTFOUND, + ERR_STUDIO_UNINITIALIZED, + ERR_STUDIO_NOT_LOADED, + ERR_INVALID_STRING, + ERR_ALREADY_LOCKED, + ERR_NOT_LOCKED, + ERR_RECORD_DISCONNECTED, + ERR_TOOMANYSAMPLES, + } + + public enum CHANNELCONTROL_TYPE : int + { + CHANNEL, + CHANNELGROUP, + MAX + } + + [StructLayout(LayoutKind.Sequential)] + public struct VECTOR + { + public float x; + public float y; + public float z; + } + + [StructLayout(LayoutKind.Sequential)] + public struct ATTRIBUTES_3D + { + public VECTOR position; + public VECTOR velocity; + public VECTOR forward; + public VECTOR up; + } + + [StructLayout(LayoutKind.Sequential)] + public struct ASYNCREADINFO + { + public IntPtr handle; + public uint offset; + public uint sizebytes; + public int priority; + + public IntPtr userdata; + public IntPtr buffer; + public uint bytesread; + public FILE_ASYNCDONE_FUNC done; + } + + public enum OUTPUTTYPE : int + { + AUTODETECT, + + UNKNOWN, + NOSOUND, + WAVWRITER, + NOSOUND_NRT, + WAVWRITER_NRT, + + WASAPI, + ASIO, + PULSEAUDIO, + ALSA, + COREAUDIO, + AUDIOTRACK, + OPENSL, + AUDIOOUT, + AUDIO3D, + WEBAUDIO, + NNAUDIO, + WINSONIC, + AAUDIO, + + MAX, + } + + public enum DEBUG_MODE : int + { + TTY, + FILE, + CALLBACK, + } + + [Flags] + public enum DEBUG_FLAGS : uint + { + NONE = 0x00000000, + ERROR = 0x00000001, + WARNING = 0x00000002, + LOG = 0x00000004, + + TYPE_MEMORY = 0x00000100, + TYPE_FILE = 0x00000200, + TYPE_CODEC = 0x00000400, + TYPE_TRACE = 0x00000800, + + DISPLAY_TIMESTAMPS = 0x00010000, + DISPLAY_LINENUMBERS = 0x00020000, + DISPLAY_THREAD = 0x00040000, + } + + [Flags] + public enum MEMORY_TYPE : uint + { + NORMAL = 0x00000000, + STREAM_FILE = 0x00000001, + STREAM_DECODE = 0x00000002, + SAMPLEDATA = 0x00000004, + DSP_BUFFER = 0x00000008, + PLUGIN = 0x00000010, + PERSISTENT = 0x00200000, + ALL = 0xFFFFFFFF + } + + public enum SPEAKERMODE : int + { + DEFAULT, + RAW, + MONO, + STEREO, + QUAD, + SURROUND, + _5POINT1, + _7POINT1, + _7POINT1POINT4, + + MAX, + } + + public enum SPEAKER : int + { + NONE = -1, + FRONT_LEFT, + FRONT_RIGHT, + FRONT_CENTER, + LOW_FREQUENCY, + SURROUND_LEFT, + SURROUND_RIGHT, + BACK_LEFT, + BACK_RIGHT, + TOP_FRONT_LEFT, + TOP_FRONT_RIGHT, + TOP_BACK_LEFT, + TOP_BACK_RIGHT, + + MAX, + } + + [Flags] + public enum CHANNELMASK : uint + { + FRONT_LEFT = 0x00000001, + FRONT_RIGHT = 0x00000002, + FRONT_CENTER = 0x00000004, + LOW_FREQUENCY = 0x00000008, + SURROUND_LEFT = 0x00000010, + SURROUND_RIGHT = 0x00000020, + BACK_LEFT = 0x00000040, + BACK_RIGHT = 0x00000080, + BACK_CENTER = 0x00000100, + + MONO = (FRONT_LEFT), + STEREO = (FRONT_LEFT | FRONT_RIGHT), + LRC = (FRONT_LEFT | FRONT_RIGHT | FRONT_CENTER), + QUAD = (FRONT_LEFT | FRONT_RIGHT | SURROUND_LEFT | SURROUND_RIGHT), + SURROUND = (FRONT_LEFT | FRONT_RIGHT | FRONT_CENTER | SURROUND_LEFT | SURROUND_RIGHT), + _5POINT1 = (FRONT_LEFT | FRONT_RIGHT | FRONT_CENTER | LOW_FREQUENCY | SURROUND_LEFT | SURROUND_RIGHT), + _5POINT1_REARS = (FRONT_LEFT | FRONT_RIGHT | FRONT_CENTER | LOW_FREQUENCY | BACK_LEFT | BACK_RIGHT), + _7POINT0 = (FRONT_LEFT | FRONT_RIGHT | FRONT_CENTER | SURROUND_LEFT | SURROUND_RIGHT | BACK_LEFT | BACK_RIGHT), + _7POINT1 = (FRONT_LEFT | FRONT_RIGHT | FRONT_CENTER | LOW_FREQUENCY | SURROUND_LEFT | SURROUND_RIGHT | BACK_LEFT | BACK_RIGHT) + } + + public enum CHANNELORDER : int + { + DEFAULT, + WAVEFORMAT, + PROTOOLS, + ALLMONO, + ALLSTEREO, + ALSA, + + MAX, + } + + public enum PLUGINTYPE : int + { + OUTPUT, + CODEC, + DSP, + + MAX, + } + + [StructLayout(LayoutKind.Sequential)] + public struct PLUGINLIST + { + PLUGINTYPE type; + IntPtr description; + } + + [Flags] + public enum INITFLAGS : uint + { + NORMAL = 0x00000000, + STREAM_FROM_UPDATE = 0x00000001, + MIX_FROM_UPDATE = 0x00000002, + _3D_RIGHTHANDED = 0x00000004, + CHANNEL_LOWPASS = 0x00000100, + CHANNEL_DISTANCEFILTER = 0x00000200, + PROFILE_ENABLE = 0x00010000, + VOL0_BECOMES_VIRTUAL = 0x00020000, + GEOMETRY_USECLOSEST = 0x00040000, + PREFER_DOLBY_DOWNMIX = 0x00080000, + THREAD_UNSAFE = 0x00100000, + PROFILE_METER_ALL = 0x00200000, + MEMORY_TRACKING = 0x00400000, + } + + public enum SOUND_TYPE : int + { + UNKNOWN, + AIFF, + ASF, + DLS, + FLAC, + FSB, + IT, + MIDI, + MOD, + MPEG, + OGGVORBIS, + PLAYLIST, + RAW, + S3M, + USER, + WAV, + XM, + XMA, + AUDIOQUEUE, + AT9, + VORBIS, + MEDIA_FOUNDATION, + MEDIACODEC, + FADPCM, + OPUS, + + MAX, + } + + public enum SOUND_FORMAT : int + { + NONE, + PCM8, + PCM16, + PCM24, + PCM32, + PCMFLOAT, + BITSTREAM, + + MAX + } + + [Flags] + public enum MODE : uint + { + DEFAULT = 0x00000000, + LOOP_OFF = 0x00000001, + LOOP_NORMAL = 0x00000002, + LOOP_BIDI = 0x00000004, + _2D = 0x00000008, + _3D = 0x00000010, + CREATESTREAM = 0x00000080, + CREATESAMPLE = 0x00000100, + CREATECOMPRESSEDSAMPLE = 0x00000200, + OPENUSER = 0x00000400, + OPENMEMORY = 0x00000800, + OPENMEMORY_POINT = 0x10000000, + OPENRAW = 0x00001000, + OPENONLY = 0x00002000, + ACCURATETIME = 0x00004000, + MPEGSEARCH = 0x00008000, + NONBLOCKING = 0x00010000, + UNIQUE = 0x00020000, + _3D_HEADRELATIVE = 0x00040000, + _3D_WORLDRELATIVE = 0x00080000, + _3D_INVERSEROLLOFF = 0x00100000, + _3D_LINEARROLLOFF = 0x00200000, + _3D_LINEARSQUAREROLLOFF = 0x00400000, + _3D_INVERSETAPEREDROLLOFF = 0x00800000, + _3D_CUSTOMROLLOFF = 0x04000000, + _3D_IGNOREGEOMETRY = 0x40000000, + IGNORETAGS = 0x02000000, + LOWMEM = 0x08000000, + VIRTUAL_PLAYFROMSTART = 0x80000000 + } + + public enum OPENSTATE : int + { + READY = 0, + LOADING, + ERROR, + CONNECTING, + BUFFERING, + SEEKING, + PLAYING, + SETPOSITION, + + MAX, + } + + public enum SOUNDGROUP_BEHAVIOR : int + { + BEHAVIOR_FAIL, + BEHAVIOR_MUTE, + BEHAVIOR_STEALLOWEST, + + MAX, + } + + public enum CHANNELCONTROL_CALLBACK_TYPE : int + { + END, + VIRTUALVOICE, + SYNCPOINT, + OCCLUSION, + + MAX, + } + + public struct CHANNELCONTROL_DSP_INDEX + { + public const int HEAD = -1; + public const int FADER = -2; + public const int TAIL = -3; + } + + public enum ERRORCALLBACK_INSTANCETYPE : int + { + NONE, + SYSTEM, + CHANNEL, + CHANNELGROUP, + CHANNELCONTROL, + SOUND, + SOUNDGROUP, + DSP, + DSPCONNECTION, + GEOMETRY, + REVERB3D, + STUDIO_SYSTEM, + STUDIO_EVENTDESCRIPTION, + STUDIO_EVENTINSTANCE, + STUDIO_PARAMETERINSTANCE, + STUDIO_BUS, + STUDIO_VCA, + STUDIO_BANK, + STUDIO_COMMANDREPLAY + } + + [StructLayout(LayoutKind.Sequential)] + public struct ERRORCALLBACK_INFO + { + public RESULT result; + public ERRORCALLBACK_INSTANCETYPE instancetype; + public IntPtr instance; + public StringWrapper functionname; + public StringWrapper functionparams; + } + + [Flags] + public enum SYSTEM_CALLBACK_TYPE : uint + { + DEVICELISTCHANGED = 0x00000001, + DEVICELOST = 0x00000002, + MEMORYALLOCATIONFAILED = 0x00000004, + THREADCREATED = 0x00000008, + BADDSPCONNECTION = 0x00000010, + PREMIX = 0x00000020, + POSTMIX = 0x00000040, + ERROR = 0x00000080, + MIDMIX = 0x00000100, + THREADDESTROYED = 0x00000200, + PREUPDATE = 0x00000400, + POSTUPDATE = 0x00000800, + RECORDLISTCHANGED = 0x00001000, + BUFFEREDNOMIX = 0x00002000, + DEVICEREINITIALIZE = 0x00004000, + OUTPUTUNDERRUN = 0x00008000, + ALL = 0xFFFFFFFF, + } + + /* + FMOD Callbacks + */ + public delegate RESULT DEBUG_CALLBACK (DEBUG_FLAGS flags, IntPtr file, int line, IntPtr func, IntPtr message); + public delegate RESULT SYSTEM_CALLBACK (IntPtr system, SYSTEM_CALLBACK_TYPE type, IntPtr commanddata1, IntPtr commanddata2, IntPtr userdata); + public delegate RESULT CHANNELCONTROL_CALLBACK (IntPtr channelcontrol, CHANNELCONTROL_TYPE controltype, CHANNELCONTROL_CALLBACK_TYPE callbacktype, IntPtr commanddata1, IntPtr commanddata2); + public delegate RESULT SOUND_NONBLOCK_CALLBACK (IntPtr sound, RESULT result); + public delegate RESULT SOUND_PCMREAD_CALLBACK (IntPtr sound, IntPtr data, uint datalen); + public delegate RESULT SOUND_PCMSETPOS_CALLBACK (IntPtr sound, int subsound, uint position, TIMEUNIT postype); + public delegate RESULT FILE_OPEN_CALLBACK (IntPtr name, ref uint filesize, ref IntPtr handle, IntPtr userdata); + public delegate RESULT FILE_CLOSE_CALLBACK (IntPtr handle, IntPtr userdata); + public delegate RESULT FILE_READ_CALLBACK (IntPtr handle, IntPtr buffer, uint sizebytes, ref uint bytesread, IntPtr userdata); + public delegate RESULT FILE_SEEK_CALLBACK (IntPtr handle, uint pos, IntPtr userdata); + public delegate RESULT FILE_ASYNCREAD_CALLBACK (IntPtr info, IntPtr userdata); + public delegate RESULT FILE_ASYNCCANCEL_CALLBACK(IntPtr info, IntPtr userdata); + public delegate RESULT FILE_ASYNCDONE_FUNC (IntPtr info, RESULT result); + public delegate IntPtr MEMORY_ALLOC_CALLBACK (uint size, MEMORY_TYPE type, IntPtr sourcestr); + public delegate IntPtr MEMORY_REALLOC_CALLBACK (IntPtr ptr, uint size, MEMORY_TYPE type, IntPtr sourcestr); + public delegate void MEMORY_FREE_CALLBACK (IntPtr ptr, MEMORY_TYPE type, IntPtr sourcestr); + public delegate float CB_3D_ROLLOFF_CALLBACK (IntPtr channelcontrol, float distance); + + public enum DSP_RESAMPLER : int + { + DEFAULT, + NOINTERP, + LINEAR, + CUBIC, + SPLINE, + + MAX, + } + + public enum DSPCONNECTION_TYPE : int + { + STANDARD, + SIDECHAIN, + SEND, + SEND_SIDECHAIN, + + MAX, + } + + public enum TAGTYPE : int + { + UNKNOWN = 0, + ID3V1, + ID3V2, + VORBISCOMMENT, + SHOUTCAST, + ICECAST, + ASF, + MIDI, + PLAYLIST, + FMOD, + USER, + + MAX + } + + public enum TAGDATATYPE : int + { + BINARY = 0, + INT, + FLOAT, + STRING, + STRING_UTF16, + STRING_UTF16BE, + STRING_UTF8, + + MAX + } + + [StructLayout(LayoutKind.Sequential)] + public struct TAG + { + public TAGTYPE type; + public TAGDATATYPE datatype; + public StringWrapper name; + public IntPtr data; + public uint datalen; + public bool updated; + } + + [Flags] + public enum TIMEUNIT : uint + { + MS = 0x00000001, + PCM = 0x00000002, + PCMBYTES = 0x00000004, + RAWBYTES = 0x00000008, + PCMFRACTION = 0x00000010, + MODORDER = 0x00000100, + MODROW = 0x00000200, + MODPATTERN = 0x00000400, + } + + public struct PORT_INDEX + { + public const ulong NONE = 0xFFFFFFFFFFFFFFFF; + } + + [StructLayout(LayoutKind.Sequential)] + public struct CREATESOUNDEXINFO + { + public int cbsize; + public uint length; + public uint fileoffset; + public int numchannels; + public int defaultfrequency; + public SOUND_FORMAT format; + public uint decodebuffersize; + public int initialsubsound; + public int numsubsounds; + public IntPtr inclusionlist; + public int inclusionlistnum; + public SOUND_PCMREAD_CALLBACK pcmreadcallback; + public SOUND_PCMSETPOS_CALLBACK pcmsetposcallback; + public SOUND_NONBLOCK_CALLBACK nonblockcallback; + public IntPtr dlsname; + public IntPtr encryptionkey; + public int maxpolyphony; + public IntPtr userdata; + public SOUND_TYPE suggestedsoundtype; + public FILE_OPEN_CALLBACK fileuseropen; + public FILE_CLOSE_CALLBACK fileuserclose; + public FILE_READ_CALLBACK fileuserread; + public FILE_SEEK_CALLBACK fileuserseek; + public FILE_ASYNCREAD_CALLBACK fileuserasyncread; + public FILE_ASYNCCANCEL_CALLBACK fileuserasynccancel; + public IntPtr fileuserdata; + public int filebuffersize; + public CHANNELORDER channelorder; + public IntPtr initialsoundgroup; + public uint initialseekposition; + public TIMEUNIT initialseekpostype; + public int ignoresetfilesystem; + public uint audioqueuepolicy; + public uint minmidigranularity; + public int nonblockthreadid; + public IntPtr fsbguid; + } + +#pragma warning disable 414 + [StructLayout(LayoutKind.Sequential)] + public struct REVERB_PROPERTIES + { + public float DecayTime; + public float EarlyDelay; + public float LateDelay; + public float HFReference; + public float HFDecayRatio; + public float Diffusion; + public float Density; + public float LowShelfFrequency; + public float LowShelfGain; + public float HighCut; + public float EarlyLateMix; + public float WetLevel; + + #region wrapperinternal + public REVERB_PROPERTIES(float decayTime, float earlyDelay, float lateDelay, float hfReference, + float hfDecayRatio, float diffusion, float density, float lowShelfFrequency, float lowShelfGain, + float highCut, float earlyLateMix, float wetLevel) + { + DecayTime = decayTime; + EarlyDelay = earlyDelay; + LateDelay = lateDelay; + HFReference = hfReference; + HFDecayRatio = hfDecayRatio; + Diffusion = diffusion; + Density = density; + LowShelfFrequency = lowShelfFrequency; + LowShelfGain = lowShelfGain; + HighCut = highCut; + EarlyLateMix = earlyLateMix; + WetLevel = wetLevel; + } + #endregion + } +#pragma warning restore 414 + + public class PRESET + { + /* Instance Env Diffus Room RoomHF RmLF DecTm DecHF DecLF Refl RefDel Revb RevDel ModTm ModDp HFRef LFRef Diffus Densty FLAGS */ + public static REVERB_PROPERTIES OFF() { return new REVERB_PROPERTIES( 1000, 7, 11, 5000, 100, 100, 100, 250, 0, 20, 96, -80.0f );} + public static REVERB_PROPERTIES GENERIC() { return new REVERB_PROPERTIES( 1500, 7, 11, 5000, 83, 100, 100, 250, 0, 14500, 96, -8.0f );} + public static REVERB_PROPERTIES PADDEDCELL() { return new REVERB_PROPERTIES( 170, 1, 2, 5000, 10, 100, 100, 250, 0, 160, 84, -7.8f );} + public static REVERB_PROPERTIES ROOM() { return new REVERB_PROPERTIES( 400, 2, 3, 5000, 83, 100, 100, 250, 0, 6050, 88, -9.4f );} + public static REVERB_PROPERTIES BATHROOM() { return new REVERB_PROPERTIES( 1500, 7, 11, 5000, 54, 100, 60, 250, 0, 2900, 83, 0.5f );} + public static REVERB_PROPERTIES LIVINGROOM() { return new REVERB_PROPERTIES( 500, 3, 4, 5000, 10, 100, 100, 250, 0, 160, 58, -19.0f );} + public static REVERB_PROPERTIES STONEROOM() { return new REVERB_PROPERTIES( 2300, 12, 17, 5000, 64, 100, 100, 250, 0, 7800, 71, -8.5f );} + public static REVERB_PROPERTIES AUDITORIUM() { return new REVERB_PROPERTIES( 4300, 20, 30, 5000, 59, 100, 100, 250, 0, 5850, 64, -11.7f );} + public static REVERB_PROPERTIES CONCERTHALL() { return new REVERB_PROPERTIES( 3900, 20, 29, 5000, 70, 100, 100, 250, 0, 5650, 80, -9.8f );} + public static REVERB_PROPERTIES CAVE() { return new REVERB_PROPERTIES( 2900, 15, 22, 5000, 100, 100, 100, 250, 0, 20000, 59, -11.3f );} + public static REVERB_PROPERTIES ARENA() { return new REVERB_PROPERTIES( 7200, 20, 30, 5000, 33, 100, 100, 250, 0, 4500, 80, -9.6f );} + public static REVERB_PROPERTIES HANGAR() { return new REVERB_PROPERTIES( 10000, 20, 30, 5000, 23, 100, 100, 250, 0, 3400, 72, -7.4f );} + public static REVERB_PROPERTIES CARPETTEDHALLWAY() { return new REVERB_PROPERTIES( 300, 2, 30, 5000, 10, 100, 100, 250, 0, 500, 56, -24.0f );} + public static REVERB_PROPERTIES HALLWAY() { return new REVERB_PROPERTIES( 1500, 7, 11, 5000, 59, 100, 100, 250, 0, 7800, 87, -5.5f );} + public static REVERB_PROPERTIES STONECORRIDOR() { return new REVERB_PROPERTIES( 270, 13, 20, 5000, 79, 100, 100, 250, 0, 9000, 86, -6.0f );} + public static REVERB_PROPERTIES ALLEY() { return new REVERB_PROPERTIES( 1500, 7, 11, 5000, 86, 100, 100, 250, 0, 8300, 80, -9.8f );} + public static REVERB_PROPERTIES FOREST() { return new REVERB_PROPERTIES( 1500, 162, 88, 5000, 54, 79, 100, 250, 0, 760, 94, -12.3f );} + public static REVERB_PROPERTIES CITY() { return new REVERB_PROPERTIES( 1500, 7, 11, 5000, 67, 50, 100, 250, 0, 4050, 66, -26.0f );} + public static REVERB_PROPERTIES MOUNTAINS() { return new REVERB_PROPERTIES( 1500, 300, 100, 5000, 21, 27, 100, 250, 0, 1220, 82, -24.0f );} + public static REVERB_PROPERTIES QUARRY() { return new REVERB_PROPERTIES( 1500, 61, 25, 5000, 83, 100, 100, 250, 0, 3400, 100, -5.0f );} + public static REVERB_PROPERTIES PLAIN() { return new REVERB_PROPERTIES( 1500, 179, 100, 5000, 50, 21, 100, 250, 0, 1670, 65, -28.0f );} + public static REVERB_PROPERTIES PARKINGLOT() { return new REVERB_PROPERTIES( 1700, 8, 12, 5000, 100, 100, 100, 250, 0, 20000, 56, -19.5f );} + public static REVERB_PROPERTIES SEWERPIPE() { return new REVERB_PROPERTIES( 2800, 14, 21, 5000, 14, 80, 60, 250, 0, 3400, 66, 1.2f );} + public static REVERB_PROPERTIES UNDERWATER() { return new REVERB_PROPERTIES( 1500, 7, 11, 5000, 10, 100, 100, 250, 0, 500, 92, 7.0f );} + } + + [StructLayout(LayoutKind.Sequential)] + public struct ADVANCEDSETTINGS + { + public int cbSize; + public int maxMPEGCodecs; + public int maxADPCMCodecs; + public int maxXMACodecs; + public int maxVorbisCodecs; + public int maxAT9Codecs; + public int maxFADPCMCodecs; + public int maxPCMCodecs; + public int ASIONumChannels; + public IntPtr ASIOChannelList; + public IntPtr ASIOSpeakerList; + public float vol0virtualvol; + public uint defaultDecodeBufferSize; + public ushort profilePort; + public uint geometryMaxFadeTime; + public float distanceFilterCenterFreq; + public int reverb3Dinstance; + public int DSPBufferPoolSize; + public DSP_RESAMPLER resamplerMethod; + public uint randomSeed; + public int maxConvolutionThreads; + } + + [Flags] + public enum DRIVER_STATE : uint + { + CONNECTED = 0x00000001, + DEFAULT = 0x00000002, + } + + public enum THREAD_PRIORITY : int + { + /* Platform specific priority range */ + PLATFORM_MIN = -32 * 1024, + PLATFORM_MAX = 32 * 1024, + + /* Platform agnostic priorities, maps internally to platform specific value */ + DEFAULT = PLATFORM_MIN - 1, + LOW = PLATFORM_MIN - 2, + MEDIUM = PLATFORM_MIN - 3, + HIGH = PLATFORM_MIN - 4, + VERY_HIGH = PLATFORM_MIN - 5, + EXTREME = PLATFORM_MIN - 6, + CRITICAL = PLATFORM_MIN - 7, + + /* Thread defaults */ + MIXER = EXTREME, + FEEDER = CRITICAL, + STREAM = VERY_HIGH, + FILE = HIGH, + NONBLOCKING = HIGH, + RECORD = HIGH, + GEOMETRY = LOW, + PROFILER = MEDIUM, + STUDIO_UPDATE = MEDIUM, + STUDIO_LOAD_BANK = MEDIUM, + STUDIO_LOAD_SAMPLE = MEDIUM, + CONVOLUTION1 = VERY_HIGH, + CONVOLUTION2 = VERY_HIGH + + } + + public enum THREAD_STACK_SIZE : uint + { + DEFAULT = 0, + MIXER = 80 * 1024, + FEEDER = 16 * 1024, + STREAM = 96 * 1024, + FILE = 48 * 1024, + NONBLOCKING = 112 * 1024, + RECORD = 16 * 1024, + GEOMETRY = 48 * 1024, + PROFILER = 128 * 1024, + STUDIO_UPDATE = 96 * 1024, + STUDIO_LOAD_BANK = 96 * 1024, + STUDIO_LOAD_SAMPLE = 96 * 1024, + CONVOLUTION1 = 16 * 1024, + CONVOLUTION2 = 16 * 1024 + } + + [Flags] + public enum THREAD_AFFINITY : long // avoid ulong for Bolt compatibility + { + /* Platform agnostic thread groupings */ + GROUP_DEFAULT = 0x4000000000000000, + GROUP_A = 0x4000000000000001, + GROUP_B = 0x4000000000000002, + GROUP_C = 0x4000000000000003, + + /* Thread defaults */ + MIXER = GROUP_A, + FEEDER = GROUP_C, + STREAM = GROUP_C, + FILE = GROUP_C, + NONBLOCKING = GROUP_C, + RECORD = GROUP_C, + GEOMETRY = GROUP_C, + PROFILER = GROUP_C, + STUDIO_UPDATE = GROUP_B, + STUDIO_LOAD_BANK = GROUP_C, + STUDIO_LOAD_SAMPLE = GROUP_C, + CONVOLUTION1 = GROUP_C, + CONVOLUTION2 = GROUP_C, + + /* Core mask, valid up to 1 << 61 */ + CORE_ALL = 0, + CORE_0 = 1 << 0, + CORE_1 = 1 << 1, + CORE_2 = 1 << 2, + CORE_3 = 1 << 3, + CORE_4 = 1 << 4, + CORE_5 = 1 << 5, + CORE_6 = 1 << 6, + CORE_7 = 1 << 7, + CORE_8 = 1 << 8, + CORE_9 = 1 << 9, + CORE_10 = 1 << 10, + CORE_11 = 1 << 11, + CORE_12 = 1 << 12, + CORE_13 = 1 << 13, + CORE_14 = 1 << 14, + CORE_15 = 1 << 15 + } + + public enum THREAD_TYPE : int + { + MIXER, + FEEDER, + STREAM, + FILE, + NONBLOCKING, + RECORD, + GEOMETRY, + PROFILER, + STUDIO_UPDATE, + STUDIO_LOAD_BANK, + STUDIO_LOAD_SAMPLE, + CONVOLUTION1, + CONVOLUTION2, + + MAX + } + + /* + FMOD System factory functions. Use this to create an FMOD System Instance. below you will see System init/close to get started. + */ + public struct Factory + { + public static RESULT System_Create(out System system) + { + return FMOD5_System_Create(out system.handle); + } + + #region importfunctions + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_Create(out IntPtr system); + + #endregion + } + + /* + FMOD global system functions (optional). + */ + public struct Memory + { + public static RESULT Initialize(IntPtr poolmem, int poollen, MEMORY_ALLOC_CALLBACK useralloc, MEMORY_REALLOC_CALLBACK userrealloc, MEMORY_FREE_CALLBACK userfree, MEMORY_TYPE memtypeflags = MEMORY_TYPE.ALL) + { + return FMOD5_Memory_Initialize(poolmem, poollen, useralloc, userrealloc, userfree, memtypeflags); + } + + public static RESULT GetStats(out int currentalloced, out int maxalloced, bool blocking = true) + { + return FMOD5_Memory_GetStats(out currentalloced, out maxalloced, blocking); + } + + #region importfunctions + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Memory_Initialize(IntPtr poolmem, int poollen, MEMORY_ALLOC_CALLBACK useralloc, MEMORY_REALLOC_CALLBACK userrealloc, MEMORY_FREE_CALLBACK userfree, MEMORY_TYPE memtypeflags); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Memory_GetStats (out int currentalloced, out int maxalloced, bool blocking); + + #endregion + } + + public struct Debug + { + public static RESULT Initialize(DEBUG_FLAGS flags, DEBUG_MODE mode = DEBUG_MODE.TTY, DEBUG_CALLBACK callback = null, string filename = null) + { + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + return FMOD5_Debug_Initialize(flags, mode, callback, encoder.byteFromStringUTF8(filename)); + } + } + + #region importfunctions + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Debug_Initialize(DEBUG_FLAGS flags, DEBUG_MODE mode, DEBUG_CALLBACK callback, byte[] filename); + + #endregion + } + + public struct Thread + { + public static RESULT SetAttributes(THREAD_TYPE type, THREAD_AFFINITY affinity = THREAD_AFFINITY.GROUP_DEFAULT, THREAD_PRIORITY priority = THREAD_PRIORITY.DEFAULT, THREAD_STACK_SIZE stacksize = THREAD_STACK_SIZE.DEFAULT) + { + if ((affinity & THREAD_AFFINITY.GROUP_DEFAULT) != 0) + { + affinity &= ~THREAD_AFFINITY.GROUP_DEFAULT; + affinity = (THREAD_AFFINITY)(((ulong)affinity) | 0x8000000000000000); + } + return FMOD5_Thread_SetAttributes(type, affinity, priority, stacksize); + } + + #region importfunctions + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Thread_SetAttributes(THREAD_TYPE type, THREAD_AFFINITY affinity, THREAD_PRIORITY priority, THREAD_STACK_SIZE stacksize); + #endregion + } + + /* + 'System' API. + */ + public struct System + { + public RESULT release() + { + return FMOD5_System_Release(this.handle); + } + + // Setup functions. + public RESULT setOutput(OUTPUTTYPE output) + { + return FMOD5_System_SetOutput(this.handle, output); + } + public RESULT getOutput(out OUTPUTTYPE output) + { + return FMOD5_System_GetOutput(this.handle, out output); + } + public RESULT getNumDrivers(out int numdrivers) + { + return FMOD5_System_GetNumDrivers(this.handle, out numdrivers); + } + public RESULT getDriverInfo(int id, out string name, int namelen, out Guid guid, out int systemrate, out SPEAKERMODE speakermode, out int speakermodechannels) + { + IntPtr stringMem = Marshal.AllocHGlobal(namelen); + + RESULT result = FMOD5_System_GetDriverInfo(this.handle, id, stringMem, namelen, out guid, out systemrate, out speakermode, out speakermodechannels); + using (StringHelper.ThreadSafeEncoding encoding = StringHelper.GetFreeHelper()) + { + name = encoding.stringFromNative(stringMem); + } + Marshal.FreeHGlobal(stringMem); + + return result; + } + public RESULT getDriverInfo(int id, out Guid guid, out int systemrate, out SPEAKERMODE speakermode, out int speakermodechannels) + { + return FMOD5_System_GetDriverInfo(this.handle, id, IntPtr.Zero, 0, out guid, out systemrate, out speakermode, out speakermodechannels); + } + public RESULT setDriver(int driver) + { + return FMOD5_System_SetDriver(this.handle, driver); + } + public RESULT getDriver(out int driver) + { + return FMOD5_System_GetDriver(this.handle, out driver); + } + public RESULT setSoftwareChannels(int numsoftwarechannels) + { + return FMOD5_System_SetSoftwareChannels(this.handle, numsoftwarechannels); + } + public RESULT getSoftwareChannels(out int numsoftwarechannels) + { + return FMOD5_System_GetSoftwareChannels(this.handle, out numsoftwarechannels); + } + public RESULT setSoftwareFormat(int samplerate, SPEAKERMODE speakermode, int numrawspeakers) + { + return FMOD5_System_SetSoftwareFormat(this.handle, samplerate, speakermode, numrawspeakers); + } + public RESULT getSoftwareFormat(out int samplerate, out SPEAKERMODE speakermode, out int numrawspeakers) + { + return FMOD5_System_GetSoftwareFormat(this.handle, out samplerate, out speakermode, out numrawspeakers); + } + public RESULT setDSPBufferSize(uint bufferlength, int numbuffers) + { + return FMOD5_System_SetDSPBufferSize(this.handle, bufferlength, numbuffers); + } + public RESULT getDSPBufferSize(out uint bufferlength, out int numbuffers) + { + return FMOD5_System_GetDSPBufferSize(this.handle, out bufferlength, out numbuffers); + } + public RESULT setFileSystem(FILE_OPEN_CALLBACK useropen, FILE_CLOSE_CALLBACK userclose, FILE_READ_CALLBACK userread, FILE_SEEK_CALLBACK userseek, FILE_ASYNCREAD_CALLBACK userasyncread, FILE_ASYNCCANCEL_CALLBACK userasynccancel, int blockalign) + { + return FMOD5_System_SetFileSystem(this.handle, useropen, userclose, userread, userseek, userasyncread, userasynccancel, blockalign); + } + public RESULT attachFileSystem(FILE_OPEN_CALLBACK useropen, FILE_CLOSE_CALLBACK userclose, FILE_READ_CALLBACK userread, FILE_SEEK_CALLBACK userseek) + { + return FMOD5_System_AttachFileSystem(this.handle, useropen, userclose, userread, userseek); + } + public RESULT setAdvancedSettings(ref ADVANCEDSETTINGS settings) + { + settings.cbSize = MarshalHelper.SizeOf(typeof(ADVANCEDSETTINGS)); + return FMOD5_System_SetAdvancedSettings(this.handle, ref settings); + } + public RESULT getAdvancedSettings(ref ADVANCEDSETTINGS settings) + { + settings.cbSize = MarshalHelper.SizeOf(typeof(ADVANCEDSETTINGS)); + return FMOD5_System_GetAdvancedSettings(this.handle, ref settings); + } + public RESULT setCallback(SYSTEM_CALLBACK callback, SYSTEM_CALLBACK_TYPE callbackmask = SYSTEM_CALLBACK_TYPE.ALL) + { + return FMOD5_System_SetCallback(this.handle, callback, callbackmask); + } + + // Plug-in support. + public RESULT setPluginPath(string path) + { + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + return FMOD5_System_SetPluginPath(this.handle, encoder.byteFromStringUTF8(path)); + } + } + public RESULT loadPlugin(string filename, out uint handle, uint priority = 0) + { + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + return FMOD5_System_LoadPlugin(this.handle, encoder.byteFromStringUTF8(filename), out handle, priority); + } + } + public RESULT unloadPlugin(uint handle) + { + return FMOD5_System_UnloadPlugin(this.handle, handle); + } + public RESULT getNumNestedPlugins(uint handle, out int count) + { + return FMOD5_System_GetNumNestedPlugins(this.handle, handle, out count); + } + public RESULT getNestedPlugin(uint handle, int index, out uint nestedhandle) + { + return FMOD5_System_GetNestedPlugin(this.handle, handle, index, out nestedhandle); + } + public RESULT getNumPlugins(PLUGINTYPE plugintype, out int numplugins) + { + return FMOD5_System_GetNumPlugins(this.handle, plugintype, out numplugins); + } + public RESULT getPluginHandle(PLUGINTYPE plugintype, int index, out uint handle) + { + return FMOD5_System_GetPluginHandle(this.handle, plugintype, index, out handle); + } + public RESULT getPluginInfo(uint handle, out PLUGINTYPE plugintype, out string name, int namelen, out uint version) + { + IntPtr stringMem = Marshal.AllocHGlobal(namelen); + + RESULT result = FMOD5_System_GetPluginInfo(this.handle, handle, out plugintype, stringMem, namelen, out version); + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + name = encoder.stringFromNative(stringMem); + } + Marshal.FreeHGlobal(stringMem); + + return result; + } + public RESULT getPluginInfo(uint handle, out PLUGINTYPE plugintype, out uint version) + { + return FMOD5_System_GetPluginInfo(this.handle, handle, out plugintype, IntPtr.Zero, 0, out version); + } + public RESULT setOutputByPlugin(uint handle) + { + return FMOD5_System_SetOutputByPlugin(this.handle, handle); + } + public RESULT getOutputByPlugin(out uint handle) + { + return FMOD5_System_GetOutputByPlugin(this.handle, out handle); + } + public RESULT createDSPByPlugin(uint handle, out DSP dsp) + { + return FMOD5_System_CreateDSPByPlugin(this.handle, handle, out dsp.handle); + } + public RESULT getDSPInfoByPlugin(uint handle, out IntPtr description) + { + return FMOD5_System_GetDSPInfoByPlugin(this.handle, handle, out description); + } + /* + public RESULT registerCodec (ref CODEC_DESCRIPTION description, out uint handle, uint priority) + public RESULT registerCodec (ref CODEC_DESCRIPTION description, out uint handle, uint priority = 0) + public RESULT registerCodec(ref CODEC_DESCRIPTION description, out uint handle, uint priority) + { + return FMOD5_System_RegisterCodec(this.handle, ref description, out handle, priority); + } + */ + public RESULT registerDSP(ref DSP_DESCRIPTION description, out uint handle) + { + return FMOD5_System_RegisterDSP(this.handle, ref description, out handle); + } + /* + public RESULT registerOutput(ref OUTPUT_DESCRIPTION description, out uint handle) + { + return FMOD5_System_RegisterOutput(this.handle, ref description, out handle); + } + */ + + // Init/Close. + public RESULT init(int maxchannels, INITFLAGS flags, IntPtr extradriverdata) + { + return FMOD5_System_Init(this.handle, maxchannels, flags, extradriverdata); + } + public RESULT close() + { + return FMOD5_System_Close(this.handle); + } + + // General post-init system functions. + public RESULT update() + { + return FMOD5_System_Update(this.handle); + } + public RESULT setSpeakerPosition(SPEAKER speaker, float x, float y, bool active) + { + return FMOD5_System_SetSpeakerPosition(this.handle, speaker, x, y, active); + } + public RESULT getSpeakerPosition(SPEAKER speaker, out float x, out float y, out bool active) + { + return FMOD5_System_GetSpeakerPosition(this.handle, speaker, out x, out y, out active); + } + public RESULT setStreamBufferSize(uint filebuffersize, TIMEUNIT filebuffersizetype) + { + return FMOD5_System_SetStreamBufferSize(this.handle, filebuffersize, filebuffersizetype); + } + public RESULT getStreamBufferSize(out uint filebuffersize, out TIMEUNIT filebuffersizetype) + { + return FMOD5_System_GetStreamBufferSize(this.handle, out filebuffersize, out filebuffersizetype); + } + public RESULT set3DSettings(float dopplerscale, float distancefactor, float rolloffscale) + { + return FMOD5_System_Set3DSettings(this.handle, dopplerscale, distancefactor, rolloffscale); + } + public RESULT get3DSettings(out float dopplerscale, out float distancefactor, out float rolloffscale) + { + return FMOD5_System_Get3DSettings(this.handle, out dopplerscale, out distancefactor, out rolloffscale); + } + public RESULT set3DNumListeners(int numlisteners) + { + return FMOD5_System_Set3DNumListeners(this.handle, numlisteners); + } + public RESULT get3DNumListeners(out int numlisteners) + { + return FMOD5_System_Get3DNumListeners(this.handle, out numlisteners); + } + public RESULT set3DListenerAttributes(int listener, ref VECTOR pos, ref VECTOR vel, ref VECTOR forward, ref VECTOR up) + { + return FMOD5_System_Set3DListenerAttributes(this.handle, listener, ref pos, ref vel, ref forward, ref up); + } + public RESULT get3DListenerAttributes(int listener, out VECTOR pos, out VECTOR vel, out VECTOR forward, out VECTOR up) + { + return FMOD5_System_Get3DListenerAttributes(this.handle, listener, out pos, out vel, out forward, out up); + } + public RESULT set3DRolloffCallback(CB_3D_ROLLOFF_CALLBACK callback) + { + return FMOD5_System_Set3DRolloffCallback(this.handle, callback); + } + public RESULT mixerSuspend() + { + return FMOD5_System_MixerSuspend(this.handle); + } + public RESULT mixerResume() + { + return FMOD5_System_MixerResume(this.handle); + } + public RESULT getDefaultMixMatrix(SPEAKERMODE sourcespeakermode, SPEAKERMODE targetspeakermode, float[] matrix, int matrixhop) + { + return FMOD5_System_GetDefaultMixMatrix(this.handle, sourcespeakermode, targetspeakermode, matrix, matrixhop); + } + public RESULT getSpeakerModeChannels(SPEAKERMODE mode, out int channels) + { + return FMOD5_System_GetSpeakerModeChannels(this.handle, mode, out channels); + } + + // System information functions. + public RESULT getVersion(out uint version) + { + return FMOD5_System_GetVersion(this.handle, out version); + } + public RESULT getOutputHandle(out IntPtr handle) + { + return FMOD5_System_GetOutputHandle(this.handle, out handle); + } + public RESULT getChannelsPlaying(out int channels) + { + return FMOD5_System_GetChannelsPlaying(this.handle, out channels, IntPtr.Zero); + } + public RESULT getChannelsPlaying(out int channels, out int realchannels) + { + return FMOD5_System_GetChannelsPlaying(this.handle, out channels, out realchannels); + } + public RESULT getCPUUsage(out float dsp, out float stream, out float geometry, out float update, out float total) + { + return FMOD5_System_GetCPUUsage(this.handle, out dsp, out stream, out geometry, out update, out total); + } + public RESULT getCPUUsageEx(out float convolutionThread1, out float convolutionThread2) + { + return FMOD5_System_GetCPUUsageEx(this.handle, out convolutionThread1, out convolutionThread2); + } + public RESULT getFileUsage(out Int64 sampleBytesRead, out Int64 streamBytesRead, out Int64 otherBytesRead) + { + return FMOD5_System_GetFileUsage(this.handle, out sampleBytesRead, out streamBytesRead, out otherBytesRead); + } + + // Sound/DSP/Channel/FX creation and retrieval. + public RESULT createSound(string name, MODE mode, ref CREATESOUNDEXINFO exinfo, out Sound sound) + { + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + return FMOD5_System_CreateSound(this.handle, encoder.byteFromStringUTF8(name), mode, ref exinfo, out sound.handle); + } + } + public RESULT createSound(byte[] data, MODE mode, ref CREATESOUNDEXINFO exinfo, out Sound sound) + { + return FMOD5_System_CreateSound(this.handle, data, mode, ref exinfo, out sound.handle); + } + public RESULT createSound(IntPtr name_or_data, MODE mode, ref CREATESOUNDEXINFO exinfo, out Sound sound) + { + return FMOD5_System_CreateSound(this.handle, name_or_data, mode, ref exinfo, out sound.handle); + } + public RESULT createSound(string name, MODE mode, out Sound sound) + { + CREATESOUNDEXINFO exinfo = new CREATESOUNDEXINFO(); + exinfo.cbsize = MarshalHelper.SizeOf(typeof(CREATESOUNDEXINFO)); + + return createSound(name, mode, ref exinfo, out sound); + } + public RESULT createStream(string name, MODE mode, ref CREATESOUNDEXINFO exinfo, out Sound sound) + { + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + return FMOD5_System_CreateStream(this.handle, encoder.byteFromStringUTF8(name), mode, ref exinfo, out sound.handle); + } + } + public RESULT createStream(byte[] data, MODE mode, ref CREATESOUNDEXINFO exinfo, out Sound sound) + { + return FMOD5_System_CreateStream(this.handle, data, mode, ref exinfo, out sound.handle); + } + public RESULT createStream(IntPtr name_or_data, MODE mode, ref CREATESOUNDEXINFO exinfo, out Sound sound) + { + return FMOD5_System_CreateStream(this.handle, name_or_data, mode, ref exinfo, out sound.handle); + } + public RESULT createStream(string name, MODE mode, out Sound sound) + { + CREATESOUNDEXINFO exinfo = new CREATESOUNDEXINFO(); + exinfo.cbsize = MarshalHelper.SizeOf(typeof(CREATESOUNDEXINFO)); + + return createStream(name, mode, ref exinfo, out sound); + } + public RESULT createDSP(ref DSP_DESCRIPTION description, out DSP dsp) + { + return FMOD5_System_CreateDSP(this.handle, ref description, out dsp.handle); + } + public RESULT createDSPByType(DSP_TYPE type, out DSP dsp) + { + return FMOD5_System_CreateDSPByType(this.handle, type, out dsp.handle); + } + public RESULT createChannelGroup(string name, out ChannelGroup channelgroup) + { + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + return FMOD5_System_CreateChannelGroup(this.handle, encoder.byteFromStringUTF8(name), out channelgroup.handle); + } + } + public RESULT createSoundGroup(string name, out SoundGroup soundgroup) + { + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + return FMOD5_System_CreateSoundGroup(this.handle, encoder.byteFromStringUTF8(name), out soundgroup.handle); + } + } + public RESULT createReverb3D(out Reverb3D reverb) + { + return FMOD5_System_CreateReverb3D(this.handle, out reverb.handle); + } + public RESULT playSound(Sound sound, ChannelGroup channelgroup, bool paused, out Channel channel) + { + return FMOD5_System_PlaySound(this.handle, sound.handle, channelgroup.handle, paused, out channel.handle); + } + public RESULT playDSP(DSP dsp, ChannelGroup channelgroup, bool paused, out Channel channel) + { + return FMOD5_System_PlayDSP(this.handle, dsp.handle, channelgroup.handle, paused, out channel.handle); + } + public RESULT getChannel(int channelid, out Channel channel) + { + return FMOD5_System_GetChannel(this.handle, channelid, out channel.handle); + } + public RESULT getDSPInfoByType(DSP_TYPE type, out IntPtr description) + { + return FMOD5_System_GetDSPInfoByType(this.handle, type, out description); + } + public RESULT getMasterChannelGroup(out ChannelGroup channelgroup) + { + return FMOD5_System_GetMasterChannelGroup(this.handle, out channelgroup.handle); + } + public RESULT getMasterSoundGroup(out SoundGroup soundgroup) + { + return FMOD5_System_GetMasterSoundGroup(this.handle, out soundgroup.handle); + } + + // Routing to ports. + public RESULT attachChannelGroupToPort(uint portType, ulong portIndex, ChannelGroup channelgroup, bool passThru = false) + { + return FMOD5_System_AttachChannelGroupToPort(this.handle, portType, portIndex, channelgroup.handle, passThru); + } + public RESULT detachChannelGroupFromPort(ChannelGroup channelgroup) + { + return FMOD5_System_DetachChannelGroupFromPort(this.handle, channelgroup.handle); + } + + // Reverb api. + public RESULT setReverbProperties(int instance, ref REVERB_PROPERTIES prop) + { + return FMOD5_System_SetReverbProperties(this.handle, instance, ref prop); + } + public RESULT getReverbProperties(int instance, out REVERB_PROPERTIES prop) + { + return FMOD5_System_GetReverbProperties(this.handle, instance, out prop); + } + + // System level DSP functionality. + public RESULT lockDSP() + { + return FMOD5_System_LockDSP(this.handle); + } + public RESULT unlockDSP() + { + return FMOD5_System_UnlockDSP(this.handle); + } + + // Recording api + public RESULT getRecordNumDrivers(out int numdrivers, out int numconnected) + { + return FMOD5_System_GetRecordNumDrivers(this.handle, out numdrivers, out numconnected); + } + public RESULT getRecordDriverInfo(int id, out string name, int namelen, out Guid guid, out int systemrate, out SPEAKERMODE speakermode, out int speakermodechannels, out DRIVER_STATE state) + { + IntPtr stringMem = Marshal.AllocHGlobal(namelen); + + RESULT result = FMOD5_System_GetRecordDriverInfo(this.handle, id, stringMem, namelen, out guid, out systemrate, out speakermode, out speakermodechannels, out state); + + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + name = encoder.stringFromNative(stringMem); + } + Marshal.FreeHGlobal(stringMem); + + return result; + } + public RESULT getRecordDriverInfo(int id, out Guid guid, out int systemrate, out SPEAKERMODE speakermode, out int speakermodechannels, out DRIVER_STATE state) + { + return FMOD5_System_GetRecordDriverInfo(this.handle, id, IntPtr.Zero, 0, out guid, out systemrate, out speakermode, out speakermodechannels, out state); + } + public RESULT getRecordPosition(int id, out uint position) + { + return FMOD5_System_GetRecordPosition(this.handle, id, out position); + } + public RESULT recordStart(int id, Sound sound, bool loop) + { + return FMOD5_System_RecordStart(this.handle, id, sound.handle, loop); + } + public RESULT recordStop(int id) + { + return FMOD5_System_RecordStop(this.handle, id); + } + public RESULT isRecording(int id, out bool recording) + { + return FMOD5_System_IsRecording(this.handle, id, out recording); + } + + // Geometry api + public RESULT createGeometry(int maxpolygons, int maxvertices, out Geometry geometry) + { + return FMOD5_System_CreateGeometry(this.handle, maxpolygons, maxvertices, out geometry.handle); + } + public RESULT setGeometrySettings(float maxworldsize) + { + return FMOD5_System_SetGeometrySettings(this.handle, maxworldsize); + } + public RESULT getGeometrySettings(out float maxworldsize) + { + return FMOD5_System_GetGeometrySettings(this.handle, out maxworldsize); + } + public RESULT loadGeometry(IntPtr data, int datasize, out Geometry geometry) + { + return FMOD5_System_LoadGeometry(this.handle, data, datasize, out geometry.handle); + } + public RESULT getGeometryOcclusion(ref VECTOR listener, ref VECTOR source, out float direct, out float reverb) + { + return FMOD5_System_GetGeometryOcclusion(this.handle, ref listener, ref source, out direct, out reverb); + } + + // Network functions + public RESULT setNetworkProxy(string proxy) + { + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + return FMOD5_System_SetNetworkProxy(this.handle, encoder.byteFromStringUTF8(proxy)); + } + } + public RESULT getNetworkProxy(out string proxy, int proxylen) + { + IntPtr stringMem = Marshal.AllocHGlobal(proxylen); + + RESULT result = FMOD5_System_GetNetworkProxy(this.handle, stringMem, proxylen); + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + proxy = encoder.stringFromNative(stringMem); + } + Marshal.FreeHGlobal(stringMem); + + return result; + } + public RESULT setNetworkTimeout(int timeout) + { + return FMOD5_System_SetNetworkTimeout(this.handle, timeout); + } + public RESULT getNetworkTimeout(out int timeout) + { + return FMOD5_System_GetNetworkTimeout(this.handle, out timeout); + } + + // Userdata set/get + public RESULT setUserData(IntPtr userdata) + { + return FMOD5_System_SetUserData(this.handle, userdata); + } + public RESULT getUserData(out IntPtr userdata) + { + return FMOD5_System_GetUserData(this.handle, out userdata); + } + + #region importfunctions + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_Release (IntPtr system); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_SetOutput (IntPtr system, OUTPUTTYPE output); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetOutput (IntPtr system, out OUTPUTTYPE output); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetNumDrivers (IntPtr system, out int numdrivers); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetDriverInfo (IntPtr system, int id, IntPtr name, int namelen, out Guid guid, out int systemrate, out SPEAKERMODE speakermode, out int speakermodechannels); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_SetDriver (IntPtr system, int driver); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetDriver (IntPtr system, out int driver); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_SetSoftwareChannels (IntPtr system, int numsoftwarechannels); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetSoftwareChannels (IntPtr system, out int numsoftwarechannels); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_SetSoftwareFormat (IntPtr system, int samplerate, SPEAKERMODE speakermode, int numrawspeakers); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetSoftwareFormat (IntPtr system, out int samplerate, out SPEAKERMODE speakermode, out int numrawspeakers); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_SetDSPBufferSize (IntPtr system, uint bufferlength, int numbuffers); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetDSPBufferSize (IntPtr system, out uint bufferlength, out int numbuffers); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_SetFileSystem (IntPtr system, FILE_OPEN_CALLBACK useropen, FILE_CLOSE_CALLBACK userclose, FILE_READ_CALLBACK userread, FILE_SEEK_CALLBACK userseek, FILE_ASYNCREAD_CALLBACK userasyncread, FILE_ASYNCCANCEL_CALLBACK userasynccancel, int blockalign); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_AttachFileSystem (IntPtr system, FILE_OPEN_CALLBACK useropen, FILE_CLOSE_CALLBACK userclose, FILE_READ_CALLBACK userread, FILE_SEEK_CALLBACK userseek); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_SetAdvancedSettings (IntPtr system, ref ADVANCEDSETTINGS settings); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetAdvancedSettings (IntPtr system, ref ADVANCEDSETTINGS settings); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_SetCallback (IntPtr system, SYSTEM_CALLBACK callback, SYSTEM_CALLBACK_TYPE callbackmask); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_SetPluginPath (IntPtr system, byte[] path); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_LoadPlugin (IntPtr system, byte[] filename, out uint handle, uint priority); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_UnloadPlugin (IntPtr system, uint handle); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetNumNestedPlugins (IntPtr system, uint handle, out int count); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetNestedPlugin (IntPtr system, uint handle, int index, out uint nestedhandle); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetNumPlugins (IntPtr system, PLUGINTYPE plugintype, out int numplugins); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetPluginHandle (IntPtr system, PLUGINTYPE plugintype, int index, out uint handle); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetPluginInfo (IntPtr system, uint handle, out PLUGINTYPE plugintype, IntPtr name, int namelen, out uint version); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_SetOutputByPlugin (IntPtr system, uint handle); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetOutputByPlugin (IntPtr system, out uint handle); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_CreateDSPByPlugin (IntPtr system, uint handle, out IntPtr dsp); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetDSPInfoByPlugin (IntPtr system, uint handle, out IntPtr description); + //[DllImport(VERSION.dll)] + //private static extern RESULT FMOD5_System_RegisterCodec (IntPtr system, out CODEC_DESCRIPTION description, out uint handle, uint priority); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_RegisterDSP (IntPtr system, ref DSP_DESCRIPTION description, out uint handle); + //[DllImport(VERSION.dll)] + //private static extern RESULT FMOD5_System_RegisterOutput (IntPtr system, ref OUTPUT_DESCRIPTION description, out uint handle); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_Init (IntPtr system, int maxchannels, INITFLAGS flags, IntPtr extradriverdata); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_Close (IntPtr system); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_Update (IntPtr system); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_SetSpeakerPosition (IntPtr system, SPEAKER speaker, float x, float y, bool active); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetSpeakerPosition (IntPtr system, SPEAKER speaker, out float x, out float y, out bool active); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_SetStreamBufferSize (IntPtr system, uint filebuffersize, TIMEUNIT filebuffersizetype); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetStreamBufferSize (IntPtr system, out uint filebuffersize, out TIMEUNIT filebuffersizetype); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_Set3DSettings (IntPtr system, float dopplerscale, float distancefactor, float rolloffscale); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_Get3DSettings (IntPtr system, out float dopplerscale, out float distancefactor, out float rolloffscale); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_Set3DNumListeners (IntPtr system, int numlisteners); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_Get3DNumListeners (IntPtr system, out int numlisteners); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_Set3DListenerAttributes (IntPtr system, int listener, ref VECTOR pos, ref VECTOR vel, ref VECTOR forward, ref VECTOR up); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_Get3DListenerAttributes (IntPtr system, int listener, out VECTOR pos, out VECTOR vel, out VECTOR forward, out VECTOR up); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_Set3DRolloffCallback (IntPtr system, CB_3D_ROLLOFF_CALLBACK callback); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_MixerSuspend (IntPtr system); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_MixerResume (IntPtr system); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetDefaultMixMatrix (IntPtr system, SPEAKERMODE sourcespeakermode, SPEAKERMODE targetspeakermode, float[] matrix, int matrixhop); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetSpeakerModeChannels (IntPtr system, SPEAKERMODE mode, out int channels); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetVersion (IntPtr system, out uint version); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetOutputHandle (IntPtr system, out IntPtr handle); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetChannelsPlaying (IntPtr system, out int channels, IntPtr zero); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetChannelsPlaying (IntPtr system, out int channels, out int realchannels); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetCPUUsage (IntPtr system, out float dsp, out float stream, out float geometry, out float update, out float total); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetCPUUsageEx (IntPtr system, out float convolutionThread1, out float convolutionThread2); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetFileUsage (IntPtr system, out Int64 sampleBytesRead, out Int64 streamBytesRead, out Int64 otherBytesRead); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_CreateSound (IntPtr system, byte[] name_or_data, MODE mode, ref CREATESOUNDEXINFO exinfo, out IntPtr sound); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_CreateSound (IntPtr system, IntPtr name_or_data, MODE mode, ref CREATESOUNDEXINFO exinfo, out IntPtr sound); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_CreateStream (IntPtr system, byte[] name_or_data, MODE mode, ref CREATESOUNDEXINFO exinfo, out IntPtr sound); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_CreateStream (IntPtr system, IntPtr name_or_data, MODE mode, ref CREATESOUNDEXINFO exinfo, out IntPtr sound); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_CreateDSP (IntPtr system, ref DSP_DESCRIPTION description, out IntPtr dsp); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_CreateDSPByType (IntPtr system, DSP_TYPE type, out IntPtr dsp); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_CreateChannelGroup (IntPtr system, byte[] name, out IntPtr channelgroup); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_CreateSoundGroup (IntPtr system, byte[] name, out IntPtr soundgroup); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_CreateReverb3D (IntPtr system, out IntPtr reverb); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_PlaySound (IntPtr system, IntPtr sound, IntPtr channelgroup, bool paused, out IntPtr channel); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_PlayDSP (IntPtr system, IntPtr dsp, IntPtr channelgroup, bool paused, out IntPtr channel); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetChannel (IntPtr system, int channelid, out IntPtr channel); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetDSPInfoByType (IntPtr system, DSP_TYPE type, out IntPtr description); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetMasterChannelGroup (IntPtr system, out IntPtr channelgroup); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetMasterSoundGroup (IntPtr system, out IntPtr soundgroup); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_AttachChannelGroupToPort (IntPtr system, uint portType, ulong portIndex, IntPtr channelgroup, bool passThru); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_DetachChannelGroupFromPort(IntPtr system, IntPtr channelgroup); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_SetReverbProperties (IntPtr system, int instance, ref REVERB_PROPERTIES prop); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetReverbProperties (IntPtr system, int instance, out REVERB_PROPERTIES prop); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_LockDSP (IntPtr system); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_UnlockDSP (IntPtr system); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetRecordNumDrivers (IntPtr system, out int numdrivers, out int numconnected); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetRecordDriverInfo (IntPtr system, int id, IntPtr name, int namelen, out Guid guid, out int systemrate, out SPEAKERMODE speakermode, out int speakermodechannels, out DRIVER_STATE state); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetRecordPosition (IntPtr system, int id, out uint position); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_RecordStart (IntPtr system, int id, IntPtr sound, bool loop); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_RecordStop (IntPtr system, int id); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_IsRecording (IntPtr system, int id, out bool recording); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_CreateGeometry (IntPtr system, int maxpolygons, int maxvertices, out IntPtr geometry); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_SetGeometrySettings (IntPtr system, float maxworldsize); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetGeometrySettings (IntPtr system, out float maxworldsize); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_LoadGeometry (IntPtr system, IntPtr data, int datasize, out IntPtr geometry); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetGeometryOcclusion (IntPtr system, ref VECTOR listener, ref VECTOR source, out float direct, out float reverb); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_SetNetworkProxy (IntPtr system, byte[] proxy); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetNetworkProxy (IntPtr system, IntPtr proxy, int proxylen); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_SetNetworkTimeout (IntPtr system, int timeout); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetNetworkTimeout (IntPtr system, out int timeout); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_SetUserData (IntPtr system, IntPtr userdata); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_System_GetUserData (IntPtr system, out IntPtr userdata); + #endregion + + #region wrapperinternal + + public IntPtr handle; + + public System(IntPtr ptr) { this.handle = ptr; } + public bool hasHandle() { return this.handle != IntPtr.Zero; } + public void clearHandle() { this.handle = IntPtr.Zero; } + + #endregion + } + + + /* + 'Sound' API. + */ + public struct Sound + { + public RESULT release() + { + return FMOD5_Sound_Release(this.handle); + } + public RESULT getSystemObject(out System system) + { + return FMOD5_Sound_GetSystemObject(this.handle, out system.handle); + } + + // Standard sound manipulation functions. + public RESULT @lock(uint offset, uint length, out IntPtr ptr1, out IntPtr ptr2, out uint len1, out uint len2) + { + return FMOD5_Sound_Lock(this.handle, offset, length, out ptr1, out ptr2, out len1, out len2); + } + public RESULT unlock(IntPtr ptr1, IntPtr ptr2, uint len1, uint len2) + { + return FMOD5_Sound_Unlock(this.handle, ptr1, ptr2, len1, len2); + } + public RESULT setDefaults(float frequency, int priority) + { + return FMOD5_Sound_SetDefaults(this.handle, frequency, priority); + } + public RESULT getDefaults(out float frequency, out int priority) + { + return FMOD5_Sound_GetDefaults(this.handle, out frequency, out priority); + } + public RESULT set3DMinMaxDistance(float min, float max) + { + return FMOD5_Sound_Set3DMinMaxDistance(this.handle, min, max); + } + public RESULT get3DMinMaxDistance(out float min, out float max) + { + return FMOD5_Sound_Get3DMinMaxDistance(this.handle, out min, out max); + } + public RESULT set3DConeSettings(float insideconeangle, float outsideconeangle, float outsidevolume) + { + return FMOD5_Sound_Set3DConeSettings(this.handle, insideconeangle, outsideconeangle, outsidevolume); + } + public RESULT get3DConeSettings(out float insideconeangle, out float outsideconeangle, out float outsidevolume) + { + return FMOD5_Sound_Get3DConeSettings(this.handle, out insideconeangle, out outsideconeangle, out outsidevolume); + } + public RESULT set3DCustomRolloff(ref VECTOR points, int numpoints) + { + return FMOD5_Sound_Set3DCustomRolloff(this.handle, ref points, numpoints); + } + public RESULT get3DCustomRolloff(out IntPtr points, out int numpoints) + { + return FMOD5_Sound_Get3DCustomRolloff(this.handle, out points, out numpoints); + } + + public RESULT getSubSound(int index, out Sound subsound) + { + return FMOD5_Sound_GetSubSound(this.handle, index, out subsound.handle); + } + public RESULT getSubSoundParent(out Sound parentsound) + { + return FMOD5_Sound_GetSubSoundParent(this.handle, out parentsound.handle); + } + public RESULT getName(out string name, int namelen) + { + IntPtr stringMem = Marshal.AllocHGlobal(namelen); + + RESULT result = FMOD5_Sound_GetName(this.handle, stringMem, namelen); + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + name = encoder.stringFromNative(stringMem); + } + Marshal.FreeHGlobal(stringMem); + + return result; + } + public RESULT getLength(out uint length, TIMEUNIT lengthtype) + { + return FMOD5_Sound_GetLength(this.handle, out length, lengthtype); + } + public RESULT getFormat(out SOUND_TYPE type, out SOUND_FORMAT format, out int channels, out int bits) + { + return FMOD5_Sound_GetFormat(this.handle, out type, out format, out channels, out bits); + } + public RESULT getNumSubSounds(out int numsubsounds) + { + return FMOD5_Sound_GetNumSubSounds(this.handle, out numsubsounds); + } + public RESULT getNumTags(out int numtags, out int numtagsupdated) + { + return FMOD5_Sound_GetNumTags(this.handle, out numtags, out numtagsupdated); + } + public RESULT getTag(string name, int index, out TAG tag) + { + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + return FMOD5_Sound_GetTag(this.handle, encoder.byteFromStringUTF8(name), index, out tag); + } + } + public RESULT getOpenState(out OPENSTATE openstate, out uint percentbuffered, out bool starving, out bool diskbusy) + { + return FMOD5_Sound_GetOpenState(this.handle, out openstate, out percentbuffered, out starving, out diskbusy); + } + public RESULT readData(IntPtr buffer, uint length, out uint read) + { + return FMOD5_Sound_ReadData(this.handle, buffer, length, out read); + } + public RESULT seekData(uint pcm) + { + return FMOD5_Sound_SeekData(this.handle, pcm); + } + public RESULT setSoundGroup(SoundGroup soundgroup) + { + return FMOD5_Sound_SetSoundGroup(this.handle, soundgroup.handle); + } + public RESULT getSoundGroup(out SoundGroup soundgroup) + { + return FMOD5_Sound_GetSoundGroup(this.handle, out soundgroup.handle); + } + + // Synchronization point API. These points can come from markers embedded in wav files, and can also generate channel callbacks. + public RESULT getNumSyncPoints(out int numsyncpoints) + { + return FMOD5_Sound_GetNumSyncPoints(this.handle, out numsyncpoints); + } + public RESULT getSyncPoint(int index, out IntPtr point) + { + return FMOD5_Sound_GetSyncPoint(this.handle, index, out point); + } + public RESULT getSyncPointInfo(IntPtr point, out string name, int namelen, out uint offset, TIMEUNIT offsettype) + { + IntPtr stringMem = Marshal.AllocHGlobal(namelen); + + RESULT result = FMOD5_Sound_GetSyncPointInfo(this.handle, point, stringMem, namelen, out offset, offsettype); + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + name = encoder.stringFromNative(stringMem); + } + Marshal.FreeHGlobal(stringMem); + + return result; + } + public RESULT getSyncPointInfo(IntPtr point, out uint offset, TIMEUNIT offsettype) + { + return FMOD5_Sound_GetSyncPointInfo(this.handle, point, IntPtr.Zero, 0, out offset, offsettype); + } + public RESULT addSyncPoint(uint offset, TIMEUNIT offsettype, string name, out IntPtr point) + { + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + return FMOD5_Sound_AddSyncPoint(this.handle, offset, offsettype, encoder.byteFromStringUTF8(name), out point); + } + } + public RESULT deleteSyncPoint(IntPtr point) + { + return FMOD5_Sound_DeleteSyncPoint(this.handle, point); + } + + // Functions also in Channel class but here they are the 'default' to save having to change it in Channel all the time. + public RESULT setMode(MODE mode) + { + return FMOD5_Sound_SetMode(this.handle, mode); + } + public RESULT getMode(out MODE mode) + { + return FMOD5_Sound_GetMode(this.handle, out mode); + } + public RESULT setLoopCount(int loopcount) + { + return FMOD5_Sound_SetLoopCount(this.handle, loopcount); + } + public RESULT getLoopCount(out int loopcount) + { + return FMOD5_Sound_GetLoopCount(this.handle, out loopcount); + } + public RESULT setLoopPoints(uint loopstart, TIMEUNIT loopstarttype, uint loopend, TIMEUNIT loopendtype) + { + return FMOD5_Sound_SetLoopPoints(this.handle, loopstart, loopstarttype, loopend, loopendtype); + } + public RESULT getLoopPoints(out uint loopstart, TIMEUNIT loopstarttype, out uint loopend, TIMEUNIT loopendtype) + { + return FMOD5_Sound_GetLoopPoints(this.handle, out loopstart, loopstarttype, out loopend, loopendtype); + } + + // For MOD/S3M/XM/IT/MID sequenced formats only. + public RESULT getMusicNumChannels(out int numchannels) + { + return FMOD5_Sound_GetMusicNumChannels(this.handle, out numchannels); + } + public RESULT setMusicChannelVolume(int channel, float volume) + { + return FMOD5_Sound_SetMusicChannelVolume(this.handle, channel, volume); + } + public RESULT getMusicChannelVolume(int channel, out float volume) + { + return FMOD5_Sound_GetMusicChannelVolume(this.handle, channel, out volume); + } + public RESULT setMusicSpeed(float speed) + { + return FMOD5_Sound_SetMusicSpeed(this.handle, speed); + } + public RESULT getMusicSpeed(out float speed) + { + return FMOD5_Sound_GetMusicSpeed(this.handle, out speed); + } + + // Userdata set/get. + public RESULT setUserData(IntPtr userdata) + { + return FMOD5_Sound_SetUserData(this.handle, userdata); + } + public RESULT getUserData(out IntPtr userdata) + { + return FMOD5_Sound_GetUserData(this.handle, out userdata); + } + + #region importfunctions + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_Release (IntPtr sound); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_GetSystemObject (IntPtr sound, out IntPtr system); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_Lock (IntPtr sound, uint offset, uint length, out IntPtr ptr1, out IntPtr ptr2, out uint len1, out uint len2); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_Unlock (IntPtr sound, IntPtr ptr1, IntPtr ptr2, uint len1, uint len2); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_SetDefaults (IntPtr sound, float frequency, int priority); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_GetDefaults (IntPtr sound, out float frequency, out int priority); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_Set3DMinMaxDistance (IntPtr sound, float min, float max); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_Get3DMinMaxDistance (IntPtr sound, out float min, out float max); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_Set3DConeSettings (IntPtr sound, float insideconeangle, float outsideconeangle, float outsidevolume); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_Get3DConeSettings (IntPtr sound, out float insideconeangle, out float outsideconeangle, out float outsidevolume); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_Set3DCustomRolloff (IntPtr sound, ref VECTOR points, int numpoints); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_Get3DCustomRolloff (IntPtr sound, out IntPtr points, out int numpoints); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_GetSubSound (IntPtr sound, int index, out IntPtr subsound); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_GetSubSoundParent (IntPtr sound, out IntPtr parentsound); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_GetName (IntPtr sound, IntPtr name, int namelen); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_GetLength (IntPtr sound, out uint length, TIMEUNIT lengthtype); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_GetFormat (IntPtr sound, out SOUND_TYPE type, out SOUND_FORMAT format, out int channels, out int bits); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_GetNumSubSounds (IntPtr sound, out int numsubsounds); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_GetNumTags (IntPtr sound, out int numtags, out int numtagsupdated); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_GetTag (IntPtr sound, byte[] name, int index, out TAG tag); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_GetOpenState (IntPtr sound, out OPENSTATE openstate, out uint percentbuffered, out bool starving, out bool diskbusy); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_ReadData (IntPtr sound, IntPtr buffer, uint length, out uint read); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_SeekData (IntPtr sound, uint pcm); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_SetSoundGroup (IntPtr sound, IntPtr soundgroup); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_GetSoundGroup (IntPtr sound, out IntPtr soundgroup); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_GetNumSyncPoints (IntPtr sound, out int numsyncpoints); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_GetSyncPoint (IntPtr sound, int index, out IntPtr point); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_GetSyncPointInfo (IntPtr sound, IntPtr point, IntPtr name, int namelen, out uint offset, TIMEUNIT offsettype); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_AddSyncPoint (IntPtr sound, uint offset, TIMEUNIT offsettype, byte[] name, out IntPtr point); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_DeleteSyncPoint (IntPtr sound, IntPtr point); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_SetMode (IntPtr sound, MODE mode); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_GetMode (IntPtr sound, out MODE mode); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_SetLoopCount (IntPtr sound, int loopcount); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_GetLoopCount (IntPtr sound, out int loopcount); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_SetLoopPoints (IntPtr sound, uint loopstart, TIMEUNIT loopstarttype, uint loopend, TIMEUNIT loopendtype); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_GetLoopPoints (IntPtr sound, out uint loopstart, TIMEUNIT loopstarttype, out uint loopend, TIMEUNIT loopendtype); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_GetMusicNumChannels (IntPtr sound, out int numchannels); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_SetMusicChannelVolume (IntPtr sound, int channel, float volume); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_GetMusicChannelVolume (IntPtr sound, int channel, out float volume); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_SetMusicSpeed (IntPtr sound, float speed); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_GetMusicSpeed (IntPtr sound, out float speed); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_SetUserData (IntPtr sound, IntPtr userdata); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Sound_GetUserData (IntPtr sound, out IntPtr userdata); + #endregion + + #region wrapperinternal + + public IntPtr handle; + + public Sound(IntPtr ptr) { this.handle = ptr; } + public bool hasHandle() { return this.handle != IntPtr.Zero; } + public void clearHandle() { this.handle = IntPtr.Zero; } + + #endregion + } + + /* + 'ChannelControl' API + */ + interface IChannelControl + { + RESULT getSystemObject (out System system); + + // General control functionality for Channels and ChannelGroups. + RESULT stop (); + RESULT setPaused (bool paused); + RESULT getPaused (out bool paused); + RESULT setVolume (float volume); + RESULT getVolume (out float volume); + RESULT setVolumeRamp (bool ramp); + RESULT getVolumeRamp (out bool ramp); + RESULT getAudibility (out float audibility); + RESULT setPitch (float pitch); + RESULT getPitch (out float pitch); + RESULT setMute (bool mute); + RESULT getMute (out bool mute); + RESULT setReverbProperties (int instance, float wet); + RESULT getReverbProperties (int instance, out float wet); + RESULT setLowPassGain (float gain); + RESULT getLowPassGain (out float gain); + RESULT setMode (MODE mode); + RESULT getMode (out MODE mode); + RESULT setCallback (CHANNELCONTROL_CALLBACK callback); + RESULT isPlaying (out bool isplaying); + + // Note all 'set' functions alter a final matrix, this is why the only get function is getMixMatrix, to avoid other get functions returning incorrect/obsolete values. + RESULT setPan (float pan); + RESULT setMixLevelsOutput (float frontleft, float frontright, float center, float lfe, float surroundleft, float surroundright, float backleft, float backright); + RESULT setMixLevelsInput (float[] levels, int numlevels); + RESULT setMixMatrix (float[] matrix, int outchannels, int inchannels, int inchannel_hop); + RESULT getMixMatrix (float[] matrix, out int outchannels, out int inchannels, int inchannel_hop); + + // Clock based functionality. + RESULT getDSPClock (out ulong dspclock, out ulong parentclock); + RESULT setDelay (ulong dspclock_start, ulong dspclock_end, bool stopchannels); + RESULT getDelay (out ulong dspclock_start, out ulong dspclock_end); + RESULT getDelay (out ulong dspclock_start, out ulong dspclock_end, out bool stopchannels); + RESULT addFadePoint (ulong dspclock, float volume); + RESULT setFadePointRamp (ulong dspclock, float volume); + RESULT removeFadePoints (ulong dspclock_start, ulong dspclock_end); + RESULT getFadePoints (ref uint numpoints, ulong[] point_dspclock, float[] point_volume); + + // DSP effects. + RESULT getDSP (int index, out DSP dsp); + RESULT addDSP (int index, DSP dsp); + RESULT removeDSP (DSP dsp); + RESULT getNumDSPs (out int numdsps); + RESULT setDSPIndex (DSP dsp, int index); + RESULT getDSPIndex (DSP dsp, out int index); + + // 3D functionality. + RESULT set3DAttributes (ref VECTOR pos, ref VECTOR vel); + RESULT get3DAttributes (out VECTOR pos, out VECTOR vel); + RESULT set3DMinMaxDistance (float mindistance, float maxdistance); + RESULT get3DMinMaxDistance (out float mindistance, out float maxdistance); + RESULT set3DConeSettings (float insideconeangle, float outsideconeangle, float outsidevolume); + RESULT get3DConeSettings (out float insideconeangle, out float outsideconeangle, out float outsidevolume); + RESULT set3DConeOrientation (ref VECTOR orientation); + RESULT get3DConeOrientation (out VECTOR orientation); + RESULT set3DCustomRolloff (ref VECTOR points, int numpoints); + RESULT get3DCustomRolloff (out IntPtr points, out int numpoints); + RESULT set3DOcclusion (float directocclusion, float reverbocclusion); + RESULT get3DOcclusion (out float directocclusion, out float reverbocclusion); + RESULT set3DSpread (float angle); + RESULT get3DSpread (out float angle); + RESULT set3DLevel (float level); + RESULT get3DLevel (out float level); + RESULT set3DDopplerLevel (float level); + RESULT get3DDopplerLevel (out float level); + RESULT set3DDistanceFilter (bool custom, float customLevel, float centerFreq); + RESULT get3DDistanceFilter (out bool custom, out float customLevel, out float centerFreq); + + // Userdata set/get. + RESULT setUserData (IntPtr userdata); + RESULT getUserData (out IntPtr userdata); + } + + /* + 'Channel' API + */ + public struct Channel : IChannelControl + { + // Channel specific control functionality. + public RESULT setFrequency(float frequency) + { + return FMOD5_Channel_SetFrequency(this.handle, frequency); + } + public RESULT getFrequency(out float frequency) + { + return FMOD5_Channel_GetFrequency(this.handle, out frequency); + } + public RESULT setPriority(int priority) + { + return FMOD5_Channel_SetPriority(this.handle, priority); + } + public RESULT getPriority(out int priority) + { + return FMOD5_Channel_GetPriority(this.handle, out priority); + } + public RESULT setPosition(uint position, TIMEUNIT postype) + { + return FMOD5_Channel_SetPosition(this.handle, position, postype); + } + public RESULT getPosition(out uint position, TIMEUNIT postype) + { + return FMOD5_Channel_GetPosition(this.handle, out position, postype); + } + public RESULT setChannelGroup(ChannelGroup channelgroup) + { + return FMOD5_Channel_SetChannelGroup(this.handle, channelgroup.handle); + } + public RESULT getChannelGroup(out ChannelGroup channelgroup) + { + return FMOD5_Channel_GetChannelGroup(this.handle, out channelgroup.handle); + } + public RESULT setLoopCount(int loopcount) + { + return FMOD5_Channel_SetLoopCount(this.handle, loopcount); + } + public RESULT getLoopCount(out int loopcount) + { + return FMOD5_Channel_GetLoopCount(this.handle, out loopcount); + } + public RESULT setLoopPoints(uint loopstart, TIMEUNIT loopstarttype, uint loopend, TIMEUNIT loopendtype) + { + return FMOD5_Channel_SetLoopPoints(this.handle, loopstart, loopstarttype, loopend, loopendtype); + } + public RESULT getLoopPoints(out uint loopstart, TIMEUNIT loopstarttype, out uint loopend, TIMEUNIT loopendtype) + { + return FMOD5_Channel_GetLoopPoints(this.handle, out loopstart, loopstarttype, out loopend, loopendtype); + } + + // Information only functions. + public RESULT isVirtual(out bool isvirtual) + { + return FMOD5_Channel_IsVirtual(this.handle, out isvirtual); + } + public RESULT getCurrentSound(out Sound sound) + { + return FMOD5_Channel_GetCurrentSound(this.handle, out sound.handle); + } + public RESULT getIndex(out int index) + { + return FMOD5_Channel_GetIndex(this.handle, out index); + } + + public RESULT getSystemObject(out System system) + { + return FMOD5_Channel_GetSystemObject(this.handle, out system.handle); + } + + // General control functionality for Channels and ChannelGroups. + public RESULT stop() + { + return FMOD5_Channel_Stop(this.handle); + } + public RESULT setPaused(bool paused) + { + return FMOD5_Channel_SetPaused(this.handle, paused); + } + public RESULT getPaused(out bool paused) + { + return FMOD5_Channel_GetPaused(this.handle, out paused); + } + public RESULT setVolume(float volume) + { + return FMOD5_Channel_SetVolume(this.handle, volume); + } + public RESULT getVolume(out float volume) + { + return FMOD5_Channel_GetVolume(this.handle, out volume); + } + public RESULT setVolumeRamp(bool ramp) + { + return FMOD5_Channel_SetVolumeRamp(this.handle, ramp); + } + public RESULT getVolumeRamp(out bool ramp) + { + return FMOD5_Channel_GetVolumeRamp(this.handle, out ramp); + } + public RESULT getAudibility(out float audibility) + { + return FMOD5_Channel_GetAudibility(this.handle, out audibility); + } + public RESULT setPitch(float pitch) + { + return FMOD5_Channel_SetPitch(this.handle, pitch); + } + public RESULT getPitch(out float pitch) + { + return FMOD5_Channel_GetPitch(this.handle, out pitch); + } + public RESULT setMute(bool mute) + { + return FMOD5_Channel_SetMute(this.handle, mute); + } + public RESULT getMute(out bool mute) + { + return FMOD5_Channel_GetMute(this.handle, out mute); + } + public RESULT setReverbProperties(int instance, float wet) + { + return FMOD5_Channel_SetReverbProperties(this.handle, instance, wet); + } + public RESULT getReverbProperties(int instance, out float wet) + { + return FMOD5_Channel_GetReverbProperties(this.handle, instance, out wet); + } + public RESULT setLowPassGain(float gain) + { + return FMOD5_Channel_SetLowPassGain(this.handle, gain); + } + public RESULT getLowPassGain(out float gain) + { + return FMOD5_Channel_GetLowPassGain(this.handle, out gain); + } + public RESULT setMode(MODE mode) + { + return FMOD5_Channel_SetMode(this.handle, mode); + } + public RESULT getMode(out MODE mode) + { + return FMOD5_Channel_GetMode(this.handle, out mode); + } + public RESULT setCallback(CHANNELCONTROL_CALLBACK callback) + { + return FMOD5_Channel_SetCallback(this.handle, callback); + } + public RESULT isPlaying(out bool isplaying) + { + return FMOD5_Channel_IsPlaying(this.handle, out isplaying); + } + + // Note all 'set' functions alter a final matrix, this is why the only get function is getMixMatrix, to avoid other get functions returning incorrect/obsolete values. + public RESULT setPan(float pan) + { + return FMOD5_Channel_SetPan(this.handle, pan); + } + public RESULT setMixLevelsOutput(float frontleft, float frontright, float center, float lfe, float surroundleft, float surroundright, float backleft, float backright) + { + return FMOD5_Channel_SetMixLevelsOutput(this.handle, frontleft, frontright, center, lfe, surroundleft, surroundright, backleft, backright); + } + public RESULT setMixLevelsInput(float[] levels, int numlevels) + { + return FMOD5_Channel_SetMixLevelsInput(this.handle, levels, numlevels); + } + public RESULT setMixMatrix(float[] matrix, int outchannels, int inchannels, int inchannel_hop = 0) + { + return FMOD5_Channel_SetMixMatrix(this.handle, matrix, outchannels, inchannels, inchannel_hop); + } + public RESULT getMixMatrix(float[] matrix, out int outchannels, out int inchannels, int inchannel_hop = 0) + { + return FMOD5_Channel_GetMixMatrix(this.handle, matrix, out outchannels, out inchannels, inchannel_hop); + } + + // Clock based functionality. + public RESULT getDSPClock(out ulong dspclock, out ulong parentclock) + { + return FMOD5_Channel_GetDSPClock(this.handle, out dspclock, out parentclock); + } + public RESULT setDelay(ulong dspclock_start, ulong dspclock_end, bool stopchannels = true) + { + return FMOD5_Channel_SetDelay(this.handle, dspclock_start, dspclock_end, stopchannels); + } + public RESULT getDelay(out ulong dspclock_start, out ulong dspclock_end) + { + return FMOD5_Channel_GetDelay(this.handle, out dspclock_start, out dspclock_end, IntPtr.Zero); + } + public RESULT getDelay(out ulong dspclock_start, out ulong dspclock_end, out bool stopchannels) + { + return FMOD5_Channel_GetDelay(this.handle, out dspclock_start, out dspclock_end, out stopchannels); + } + public RESULT addFadePoint(ulong dspclock, float volume) + { + return FMOD5_Channel_AddFadePoint(this.handle, dspclock, volume); + } + public RESULT setFadePointRamp(ulong dspclock, float volume) + { + return FMOD5_Channel_SetFadePointRamp(this.handle, dspclock, volume); + } + public RESULT removeFadePoints(ulong dspclock_start, ulong dspclock_end) + { + return FMOD5_Channel_RemoveFadePoints(this.handle, dspclock_start, dspclock_end); + } + public RESULT getFadePoints(ref uint numpoints, ulong[] point_dspclock, float[] point_volume) + { + return FMOD5_Channel_GetFadePoints(this.handle, ref numpoints, point_dspclock, point_volume); + } + + // DSP effects. + public RESULT getDSP(int index, out DSP dsp) + { + return FMOD5_Channel_GetDSP(this.handle, index, out dsp.handle); + } + public RESULT addDSP(int index, DSP dsp) + { + return FMOD5_Channel_AddDSP(this.handle, index, dsp.handle); + } + public RESULT removeDSP(DSP dsp) + { + return FMOD5_Channel_RemoveDSP(this.handle, dsp.handle); + } + public RESULT getNumDSPs(out int numdsps) + { + return FMOD5_Channel_GetNumDSPs(this.handle, out numdsps); + } + public RESULT setDSPIndex(DSP dsp, int index) + { + return FMOD5_Channel_SetDSPIndex(this.handle, dsp.handle, index); + } + public RESULT getDSPIndex(DSP dsp, out int index) + { + return FMOD5_Channel_GetDSPIndex(this.handle, dsp.handle, out index); + } + + // 3D functionality. + public RESULT set3DAttributes(ref VECTOR pos, ref VECTOR vel) + { + return FMOD5_Channel_Set3DAttributes(this.handle, ref pos, ref vel); + } + public RESULT get3DAttributes(out VECTOR pos, out VECTOR vel) + { + return FMOD5_Channel_Get3DAttributes(this.handle, out pos, out vel); + } + public RESULT set3DMinMaxDistance(float mindistance, float maxdistance) + { + return FMOD5_Channel_Set3DMinMaxDistance(this.handle, mindistance, maxdistance); + } + public RESULT get3DMinMaxDistance(out float mindistance, out float maxdistance) + { + return FMOD5_Channel_Get3DMinMaxDistance(this.handle, out mindistance, out maxdistance); + } + public RESULT set3DConeSettings(float insideconeangle, float outsideconeangle, float outsidevolume) + { + return FMOD5_Channel_Set3DConeSettings(this.handle, insideconeangle, outsideconeangle, outsidevolume); + } + public RESULT get3DConeSettings(out float insideconeangle, out float outsideconeangle, out float outsidevolume) + { + return FMOD5_Channel_Get3DConeSettings(this.handle, out insideconeangle, out outsideconeangle, out outsidevolume); + } + public RESULT set3DConeOrientation(ref VECTOR orientation) + { + return FMOD5_Channel_Set3DConeOrientation(this.handle, ref orientation); + } + public RESULT get3DConeOrientation(out VECTOR orientation) + { + return FMOD5_Channel_Get3DConeOrientation(this.handle, out orientation); + } + public RESULT set3DCustomRolloff(ref VECTOR points, int numpoints) + { + return FMOD5_Channel_Set3DCustomRolloff(this.handle, ref points, numpoints); + } + public RESULT get3DCustomRolloff(out IntPtr points, out int numpoints) + { + return FMOD5_Channel_Get3DCustomRolloff(this.handle, out points, out numpoints); + } + public RESULT set3DOcclusion(float directocclusion, float reverbocclusion) + { + return FMOD5_Channel_Set3DOcclusion(this.handle, directocclusion, reverbocclusion); + } + public RESULT get3DOcclusion(out float directocclusion, out float reverbocclusion) + { + return FMOD5_Channel_Get3DOcclusion(this.handle, out directocclusion, out reverbocclusion); + } + public RESULT set3DSpread(float angle) + { + return FMOD5_Channel_Set3DSpread(this.handle, angle); + } + public RESULT get3DSpread(out float angle) + { + return FMOD5_Channel_Get3DSpread(this.handle, out angle); + } + public RESULT set3DLevel(float level) + { + return FMOD5_Channel_Set3DLevel(this.handle, level); + } + public RESULT get3DLevel(out float level) + { + return FMOD5_Channel_Get3DLevel(this.handle, out level); + } + public RESULT set3DDopplerLevel(float level) + { + return FMOD5_Channel_Set3DDopplerLevel(this.handle, level); + } + public RESULT get3DDopplerLevel(out float level) + { + return FMOD5_Channel_Get3DDopplerLevel(this.handle, out level); + } + public RESULT set3DDistanceFilter(bool custom, float customLevel, float centerFreq) + { + return FMOD5_Channel_Set3DDistanceFilter(this.handle, custom, customLevel, centerFreq); + } + public RESULT get3DDistanceFilter(out bool custom, out float customLevel, out float centerFreq) + { + return FMOD5_Channel_Get3DDistanceFilter(this.handle, out custom, out customLevel, out centerFreq); + } + + // Userdata set/get. + public RESULT setUserData(IntPtr userdata) + { + return FMOD5_Channel_SetUserData(this.handle, userdata); + } + public RESULT getUserData(out IntPtr userdata) + { + return FMOD5_Channel_GetUserData(this.handle, out userdata); + } + + #region importfunctions + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_SetFrequency (IntPtr channel, float frequency); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_GetFrequency (IntPtr channel, out float frequency); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_SetPriority (IntPtr channel, int priority); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_GetPriority (IntPtr channel, out int priority); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_SetPosition (IntPtr channel, uint position, TIMEUNIT postype); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_GetPosition (IntPtr channel, out uint position, TIMEUNIT postype); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_SetChannelGroup (IntPtr channel, IntPtr channelgroup); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_GetChannelGroup (IntPtr channel, out IntPtr channelgroup); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_SetLoopCount (IntPtr channel, int loopcount); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_GetLoopCount (IntPtr channel, out int loopcount); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_SetLoopPoints (IntPtr channel, uint loopstart, TIMEUNIT loopstarttype, uint loopend, TIMEUNIT loopendtype); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_GetLoopPoints (IntPtr channel, out uint loopstart, TIMEUNIT loopstarttype, out uint loopend, TIMEUNIT loopendtype); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_IsVirtual (IntPtr channel, out bool isvirtual); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_GetCurrentSound (IntPtr channel, out IntPtr sound); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_GetIndex (IntPtr channel, out int index); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_GetSystemObject (IntPtr channel, out IntPtr system); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_Stop (IntPtr channel); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_SetPaused (IntPtr channel, bool paused); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_GetPaused (IntPtr channel, out bool paused); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_SetVolume (IntPtr channel, float volume); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_GetVolume (IntPtr channel, out float volume); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_SetVolumeRamp (IntPtr channel, bool ramp); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_GetVolumeRamp (IntPtr channel, out bool ramp); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_GetAudibility (IntPtr channel, out float audibility); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_SetPitch (IntPtr channel, float pitch); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_GetPitch (IntPtr channel, out float pitch); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_SetMute (IntPtr channel, bool mute); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_GetMute (IntPtr channel, out bool mute); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_SetReverbProperties (IntPtr channel, int instance, float wet); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_GetReverbProperties (IntPtr channel, int instance, out float wet); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_SetLowPassGain (IntPtr channel, float gain); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_GetLowPassGain (IntPtr channel, out float gain); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_SetMode (IntPtr channel, MODE mode); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_GetMode (IntPtr channel, out MODE mode); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_SetCallback (IntPtr channel, CHANNELCONTROL_CALLBACK callback); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_IsPlaying (IntPtr channel, out bool isplaying); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_SetPan (IntPtr channel, float pan); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_SetMixLevelsOutput (IntPtr channel, float frontleft, float frontright, float center, float lfe, float surroundleft, float surroundright, float backleft, float backright); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_SetMixLevelsInput (IntPtr channel, float[] levels, int numlevels); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_SetMixMatrix (IntPtr channel, float[] matrix, int outchannels, int inchannels, int inchannel_hop); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_GetMixMatrix (IntPtr channel, float[] matrix, out int outchannels, out int inchannels, int inchannel_hop); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_GetDSPClock (IntPtr channel, out ulong dspclock, out ulong parentclock); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_SetDelay (IntPtr channel, ulong dspclock_start, ulong dspclock_end, bool stopchannels); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_GetDelay (IntPtr channel, out ulong dspclock_start, out ulong dspclock_end, IntPtr zero); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_GetDelay (IntPtr channel, out ulong dspclock_start, out ulong dspclock_end, out bool stopchannels); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_AddFadePoint (IntPtr channel, ulong dspclock, float volume); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_SetFadePointRamp (IntPtr channel, ulong dspclock, float volume); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_RemoveFadePoints (IntPtr channel, ulong dspclock_start, ulong dspclock_end); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_GetFadePoints (IntPtr channel, ref uint numpoints, ulong[] point_dspclock, float[] point_volume); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_GetDSP (IntPtr channel, int index, out IntPtr dsp); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_AddDSP (IntPtr channel, int index, IntPtr dsp); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_RemoveDSP (IntPtr channel, IntPtr dsp); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_GetNumDSPs (IntPtr channel, out int numdsps); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_SetDSPIndex (IntPtr channel, IntPtr dsp, int index); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_GetDSPIndex (IntPtr channel, IntPtr dsp, out int index); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_Set3DAttributes (IntPtr channel, ref VECTOR pos, ref VECTOR vel); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_Get3DAttributes (IntPtr channel, out VECTOR pos, out VECTOR vel); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_Set3DMinMaxDistance (IntPtr channel, float mindistance, float maxdistance); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_Get3DMinMaxDistance (IntPtr channel, out float mindistance, out float maxdistance); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_Set3DConeSettings (IntPtr channel, float insideconeangle, float outsideconeangle, float outsidevolume); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_Get3DConeSettings (IntPtr channel, out float insideconeangle, out float outsideconeangle, out float outsidevolume); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_Set3DConeOrientation (IntPtr channel, ref VECTOR orientation); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_Get3DConeOrientation (IntPtr channel, out VECTOR orientation); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_Set3DCustomRolloff (IntPtr channel, ref VECTOR points, int numpoints); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_Get3DCustomRolloff (IntPtr channel, out IntPtr points, out int numpoints); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_Set3DOcclusion (IntPtr channel, float directocclusion, float reverbocclusion); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_Get3DOcclusion (IntPtr channel, out float directocclusion, out float reverbocclusion); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_Set3DSpread (IntPtr channel, float angle); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_Get3DSpread (IntPtr channel, out float angle); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_Set3DLevel (IntPtr channel, float level); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_Get3DLevel (IntPtr channel, out float level); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_Set3DDopplerLevel (IntPtr channel, float level); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_Get3DDopplerLevel (IntPtr channel, out float level); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_Set3DDistanceFilter (IntPtr channel, bool custom, float customLevel, float centerFreq); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_Get3DDistanceFilter (IntPtr channel, out bool custom, out float customLevel, out float centerFreq); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_SetUserData (IntPtr channel, IntPtr userdata); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Channel_GetUserData (IntPtr channel, out IntPtr userdata); + #endregion + + #region wrapperinternal + + public IntPtr handle; + + public Channel(IntPtr ptr) { this.handle = ptr; } + public bool hasHandle() { return this.handle != IntPtr.Zero; } + public void clearHandle() { this.handle = IntPtr.Zero; } + + #endregion + } + + /* + 'ChannelGroup' API + */ + public struct ChannelGroup : IChannelControl + { + public RESULT release() + { + return FMOD5_ChannelGroup_Release(this.handle); + } + + // Nested channel groups. + public RESULT addGroup(ChannelGroup group, bool propagatedspclock = true) + { + return FMOD5_ChannelGroup_AddGroup(this.handle, group.handle, propagatedspclock, IntPtr.Zero); + } + public RESULT addGroup(ChannelGroup group, bool propagatedspclock, out DSPConnection connection) + { + return FMOD5_ChannelGroup_AddGroup(this.handle, group.handle, propagatedspclock, out connection.handle); + } + public RESULT getNumGroups(out int numgroups) + { + return FMOD5_ChannelGroup_GetNumGroups(this.handle, out numgroups); + } + public RESULT getGroup(int index, out ChannelGroup group) + { + return FMOD5_ChannelGroup_GetGroup(this.handle, index, out group.handle); + } + public RESULT getParentGroup(out ChannelGroup group) + { + return FMOD5_ChannelGroup_GetParentGroup(this.handle, out group.handle); + } + + // Information only functions. + public RESULT getName(out string name, int namelen) + { + IntPtr stringMem = Marshal.AllocHGlobal(namelen); + + RESULT result = FMOD5_ChannelGroup_GetName(this.handle, stringMem, namelen); + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + name = encoder.stringFromNative(stringMem); + } + Marshal.FreeHGlobal(stringMem); + + return result; + } + public RESULT getNumChannels(out int numchannels) + { + return FMOD5_ChannelGroup_GetNumChannels(this.handle, out numchannels); + } + public RESULT getChannel(int index, out Channel channel) + { + return FMOD5_ChannelGroup_GetChannel(this.handle, index, out channel.handle); + } + + public RESULT getSystemObject(out System system) + { + return FMOD5_ChannelGroup_GetSystemObject(this.handle, out system.handle); + } + + // General control functionality for Channels and ChannelGroups. + public RESULT stop() + { + return FMOD5_ChannelGroup_Stop(this.handle); + } + public RESULT setPaused(bool paused) + { + return FMOD5_ChannelGroup_SetPaused(this.handle, paused); + } + public RESULT getPaused(out bool paused) + { + return FMOD5_ChannelGroup_GetPaused(this.handle, out paused); + } + public RESULT setVolume(float volume) + { + return FMOD5_ChannelGroup_SetVolume(this.handle, volume); + } + public RESULT getVolume(out float volume) + { + return FMOD5_ChannelGroup_GetVolume(this.handle, out volume); + } + public RESULT setVolumeRamp(bool ramp) + { + return FMOD5_ChannelGroup_SetVolumeRamp(this.handle, ramp); + } + public RESULT getVolumeRamp(out bool ramp) + { + return FMOD5_ChannelGroup_GetVolumeRamp(this.handle, out ramp); + } + public RESULT getAudibility(out float audibility) + { + return FMOD5_ChannelGroup_GetAudibility(this.handle, out audibility); + } + public RESULT setPitch(float pitch) + { + return FMOD5_ChannelGroup_SetPitch(this.handle, pitch); + } + public RESULT getPitch(out float pitch) + { + return FMOD5_ChannelGroup_GetPitch(this.handle, out pitch); + } + public RESULT setMute(bool mute) + { + return FMOD5_ChannelGroup_SetMute(this.handle, mute); + } + public RESULT getMute(out bool mute) + { + return FMOD5_ChannelGroup_GetMute(this.handle, out mute); + } + public RESULT setReverbProperties(int instance, float wet) + { + return FMOD5_ChannelGroup_SetReverbProperties(this.handle, instance, wet); + } + public RESULT getReverbProperties(int instance, out float wet) + { + return FMOD5_ChannelGroup_GetReverbProperties(this.handle, instance, out wet); + } + public RESULT setLowPassGain(float gain) + { + return FMOD5_ChannelGroup_SetLowPassGain(this.handle, gain); + } + public RESULT getLowPassGain(out float gain) + { + return FMOD5_ChannelGroup_GetLowPassGain(this.handle, out gain); + } + public RESULT setMode(MODE mode) + { + return FMOD5_ChannelGroup_SetMode(this.handle, mode); + } + public RESULT getMode(out MODE mode) + { + return FMOD5_ChannelGroup_GetMode(this.handle, out mode); + } + public RESULT setCallback(CHANNELCONTROL_CALLBACK callback) + { + return FMOD5_ChannelGroup_SetCallback(this.handle, callback); + } + public RESULT isPlaying(out bool isplaying) + { + return FMOD5_ChannelGroup_IsPlaying(this.handle, out isplaying); + } + + // Note all 'set' functions alter a final matrix, this is why the only get function is getMixMatrix, to avoid other get functions returning incorrect/obsolete values. + public RESULT setPan(float pan) + { + return FMOD5_ChannelGroup_SetPan(this.handle, pan); + } + public RESULT setMixLevelsOutput(float frontleft, float frontright, float center, float lfe, float surroundleft, float surroundright, float backleft, float backright) + { + return FMOD5_ChannelGroup_SetMixLevelsOutput(this.handle, frontleft, frontright, center, lfe, surroundleft, surroundright, backleft, backright); + } + public RESULT setMixLevelsInput(float[] levels, int numlevels) + { + return FMOD5_ChannelGroup_SetMixLevelsInput(this.handle, levels, numlevels); + } + public RESULT setMixMatrix(float[] matrix, int outchannels, int inchannels, int inchannel_hop) + { + return FMOD5_ChannelGroup_SetMixMatrix(this.handle, matrix, outchannels, inchannels, inchannel_hop); + } + public RESULT getMixMatrix(float[] matrix, out int outchannels, out int inchannels, int inchannel_hop) + { + return FMOD5_ChannelGroup_GetMixMatrix(this.handle, matrix, out outchannels, out inchannels, inchannel_hop); + } + + // Clock based functionality. + public RESULT getDSPClock(out ulong dspclock, out ulong parentclock) + { + return FMOD5_ChannelGroup_GetDSPClock(this.handle, out dspclock, out parentclock); + } + public RESULT setDelay(ulong dspclock_start, ulong dspclock_end, bool stopchannels) + { + return FMOD5_ChannelGroup_SetDelay(this.handle, dspclock_start, dspclock_end, stopchannels); + } + public RESULT getDelay(out ulong dspclock_start, out ulong dspclock_end) + { + return FMOD5_ChannelGroup_GetDelay(this.handle, out dspclock_start, out dspclock_end, IntPtr.Zero); + } + public RESULT getDelay(out ulong dspclock_start, out ulong dspclock_end, out bool stopchannels) + { + return FMOD5_ChannelGroup_GetDelay(this.handle, out dspclock_start, out dspclock_end, out stopchannels); + } + public RESULT addFadePoint(ulong dspclock, float volume) + { + return FMOD5_ChannelGroup_AddFadePoint(this.handle, dspclock, volume); + } + public RESULT setFadePointRamp(ulong dspclock, float volume) + { + return FMOD5_ChannelGroup_SetFadePointRamp(this.handle, dspclock, volume); + } + public RESULT removeFadePoints(ulong dspclock_start, ulong dspclock_end) + { + return FMOD5_ChannelGroup_RemoveFadePoints(this.handle, dspclock_start, dspclock_end); + } + public RESULT getFadePoints(ref uint numpoints, ulong[] point_dspclock, float[] point_volume) + { + return FMOD5_ChannelGroup_GetFadePoints(this.handle, ref numpoints, point_dspclock, point_volume); + } + + // DSP effects. + public RESULT getDSP(int index, out DSP dsp) + { + return FMOD5_ChannelGroup_GetDSP(this.handle, index, out dsp.handle); + } + public RESULT addDSP(int index, DSP dsp) + { + return FMOD5_ChannelGroup_AddDSP(this.handle, index, dsp.handle); + } + public RESULT removeDSP(DSP dsp) + { + return FMOD5_ChannelGroup_RemoveDSP(this.handle, dsp.handle); + } + public RESULT getNumDSPs(out int numdsps) + { + return FMOD5_ChannelGroup_GetNumDSPs(this.handle, out numdsps); + } + public RESULT setDSPIndex(DSP dsp, int index) + { + return FMOD5_ChannelGroup_SetDSPIndex(this.handle, dsp.handle, index); + } + public RESULT getDSPIndex(DSP dsp, out int index) + { + return FMOD5_ChannelGroup_GetDSPIndex(this.handle, dsp.handle, out index); + } + + // 3D functionality. + public RESULT set3DAttributes(ref VECTOR pos, ref VECTOR vel) + { + return FMOD5_ChannelGroup_Set3DAttributes(this.handle, ref pos, ref vel); + } + public RESULT get3DAttributes(out VECTOR pos, out VECTOR vel) + { + return FMOD5_ChannelGroup_Get3DAttributes(this.handle, out pos, out vel); + } + public RESULT set3DMinMaxDistance(float mindistance, float maxdistance) + { + return FMOD5_ChannelGroup_Set3DMinMaxDistance(this.handle, mindistance, maxdistance); + } + public RESULT get3DMinMaxDistance(out float mindistance, out float maxdistance) + { + return FMOD5_ChannelGroup_Get3DMinMaxDistance(this.handle, out mindistance, out maxdistance); + } + public RESULT set3DConeSettings(float insideconeangle, float outsideconeangle, float outsidevolume) + { + return FMOD5_ChannelGroup_Set3DConeSettings(this.handle, insideconeangle, outsideconeangle, outsidevolume); + } + public RESULT get3DConeSettings(out float insideconeangle, out float outsideconeangle, out float outsidevolume) + { + return FMOD5_ChannelGroup_Get3DConeSettings(this.handle, out insideconeangle, out outsideconeangle, out outsidevolume); + } + public RESULT set3DConeOrientation(ref VECTOR orientation) + { + return FMOD5_ChannelGroup_Set3DConeOrientation(this.handle, ref orientation); + } + public RESULT get3DConeOrientation(out VECTOR orientation) + { + return FMOD5_ChannelGroup_Get3DConeOrientation(this.handle, out orientation); + } + public RESULT set3DCustomRolloff(ref VECTOR points, int numpoints) + { + return FMOD5_ChannelGroup_Set3DCustomRolloff(this.handle, ref points, numpoints); + } + public RESULT get3DCustomRolloff(out IntPtr points, out int numpoints) + { + return FMOD5_ChannelGroup_Get3DCustomRolloff(this.handle, out points, out numpoints); + } + public RESULT set3DOcclusion(float directocclusion, float reverbocclusion) + { + return FMOD5_ChannelGroup_Set3DOcclusion(this.handle, directocclusion, reverbocclusion); + } + public RESULT get3DOcclusion(out float directocclusion, out float reverbocclusion) + { + return FMOD5_ChannelGroup_Get3DOcclusion(this.handle, out directocclusion, out reverbocclusion); + } + public RESULT set3DSpread(float angle) + { + return FMOD5_ChannelGroup_Set3DSpread(this.handle, angle); + } + public RESULT get3DSpread(out float angle) + { + return FMOD5_ChannelGroup_Get3DSpread(this.handle, out angle); + } + public RESULT set3DLevel(float level) + { + return FMOD5_ChannelGroup_Set3DLevel(this.handle, level); + } + public RESULT get3DLevel(out float level) + { + return FMOD5_ChannelGroup_Get3DLevel(this.handle, out level); + } + public RESULT set3DDopplerLevel(float level) + { + return FMOD5_ChannelGroup_Set3DDopplerLevel(this.handle, level); + } + public RESULT get3DDopplerLevel(out float level) + { + return FMOD5_ChannelGroup_Get3DDopplerLevel(this.handle, out level); + } + public RESULT set3DDistanceFilter(bool custom, float customLevel, float centerFreq) + { + return FMOD5_ChannelGroup_Set3DDistanceFilter(this.handle, custom, customLevel, centerFreq); + } + public RESULT get3DDistanceFilter(out bool custom, out float customLevel, out float centerFreq) + { + return FMOD5_ChannelGroup_Get3DDistanceFilter(this.handle, out custom, out customLevel, out centerFreq); + } + + // Userdata set/get. + public RESULT setUserData(IntPtr userdata) + { + return FMOD5_ChannelGroup_SetUserData(this.handle, userdata); + } + public RESULT getUserData(out IntPtr userdata) + { + return FMOD5_ChannelGroup_GetUserData(this.handle, out userdata); + } + + #region importfunctions + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_Release (IntPtr channelgroup); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_AddGroup (IntPtr channelgroup, IntPtr group, bool propagatedspclock, IntPtr zero); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_AddGroup (IntPtr channelgroup, IntPtr group, bool propagatedspclock, out IntPtr connection); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_GetNumGroups (IntPtr channelgroup, out int numgroups); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_GetGroup (IntPtr channelgroup, int index, out IntPtr group); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_GetParentGroup (IntPtr channelgroup, out IntPtr group); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_GetName (IntPtr channelgroup, IntPtr name, int namelen); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_GetNumChannels (IntPtr channelgroup, out int numchannels); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_GetChannel (IntPtr channelgroup, int index, out IntPtr channel); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_GetSystemObject (IntPtr channelgroup, out IntPtr system); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_Stop (IntPtr channelgroup); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_SetPaused (IntPtr channelgroup, bool paused); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_GetPaused (IntPtr channelgroup, out bool paused); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_SetVolume (IntPtr channelgroup, float volume); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_GetVolume (IntPtr channelgroup, out float volume); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_SetVolumeRamp (IntPtr channelgroup, bool ramp); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_GetVolumeRamp (IntPtr channelgroup, out bool ramp); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_GetAudibility (IntPtr channelgroup, out float audibility); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_SetPitch (IntPtr channelgroup, float pitch); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_GetPitch (IntPtr channelgroup, out float pitch); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_SetMute (IntPtr channelgroup, bool mute); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_GetMute (IntPtr channelgroup, out bool mute); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_SetReverbProperties (IntPtr channelgroup, int instance, float wet); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_GetReverbProperties (IntPtr channelgroup, int instance, out float wet); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_SetLowPassGain (IntPtr channelgroup, float gain); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_GetLowPassGain (IntPtr channelgroup, out float gain); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_SetMode (IntPtr channelgroup, MODE mode); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_GetMode (IntPtr channelgroup, out MODE mode); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_SetCallback (IntPtr channelgroup, CHANNELCONTROL_CALLBACK callback); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_IsPlaying (IntPtr channelgroup, out bool isplaying); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_SetPan (IntPtr channelgroup, float pan); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_SetMixLevelsOutput (IntPtr channelgroup, float frontleft, float frontright, float center, float lfe, float surroundleft, float surroundright, float backleft, float backright); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_SetMixLevelsInput (IntPtr channelgroup, float[] levels, int numlevels); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_SetMixMatrix (IntPtr channelgroup, float[] matrix, int outchannels, int inchannels, int inchannel_hop); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_GetMixMatrix (IntPtr channelgroup, float[] matrix, out int outchannels, out int inchannels, int inchannel_hop); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_GetDSPClock (IntPtr channelgroup, out ulong dspclock, out ulong parentclock); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_SetDelay (IntPtr channelgroup, ulong dspclock_start, ulong dspclock_end, bool stopchannels); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_GetDelay (IntPtr channelgroup, out ulong dspclock_start, out ulong dspclock_end, IntPtr zero); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_GetDelay (IntPtr channelgroup, out ulong dspclock_start, out ulong dspclock_end, out bool stopchannels); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_AddFadePoint (IntPtr channelgroup, ulong dspclock, float volume); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_SetFadePointRamp (IntPtr channelgroup, ulong dspclock, float volume); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_RemoveFadePoints (IntPtr channelgroup, ulong dspclock_start, ulong dspclock_end); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_GetFadePoints (IntPtr channelgroup, ref uint numpoints, ulong[] point_dspclock, float[] point_volume); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_GetDSP (IntPtr channelgroup, int index, out IntPtr dsp); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_AddDSP (IntPtr channelgroup, int index, IntPtr dsp); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_RemoveDSP (IntPtr channelgroup, IntPtr dsp); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_GetNumDSPs (IntPtr channelgroup, out int numdsps); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_SetDSPIndex (IntPtr channelgroup, IntPtr dsp, int index); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_GetDSPIndex (IntPtr channelgroup, IntPtr dsp, out int index); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_Set3DAttributes (IntPtr channelgroup, ref VECTOR pos, ref VECTOR vel); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_Get3DAttributes (IntPtr channelgroup, out VECTOR pos, out VECTOR vel); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_Set3DMinMaxDistance (IntPtr channelgroup, float mindistance, float maxdistance); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_Get3DMinMaxDistance (IntPtr channelgroup, out float mindistance, out float maxdistance); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_Set3DConeSettings (IntPtr channelgroup, float insideconeangle, float outsideconeangle, float outsidevolume); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_Get3DConeSettings (IntPtr channelgroup, out float insideconeangle, out float outsideconeangle, out float outsidevolume); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_Set3DConeOrientation(IntPtr channelgroup, ref VECTOR orientation); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_Get3DConeOrientation(IntPtr channelgroup, out VECTOR orientation); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_Set3DCustomRolloff (IntPtr channelgroup, ref VECTOR points, int numpoints); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_Get3DCustomRolloff (IntPtr channelgroup, out IntPtr points, out int numpoints); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_Set3DOcclusion (IntPtr channelgroup, float directocclusion, float reverbocclusion); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_Get3DOcclusion (IntPtr channelgroup, out float directocclusion, out float reverbocclusion); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_Set3DSpread (IntPtr channelgroup, float angle); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_Get3DSpread (IntPtr channelgroup, out float angle); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_Set3DLevel (IntPtr channelgroup, float level); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_Get3DLevel (IntPtr channelgroup, out float level); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_Set3DDopplerLevel (IntPtr channelgroup, float level); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_Get3DDopplerLevel (IntPtr channelgroup, out float level); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_Set3DDistanceFilter (IntPtr channelgroup, bool custom, float customLevel, float centerFreq); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_Get3DDistanceFilter (IntPtr channelgroup, out bool custom, out float customLevel, out float centerFreq); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_SetUserData (IntPtr channelgroup, IntPtr userdata); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_ChannelGroup_GetUserData (IntPtr channelgroup, out IntPtr userdata); + #endregion + + #region wrapperinternal + + public IntPtr handle; + + public ChannelGroup(IntPtr ptr) { this.handle = ptr; } + public bool hasHandle() { return this.handle != IntPtr.Zero; } + public void clearHandle() { this.handle = IntPtr.Zero; } + + #endregion + } + + /* + 'SoundGroup' API + */ + public struct SoundGroup + { + public RESULT release() + { + return FMOD5_SoundGroup_Release(this.handle); + } + + public RESULT getSystemObject(out System system) + { + return FMOD5_SoundGroup_GetSystemObject(this.handle, out system.handle); + } + + // SoundGroup control functions. + public RESULT setMaxAudible(int maxaudible) + { + return FMOD5_SoundGroup_SetMaxAudible(this.handle, maxaudible); + } + public RESULT getMaxAudible(out int maxaudible) + { + return FMOD5_SoundGroup_GetMaxAudible(this.handle, out maxaudible); + } + public RESULT setMaxAudibleBehavior(SOUNDGROUP_BEHAVIOR behavior) + { + return FMOD5_SoundGroup_SetMaxAudibleBehavior(this.handle, behavior); + } + public RESULT getMaxAudibleBehavior(out SOUNDGROUP_BEHAVIOR behavior) + { + return FMOD5_SoundGroup_GetMaxAudibleBehavior(this.handle, out behavior); + } + public RESULT setMuteFadeSpeed(float speed) + { + return FMOD5_SoundGroup_SetMuteFadeSpeed(this.handle, speed); + } + public RESULT getMuteFadeSpeed(out float speed) + { + return FMOD5_SoundGroup_GetMuteFadeSpeed(this.handle, out speed); + } + public RESULT setVolume(float volume) + { + return FMOD5_SoundGroup_SetVolume(this.handle, volume); + } + public RESULT getVolume(out float volume) + { + return FMOD5_SoundGroup_GetVolume(this.handle, out volume); + } + public RESULT stop() + { + return FMOD5_SoundGroup_Stop(this.handle); + } + + // Information only functions. + public RESULT getName(out string name, int namelen) + { + IntPtr stringMem = Marshal.AllocHGlobal(namelen); + + RESULT result = FMOD5_SoundGroup_GetName(this.handle, stringMem, namelen); + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + name = encoder.stringFromNative(stringMem); + } + Marshal.FreeHGlobal(stringMem); + + return result; + } + public RESULT getNumSounds(out int numsounds) + { + return FMOD5_SoundGroup_GetNumSounds(this.handle, out numsounds); + } + public RESULT getSound(int index, out Sound sound) + { + return FMOD5_SoundGroup_GetSound(this.handle, index, out sound.handle); + } + public RESULT getNumPlaying(out int numplaying) + { + return FMOD5_SoundGroup_GetNumPlaying(this.handle, out numplaying); + } + + // Userdata set/get. + public RESULT setUserData(IntPtr userdata) + { + return FMOD5_SoundGroup_SetUserData(this.handle, userdata); + } + public RESULT getUserData(out IntPtr userdata) + { + return FMOD5_SoundGroup_GetUserData(this.handle, out userdata); + } + + #region importfunctions + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_SoundGroup_Release (IntPtr soundgroup); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_SoundGroup_GetSystemObject (IntPtr soundgroup, out IntPtr system); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_SoundGroup_SetMaxAudible (IntPtr soundgroup, int maxaudible); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_SoundGroup_GetMaxAudible (IntPtr soundgroup, out int maxaudible); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_SoundGroup_SetMaxAudibleBehavior (IntPtr soundgroup, SOUNDGROUP_BEHAVIOR behavior); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_SoundGroup_GetMaxAudibleBehavior (IntPtr soundgroup, out SOUNDGROUP_BEHAVIOR behavior); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_SoundGroup_SetMuteFadeSpeed (IntPtr soundgroup, float speed); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_SoundGroup_GetMuteFadeSpeed (IntPtr soundgroup, out float speed); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_SoundGroup_SetVolume (IntPtr soundgroup, float volume); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_SoundGroup_GetVolume (IntPtr soundgroup, out float volume); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_SoundGroup_Stop (IntPtr soundgroup); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_SoundGroup_GetName (IntPtr soundgroup, IntPtr name, int namelen); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_SoundGroup_GetNumSounds (IntPtr soundgroup, out int numsounds); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_SoundGroup_GetSound (IntPtr soundgroup, int index, out IntPtr sound); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_SoundGroup_GetNumPlaying (IntPtr soundgroup, out int numplaying); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_SoundGroup_SetUserData (IntPtr soundgroup, IntPtr userdata); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_SoundGroup_GetUserData (IntPtr soundgroup, out IntPtr userdata); + #endregion + + #region wrapperinternal + + public IntPtr handle; + + public SoundGroup(IntPtr ptr) { this.handle = ptr; } + public bool hasHandle() { return this.handle != IntPtr.Zero; } + public void clearHandle() { this.handle = IntPtr.Zero; } + + #endregion + } + + /* + 'DSP' API + */ + public struct DSP + { + public RESULT release() + { + return FMOD5_DSP_Release(this.handle); + } + public RESULT getSystemObject(out System system) + { + return FMOD5_DSP_GetSystemObject(this.handle, out system.handle); + } + + // Connection / disconnection / input and output enumeration. + public RESULT addInput(DSP input) + { + return FMOD5_DSP_AddInput(this.handle, input.handle, IntPtr.Zero, DSPCONNECTION_TYPE.STANDARD); + } + public RESULT addInput(DSP input, out DSPConnection connection, DSPCONNECTION_TYPE type = DSPCONNECTION_TYPE.STANDARD) + { + return FMOD5_DSP_AddInput(this.handle, input.handle, out connection.handle, type); + } + public RESULT disconnectFrom(DSP target, DSPConnection connection) + { + return FMOD5_DSP_DisconnectFrom(this.handle, target.handle, connection.handle); + } + public RESULT disconnectAll(bool inputs, bool outputs) + { + return FMOD5_DSP_DisconnectAll(this.handle, inputs, outputs); + } + public RESULT getNumInputs(out int numinputs) + { + return FMOD5_DSP_GetNumInputs(this.handle, out numinputs); + } + public RESULT getNumOutputs(out int numoutputs) + { + return FMOD5_DSP_GetNumOutputs(this.handle, out numoutputs); + } + public RESULT getInput(int index, out DSP input, out DSPConnection inputconnection) + { + return FMOD5_DSP_GetInput(this.handle, index, out input.handle, out inputconnection.handle); + } + public RESULT getOutput(int index, out DSP output, out DSPConnection outputconnection) + { + return FMOD5_DSP_GetOutput(this.handle, index, out output.handle, out outputconnection.handle); + } + + // DSP unit control. + public RESULT setActive(bool active) + { + return FMOD5_DSP_SetActive(this.handle, active); + } + public RESULT getActive(out bool active) + { + return FMOD5_DSP_GetActive(this.handle, out active); + } + public RESULT setBypass(bool bypass) + { + return FMOD5_DSP_SetBypass(this.handle, bypass); + } + public RESULT getBypass(out bool bypass) + { + return FMOD5_DSP_GetBypass(this.handle, out bypass); + } + public RESULT setWetDryMix(float prewet, float postwet, float dry) + { + return FMOD5_DSP_SetWetDryMix(this.handle, prewet, postwet, dry); + } + public RESULT getWetDryMix(out float prewet, out float postwet, out float dry) + { + return FMOD5_DSP_GetWetDryMix(this.handle, out prewet, out postwet, out dry); + } + public RESULT setChannelFormat(CHANNELMASK channelmask, int numchannels, SPEAKERMODE source_speakermode) + { + return FMOD5_DSP_SetChannelFormat(this.handle, channelmask, numchannels, source_speakermode); + } + public RESULT getChannelFormat(out CHANNELMASK channelmask, out int numchannels, out SPEAKERMODE source_speakermode) + { + return FMOD5_DSP_GetChannelFormat(this.handle, out channelmask, out numchannels, out source_speakermode); + } + public RESULT getOutputChannelFormat(CHANNELMASK inmask, int inchannels, SPEAKERMODE inspeakermode, out CHANNELMASK outmask, out int outchannels, out SPEAKERMODE outspeakermode) + { + return FMOD5_DSP_GetOutputChannelFormat(this.handle, inmask, inchannels, inspeakermode, out outmask, out outchannels, out outspeakermode); + } + public RESULT reset() + { + return FMOD5_DSP_Reset(this.handle); + } + + // DSP parameter control. + public RESULT setParameterFloat(int index, float value) + { + return FMOD5_DSP_SetParameterFloat(this.handle, index, value); + } + public RESULT setParameterInt(int index, int value) + { + return FMOD5_DSP_SetParameterInt(this.handle, index, value); + } + public RESULT setParameterBool(int index, bool value) + { + return FMOD5_DSP_SetParameterBool(this.handle, index, value); + } + public RESULT setParameterData(int index, byte[] data) + { + return FMOD5_DSP_SetParameterData(this.handle, index, Marshal.UnsafeAddrOfPinnedArrayElement(data, 0), (uint)data.Length); + } + public RESULT getParameterFloat(int index, out float value) + { + return FMOD5_DSP_GetParameterFloat(this.handle, index, out value, IntPtr.Zero, 0); + } + public RESULT getParameterInt(int index, out int value) + { + return FMOD5_DSP_GetParameterInt(this.handle, index, out value, IntPtr.Zero, 0); + } + public RESULT getParameterBool(int index, out bool value) + { + return FMOD5_DSP_GetParameterBool(this.handle, index, out value, IntPtr.Zero, 0); + } + public RESULT getParameterData(int index, out IntPtr data, out uint length) + { + return FMOD5_DSP_GetParameterData(this.handle, index, out data, out length, IntPtr.Zero, 0); + } + public RESULT getNumParameters(out int numparams) + { + return FMOD5_DSP_GetNumParameters(this.handle, out numparams); + } + public RESULT getParameterInfo(int index, out DSP_PARAMETER_DESC desc) + { + IntPtr descPtr; + RESULT result = FMOD5_DSP_GetParameterInfo(this.handle, index, out descPtr); + desc = (DSP_PARAMETER_DESC)MarshalHelper.PtrToStructure(descPtr, typeof(DSP_PARAMETER_DESC)); + return result; + } + public RESULT getDataParameterIndex(int datatype, out int index) + { + return FMOD5_DSP_GetDataParameterIndex(this.handle, datatype, out index); + } + public RESULT showConfigDialog(IntPtr hwnd, bool show) + { + return FMOD5_DSP_ShowConfigDialog(this.handle, hwnd, show); + } + + // DSP attributes. + public RESULT getInfo(out string name, out uint version, out int channels, out int configwidth, out int configheight) + { + IntPtr nameMem = Marshal.AllocHGlobal(32); + + RESULT result = FMOD5_DSP_GetInfo(this.handle, nameMem, out version, out channels, out configwidth, out configheight); + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + name = encoder.stringFromNative(nameMem); + } + Marshal.FreeHGlobal(nameMem); + return result; + } + public RESULT getInfo(out uint version, out int channels, out int configwidth, out int configheight) + { + return FMOD5_DSP_GetInfo(this.handle, IntPtr.Zero, out version, out channels, out configwidth, out configheight); ; + } + public RESULT getType(out DSP_TYPE type) + { + return FMOD5_DSP_GetType(this.handle, out type); + } + public RESULT getIdle(out bool idle) + { + return FMOD5_DSP_GetIdle(this.handle, out idle); + } + + // Userdata set/get. + public RESULT setUserData(IntPtr userdata) + { + return FMOD5_DSP_SetUserData(this.handle, userdata); + } + public RESULT getUserData(out IntPtr userdata) + { + return FMOD5_DSP_GetUserData(this.handle, out userdata); + } + + // Metering. + public RESULT setMeteringEnabled(bool inputEnabled, bool outputEnabled) + { + return FMOD5_DSP_SetMeteringEnabled(this.handle, inputEnabled, outputEnabled); + } + public RESULT getMeteringEnabled(out bool inputEnabled, out bool outputEnabled) + { + return FMOD5_DSP_GetMeteringEnabled(this.handle, out inputEnabled, out outputEnabled); + } + + public RESULT getMeteringInfo(IntPtr zero, out DSP_METERING_INFO outputInfo) + { + return FMOD5_DSP_GetMeteringInfo(this.handle, zero, out outputInfo); + } + public RESULT getMeteringInfo(out DSP_METERING_INFO inputInfo, IntPtr zero) + { + return FMOD5_DSP_GetMeteringInfo(this.handle, out inputInfo, zero); + } + public RESULT getMeteringInfo(out DSP_METERING_INFO inputInfo, out DSP_METERING_INFO outputInfo) + { + return FMOD5_DSP_GetMeteringInfo(this.handle, out inputInfo, out outputInfo); + } + + public RESULT getCPUUsage(out uint exclusive, out uint inclusive) + { + return FMOD5_DSP_GetCPUUsage(this.handle, out exclusive, out inclusive); + } + + #region importfunctions + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_Release (IntPtr dsp); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_GetSystemObject (IntPtr dsp, out IntPtr system); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_AddInput (IntPtr dsp, IntPtr input, IntPtr zero, DSPCONNECTION_TYPE type); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_AddInput (IntPtr dsp, IntPtr input, out IntPtr connection, DSPCONNECTION_TYPE type); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_DisconnectFrom (IntPtr dsp, IntPtr target, IntPtr connection); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_DisconnectAll (IntPtr dsp, bool inputs, bool outputs); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_GetNumInputs (IntPtr dsp, out int numinputs); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_GetNumOutputs (IntPtr dsp, out int numoutputs); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_GetInput (IntPtr dsp, int index, out IntPtr input, out IntPtr inputconnection); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_GetOutput (IntPtr dsp, int index, out IntPtr output, out IntPtr outputconnection); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_SetActive (IntPtr dsp, bool active); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_GetActive (IntPtr dsp, out bool active); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_SetBypass (IntPtr dsp, bool bypass); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_GetBypass (IntPtr dsp, out bool bypass); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_SetWetDryMix (IntPtr dsp, float prewet, float postwet, float dry); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_GetWetDryMix (IntPtr dsp, out float prewet, out float postwet, out float dry); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_SetChannelFormat (IntPtr dsp, CHANNELMASK channelmask, int numchannels, SPEAKERMODE source_speakermode); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_GetChannelFormat (IntPtr dsp, out CHANNELMASK channelmask, out int numchannels, out SPEAKERMODE source_speakermode); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_GetOutputChannelFormat (IntPtr dsp, CHANNELMASK inmask, int inchannels, SPEAKERMODE inspeakermode, out CHANNELMASK outmask, out int outchannels, out SPEAKERMODE outspeakermode); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_Reset (IntPtr dsp); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_SetParameterFloat (IntPtr dsp, int index, float value); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_SetParameterInt (IntPtr dsp, int index, int value); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_SetParameterBool (IntPtr dsp, int index, bool value); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_SetParameterData (IntPtr dsp, int index, IntPtr data, uint length); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_GetParameterFloat (IntPtr dsp, int index, out float value, IntPtr valuestr, int valuestrlen); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_GetParameterInt (IntPtr dsp, int index, out int value, IntPtr valuestr, int valuestrlen); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_GetParameterBool (IntPtr dsp, int index, out bool value, IntPtr valuestr, int valuestrlen); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_GetParameterData (IntPtr dsp, int index, out IntPtr data, out uint length, IntPtr valuestr, int valuestrlen); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_GetNumParameters (IntPtr dsp, out int numparams); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_GetParameterInfo (IntPtr dsp, int index, out IntPtr desc); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_GetDataParameterIndex (IntPtr dsp, int datatype, out int index); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_ShowConfigDialog (IntPtr dsp, IntPtr hwnd, bool show); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_GetInfo (IntPtr dsp, IntPtr name, out uint version, out int channels, out int configwidth, out int configheight); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_GetType (IntPtr dsp, out DSP_TYPE type); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_GetIdle (IntPtr dsp, out bool idle); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_SetUserData (IntPtr dsp, IntPtr userdata); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSP_GetUserData (IntPtr dsp, out IntPtr userdata); + [DllImport(VERSION.dll)] + public static extern RESULT FMOD5_DSP_SetMeteringEnabled (IntPtr dsp, bool inputEnabled, bool outputEnabled); + [DllImport(VERSION.dll)] + public static extern RESULT FMOD5_DSP_GetMeteringEnabled (IntPtr dsp, out bool inputEnabled, out bool outputEnabled); + [DllImport(VERSION.dll)] + public static extern RESULT FMOD5_DSP_GetMeteringInfo (IntPtr dsp, IntPtr zero, out DSP_METERING_INFO outputInfo); + [DllImport(VERSION.dll)] + public static extern RESULT FMOD5_DSP_GetMeteringInfo (IntPtr dsp, out DSP_METERING_INFO inputInfo, IntPtr zero); + [DllImport(VERSION.dll)] + public static extern RESULT FMOD5_DSP_GetMeteringInfo (IntPtr dsp, out DSP_METERING_INFO inputInfo, out DSP_METERING_INFO outputInfo); + [DllImport(VERSION.dll)] + public static extern RESULT FMOD5_DSP_GetCPUUsage (IntPtr dsp, out uint exclusive, out uint inclusive); + #endregion + + #region wrapperinternal + + public IntPtr handle; + + public DSP(IntPtr ptr) { this.handle = ptr; } + public bool hasHandle() { return this.handle != IntPtr.Zero; } + public void clearHandle() { this.handle = IntPtr.Zero; } + + #endregion + } + + /* + 'DSPConnection' API + */ + public struct DSPConnection + { + public RESULT getInput(out DSP input) + { + return FMOD5_DSPConnection_GetInput(this.handle, out input.handle); + } + public RESULT getOutput(out DSP output) + { + return FMOD5_DSPConnection_GetOutput(this.handle, out output.handle); + } + public RESULT setMix(float volume) + { + return FMOD5_DSPConnection_SetMix(this.handle, volume); + } + public RESULT getMix(out float volume) + { + return FMOD5_DSPConnection_GetMix(this.handle, out volume); + } + public RESULT setMixMatrix(float[] matrix, int outchannels, int inchannels, int inchannel_hop = 0) + { + return FMOD5_DSPConnection_SetMixMatrix(this.handle, matrix, outchannels, inchannels, inchannel_hop); + } + public RESULT getMixMatrix(float[] matrix, out int outchannels, out int inchannels, int inchannel_hop = 0) + { + return FMOD5_DSPConnection_GetMixMatrix(this.handle, matrix, out outchannels, out inchannels, inchannel_hop); + } + public RESULT getType(out DSPCONNECTION_TYPE type) + { + return FMOD5_DSPConnection_GetType(this.handle, out type); + } + + // Userdata set/get. + public RESULT setUserData(IntPtr userdata) + { + return FMOD5_DSPConnection_SetUserData(this.handle, userdata); + } + public RESULT getUserData(out IntPtr userdata) + { + return FMOD5_DSPConnection_GetUserData(this.handle, out userdata); + } + + #region importfunctions + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSPConnection_GetInput (IntPtr dspconnection, out IntPtr input); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSPConnection_GetOutput (IntPtr dspconnection, out IntPtr output); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSPConnection_SetMix (IntPtr dspconnection, float volume); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSPConnection_GetMix (IntPtr dspconnection, out float volume); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSPConnection_SetMixMatrix (IntPtr dspconnection, float[] matrix, int outchannels, int inchannels, int inchannel_hop); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSPConnection_GetMixMatrix (IntPtr dspconnection, float[] matrix, out int outchannels, out int inchannels, int inchannel_hop); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSPConnection_GetType (IntPtr dspconnection, out DSPCONNECTION_TYPE type); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSPConnection_SetUserData (IntPtr dspconnection, IntPtr userdata); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_DSPConnection_GetUserData (IntPtr dspconnection, out IntPtr userdata); + #endregion + + #region wrapperinternal + + public IntPtr handle; + + public DSPConnection(IntPtr ptr) { this.handle = ptr; } + public bool hasHandle() { return this.handle != IntPtr.Zero; } + public void clearHandle() { this.handle = IntPtr.Zero; } + + #endregion + } + + /* + 'Geometry' API + */ + public struct Geometry + { + public RESULT release() + { + return FMOD5_Geometry_Release(this.handle); + } + + // Polygon manipulation. + public RESULT addPolygon(float directocclusion, float reverbocclusion, bool doublesided, int numvertices, VECTOR[] vertices, out int polygonindex) + { + return FMOD5_Geometry_AddPolygon(this.handle, directocclusion, reverbocclusion, doublesided, numvertices, vertices, out polygonindex); + } + public RESULT getNumPolygons(out int numpolygons) + { + return FMOD5_Geometry_GetNumPolygons(this.handle, out numpolygons); + } + public RESULT getMaxPolygons(out int maxpolygons, out int maxvertices) + { + return FMOD5_Geometry_GetMaxPolygons(this.handle, out maxpolygons, out maxvertices); + } + public RESULT getPolygonNumVertices(int index, out int numvertices) + { + return FMOD5_Geometry_GetPolygonNumVertices(this.handle, index, out numvertices); + } + public RESULT setPolygonVertex(int index, int vertexindex, ref VECTOR vertex) + { + return FMOD5_Geometry_SetPolygonVertex(this.handle, index, vertexindex, ref vertex); + } + public RESULT getPolygonVertex(int index, int vertexindex, out VECTOR vertex) + { + return FMOD5_Geometry_GetPolygonVertex(this.handle, index, vertexindex, out vertex); + } + public RESULT setPolygonAttributes(int index, float directocclusion, float reverbocclusion, bool doublesided) + { + return FMOD5_Geometry_SetPolygonAttributes(this.handle, index, directocclusion, reverbocclusion, doublesided); + } + public RESULT getPolygonAttributes(int index, out float directocclusion, out float reverbocclusion, out bool doublesided) + { + return FMOD5_Geometry_GetPolygonAttributes(this.handle, index, out directocclusion, out reverbocclusion, out doublesided); + } + + // Object manipulation. + public RESULT setActive(bool active) + { + return FMOD5_Geometry_SetActive(this.handle, active); + } + public RESULT getActive(out bool active) + { + return FMOD5_Geometry_GetActive(this.handle, out active); + } + public RESULT setRotation(ref VECTOR forward, ref VECTOR up) + { + return FMOD5_Geometry_SetRotation(this.handle, ref forward, ref up); + } + public RESULT getRotation(out VECTOR forward, out VECTOR up) + { + return FMOD5_Geometry_GetRotation(this.handle, out forward, out up); + } + public RESULT setPosition(ref VECTOR position) + { + return FMOD5_Geometry_SetPosition(this.handle, ref position); + } + public RESULT getPosition(out VECTOR position) + { + return FMOD5_Geometry_GetPosition(this.handle, out position); + } + public RESULT setScale(ref VECTOR scale) + { + return FMOD5_Geometry_SetScale(this.handle, ref scale); + } + public RESULT getScale(out VECTOR scale) + { + return FMOD5_Geometry_GetScale(this.handle, out scale); + } + public RESULT save(IntPtr data, out int datasize) + { + return FMOD5_Geometry_Save(this.handle, data, out datasize); + } + + // Userdata set/get. + public RESULT setUserData(IntPtr userdata) + { + return FMOD5_Geometry_SetUserData(this.handle, userdata); + } + public RESULT getUserData(out IntPtr userdata) + { + return FMOD5_Geometry_GetUserData(this.handle, out userdata); + } + + #region importfunctions + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Geometry_Release (IntPtr geometry); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Geometry_AddPolygon (IntPtr geometry, float directocclusion, float reverbocclusion, bool doublesided, int numvertices, VECTOR[] vertices, out int polygonindex); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Geometry_GetNumPolygons (IntPtr geometry, out int numpolygons); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Geometry_GetMaxPolygons (IntPtr geometry, out int maxpolygons, out int maxvertices); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Geometry_GetPolygonNumVertices(IntPtr geometry, int index, out int numvertices); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Geometry_SetPolygonVertex (IntPtr geometry, int index, int vertexindex, ref VECTOR vertex); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Geometry_GetPolygonVertex (IntPtr geometry, int index, int vertexindex, out VECTOR vertex); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Geometry_SetPolygonAttributes (IntPtr geometry, int index, float directocclusion, float reverbocclusion, bool doublesided); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Geometry_GetPolygonAttributes (IntPtr geometry, int index, out float directocclusion, out float reverbocclusion, out bool doublesided); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Geometry_SetActive (IntPtr geometry, bool active); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Geometry_GetActive (IntPtr geometry, out bool active); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Geometry_SetRotation (IntPtr geometry, ref VECTOR forward, ref VECTOR up); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Geometry_GetRotation (IntPtr geometry, out VECTOR forward, out VECTOR up); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Geometry_SetPosition (IntPtr geometry, ref VECTOR position); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Geometry_GetPosition (IntPtr geometry, out VECTOR position); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Geometry_SetScale (IntPtr geometry, ref VECTOR scale); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Geometry_GetScale (IntPtr geometry, out VECTOR scale); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Geometry_Save (IntPtr geometry, IntPtr data, out int datasize); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Geometry_SetUserData (IntPtr geometry, IntPtr userdata); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Geometry_GetUserData (IntPtr geometry, out IntPtr userdata); + #endregion + + #region wrapperinternal + + public IntPtr handle; + + public Geometry(IntPtr ptr) { this.handle = ptr; } + public bool hasHandle() { return this.handle != IntPtr.Zero; } + public void clearHandle() { this.handle = IntPtr.Zero; } + + #endregion + } + + /* + 'Reverb3D' API + */ + public struct Reverb3D + { + public RESULT release() + { + return FMOD5_Reverb3D_Release(this.handle); + } + + // Reverb manipulation. + public RESULT set3DAttributes(ref VECTOR position, float mindistance, float maxdistance) + { + return FMOD5_Reverb3D_Set3DAttributes(this.handle, ref position, mindistance, maxdistance); + } + public RESULT get3DAttributes(ref VECTOR position, ref float mindistance, ref float maxdistance) + { + return FMOD5_Reverb3D_Get3DAttributes(this.handle, ref position, ref mindistance, ref maxdistance); + } + public RESULT setProperties(ref REVERB_PROPERTIES properties) + { + return FMOD5_Reverb3D_SetProperties(this.handle, ref properties); + } + public RESULT getProperties(ref REVERB_PROPERTIES properties) + { + return FMOD5_Reverb3D_GetProperties(this.handle, ref properties); + } + public RESULT setActive(bool active) + { + return FMOD5_Reverb3D_SetActive(this.handle, active); + } + public RESULT getActive(out bool active) + { + return FMOD5_Reverb3D_GetActive(this.handle, out active); + } + + // Userdata set/get. + public RESULT setUserData(IntPtr userdata) + { + return FMOD5_Reverb3D_SetUserData(this.handle, userdata); + } + public RESULT getUserData(out IntPtr userdata) + { + return FMOD5_Reverb3D_GetUserData(this.handle, out userdata); + } + + #region importfunctions + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Reverb3D_Release (IntPtr reverb3d); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Reverb3D_Set3DAttributes (IntPtr reverb3d, ref VECTOR position, float mindistance, float maxdistance); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Reverb3D_Get3DAttributes (IntPtr reverb3d, ref VECTOR position, ref float mindistance, ref float maxdistance); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Reverb3D_SetProperties (IntPtr reverb3d, ref REVERB_PROPERTIES properties); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Reverb3D_GetProperties (IntPtr reverb3d, ref REVERB_PROPERTIES properties); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Reverb3D_SetActive (IntPtr reverb3d, bool active); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Reverb3D_GetActive (IntPtr reverb3d, out bool active); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Reverb3D_SetUserData (IntPtr reverb3d, IntPtr userdata); + [DllImport(VERSION.dll)] + private static extern RESULT FMOD5_Reverb3D_GetUserData (IntPtr reverb3d, out IntPtr userdata); + #endregion + + #region wrapperinternal + + public IntPtr handle; + + public Reverb3D(IntPtr ptr) { this.handle = ptr; } + public bool hasHandle() { return this.handle != IntPtr.Zero; } + public void clearHandle() { this.handle = IntPtr.Zero; } + + #endregion + } + + #region Helper Functions + [StructLayout(LayoutKind.Sequential)] + public struct StringWrapper + { + IntPtr nativeUtf8Ptr; + + public StringWrapper(IntPtr ptr) + { + nativeUtf8Ptr = ptr; + } + + public static implicit operator string(StringWrapper fstring) + { + using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper()) + { + return encoder.stringFromNative(fstring.nativeUtf8Ptr); + } + } + } + + static class StringHelper + { + public class ThreadSafeEncoding : IDisposable + { + UTF8Encoding encoding = new UTF8Encoding(); + byte[] encodedBuffer = new byte[128]; + char[] decodedBuffer = new char[128]; + bool inUse; + GCHandle gcHandle; + + public bool InUse() { return inUse; } + public void SetInUse() { inUse = true; } + + private int roundUpPowerTwo(int number) + { + int newNumber = 1; + while (newNumber <= number) + { + newNumber *= 2; + } + + return newNumber; + } + + public byte[] byteFromStringUTF8(string s) + { + if (s == null) + { + return null; + } + + int maximumLength = encoding.GetMaxByteCount(s.Length) + 1; // +1 for null terminator + if (maximumLength > encodedBuffer.Length) + { + int encodedLength = encoding.GetByteCount(s) + 1; // +1 for null terminator + if (encodedLength > encodedBuffer.Length) + { + encodedBuffer = new byte[roundUpPowerTwo(encodedLength)]; + } + } + + int byteCount = encoding.GetBytes(s, 0, s.Length, encodedBuffer, 0); + encodedBuffer[byteCount] = 0; // Apply null terminator + + return encodedBuffer; + } + + public IntPtr intptrFromStringUTF8(string s) + { + if (s == null) + { + return IntPtr.Zero; + } + + gcHandle = GCHandle.Alloc(byteFromStringUTF8(s), GCHandleType.Pinned); + return gcHandle.AddrOfPinnedObject(); + } + + public string stringFromNative(IntPtr nativePtr) + { + if (nativePtr == IntPtr.Zero) + { + return ""; + } + + int nativeLen = 0; + while (Marshal.ReadByte(nativePtr, nativeLen) != 0) + { + nativeLen++; + } + + if (nativeLen == 0) + { + return ""; + } + + if (nativeLen > encodedBuffer.Length) + { + encodedBuffer = new byte[roundUpPowerTwo(nativeLen)]; + } + + Marshal.Copy(nativePtr, encodedBuffer, 0, nativeLen); + + int maximumLength = encoding.GetMaxCharCount(nativeLen); + if (maximumLength > decodedBuffer.Length) + { + int decodedLength = encoding.GetCharCount(encodedBuffer, 0, nativeLen); + if (decodedLength > decodedBuffer.Length) + { + decodedBuffer = new char[roundUpPowerTwo(decodedLength)]; + } + } + + int charCount = encoding.GetChars(encodedBuffer, 0, nativeLen, decodedBuffer, 0); + + return new String(decodedBuffer, 0, charCount); + } + + public void Dispose() + { + if (gcHandle.IsAllocated) + { + gcHandle.Free(); + } + lock (encoders) + { + inUse = false; + } + } + } + + static List encoders = new List(1); + + public static ThreadSafeEncoding GetFreeHelper() + { + lock (encoders) + { + ThreadSafeEncoding helper = null; + // Search for not in use helper + for (int i = 0; i < encoders.Count; i++) + { + if (!encoders[i].InUse()) + { + helper = encoders[i]; + break; + } + } + // Otherwise create another helper + if (helper == null) + { + helper = new ThreadSafeEncoding(); + encoders.Add(helper); + } + helper.SetInUse(); + return helper; + } + } + } + + // Some of the Marshal functions were marked as deprecated / obsolete, however that decision was reversed: https://github.com/dotnet/corefx/pull/10541 + // Use the old syntax (non-generic) to ensure maximum compatibility (especially with Unity) ignoring the warnings + public static class MarshalHelper + { +#pragma warning disable 618 + public static int SizeOf(Type t) + { + return Marshal.SizeOf(t); // Always use Type version, never Object version as it boxes causes GC allocations + } + + public static object PtrToStructure(IntPtr ptr, Type structureType) + { + return Marshal.PtrToStructure(ptr, structureType); + } +#pragma warning restore 618 + } + + #endregion +} diff --git a/Radegast/FMOD/fmod_dsp.cs b/Radegast/FMOD/fmod_dsp.cs new file mode 100644 index 000000000..5df37d08c --- /dev/null +++ b/Radegast/FMOD/fmod_dsp.cs @@ -0,0 +1,885 @@ +/* ======================================================================================== */ +/* FMOD Core API - DSP header file. */ +/* Copyright (c), Firelight Technologies Pty, Ltd. 2004-2021. */ +/* */ +/* Use this header if you are wanting to develop your own DSP plugin to use with FMODs */ +/* dsp system. With this header you can make your own DSP plugin that FMOD can */ +/* register and use. See the documentation and examples on how to make a working plugin. */ +/* */ +/* For more detail visit: */ +/* https://fmod.com/resources/documentation-api?version=2.0&page=plugin-api-dsp.html */ +/* =========================================================================================*/ + +using System; +using System.Text; +using System.Runtime.InteropServices; + +namespace FMOD +{ + [StructLayout(LayoutKind.Sequential)] + public struct DSP_BUFFER_ARRAY + { + public int numbuffers; + public int[] buffernumchannels; + public CHANNELMASK[] bufferchannelmask; + public IntPtr[] buffers; + public SPEAKERMODE speakermode; + } + + public enum DSP_PROCESS_OPERATION + { + PROCESS_PERFORM = 0, + PROCESS_QUERY + } + + [StructLayout(LayoutKind.Sequential)] + public struct COMPLEX + { + public float real; + public float imag; + } + + public enum DSP_PAN_SURROUND_FLAGS + { + DEFAULT = 0, + ROTATION_NOT_BIASED = 1, + } + + + /* + DSP callbacks + */ + public delegate RESULT DSP_CREATECALLBACK (ref DSP_STATE dsp_state); + public delegate RESULT DSP_RELEASECALLBACK (ref DSP_STATE dsp_state); + public delegate RESULT DSP_RESETCALLBACK (ref DSP_STATE dsp_state); + public delegate RESULT DSP_SETPOSITIONCALLBACK (ref DSP_STATE dsp_state, uint pos); + public delegate RESULT DSP_READCALLBACK (ref DSP_STATE dsp_state, IntPtr inbuffer, IntPtr outbuffer, uint length, int inchannels, ref int outchannels); + public delegate RESULT DSP_SHOULDIPROCESS_CALLBACK (ref DSP_STATE dsp_state, bool inputsidle, uint length, CHANNELMASK inmask, int inchannels, SPEAKERMODE speakermode); + public delegate RESULT DSP_PROCESS_CALLBACK (ref DSP_STATE dsp_state, uint length, ref DSP_BUFFER_ARRAY inbufferarray, ref DSP_BUFFER_ARRAY outbufferarray, bool inputsidle, DSP_PROCESS_OPERATION op); + public delegate RESULT DSP_SETPARAM_FLOAT_CALLBACK (ref DSP_STATE dsp_state, int index, float value); + public delegate RESULT DSP_SETPARAM_INT_CALLBACK (ref DSP_STATE dsp_state, int index, int value); + public delegate RESULT DSP_SETPARAM_BOOL_CALLBACK (ref DSP_STATE dsp_state, int index, bool value); + public delegate RESULT DSP_SETPARAM_DATA_CALLBACK (ref DSP_STATE dsp_state, int index, IntPtr data, uint length); + public delegate RESULT DSP_GETPARAM_FLOAT_CALLBACK (ref DSP_STATE dsp_state, int index, ref float value, IntPtr valuestr); + public delegate RESULT DSP_GETPARAM_INT_CALLBACK (ref DSP_STATE dsp_state, int index, ref int value, IntPtr valuestr); + public delegate RESULT DSP_GETPARAM_BOOL_CALLBACK (ref DSP_STATE dsp_state, int index, ref bool value, IntPtr valuestr); + public delegate RESULT DSP_GETPARAM_DATA_CALLBACK (ref DSP_STATE dsp_state, int index, ref IntPtr data, ref uint length, IntPtr valuestr); + public delegate RESULT DSP_SYSTEM_REGISTER_CALLBACK (ref DSP_STATE dsp_state); + public delegate RESULT DSP_SYSTEM_DEREGISTER_CALLBACK (ref DSP_STATE dsp_state); + public delegate RESULT DSP_SYSTEM_MIX_CALLBACK (ref DSP_STATE dsp_state, int stage); + + + /* + DSP functions + */ + public delegate IntPtr DSP_ALLOC_FUNC (uint size, MEMORY_TYPE type, IntPtr sourcestr); + public delegate IntPtr DSP_REALLOC_FUNC (IntPtr ptr, uint size, MEMORY_TYPE type, IntPtr sourcestr); + public delegate void DSP_FREE_FUNC (IntPtr ptr, MEMORY_TYPE type, IntPtr sourcestr); + public delegate void DSP_LOG_FUNC (DEBUG_FLAGS level, IntPtr file, int line, IntPtr function, IntPtr format); + public delegate RESULT DSP_GETSAMPLERATE_FUNC (ref DSP_STATE dsp_state, ref int rate); + public delegate RESULT DSP_GETBLOCKSIZE_FUNC (ref DSP_STATE dsp_state, ref uint blocksize); + public delegate RESULT DSP_GETSPEAKERMODE_FUNC (ref DSP_STATE dsp_state, ref int speakermode_mixer, ref int speakermode_output); + public delegate RESULT DSP_GETCLOCK_FUNC (ref DSP_STATE dsp_state, out ulong clock, out uint offset, out uint length); + public delegate RESULT DSP_GETLISTENERATTRIBUTES_FUNC (ref DSP_STATE dsp_state, ref int numlisteners, IntPtr attributes); + public delegate RESULT DSP_GETUSERDATA_FUNC (ref DSP_STATE dsp_state, out IntPtr userdata); + public delegate RESULT DSP_DFT_FFTREAL_FUNC (ref DSP_STATE dsp_state, int size, IntPtr signal, IntPtr dft, IntPtr window, int signalhop); + public delegate RESULT DSP_DFT_IFFTREAL_FUNC (ref DSP_STATE dsp_state, int size, IntPtr dft, IntPtr signal, IntPtr window, int signalhop); + public delegate RESULT DSP_PAN_SUMMONOMATRIX_FUNC (ref DSP_STATE dsp_state, int sourceSpeakerMode, float lowFrequencyGain, float overallGain, IntPtr matrix); + public delegate RESULT DSP_PAN_SUMSTEREOMATRIX_FUNC (ref DSP_STATE dsp_state, int sourceSpeakerMode, float pan, float lowFrequencyGain, float overallGain, int matrixHop, IntPtr matrix); + public delegate RESULT DSP_PAN_SUMSURROUNDMATRIX_FUNC (ref DSP_STATE dsp_state, int sourceSpeakerMode, int targetSpeakerMode, float direction, float extent, float rotation, float lowFrequencyGain, float overallGain, int matrixHop, IntPtr matrix, DSP_PAN_SURROUND_FLAGS flags); + public delegate RESULT DSP_PAN_SUMMONOTOSURROUNDMATRIX_FUNC (ref DSP_STATE dsp_state, int targetSpeakerMode, float direction, float extent, float lowFrequencyGain, float overallGain, int matrixHop, IntPtr matrix); + public delegate RESULT DSP_PAN_SUMSTEREOTOSURROUNDMATRIX_FUNC (ref DSP_STATE dsp_state, int targetSpeakerMode, float direction, float extent, float rotation, float lowFrequencyGain, float overallGain, int matrixHop, IntPtr matrix); + public delegate RESULT DSP_PAN_GETROLLOFFGAIN_FUNC (ref DSP_STATE dsp_state, DSP_PAN_3D_ROLLOFF_TYPE rolloff, float distance, float mindistance, float maxdistance, out float gain); + + + public enum DSP_TYPE : int + { + UNKNOWN, + MIXER, + OSCILLATOR, + LOWPASS, + ITLOWPASS, + HIGHPASS, + ECHO, + FADER, + FLANGE, + DISTORTION, + NORMALIZE, + LIMITER, + PARAMEQ, + PITCHSHIFT, + CHORUS, + VSTPLUGIN, + WINAMPPLUGIN, + ITECHO, + COMPRESSOR, + SFXREVERB, + LOWPASS_SIMPLE, + DELAY, + TREMOLO, + LADSPAPLUGIN, + SEND, + RETURN, + HIGHPASS_SIMPLE, + PAN, + THREE_EQ, + FFT, + LOUDNESS_METER, + ENVELOPEFOLLOWER, + CONVOLUTIONREVERB, + CHANNELMIX, + TRANSCEIVER, + OBJECTPAN, + MULTIBAND_EQ, + MAX + } + + public enum DSP_PARAMETER_TYPE + { + FLOAT = 0, + INT, + BOOL, + DATA, + MAX + } + + public enum DSP_PARAMETER_FLOAT_MAPPING_TYPE + { + DSP_PARAMETER_FLOAT_MAPPING_TYPE_LINEAR = 0, + DSP_PARAMETER_FLOAT_MAPPING_TYPE_AUTO, + DSP_PARAMETER_FLOAT_MAPPING_TYPE_PIECEWISE_LINEAR, + } + + [StructLayout(LayoutKind.Sequential)] + public struct DSP_PARAMETER_FLOAT_MAPPING_PIECEWISE_LINEAR + { + public int numpoints; + public IntPtr pointparamvalues; + public IntPtr pointpositions; + } + + [StructLayout(LayoutKind.Sequential)] + public struct DSP_PARAMETER_FLOAT_MAPPING + { + public DSP_PARAMETER_FLOAT_MAPPING_TYPE type; + public DSP_PARAMETER_FLOAT_MAPPING_PIECEWISE_LINEAR piecewiselinearmapping; + } + + + [StructLayout(LayoutKind.Sequential)] + public struct DSP_PARAMETER_DESC_FLOAT + { + public float min; + public float max; + public float defaultval; + public DSP_PARAMETER_FLOAT_MAPPING mapping; + } + + [StructLayout(LayoutKind.Sequential)] + public struct DSP_PARAMETER_DESC_INT + { + public int min; + public int max; + public int defaultval; + public bool goestoinf; + public IntPtr valuenames; + } + + [StructLayout(LayoutKind.Sequential)] + public struct DSP_PARAMETER_DESC_BOOL + { + public bool defaultval; + public IntPtr valuenames; + } + + [StructLayout(LayoutKind.Sequential)] + public struct DSP_PARAMETER_DESC_DATA + { + public int datatype; + } + + [StructLayout(LayoutKind.Explicit)] + public struct DSP_PARAMETER_DESC_UNION + { + [FieldOffset(0)] + public DSP_PARAMETER_DESC_FLOAT floatdesc; + [FieldOffset(0)] + public DSP_PARAMETER_DESC_INT intdesc; + [FieldOffset(0)] + public DSP_PARAMETER_DESC_BOOL booldesc; + [FieldOffset(0)] + public DSP_PARAMETER_DESC_DATA datadesc; + } + + [StructLayout(LayoutKind.Sequential)] + public struct DSP_PARAMETER_DESC + { + public DSP_PARAMETER_TYPE type; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] + public byte[] name; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] + public byte[] label; + public string description; + + public DSP_PARAMETER_DESC_UNION desc; + } + + public enum DSP_PARAMETER_DATA_TYPE + { + DSP_PARAMETER_DATA_TYPE_USER = 0, + DSP_PARAMETER_DATA_TYPE_OVERALLGAIN = -1, + DSP_PARAMETER_DATA_TYPE_3DATTRIBUTES = -2, + DSP_PARAMETER_DATA_TYPE_SIDECHAIN = -3, + DSP_PARAMETER_DATA_TYPE_FFT = -4, + DSP_PARAMETER_DATA_TYPE_3DATTRIBUTES_MULTI = -5 + } + + [StructLayout(LayoutKind.Sequential)] + public struct DSP_PARAMETER_OVERALLGAIN + { + public float linear_gain; + public float linear_gain_additive; + } + + [StructLayout(LayoutKind.Sequential)] + public struct DSP_PARAMETER_3DATTRIBUTES + { + public ATTRIBUTES_3D relative; + public ATTRIBUTES_3D absolute; + } + + [StructLayout(LayoutKind.Sequential)] + public struct DSP_PARAMETER_3DATTRIBUTES_MULTI + { + public int numlisteners; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] + public ATTRIBUTES_3D[] relative; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] + public float[] weight; + public ATTRIBUTES_3D absolute; + } + + [StructLayout(LayoutKind.Sequential)] + public struct DSP_PARAMETER_SIDECHAIN + { + public int sidechainenable; + } + + [StructLayout(LayoutKind.Sequential)] + public struct DSP_PARAMETER_FFT + { + public int length; + public int numchannels; + + [MarshalAs(UnmanagedType.ByValArray,SizeConst=32)] + private IntPtr[] spectrum_internal; + + public float[][] spectrum + { + get + { + var buffer = new float[numchannels][]; + + for (int i = 0; i < numchannels; ++i) + { + buffer[i] = new float[length]; + Marshal.Copy(spectrum_internal[i], buffer[i], 0, length); + } + + return buffer; + } + } + + public void getSpectrum(ref float[][] buffer) + { + int bufferLength = Math.Min(buffer.Length, numchannels); + for (int i = 0; i < bufferLength; ++i) + { + getSpectrum(i, ref buffer[i]); + } + } + + public void getSpectrum(int channel, ref float[] buffer) + { + int bufferLength = Math.Min(buffer.Length, length); + Marshal.Copy(spectrum_internal[channel], buffer, 0, bufferLength); + } + } + + [StructLayout(LayoutKind.Sequential)] + public struct DSP_LOUDNESS_METER_INFO_TYPE + { + public float momentaryloudness; + public float shorttermloudness; + public float integratedloudness; + public float loudness10thpercentile; + public float loudness95thpercentile; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 66)] + public float[] loudnesshistogram; + public float maxtruepeak; + public float maxmomentaryloudness; + } + + [StructLayout(LayoutKind.Sequential)] + public struct DSP_LOUDNESS_METER_WEIGHTING_TYPE + { + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] + public float[] channelweight; + } + + [StructLayout(LayoutKind.Sequential)] + public struct DSP_DESCRIPTION + { + public uint pluginsdkversion; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] + public byte[] name; + public uint version; + public int numinputbuffers; + public int numoutputbuffers; + public DSP_CREATECALLBACK create; + public DSP_RELEASECALLBACK release; + public DSP_RESETCALLBACK reset; + public DSP_READCALLBACK read; + public DSP_PROCESS_CALLBACK process; + public DSP_SETPOSITIONCALLBACK setposition; + + public int numparameters; + public IntPtr paramdesc; + public DSP_SETPARAM_FLOAT_CALLBACK setparameterfloat; + public DSP_SETPARAM_INT_CALLBACK setparameterint; + public DSP_SETPARAM_BOOL_CALLBACK setparameterbool; + public DSP_SETPARAM_DATA_CALLBACK setparameterdata; + public DSP_GETPARAM_FLOAT_CALLBACK getparameterfloat; + public DSP_GETPARAM_INT_CALLBACK getparameterint; + public DSP_GETPARAM_BOOL_CALLBACK getparameterbool; + public DSP_GETPARAM_DATA_CALLBACK getparameterdata; + public DSP_SHOULDIPROCESS_CALLBACK shouldiprocess; + public IntPtr userdata; + + public DSP_SYSTEM_REGISTER_CALLBACK sys_register; + public DSP_SYSTEM_DEREGISTER_CALLBACK sys_deregister; + public DSP_SYSTEM_MIX_CALLBACK sys_mix; + } + + [StructLayout(LayoutKind.Sequential)] + public struct DSP_STATE_DFT_FUNCTIONS + { + public DSP_DFT_FFTREAL_FUNC fftreal; + public DSP_DFT_IFFTREAL_FUNC inversefftreal; + } + + [StructLayout(LayoutKind.Sequential)] + public struct DSP_STATE_PAN_FUNCTIONS + { + public DSP_PAN_SUMMONOMATRIX_FUNC summonomatrix; + public DSP_PAN_SUMSTEREOMATRIX_FUNC sumstereomatrix; + public DSP_PAN_SUMSURROUNDMATRIX_FUNC sumsurroundmatrix; + public DSP_PAN_SUMMONOTOSURROUNDMATRIX_FUNC summonotosurroundmatrix; + public DSP_PAN_SUMSTEREOTOSURROUNDMATRIX_FUNC sumstereotosurroundmatrix; + public DSP_PAN_GETROLLOFFGAIN_FUNC getrolloffgain; + } + + [StructLayout(LayoutKind.Sequential)] + public struct DSP_STATE_FUNCTIONS + { + public DSP_ALLOC_FUNC alloc; + public DSP_REALLOC_FUNC realloc; + public DSP_FREE_FUNC free; + public DSP_GETSAMPLERATE_FUNC getsamplerate; + public DSP_GETBLOCKSIZE_FUNC getblocksize; + public IntPtr dft; + public IntPtr pan; + public DSP_GETSPEAKERMODE_FUNC getspeakermode; + public DSP_GETCLOCK_FUNC getclock; + public DSP_GETLISTENERATTRIBUTES_FUNC getlistenerattributes; + public DSP_LOG_FUNC log; + public DSP_GETUSERDATA_FUNC getuserdata; + } + + [StructLayout(LayoutKind.Sequential)] + public struct DSP_STATE + { + public IntPtr instance; + public IntPtr plugindata; + public uint channelmask; + public int source_speakermode; + public IntPtr sidechaindata; + public int sidechainchannels; + public IntPtr functions; + public int systemobject; + } + + [StructLayout(LayoutKind.Sequential)] + public struct DSP_METERING_INFO + { + public int numsamples; + [MarshalAs(UnmanagedType.ByValArray, SizeConst=32)] + public float[] peaklevel; + [MarshalAs(UnmanagedType.ByValArray, SizeConst=32)] + public float[] rmslevel; + public short numchannels; + } + + /* + ============================================================================================================== + + FMOD built in effect parameters. + Use DSP::setParameter with these enums for the 'index' parameter. + + ============================================================================================================== + */ + + public enum DSP_OSCILLATOR : int + { + TYPE, + RATE + } + + public enum DSP_LOWPASS : int + { + CUTOFF, + RESONANCE + } + + public enum DSP_ITLOWPASS : int + { + CUTOFF, + RESONANCE + } + + public enum DSP_HIGHPASS : int + { + CUTOFF, + RESONANCE + } + + public enum DSP_ECHO : int + { + DELAY, + FEEDBACK, + DRYLEVEL, + WETLEVEL + } + + public enum DSP_FADER : int + { + GAIN, + OVERALL_GAIN, + } + + public enum DSP_DELAY : int + { + CH0, + CH1, + CH2, + CH3, + CH4, + CH5, + CH6, + CH7, + CH8, + CH9, + CH10, + CH11, + CH12, + CH13, + CH14, + CH15, + MAXDELAY, + } + + public enum DSP_FLANGE : int + { + MIX, + DEPTH, + RATE + } + + public enum DSP_TREMOLO : int + { + FREQUENCY, + DEPTH, + SHAPE, + SKEW, + DUTY, + SQUARE, + PHASE, + SPREAD + } + + public enum DSP_DISTORTION : int + { + LEVEL + } + + public enum DSP_NORMALIZE : int + { + FADETIME, + THRESHHOLD, + MAXAMP + } + + public enum DSP_LIMITER : int + { + RELEASETIME, + CEILING, + MAXIMIZERGAIN, + MODE, + } + + public enum DSP_PARAMEQ : int + { + CENTER, + BANDWIDTH, + GAIN + } + + public enum DSP_MULTIBAND_EQ : int + { + A_FILTER, + A_FREQUENCY, + A_Q, + A_GAIN, + B_FILTER, + B_FREQUENCY, + B_Q, + B_GAIN, + C_FILTER, + C_FREQUENCY, + C_Q, + C_GAIN, + D_FILTER, + D_FREQUENCY, + D_Q, + D_GAIN, + E_FILTER, + E_FREQUENCY, + E_Q, + E_GAIN, + } + + public enum DSP_MULTIBAND_EQ_FILTER_TYPE : int + { + DISABLED, + LOWPASS_12DB, + LOWPASS_24DB, + LOWPASS_48DB, + HIGHPASS_12DB, + HIGHPASS_24DB, + HIGHPASS_48DB, + LOWSHELF, + HIGHSHELF, + PEAKING, + BANDPASS, + NOTCH, + ALLPASS, + } + + public enum DSP_PITCHSHIFT : int + { + PITCH, + FFTSIZE, + OVERLAP, + MAXCHANNELS + } + + public enum DSP_CHORUS : int + { + MIX, + RATE, + DEPTH, + } + + public enum DSP_ITECHO : int + { + WETDRYMIX, + FEEDBACK, + LEFTDELAY, + RIGHTDELAY, + PANDELAY + } + + public enum DSP_COMPRESSOR : int + { + THRESHOLD, + RATIO, + ATTACK, + RELEASE, + GAINMAKEUP, + USESIDECHAIN, + LINKED + } + + public enum DSP_SFXREVERB : int + { + DECAYTIME, + EARLYDELAY, + LATEDELAY, + HFREFERENCE, + HFDECAYRATIO, + DIFFUSION, + DENSITY, + LOWSHELFFREQUENCY, + LOWSHELFGAIN, + HIGHCUT, + EARLYLATEMIX, + WETLEVEL, + DRYLEVEL + } + + public enum DSP_LOWPASS_SIMPLE : int + { + CUTOFF + } + + public enum DSP_SEND : int + { + RETURNID, + LEVEL, + } + + public enum DSP_RETURN : int + { + ID, + INPUT_SPEAKER_MODE + } + + public enum DSP_HIGHPASS_SIMPLE : int + { + CUTOFF + } + + public enum DSP_PAN_2D_STEREO_MODE_TYPE : int + { + DISTRIBUTED, + DISCRETE + } + + public enum DSP_PAN_MODE_TYPE : int + { + MONO, + STEREO, + SURROUND + } + + public enum DSP_PAN_3D_ROLLOFF_TYPE : int + { + LINEARSQUARED, + LINEAR, + INVERSE, + INVERSETAPERED, + CUSTOM + } + + public enum DSP_PAN_3D_EXTENT_MODE_TYPE : int + { + AUTO, + USER, + OFF + } + + public enum DSP_PAN : int + { + MODE, + _2D_STEREO_POSITION, + _2D_DIRECTION, + _2D_EXTENT, + _2D_ROTATION, + _2D_LFE_LEVEL, + _2D_STEREO_MODE, + _2D_STEREO_SEPARATION, + _2D_STEREO_AXIS, + ENABLED_SPEAKERS, + _3D_POSITION, + _3D_ROLLOFF, + _3D_MIN_DISTANCE, + _3D_MAX_DISTANCE, + _3D_EXTENT_MODE, + _3D_SOUND_SIZE, + _3D_MIN_EXTENT, + _3D_PAN_BLEND, + LFE_UPMIX_ENABLED, + OVERALL_GAIN, + SURROUND_SPEAKER_MODE, + _2D_HEIGHT_BLEND, + } + + public enum DSP_THREE_EQ_CROSSOVERSLOPE_TYPE : int + { + _12DB, + _24DB, + _48DB + } + + public enum DSP_THREE_EQ : int + { + LOWGAIN, + MIDGAIN, + HIGHGAIN, + LOWCROSSOVER, + HIGHCROSSOVER, + CROSSOVERSLOPE + } + + public enum DSP_FFT_WINDOW : int + { + RECT, + TRIANGLE, + HAMMING, + HANNING, + BLACKMAN, + BLACKMANHARRIS + } + + public enum DSP_FFT : int + { + WINDOWSIZE, + WINDOWTYPE, + SPECTRUMDATA, + DOMINANT_FREQ + } + + + public enum DSP_LOUDNESS_METER : int + { + STATE, + WEIGHTING, + INFO + } + + + public enum DSP_LOUDNESS_METER_STATE_TYPE : int + { + RESET_INTEGRATED = -3, + RESET_MAXPEAK = -2, + RESET_ALL = -1, + PAUSED = 0, + ANALYZING = 1 + } + + public enum DSP_ENVELOPEFOLLOWER : int + { + ATTACK, + RELEASE, + ENVELOPE, + USESIDECHAIN + } + + public enum DSP_CONVOLUTION_REVERB : int + { + IR, + WET, + DRY, + LINKED + } + + public enum DSP_CHANNELMIX_OUTPUT : int + { + DEFAULT, + ALLMONO, + ALLSTEREO, + ALLQUAD, + ALL5POINT1, + ALL7POINT1, + ALLLFE, + ALL7POINT1POINT4 + } + + public enum DSP_CHANNELMIX : int + { + OUTPUTGROUPING, + GAIN_CH0, + GAIN_CH1, + GAIN_CH2, + GAIN_CH3, + GAIN_CH4, + GAIN_CH5, + GAIN_CH6, + GAIN_CH7, + GAIN_CH8, + GAIN_CH9, + GAIN_CH10, + GAIN_CH11, + GAIN_CH12, + GAIN_CH13, + GAIN_CH14, + GAIN_CH15, + GAIN_CH16, + GAIN_CH17, + GAIN_CH18, + GAIN_CH19, + GAIN_CH20, + GAIN_CH21, + GAIN_CH22, + GAIN_CH23, + GAIN_CH24, + GAIN_CH25, + GAIN_CH26, + GAIN_CH27, + GAIN_CH28, + GAIN_CH29, + GAIN_CH30, + GAIN_CH31, + OUTPUT_CH0, + OUTPUT_CH1, + OUTPUT_CH2, + OUTPUT_CH3, + OUTPUT_CH4, + OUTPUT_CH5, + OUTPUT_CH6, + OUTPUT_CH7, + OUTPUT_CH8, + OUTPUT_CH9, + OUTPUT_CH10, + OUTPUT_CH11, + OUTPUT_CH12, + OUTPUT_CH13, + OUTPUT_CH14, + OUTPUT_CH15, + OUTPUT_CH16, + OUTPUT_CH17, + OUTPUT_CH18, + OUTPUT_CH19, + OUTPUT_CH20, + OUTPUT_CH21, + OUTPUT_CH22, + OUTPUT_CH23, + OUTPUT_CH24, + OUTPUT_CH25, + OUTPUT_CH26, + OUTPUT_CH27, + OUTPUT_CH28, + OUTPUT_CH29, + OUTPUT_CH30, + OUTPUT_CH31, + } + + public enum DSP_TRANSCEIVER_SPEAKERMODE : int + { + AUTO = -1, + MONO = 0, + STEREO, + SURROUND, + } + + public enum DSP_TRANSCEIVER : int + { + TRANSMIT, + GAIN, + CHANNEL, + TRANSMITSPEAKERMODE + } + + public enum DSP_OBJECTPAN : int + { + _3D_POSITION, + _3D_ROLLOFF, + _3D_MIN_DISTANCE, + _3D_MAX_DISTANCE, + _3D_EXTENT_MODE, + _3D_SOUND_SIZE, + _3D_MIN_EXTENT, + OVERALL_GAIN, + OUTPUTGAIN + } +} diff --git a/Radegast/FMOD/fmod_errors.cs b/Radegast/FMOD/fmod_errors.cs new file mode 100644 index 000000000..e7b9cd26d --- /dev/null +++ b/Radegast/FMOD/fmod_errors.cs @@ -0,0 +1,106 @@ +/* ============================================================================================== */ +/* FMOD Core / Studio API - Error string header file. */ +/* Copyright (c), Firelight Technologies Pty, Ltd. 2004-2021. */ +/* */ +/* Use this header if you want to store or display a string version / english explanation */ +/* of the FMOD error codes. */ +/* */ +/* For more detail visit: */ +/* https://fmod.com/resources/documentation-api?version=2.0&page=core-api-common.html#fmod_result */ +/* =============================================================================================== */ + +namespace FMOD +{ + public class Error + { + public static string String(FMOD.RESULT errcode) + { + switch (errcode) + { + case FMOD.RESULT.OK: return "No errors."; + case FMOD.RESULT.ERR_BADCOMMAND: return "Tried to call a function on a data type that does not allow this type of functionality (ie calling Sound::lock on a streaming sound)."; + case FMOD.RESULT.ERR_CHANNEL_ALLOC: return "Error trying to allocate a channel."; + case FMOD.RESULT.ERR_CHANNEL_STOLEN: return "The specified channel has been reused to play another sound."; + case FMOD.RESULT.ERR_DMA: return "DMA Failure. See debug output for more information."; + case FMOD.RESULT.ERR_DSP_CONNECTION: return "DSP connection error. Connection possibly caused a cyclic dependency or connected dsps with incompatible buffer counts."; + case FMOD.RESULT.ERR_DSP_DONTPROCESS: return "DSP return code from a DSP process query callback. Tells mixer not to call the process callback and therefore not consume CPU. Use this to optimize the DSP graph."; + case FMOD.RESULT.ERR_DSP_FORMAT: return "DSP Format error. A DSP unit may have attempted to connect to this network with the wrong format, or a matrix may have been set with the wrong size if the target unit has a specified channel map."; + case FMOD.RESULT.ERR_DSP_INUSE: return "DSP is already in the mixer's DSP network. It must be removed before being reinserted or released."; + case FMOD.RESULT.ERR_DSP_NOTFOUND: return "DSP connection error. Couldn't find the DSP unit specified."; + case FMOD.RESULT.ERR_DSP_RESERVED: return "DSP operation error. Cannot perform operation on this DSP as it is reserved by the system."; + case FMOD.RESULT.ERR_DSP_SILENCE: return "DSP return code from a DSP process query callback. Tells mixer silence would be produced from read, so go idle and not consume CPU. Use this to optimize the DSP graph."; + case FMOD.RESULT.ERR_DSP_TYPE: return "DSP operation cannot be performed on a DSP of this type."; + case FMOD.RESULT.ERR_FILE_BAD: return "Error loading file."; + case FMOD.RESULT.ERR_FILE_COULDNOTSEEK: return "Couldn't perform seek operation. This is a limitation of the medium (ie netstreams) or the file format."; + case FMOD.RESULT.ERR_FILE_DISKEJECTED: return "Media was ejected while reading."; + case FMOD.RESULT.ERR_FILE_EOF: return "End of file unexpectedly reached while trying to read essential data (truncated?)."; + case FMOD.RESULT.ERR_FILE_ENDOFDATA: return "End of current chunk reached while trying to read data."; + case FMOD.RESULT.ERR_FILE_NOTFOUND: return "File not found."; + case FMOD.RESULT.ERR_FORMAT: return "Unsupported file or audio format."; + case FMOD.RESULT.ERR_HEADER_MISMATCH: return "There is a version mismatch between the FMOD header and either the FMOD Studio library or the FMOD Low Level library."; + case FMOD.RESULT.ERR_HTTP: return "A HTTP error occurred. This is a catch-all for HTTP errors not listed elsewhere."; + case FMOD.RESULT.ERR_HTTP_ACCESS: return "The specified resource requires authentication or is forbidden."; + case FMOD.RESULT.ERR_HTTP_PROXY_AUTH: return "Proxy authentication is required to access the specified resource."; + case FMOD.RESULT.ERR_HTTP_SERVER_ERROR: return "A HTTP server error occurred."; + case FMOD.RESULT.ERR_HTTP_TIMEOUT: return "The HTTP request timed out."; + case FMOD.RESULT.ERR_INITIALIZATION: return "FMOD was not initialized correctly to support this function."; + case FMOD.RESULT.ERR_INITIALIZED: return "Cannot call this command after System::init."; + case FMOD.RESULT.ERR_INTERNAL: return "An error occurred that wasn't supposed to. Contact support."; + case FMOD.RESULT.ERR_INVALID_FLOAT: return "Value passed in was a NaN, Inf or denormalized float."; + case FMOD.RESULT.ERR_INVALID_HANDLE: return "An invalid object handle was used."; + case FMOD.RESULT.ERR_INVALID_PARAM: return "An invalid parameter was passed to this function."; + case FMOD.RESULT.ERR_INVALID_POSITION: return "An invalid seek position was passed to this function."; + case FMOD.RESULT.ERR_INVALID_SPEAKER: return "An invalid speaker was passed to this function based on the current speaker mode."; + case FMOD.RESULT.ERR_INVALID_SYNCPOINT: return "The syncpoint did not come from this sound handle."; + case FMOD.RESULT.ERR_INVALID_THREAD: return "Tried to call a function on a thread that is not supported."; + case FMOD.RESULT.ERR_INVALID_VECTOR: return "The vectors passed in are not unit length, or perpendicular."; + case FMOD.RESULT.ERR_MAXAUDIBLE: return "Reached maximum audible playback count for this sound's soundgroup."; + case FMOD.RESULT.ERR_MEMORY: return "Not enough memory or resources."; + case FMOD.RESULT.ERR_MEMORY_CANTPOINT: return "Can't use FMOD_OPENMEMORY_POINT on non PCM source data, or non mp3/xma/adpcm data if FMOD_CREATECOMPRESSEDSAMPLE was used."; + case FMOD.RESULT.ERR_NEEDS3D: return "Tried to call a command on a 2d sound when the command was meant for 3d sound."; + case FMOD.RESULT.ERR_NEEDSHARDWARE: return "Tried to use a feature that requires hardware support."; + case FMOD.RESULT.ERR_NET_CONNECT: return "Couldn't connect to the specified host."; + case FMOD.RESULT.ERR_NET_SOCKET_ERROR: return "A socket error occurred. This is a catch-all for socket-related errors not listed elsewhere."; + case FMOD.RESULT.ERR_NET_URL: return "The specified URL couldn't be resolved."; + case FMOD.RESULT.ERR_NET_WOULD_BLOCK: return "Operation on a non-blocking socket could not complete immediately."; + case FMOD.RESULT.ERR_NOTREADY: return "Operation could not be performed because specified sound/DSP connection is not ready."; + case FMOD.RESULT.ERR_OUTPUT_ALLOCATED: return "Error initializing output device, but more specifically, the output device is already in use and cannot be reused."; + case FMOD.RESULT.ERR_OUTPUT_CREATEBUFFER: return "Error creating hardware sound buffer."; + case FMOD.RESULT.ERR_OUTPUT_DRIVERCALL: return "A call to a standard soundcard driver failed, which could possibly mean a bug in the driver or resources were missing or exhausted."; + case FMOD.RESULT.ERR_OUTPUT_FORMAT: return "Soundcard does not support the specified format."; + case FMOD.RESULT.ERR_OUTPUT_INIT: return "Error initializing output device."; + case FMOD.RESULT.ERR_OUTPUT_NODRIVERS: return "The output device has no drivers installed. If pre-init, FMOD_OUTPUT_NOSOUND is selected as the output mode. If post-init, the function just fails."; + case FMOD.RESULT.ERR_PLUGIN: return "An unspecified error has been returned from a plugin."; + case FMOD.RESULT.ERR_PLUGIN_MISSING: return "A requested output, dsp unit type or codec was not available."; + case FMOD.RESULT.ERR_PLUGIN_RESOURCE: return "A resource that the plugin requires cannot be found. (ie the DLS file for MIDI playback)"; + case FMOD.RESULT.ERR_PLUGIN_VERSION: return "A plugin was built with an unsupported SDK version."; + case FMOD.RESULT.ERR_RECORD: return "An error occurred trying to initialize the recording device."; + case FMOD.RESULT.ERR_REVERB_CHANNELGROUP: return "Reverb properties cannot be set on this channel because a parent channelgroup owns the reverb connection."; + case FMOD.RESULT.ERR_REVERB_INSTANCE: return "Specified instance in FMOD_REVERB_PROPERTIES couldn't be set. Most likely because it is an invalid instance number or the reverb doesn't exist."; + case FMOD.RESULT.ERR_SUBSOUNDS: return "The error occurred because the sound referenced contains subsounds when it shouldn't have, or it doesn't contain subsounds when it should have. The operation may also not be able to be performed on a parent sound."; + case FMOD.RESULT.ERR_SUBSOUND_ALLOCATED: return "This subsound is already being used by another sound, you cannot have more than one parent to a sound. Null out the other parent's entry first."; + case FMOD.RESULT.ERR_SUBSOUND_CANTMOVE: return "Shared subsounds cannot be replaced or moved from their parent stream, such as when the parent stream is an FSB file."; + case FMOD.RESULT.ERR_TAGNOTFOUND: return "The specified tag could not be found or there are no tags."; + case FMOD.RESULT.ERR_TOOMANYCHANNELS: return "The sound created exceeds the allowable input channel count. This can be increased using the 'maxinputchannels' parameter in System::setSoftwareFormat."; + case FMOD.RESULT.ERR_TRUNCATED: return "The retrieved string is too long to fit in the supplied buffer and has been truncated."; + case FMOD.RESULT.ERR_UNIMPLEMENTED: return "Something in FMOD hasn't been implemented when it should be! contact support!"; + case FMOD.RESULT.ERR_UNINITIALIZED: return "This command failed because System::init or System::setDriver was not called."; + case FMOD.RESULT.ERR_UNSUPPORTED: return "A command issued was not supported by this object. Possibly a plugin without certain callbacks specified."; + case FMOD.RESULT.ERR_VERSION: return "The version number of this file format is not supported."; + case FMOD.RESULT.ERR_EVENT_ALREADY_LOADED: return "The specified bank has already been loaded."; + case FMOD.RESULT.ERR_EVENT_LIVEUPDATE_BUSY: return "The live update connection failed due to the game already being connected."; + case FMOD.RESULT.ERR_EVENT_LIVEUPDATE_MISMATCH: return "The live update connection failed due to the game data being out of sync with the tool."; + case FMOD.RESULT.ERR_EVENT_LIVEUPDATE_TIMEOUT: return "The live update connection timed out."; + case FMOD.RESULT.ERR_EVENT_NOTFOUND: return "The requested event, bus or vca could not be found."; + case FMOD.RESULT.ERR_STUDIO_UNINITIALIZED: return "The Studio::System object is not yet initialized."; + case FMOD.RESULT.ERR_STUDIO_NOT_LOADED: return "The specified resource is not loaded, so it can't be unloaded."; + case FMOD.RESULT.ERR_INVALID_STRING: return "An invalid string was passed to this function."; + case FMOD.RESULT.ERR_ALREADY_LOCKED: return "The specified resource is already locked."; + case FMOD.RESULT.ERR_NOT_LOCKED: return "The specified resource is not locked, so it can't be unlocked."; + case FMOD.RESULT.ERR_RECORD_DISCONNECTED: return "The specified recording driver has been disconnected."; + case FMOD.RESULT.ERR_TOOMANYSAMPLES: return "The length provided exceed the allowable limit."; + default: return "Unknown error."; + } + } + } +} diff --git a/Radegast/FormFlash.cs b/Radegast/FormFlash.cs index 0ece89325..08ce2197d 100644 --- a/Radegast/FormFlash.cs +++ b/Radegast/FormFlash.cs @@ -94,6 +94,7 @@ public struct FLASHWINFO public Int32 dwTimeout; } +[Flags] public enum FLASHWINFOFLAGS { FLASHW_STOP = 0, diff --git a/Radegast/GUI/Consoles/AnimDetail.cs b/Radegast/GUI/Consoles/AnimDetail.cs index e4aa842fb..9ac843d65 100644 --- a/Radegast/GUI/Consoles/AnimDetail.cs +++ b/Radegast/GUI/Consoles/AnimDetail.cs @@ -1,33 +1,23 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections.Generic; using System.Windows.Forms; @@ -50,13 +40,13 @@ public partial class AnimDetail : UserControl public AnimDetail(RadegastInstance instance, Avatar av, UUID anim, int n) { InitializeComponent(); - Disposed += new EventHandler(AnimDetail_Disposed); + Disposed += AnimDetail_Disposed; this.instance = instance; this.av = av; this.anim = anim; this.n = n; - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } void AnimDetail_Disposed(object sender, EventArgs e) @@ -72,12 +62,12 @@ private void AnimDetail_Load(object sender, EventArgs e) return; } - groupBox1.Text = "Animation " + n + " (" + anim + ") for " + av.Name; + groupBox1.Text = $"Animation {n} ({anim}) for {av.Name}"; - friends = instance.Client.Friends.FriendList.FindAll(delegate(FriendInfo f) { return true; }); + friends = instance.Client.Friends.FriendList.FindAll((FriendInfo f) => true); pnlSave.Visible = false; - boxAnimName.Text = "Animation " + n; + boxAnimName.Text = $"Animation {n}"; cbFriends.DropDownStyle = ComboBoxStyle.DropDownList; foreach (FriendInfo f in friends) @@ -90,12 +80,17 @@ private void AnimDetail_Load(object sender, EventArgs e) private void btnSave_Click(object sender, EventArgs e) { - WindowWrapper mainWindow = new WindowWrapper(frmMain.ActiveForm.Handle); - System.Windows.Forms.SaveFileDialog dlg = new SaveFileDialog(); - dlg.AddExtension = true; - dlg.RestoreDirectory = true; - dlg.Title = "Save animation as..."; - dlg.Filter = "Second Life Animation (*.sla)|*.sla"; + if (Form.ActiveForm != null) + { + WindowWrapper mainWindow = new WindowWrapper(Form.ActiveForm.Handle); + } + SaveFileDialog dlg = new SaveFileDialog + { + AddExtension = true, + RestoreDirectory = true, + Title = "Save animation as...", + Filter = "Second Life Animation (*.sla)|*.sla" + }; DialogResult res = dlg.ShowDialog(); if (res == DialogResult.OK) @@ -174,7 +169,7 @@ void On_ItemCreated(bool success, string status, UUID itemID, UUID assetID) } else { - Logger.Log("Created inventory item " + itemID.ToString(), Helpers.LogLevel.Info); + Logger.Log("Created inventory item " + itemID, Helpers.LogLevel.Info); lblStatus.Text = "Sending to " + friend.Name; Logger.Log("Sending item to " + friend.Name, Helpers.LogLevel.Info); diff --git a/Radegast/GUI/Consoles/AnimTab.cs b/Radegast/GUI/Consoles/AnimTab.cs index 83480c5bc..0100a438f 100644 --- a/Radegast/GUI/Consoles/AnimTab.cs +++ b/Radegast/GUI/Consoles/AnimTab.cs @@ -1,38 +1,27 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; -using System.IO; using OpenMetaverse; namespace Radegast @@ -48,20 +37,20 @@ public partial class AnimTab : UserControl public AnimTab(RadegastInstance instance, Avatar av) { InitializeComponent(); - Disposed += new EventHandler(AnimTab_Disposed); + Disposed += AnimTab_Disposed; this.instance = instance; this.av = av; - this.client = instance.Client; + client = instance.Client; // Callbacks - client.Avatars.AvatarAnimation += new EventHandler(Avatars_AvatarAnimation); + client.Avatars.AvatarAnimation += Avatars_AvatarAnimation; - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } void AnimTab_Disposed(object sender, EventArgs e) { - client.Avatars.AvatarAnimation -= new EventHandler(Avatars_AvatarAnimation); + client.Avatars.AvatarAnimation -= Avatars_AvatarAnimation; } void Avatars_AvatarAnimation(object sender, AvatarAnimationEventArgs e) diff --git a/Radegast/GUI/Consoles/Assets/Guesture.Designer.cs b/Radegast/GUI/Consoles/Assets/Gesture.Designer.cs similarity index 98% rename from Radegast/GUI/Consoles/Assets/Guesture.Designer.cs rename to Radegast/GUI/Consoles/Assets/Gesture.Designer.cs index 22acf7cf6..c34c5ea69 100644 --- a/Radegast/GUI/Consoles/Assets/Guesture.Designer.cs +++ b/Radegast/GUI/Consoles/Assets/Gesture.Designer.cs @@ -30,7 +30,7 @@ // namespace Radegast { - partial class Guesture + partial class Gesture { /// /// Required designer variable. @@ -58,7 +58,7 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Guesture)); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Gesture)); this.lnPanel = new Radegast.LineNumberPanel(); this.rtbInfo = new Radegast.RRichTextBox(); this.toolStrip1 = new System.Windows.Forms.ToolStrip(); @@ -144,14 +144,14 @@ private void InitializeComponent() this.tlblStatus.Text = "Status"; this.tlblStatus.ToolTipText = "Status"; // - // Guesture + // Gesture // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.Controls.Add(this.rtbInfo); this.Controls.Add(this.lnPanel); this.Controls.Add(this.toolStrip1); - this.Name = "Guesture"; + this.Name = "Gesture"; this.Size = new System.Drawing.Size(383, 334); this.toolStrip1.ResumeLayout(false); this.toolStrip1.PerformLayout(); diff --git a/Radegast/GUI/Consoles/Assets/Guesture.cs b/Radegast/GUI/Consoles/Assets/Gesture.cs similarity index 64% rename from Radegast/GUI/Consoles/Assets/Guesture.cs rename to Radegast/GUI/Consoles/Assets/Gesture.cs index 8e8ee1cbb..e984c5417 100644 --- a/Radegast/GUI/Consoles/Assets/Guesture.cs +++ b/Radegast/GUI/Consoles/Assets/Gesture.cs @@ -1,33 +1,23 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Windows.Forms; using OpenMetaverse; @@ -35,17 +25,17 @@ namespace Radegast { - public partial class Guesture : DettachableControl + public partial class Gesture : DettachableControl { private RadegastInstance instance; - private GridClient client { get { return instance.Client; } } + private GridClient client => instance.Client; private InventoryGesture gesture; private AssetGesture gestureAsset; - public Guesture(RadegastInstance instance, InventoryGesture gesture) + public Gesture(RadegastInstance instance, InventoryGesture gesture) { InitializeComponent(); - Disposed += new EventHandler(Guesture_Disposed); + Disposed += Guesture_Disposed; if (!instance.advancedDebugging) { @@ -59,7 +49,7 @@ public Guesture(RadegastInstance instance, InventoryGesture gesture) tlblStatus.Text = "Downloading..."; client.Assets.RequestAsset(gesture.AssetUUID, AssetType.Gesture, true, Assets_OnAssetReceived); - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } void Guesture_Disposed(object sender, EventArgs e) @@ -86,9 +76,9 @@ void Assets_OnAssetReceived(AssetDownload transfer, Asset asset) gestureAsset = (AssetGesture)asset; if (gestureAsset.Decode()) { - for (int i = 0; i < gestureAsset.Sequence.Count; i++) + foreach (GestureStep step in gestureAsset.Sequence) { - rtbInfo.AppendText(gestureAsset.Sequence[i].ToString().Trim() + Environment.NewLine); + rtbInfo.AppendText(step.ToString().Trim() + Environment.NewLine); } } } diff --git a/Radegast/GUI/Consoles/Assets/Guesture.resx b/Radegast/GUI/Consoles/Assets/Gesture.resx similarity index 98% rename from Radegast/GUI/Consoles/Assets/Guesture.resx rename to Radegast/GUI/Consoles/Assets/Gesture.resx index ae67aec4e..2f809a0d5 100644 --- a/Radegast/GUI/Consoles/Assets/Guesture.resx +++ b/Radegast/GUI/Consoles/Assets/Gesture.resx @@ -1,169 +1,169 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - - - - - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIISURBVDhPpZP7S1NxGMbPPxKaXVUkMEq8IpKUCoY/hGgI - ymqkDYYXcCjDZOANURSjCNGFQUTsl4GXVMxKk62YU4fXQpaIlygHQxBRH8/zwvyaIAYe+HLgnPN8nue9 - HA3nvDTq63oW/jm13XOwvPTB3DYFY5MH+bXfcN8ygfTSMSSXfESicQDxBqdYHwH29g9w2tnZ3UcguIvN - rR3417exuBJE5N1n/wfwLgXEOc38Bc6xNRHb+/y4nm49G0Bnit2zf9H6bkliE/jKuYxrd6oVgDWfjB+K - TWeKMyrGEVfowITvD9re/9ABVQrAhh0HHK+ZselMMaN/mvwtDb+aVqkA7HYIwIj3ysfluPTorJnP6Ezx - oHsD1s5ZXEktUwCOioB5f1CEPR9+wTG6iuiserTo8dkwng7HT/R+XUPF8xlcTjErAOdMcW6NW8STiwG8 - 7vej8oUPN/PsEv3t8Ao0TZP3T1u8uJRkUgAuSYHtO97oLxmXd5t9Ho8aPTK+GzntqNfrLm2fFoihwYOI - xGIF4KjoGBLzY1OrF9k6OOFxnwDC4wxIMX1G0pMhgVyMNyoA13PAtS7OrJk1PrC69LUdQWxuF6IybHrX - LRI7JrtZdoDAo1XmbjMyD+tjSXxGcXRmnYg5ttD9QuxDhN0uUgDOmbvNTpPOJaGAo2K36cyaGZvOFIfd - KlSA8/zRh9ABIDUG+1JpAAAAAElFTkSuQmCC - - - - - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIISURBVDhPpZP7S1NxGMbPPxKaXVUkMEq8IpKUCoY/hGgI - ymqkDYYXcCjDZOANURSjCNGFQUTsl4GXVMxKk62YU4fXQpaIlygHQxBRH8/zwvyaIAYe+HLgnPN8nue9 - HA3nvDTq63oW/jm13XOwvPTB3DYFY5MH+bXfcN8ygfTSMSSXfESicQDxBqdYHwH29g9w2tnZ3UcguIvN - rR3417exuBJE5N1n/wfwLgXEOc38Bc6xNRHb+/y4nm49G0Bnit2zf9H6bkliE/jKuYxrd6oVgDWfjB+K - TWeKMyrGEVfowITvD9re/9ABVQrAhh0HHK+ZselMMaN/mvwtDb+aVqkA7HYIwIj3ysfluPTorJnP6Ezx - oHsD1s5ZXEktUwCOioB5f1CEPR9+wTG6iuiserTo8dkwng7HT/R+XUPF8xlcTjErAOdMcW6NW8STiwG8 - 7vej8oUPN/PsEv3t8Ao0TZP3T1u8uJRkUgAuSYHtO97oLxmXd5t9Ho8aPTK+GzntqNfrLm2fFoihwYOI - xGIF4KjoGBLzY1OrF9k6OOFxnwDC4wxIMX1G0pMhgVyMNyoA13PAtS7OrJk1PrC69LUdQWxuF6IybHrX - LRI7JrtZdoDAo1XmbjMyD+tjSXxGcXRmnYg5ttD9QuxDhN0uUgDOmbvNTpPOJaGAo2K36cyaGZvOFIfd - KlSA8/zRh9ABIDUG+1JpAAAAAElFTkSuQmCC - - - - - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIISURBVDhPpZP7S1NxGMbPPxKaXVUkMEq8IpKUCoY/hGgI - ymqkDYYXcCjDZOANURSjCNGFQUTsl4GXVMxKk62YU4fXQpaIlygHQxBRH8/zwvyaIAYe+HLgnPN8nue9 - HA3nvDTq63oW/jm13XOwvPTB3DYFY5MH+bXfcN8ygfTSMSSXfESicQDxBqdYHwH29g9w2tnZ3UcguIvN - rR3417exuBJE5N1n/wfwLgXEOc38Bc6xNRHb+/y4nm49G0Bnit2zf9H6bkliE/jKuYxrd6oVgDWfjB+K - TWeKMyrGEVfowITvD9re/9ABVQrAhh0HHK+ZselMMaN/mvwtDb+aVqkA7HYIwIj3ysfluPTorJnP6Ezx - oHsD1s5ZXEktUwCOioB5f1CEPR9+wTG6iuiserTo8dkwng7HT/R+XUPF8xlcTjErAOdMcW6NW8STiwG8 - 7vej8oUPN/PsEv3t8Ao0TZP3T1u8uJRkUgAuSYHtO97oLxmXd5t9Ho8aPTK+GzntqNfrLm2fFoihwYOI - xGIF4KjoGBLzY1OrF9k6OOFxnwDC4wxIMX1G0pMhgVyMNyoA13PAtS7OrJk1PrC69LUdQWxuF6IybHrX - LRI7JrtZdoDAo1XmbjMyD+tjSXxGcXRmnYg5ttD9QuxDhN0uUgDOmbvNTpPOJaGAo2K36cyaGZvOFIfd - KlSA8/zRh9ABIDUG+1JpAAAAAElFTkSuQmCC - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIISURBVDhPpZP7S1NxGMbPPxKaXVUkMEq8IpKUCoY/hGgI + ymqkDYYXcCjDZOANURSjCNGFQUTsl4GXVMxKk62YU4fXQpaIlygHQxBRH8/zwvyaIAYe+HLgnPN8nue9 + HA3nvDTq63oW/jm13XOwvPTB3DYFY5MH+bXfcN8ygfTSMSSXfESicQDxBqdYHwH29g9w2tnZ3UcguIvN + rR3417exuBJE5N1n/wfwLgXEOc38Bc6xNRHb+/y4nm49G0Bnit2zf9H6bkliE/jKuYxrd6oVgDWfjB+K + TWeKMyrGEVfowITvD9re/9ABVQrAhh0HHK+ZselMMaN/mvwtDb+aVqkA7HYIwIj3ysfluPTorJnP6Ezx + oHsD1s5ZXEktUwCOioB5f1CEPR9+wTG6iuiserTo8dkwng7HT/R+XUPF8xlcTjErAOdMcW6NW8STiwG8 + 7vej8oUPN/PsEv3t8Ao0TZP3T1u8uJRkUgAuSYHtO97oLxmXd5t9Ho8aPTK+GzntqNfrLm2fFoihwYOI + xGIF4KjoGBLzY1OrF9k6OOFxnwDC4wxIMX1G0pMhgVyMNyoA13PAtS7OrJk1PrC69LUdQWxuF6IybHrX + LRI7JrtZdoDAo1XmbjMyD+tjSXxGcXRmnYg5ttD9QuxDhN0uUgDOmbvNTpPOJaGAo2K36cyaGZvOFIfd + KlSA8/zRh9ABIDUG+1JpAAAAAElFTkSuQmCC + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIISURBVDhPpZP7S1NxGMbPPxKaXVUkMEq8IpKUCoY/hGgI + ymqkDYYXcCjDZOANURSjCNGFQUTsl4GXVMxKk62YU4fXQpaIlygHQxBRH8/zwvyaIAYe+HLgnPN8nue9 + HA3nvDTq63oW/jm13XOwvPTB3DYFY5MH+bXfcN8ygfTSMSSXfESicQDxBqdYHwH29g9w2tnZ3UcguIvN + rR3417exuBJE5N1n/wfwLgXEOc38Bc6xNRHb+/y4nm49G0Bnit2zf9H6bkliE/jKuYxrd6oVgDWfjB+K + TWeKMyrGEVfowITvD9re/9ABVQrAhh0HHK+ZselMMaN/mvwtDb+aVqkA7HYIwIj3ysfluPTorJnP6Ezx + oHsD1s5ZXEktUwCOioB5f1CEPR9+wTG6iuiserTo8dkwng7HT/R+XUPF8xlcTjErAOdMcW6NW8STiwG8 + 7vej8oUPN/PsEv3t8Ao0TZP3T1u8uJRkUgAuSYHtO97oLxmXd5t9Ho8aPTK+GzntqNfrLm2fFoihwYOI + xGIF4KjoGBLzY1OrF9k6OOFxnwDC4wxIMX1G0pMhgVyMNyoA13PAtS7OrJk1PrC69LUdQWxuF6IybHrX + LRI7JrtZdoDAo1XmbjMyD+tjSXxGcXRmnYg5ttD9QuxDhN0uUgDOmbvNTpPOJaGAo2K36cyaGZvOFIfd + KlSA8/zRh9ABIDUG+1JpAAAAAElFTkSuQmCC + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIISURBVDhPpZP7S1NxGMbPPxKaXVUkMEq8IpKUCoY/hGgI + ymqkDYYXcCjDZOANURSjCNGFQUTsl4GXVMxKk62YU4fXQpaIlygHQxBRH8/zwvyaIAYe+HLgnPN8nue9 + HA3nvDTq63oW/jm13XOwvPTB3DYFY5MH+bXfcN8ygfTSMSSXfESicQDxBqdYHwH29g9w2tnZ3UcguIvN + rR3417exuBJE5N1n/wfwLgXEOc38Bc6xNRHb+/y4nm49G0Bnit2zf9H6bkliE/jKuYxrd6oVgDWfjB+K + TWeKMyrGEVfowITvD9re/9ABVQrAhh0HHK+ZselMMaN/mvwtDb+aVqkA7HYIwIj3ysfluPTorJnP6Ezx + oHsD1s5ZXEktUwCOioB5f1CEPR9+wTG6iuiserTo8dkwng7HT/R+XUPF8xlcTjErAOdMcW6NW8STiwG8 + 7vej8oUPN/PsEv3t8Ao0TZP3T1u8uJRkUgAuSYHtO97oLxmXd5t9Ho8aPTK+GzntqNfrLm2fFoihwYOI + xGIF4KjoGBLzY1OrF9k6OOFxnwDC4wxIMX1G0pMhgVyMNyoA13PAtS7OrJk1PrC69LUdQWxuF6IybHrX + LRI7JrtZdoDAo1XmbjMyD+tjSXxGcXRmnYg5ttD9QuxDhN0uUgDOmbvNTpPOJaGAo2K36cyaGZvOFIfd + KlSA8/zRh9ABIDUG+1JpAAAAAElFTkSuQmCC + + \ No newline at end of file diff --git a/Radegast/GUI/Consoles/Assets/Landmark.cs b/Radegast/GUI/Consoles/Assets/Landmark.cs index 5fd3d7f92..f32e3c84f 100644 --- a/Radegast/GUI/Consoles/Assets/Landmark.cs +++ b/Radegast/GUI/Consoles/Assets/Landmark.cs @@ -1,33 +1,23 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Windows.Forms; using OpenMetaverse; @@ -38,7 +28,7 @@ namespace Radegast public partial class Landmark : DettachableControl { private RadegastInstance instance; - private GridClient client { get { return instance.Client; } } + private GridClient client => instance.Client; private InventoryLandmark landmark; private AssetLandmark decodedLandmark; private UUID parcelID; @@ -64,21 +54,21 @@ public Landmark(RadegastInstance instance, UUID parcelID) void Init(RadegastInstance instance) { InitializeComponent(); - Disposed += new EventHandler(Landmark_Disposed); + Disposed += Landmark_Disposed; this.instance = instance; // Callbacks - client.Grid.RegionHandleReply += new EventHandler(Grid_RegionHandleReply); - client.Parcels.ParcelInfoReply += new EventHandler(Parcels_ParcelInfoReply); + client.Grid.RegionHandleReply += Grid_RegionHandleReply; + client.Parcels.ParcelInfoReply += Parcels_ParcelInfoReply; - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } void Landmark_Disposed(object sender, EventArgs e) { - client.Grid.RegionHandleReply -= new EventHandler(Grid_RegionHandleReply); - client.Parcels.ParcelInfoReply -= new EventHandler(Parcels_ParcelInfoReply); + client.Grid.RegionHandleReply -= Grid_RegionHandleReply; + client.Parcels.ParcelInfoReply -= Parcels_ParcelInfoReply; } void Parcels_ParcelInfoReply(object sender, ParcelInfoReplyEventArgs e) @@ -92,15 +82,14 @@ void Parcels_ParcelInfoReply(object sender, ParcelInfoReplyEventArgs e) return; } - this.parcel = e.Parcel; + parcel = e.Parcel; pnlDetail.Visible = true; if (parcel.SnapshotID != UUID.Zero) { - SLImageHandler img = new SLImageHandler(instance, parcel.SnapshotID, ""); - img.Dock = DockStyle.Fill; + SLImageHandler img = new SLImageHandler(instance, parcel.SnapshotID, "") {Dock = DockStyle.Fill}; pnlDetail.Controls.Add(img); - pnlDetail.Disposed += (object senderx, EventArgs ex) => + pnlDetail.Disposed += (senderx, ex) => { img.Dispose(); }; @@ -112,20 +101,17 @@ void Parcels_ParcelInfoReply(object sender, ParcelInfoReplyEventArgs e) if (parcelLocation) { - localPosition = new Vector3(); - localPosition.X = parcel.GlobalX % 256; - localPosition.Y = parcel.GlobalY % 256; - localPosition.Z = parcel.GlobalZ; + localPosition = new Vector3 + { + X = parcel.GlobalX % 256, + Y = parcel.GlobalY % 256, + Z = parcel.GlobalZ + }; } - if (decodedLandmark == null) - { - txtParcelName.Text = string.Format("{0} - {1} ", parcel.Name, parcel.SimName); - } - else - { - txtParcelName.Text = string.Format("{0} - {1} ({2}, {3}, {4}) ", parcel.Name, parcel.SimName, (int)decodedLandmark.Position.X, (int)decodedLandmark.Position.Y, (int)decodedLandmark.Position.Z); - } + txtParcelName.Text = decodedLandmark == null + ? $"{parcel.Name} - {parcel.SimName} " + : $"{parcel.Name} - {parcel.SimName} ({(int) decodedLandmark.Position.X}, {(int) decodedLandmark.Position.Y}, {(int) decodedLandmark.Position.Z}) "; txtParcelDescription.Text = parcel.Description; } diff --git a/Radegast/GUI/Consoles/Assets/Notecard.cs b/Radegast/GUI/Consoles/Assets/Notecard.cs index 1599bf1c6..b31063d3a 100644 --- a/Radegast/GUI/Consoles/Assets/Notecard.cs +++ b/Radegast/GUI/Consoles/Assets/Notecard.cs @@ -1,33 +1,23 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections.Generic; using System.Windows.Forms; @@ -39,7 +29,7 @@ namespace Radegast public partial class Notecard : DettachableControl { private RadegastInstance instance; - private GridClient client { get { return instance.Client; } } + private GridClient client => instance.Client; private InventoryNotecard notecard; private AssetNotecard receivedNotecard; private Primitive prim; @@ -52,7 +42,7 @@ public Notecard(RadegastInstance instance, InventoryNotecard notecard) public Notecard(RadegastInstance instance, InventoryNotecard notecard, Primitive prim) { InitializeComponent(); - Disposed += new EventHandler(Notecard_Disposed); + Disposed += Notecard_Disposed; this.instance = instance; this.notecard = notecard; @@ -72,17 +62,19 @@ public Notecard(RadegastInstance instance, InventoryNotecard notecard, Primitive rtbContent.Text = " "; UpdateStatus("Loading..."); + var transferID = UUID.Random(); if (prim == null) { - client.Assets.RequestInventoryAsset(notecard, true, Assets_OnAssetReceived); + client.Assets.RequestInventoryAsset(notecard, true, transferID, Assets_OnAssetReceived); } else { - client.Assets.RequestInventoryAsset(notecard.AssetUUID, notecard.UUID, prim.ID, prim.OwnerID, notecard.AssetType, true, Assets_OnAssetReceived); + client.Assets.RequestInventoryAsset(notecard.AssetUUID, notecard.UUID, prim.ID, prim.OwnerID, + notecard.AssetType, true, transferID, Assets_OnAssetReceived); } } - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } void Notecard_Disposed(object sender, EventArgs e) @@ -146,12 +138,12 @@ void Assets_OnAssetReceived(AssetDownload transfer, Asset asset) titem.DisplayStyle = ToolStripItemDisplayStyle.Text; } - titem.Name = item.UUID.ToString(); ; + titem.Name = item.UUID.ToString(); titem.Tag = item; - titem.Click += new EventHandler(attachmentMenuItem_Click); + titem.Click += attachmentMenuItem_Click; var saveToInv = new ToolStripMenuItem("Save to inventory"); - saveToInv.Click += (object xsender, EventArgs xe) => + saveToInv.Click += (xsender, xe) => { client.Inventory.RequestCopyItemFromNotecard(UUID.Zero, notecard.UUID, @@ -193,17 +185,15 @@ private void Inventory_OnInventoryItemCopied(InventoryBase item) if (item is InventoryNotecard) { - Notecard nc = new Notecard(instance, (InventoryNotecard)item); - nc.pnlKeepDiscard.Visible = true; + Notecard nc = new Notecard(instance, (InventoryNotecard) item) {pnlKeepDiscard = {Visible = true}}; nc.ShowDetached(); } } void attachmentMenuItem_Click(object sender, EventArgs e) { - if (sender is ToolStripMenuItem) + if (sender is ToolStripMenuItem titem) { - ToolStripMenuItem titem = (ToolStripMenuItem)sender; InventoryItem item = (InventoryItem)titem.Tag; switch (item.AssetType) @@ -235,7 +225,8 @@ private void btnRefresh_Click(object sender, EventArgs e) if (notecard.AssetUUID == UUID.Zero) return; rtbContent.Text = "Loading..."; - client.Assets.RequestInventoryAsset(notecard, true, Assets_OnAssetReceived); + var transferID = UUID.Random(); + client.Assets.RequestInventoryAsset(notecard, true, transferID, Assets_OnAssetReceived); } private void rtbContent_LinkClicked(object sender, LinkClickedEventArgs e) @@ -281,7 +272,7 @@ private void tbtnExit_Click(object sender, EventArgs e) { if (Detached) { - FindForm().Close(); + FindForm()?.Close(); } } @@ -289,13 +280,15 @@ private void tbtnSave_Click(object sender, EventArgs e) { bool success = false; string message = ""; - AssetNotecard n = new AssetNotecard(); - n.BodyText = rtbContent.Text; - n.EmbeddedItems = new List(); + AssetNotecard n = new AssetNotecard + { + BodyText = rtbContent.Text, + EmbeddedItems = new List() + }; if (receivedNotecard != null) { - for (int i = 0; i < receivedNotecard.EmbeddedItems.Count; i++) + for (var i = 0; i < receivedNotecard.EmbeddedItems.Count; i++) { n.EmbeddedItems.Add(receivedNotecard.EmbeddedItems[i]); int indexChar = 0xdc00 + i; diff --git a/Radegast/GUI/Consoles/Assets/SLImageHandler.cs b/Radegast/GUI/Consoles/Assets/SLImageHandler.cs index 1f54c8652..13b504ad8 100644 --- a/Radegast/GUI/Consoles/Assets/SLImageHandler.cs +++ b/Radegast/GUI/Consoles/Assets/SLImageHandler.cs @@ -1,52 +1,43 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2021, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Drawing; using System.Drawing.Imaging; using System.Windows.Forms; using OpenMetaverse; -using OpenMetaverse.Imaging; using OpenMetaverse.Assets; using System.IO; +using CoreJ2K; +using SkiaSharp; +using SkiaSharp.Views.Desktop; namespace Radegast { public partial class SLImageHandler : DettachableControl { private RadegastInstance instance; - private GridClient client { get { return instance.Client; } } + private GridClient client => instance.Client; private UUID imageID; - byte[] jpegdata; - ManagedImage imgManaged; + byte[] j2kdata; Image image; bool allowSave = false; @@ -54,17 +45,13 @@ public partial class SLImageHandler : DettachableControl public PictureBoxSizeMode SizeMode { - get { return pictureBox1.SizeMode; } - set { pictureBox1.SizeMode = value; } + get => pictureBox1.SizeMode; + set => pictureBox1.SizeMode = value; } public override string Text { - get - { - - return base.Text; - } + get => base.Text; set { base.Text = value; @@ -84,7 +71,7 @@ public SLImageHandler() { InitializeComponent(); - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } public SLImageHandler(RadegastInstance instance, UUID image, string label) @@ -98,16 +85,16 @@ public SLImageHandler(RadegastInstance instance, UUID image, string label, bool InitializeComponent(); Init(instance, image, label); - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } public void Init(RadegastInstance instance, UUID image, string label) { - Disposed += new EventHandler(SLImageHandler_Disposed); + Disposed += SLImageHandler_Disposed; pictureBox1.AllowDrop = true; this.instance = instance; - this.imageID = image; + imageID = image; Text = string.IsNullOrEmpty(label) ? "Image" : label; @@ -120,7 +107,7 @@ public void Init(RadegastInstance instance, UUID image, string label) } // Callbacks - client.Assets.ImageReceiveProgress += new EventHandler(Assets_ImageReceiveProgress); + client.Assets.ImageReceiveProgress += Assets_ImageReceiveProgress; UpdateImage(imageID); } @@ -144,7 +131,7 @@ public void UpdateImage(UUID imageID) } else if (state == TextureRequestState.Progress) { - // DisplayPartialImage(assetTexture); + DisplayPartialImage(assetTexture); } }, true); @@ -152,12 +139,12 @@ public void UpdateImage(UUID imageID) void SLImageHandler_Disposed(object sender, EventArgs e) { - client.Assets.ImageReceiveProgress -= new EventHandler(Assets_ImageReceiveProgress); + client.Assets.ImageReceiveProgress -= Assets_ImageReceiveProgress; } void Assets_ImageReceiveProgress(object sender, ImageReceiveProgressEventArgs e) { - if (this.imageID != e.ImageID) + if (imageID != e.ImageID) { return; } @@ -178,7 +165,7 @@ void Assets_ImageReceiveProgress(object sender, ImageReceiveProgressEventArgs e) { return; } - lblProgress.Text = String.Format("{0} of {1}KB ({2}%)", (int)e.Received / 1024, (int)e.Total / 1024, pct); + lblProgress.Text = string.Format("{0} of {1}KB ({2}%)", (int)e.Received / 1024, (int)e.Total / 1024, pct); progressBar1.Value = pct; } @@ -193,20 +180,18 @@ void DisplayPartialImage(AssetTexture assetTexture) try { - ManagedImage tmp; - System.Drawing.Image img; - if (OpenJPEG.DecodeToImage(assetTexture.AssetData, out tmp, out img)) - { - pictureBox1.Image = img; - pictureBox1.Enabled = true; - } + pictureBox1.Image = J2kImage.FromBytes(assetTexture.AssetData).As().ToBitmap(); + pictureBox1.Enabled = true; + } + catch (Exception e) { + Hide(); + Console.WriteLine("Error decoding image: " + e.Message); } - catch (Exception) { } } private void Assets_OnImageReceived(AssetTexture assetTexture) { - if (assetTexture.AssetID != this.imageID) + if (assetTexture.AssetID != imageID) { return; } @@ -223,25 +208,21 @@ private void Assets_OnImageReceived(AssetTexture assetTexture) progressBar1.Hide(); lblProgress.Hide(); - if (!OpenJPEG.DecodeToImage(assetTexture.AssetData, out imgManaged, out image)) - { - throw new Exception("decoding failure"); - } - + image = J2kImage.FromBytes(assetTexture.AssetData).As().ToBitmap(); Text = Text; // yeah, really ;) pictureBox1.Image = image; pictureBox1.Enabled = true; - jpegdata = assetTexture.AssetData; + j2kdata = assetTexture.AssetData; if (Detached) { ClientSize = pictureBox1.Size = new Size(image.Width, image.Height); } } - catch (Exception excp) + catch (Exception e) { - this.Hide(); - System.Console.WriteLine("Error decoding image: " + excp.Message); + Hide(); + Console.WriteLine("Error decoding image: " + e.Message); } } @@ -256,16 +237,14 @@ protected override void Detach() private void saveToolStripMenuItem_Click(object sender, EventArgs e) { - if (imgManaged == null) + SaveFileDialog dlg = new SaveFileDialog { - return; - } - - System.Windows.Forms.SaveFileDialog dlg = new SaveFileDialog(); - dlg.AddExtension = true; - dlg.RestoreDirectory = true; - dlg.Title = "Save image as..."; - dlg.Filter = "Targa (*.tga)|*.tga|Jpeg2000 (*.j2c)|*.j2c|PNG (*.png)|*.png|Jpeg (*.jpg)|*.jpg|Bitmap (*.bmp)|*.bmp"; + AddExtension = true, + RestoreDirectory = true, + Title = "Save image as...", + Filter = + "Targa (*.tga)|*.tga|Jpeg2000 (*.j2c)|*.j2c|PNG (*.png)|*.png|Jpeg (*.jpg)|*.jpg|Bitmap (*.bmp)|*.bmp" + }; @@ -273,12 +252,14 @@ private void saveToolStripMenuItem_Click(object sender, EventArgs e) { int type = dlg.FilterIndex; if (type == 2) - { // jpeg200 - File.WriteAllBytes(dlg.FileName, jpegdata); + { // jpeg2000 + File.WriteAllBytes(dlg.FileName, j2kdata); } else if (type == 1) { // targa - File.WriteAllBytes(dlg.FileName, imgManaged.ExportTGA()); + var bmp = (Bitmap)image; + var mi = new OpenMetaverse.Imaging.ManagedImage(bmp.ToSKBitmap()); + File.WriteAllBytes(dlg.FileName, OpenMetaverse.Imaging.Targa.Encode(mi)); } else if (type == 3) { // png @@ -341,9 +322,9 @@ private void pictureBox1_DragDrop(object sender, DragEventArgs e) if (node.Tag is InventorySnapshot || node.Tag is InventoryTexture) { UUID imgID = UUID.Zero; - if (node.Tag is InventorySnapshot) + if (node.Tag is InventorySnapshot snapshot) { - imgID = ((InventorySnapshot)node.Tag).AssetUUID; + imgID = snapshot.AssetUUID; } else { @@ -351,10 +332,7 @@ private void pictureBox1_DragDrop(object sender, DragEventArgs e) } var handler = ImageUpdated; - if (handler != null) - { - handler(this, new ImageUpdatedEventArgs(imgID)); - } + handler?.Invoke(this, new ImageUpdatedEventArgs(imgID)); } } @@ -432,10 +410,7 @@ private void tbtnClear_Click(object sender, EventArgs e) { UpdateImage(UUID.Zero); var handler = ImageUpdated; - if (handler != null) - { - handler(this, new ImageUpdatedEventArgs(UUID.Zero)); - } + handler?.Invoke(this, new ImageUpdatedEventArgs(UUID.Zero)); } } @@ -462,16 +437,13 @@ private void tbtnPaste_Click(object sender, EventArgs e) UpdateImage(newID); var handler = ImageUpdated; - if (handler != null) - { - handler(this, new ImageUpdatedEventArgs(newID)); - } + handler?.Invoke(this, new ImageUpdatedEventArgs(newID)); } } private void tbtbInvShow_Click(object sender, EventArgs e) { - if (tbtbInvShow.Tag == null || !(tbtbInvShow.Tag is InventoryItem)) return; + if (!(tbtbInvShow.Tag is InventoryItem)) return; InventoryItem item = (InventoryItem)tbtbInvShow.Tag; @@ -490,7 +462,7 @@ public class ImageUpdatedEventArgs : EventArgs public ImageUpdatedEventArgs(UUID imageID) { - this.NewImageID = imageID; + NewImageID = imageID; } } } diff --git a/Radegast/GUI/Consoles/Assets/ScriptEditor.cs b/Radegast/GUI/Consoles/Assets/ScriptEditor.cs index 99079bb6e..23cb6be32 100644 --- a/Radegast/GUI/Consoles/Assets/ScriptEditor.cs +++ b/Radegast/GUI/Consoles/Assets/ScriptEditor.cs @@ -1,33 +1,23 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections.Generic; using System.Drawing; @@ -43,7 +33,7 @@ namespace Radegast public partial class ScriptEditor : UserControl { private RadegastInstance instance; - private GridClient client { get { return instance.Client; } } + private GridClient client => instance.Client; private InventoryLSL script; private string scriptName; private string fileName; @@ -63,7 +53,7 @@ public ScriptEditor(RadegastInstance instance, InventoryLSL script) public ScriptEditor(RadegastInstance instance, InventoryLSL script, Primitive prim) { InitializeComponent(); - Disposed += new EventHandler(SscriptEditor_Disposed); + Disposed += SscriptEditor_Disposed; this.instance = instance; this.script = script; @@ -71,10 +61,10 @@ public ScriptEditor(RadegastInstance instance, InventoryLSL script, Primitive pr rtb.SyntaxHighlightEnabled = instance.GlobalSettings["script_syntax_highlight"].AsBoolean(); lblScripStatus.Text = string.Empty; - lblScripStatus.TextChanged += (object sender, EventArgs e) => + lblScripStatus.TextChanged += (sender, e) => instance.TabConsole.DisplayNotificationInChat(lblScripStatus.Text, ChatBufferTextStyle.Invisible); Dock = DockStyle.Fill; - this.TabStop = false; + TabStop = false; if (prim == null) { @@ -85,15 +75,17 @@ public ScriptEditor(RadegastInstance instance, InventoryLSL script, Primitive pr if (script != null) { scriptName = script.Name; + var transferID = UUID.Random(); if (prim != null) { - client.Assets.RequestInventoryAsset(script.AssetUUID, script.UUID, prim.ID, prim.OwnerID, script.AssetType, true, Assets_OnAssetReceived); + client.Assets.RequestInventoryAsset(script.AssetUUID, script.UUID, prim.ID, prim.OwnerID, script.AssetType, + true, transferID, Assets_OnAssetReceived); client.Inventory.RequestGetScriptRunning(prim.ID, script.UUID); client.Inventory.ScriptRunningReply += OnScriptRunningReplyReceived; } else { - client.Assets.RequestInventoryAsset(script, true, Assets_OnAssetReceived); + client.Assets.RequestInventoryAsset(script, true, transferID, Assets_OnAssetReceived); } rtb.Text = lblScripStatus.Text = "Loading script..."; } @@ -103,7 +95,7 @@ public ScriptEditor(RadegastInstance instance, InventoryLSL script, Primitive pr rtb.SelectionStart = 0; } - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } void SscriptEditor_Disposed(object sender, EventArgs e) @@ -133,14 +125,12 @@ void Assets_OnAssetReceived(AssetDownload transfer, Asset asset) return; } - if (!transfer.Success || asset.AssetType != AssetType.LSLText) - { + if (!transfer.Success || asset.AssetType != AssetType.LSLText) { lblScripStatus.Text = rtb.Text = "Failed to download."; return; - } - else + } else { lblScripStatus.Text = rtb.Text = "OK"; - + } asset.Decode(); rtb.Text = ((AssetScriptText)asset).Source; lineNubersForRtb.Invalidate(); @@ -162,10 +152,7 @@ private void SetTitle() public bool Detached { - get - { - return detached; - } + get => detached; set { @@ -193,10 +180,7 @@ private void Detach() { detached = true; - if (detachedForm != null) - { - detachedForm.Dispose(); - } + detachedForm?.Dispose(); detachedForm = new Form(); originalParent = Parent; @@ -205,11 +189,11 @@ private void Detach() SetTitle(); detachedForm.ActiveControl = this; detachedForm.Show(); - detachedForm.FormClosing += new FormClosingEventHandler(detachedForm_FormClosing); + detachedForm.FormClosing += detachedForm_FormClosing; if (originalParent != null) { - originalParent.ControlAdded += new ControlEventHandler(originalParent_ControlAdded); + originalParent.ControlAdded += originalParent_ControlAdded; } else { @@ -234,9 +218,9 @@ void originalParent_ControlAdded(object sender, ControlEventArgs e) { if (detachedForm != null) { - detachedForm.FormClosing -= new FormClosingEventHandler(detachedForm_FormClosing); + detachedForm.FormClosing -= detachedForm_FormClosing; } - originalParent.ControlAdded -= new ControlEventHandler(originalParent_ControlAdded); + originalParent.ControlAdded -= originalParent_ControlAdded; tbtnAttach.Visible = false; } @@ -251,7 +235,7 @@ private void Retach() if (originalParent != null) { - originalParent.ControlAdded -= new ControlEventHandler(originalParent_ControlAdded); + originalParent.ControlAdded -= originalParent_ControlAdded; Parent = originalParent; } @@ -296,10 +280,12 @@ private void tbtbSaveToDisk_Click_1(object sender, EventArgs e) private void tbtbSaveToDisk_Click(object sender, EventArgs e) { - SaveFileDialog dlg = new SaveFileDialog(); - dlg.Title = "Save script"; - dlg.Filter = "LSL script file (*.lsl)|*.lsl|Plain text file (*.txt)|*.txt"; - dlg.FileName = RadegastMisc.SafeFileName(scriptName); + SaveFileDialog dlg = new SaveFileDialog + { + Title = "Save script", + Filter = "LSL script file (*.lsl)|*.lsl|Plain text file (*.txt)|*.txt", + FileName = RadegastMisc.SafeFileName(scriptName) + }; DialogResult res = dlg.ShowDialog(); if (res == DialogResult.OK) @@ -314,10 +300,12 @@ private void tbtbSaveToDisk_Click(object sender, EventArgs e) private void tbtbLoadFromDisk_Click(object sender, EventArgs e) { - OpenFileDialog dlg = new OpenFileDialog(); - dlg.Title = "Open script"; - dlg.Filter = "LSL script files (*.lsl)|*.lsl|Plain text files (*.txt)|*.txt|All files (*.*)|*.*"; - dlg.Multiselect = false; + OpenFileDialog dlg = new OpenFileDialog + { + Title = "Open script", + Filter = "LSL script files (*.lsl)|*.lsl|Plain text files (*.txt)|*.txt|All files (*.*)|*.*", + Multiselect = false + }; DialogResult res = dlg.ShowDialog(); if (res == DialogResult.OK) @@ -333,7 +321,7 @@ private void tbtbLoadFromDisk_Click(object sender, EventArgs e) private void tbtnExit_Click(object sender, EventArgs e) { - FindForm().Close(); + FindForm()?.Close(); } private void rtb_SelectionChanged(object sender, EventArgs e) @@ -643,18 +631,19 @@ private void tfindReplace_Click(object sender, EventArgs e) private static string ReplaceEx(string original, string pattern, string replacement) { - int count, position0, position1; - count = position0 = position1 = 0; + int position0, position1; + var count = position0 = position1 = 0; string upperString = original.ToUpper(); string upperPattern = pattern.ToUpper(); int inc = (original.Length / pattern.Length) * (replacement.Length - pattern.Length); char[] chars = new char[original.Length + Math.Max(0, inc)]; - while ((position1 = upperString.IndexOf(upperPattern, position0)) != -1) + while ((position1 = upperString.IndexOf(upperPattern, position0, StringComparison.Ordinal)) != -1) { for (int i = position0; i < position1; ++i) chars[count++] = original[i]; - for (int i = 0; i < replacement.Length; ++i) - chars[count++] = replacement[i]; + foreach (var r in replacement) + chars[count++] = r; + position0 = position1 + pattern.Length; } if (position0 == 0) return original; @@ -680,7 +669,7 @@ private void tfindReplaceAll_Click(object sender, EventArgs e) private void syntaxHiglightingToolStripMenuItem_Click(object sender, EventArgs e) { - if (rtb.SyntaxHighlightEnabled == true) + if (rtb.SyntaxHighlightEnabled) { rtb.SyntaxHighlightEnabled = false; } @@ -700,7 +689,7 @@ private void ReadCursorPosition() private void tbtbSave_Click(object sender, EventArgs e) { - InventoryManager.ScriptUpdatedCallback handler = (bool uploadSuccess, string uploadStatus, bool compileSuccess, List compileMessages, UUID itemID, UUID assetID) => + InventoryManager.ScriptUpdatedCallback handler = (uploadSuccess, uploadStatus, compileSuccess, compileMessages, itemID, assetID) => { if (!IsHandleCreated && instance.MonoRuntime) return; @@ -764,8 +753,7 @@ private void tbtbSave_Click(object sender, EventArgs e) txtStatus.Hide(); txtStatus.Text = string.Empty; - AssetScriptText n = new AssetScriptText(); - n.Source = rtb.Text; + AssetScriptText n = new AssetScriptText {Source = rtb.Text}; n.Encode(); if (prim != null) diff --git a/Radegast/GUI/Consoles/AttachmentDetail.cs b/Radegast/GUI/Consoles/AttachmentDetail.cs index 017de656c..9a996d1d5 100644 --- a/Radegast/GUI/Consoles/AttachmentDetail.cs +++ b/Radegast/GUI/Consoles/AttachmentDetail.cs @@ -1,42 +1,26 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections.Generic; using System.Windows.Forms; -#if (COGBOT_LIBOMV || USE_STHREADS) -using ThreadPoolUtil; -using Thread = ThreadPoolUtil.Thread; -using ThreadPool = ThreadPoolUtil.ThreadPool; -using Monitor = ThreadPoolUtil.Monitor; -#endif using System.Threading; using OpenMetaverse; @@ -46,14 +30,14 @@ namespace Radegast public partial class AttachmentDetail : UserControl { private RadegastInstance instance; - private GridClient client { get { return instance.Client; } } + private GridClient client => instance.Client; private Avatar av; private Primitive attachment; public AttachmentDetail(RadegastInstance instance, Avatar av, Primitive attachment) { InitializeComponent(); - Disposed += new EventHandler(AttachmentDetail_Disposed); + Disposed += AttachmentDetail_Disposed; this.instance = instance; this.av = av; @@ -67,14 +51,14 @@ public AttachmentDetail(RadegastInstance instance, Avatar av, Primitive attachme } // Callbacks - client.Objects.ObjectProperties += new EventHandler(Objects_ObjectProperties); + client.Objects.ObjectProperties += Objects_ObjectProperties; - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } void AttachmentDetail_Disposed(object sender, EventArgs e) { - client.Objects.ObjectProperties -= new EventHandler(Objects_ObjectProperties); + client.Objects.ObjectProperties -= Objects_ObjectProperties; } private void AttachmentDetail_Load(object sender, EventArgs e) @@ -108,13 +92,10 @@ private void UpdateControls() } List parts = client.Network.CurrentSim.ObjectsPrimitives.FindAll( - delegate(Primitive prim) - { - return (prim.LocalID == attachment.LocalID || prim.ParentID == attachment.LocalID); - } + prim => (prim.LocalID == attachment.LocalID || prim.ParentID == attachment.LocalID) ); - lblPrimCount.Text = "Prims: " + parts.Count.ToString(); + lblPrimCount.Text = $"Prims: {parts.Count}"; } void Objects_ObjectProperties(object sender, ObjectPropertiesEventArgs e) @@ -133,37 +114,40 @@ private void btnTouch_Click(object sender, EventArgs e) private void btnSave_Click(object sender, EventArgs e) { - WindowWrapper mainWindow = new WindowWrapper(frmMain.ActiveForm.Handle); - System.Windows.Forms.SaveFileDialog dlg = new SaveFileDialog(); - dlg.AddExtension = true; - dlg.RestoreDirectory = true; - dlg.Title = "Save object as..."; - dlg.Filter = "XML file (*.xml)|*.xml"; + if (Form.ActiveForm == null) return; + WindowWrapper mainWindow = new WindowWrapper(Form.ActiveForm.Handle); + SaveFileDialog dlg = new SaveFileDialog + { + AddExtension = true, + RestoreDirectory = true, + Title = "Save object as...", + Filter = "XML file (*.xml)|*.xml" + }; DialogResult res = dlg.ShowDialog(); if (res == DialogResult.OK) { - Thread t = new Thread(new ThreadStart(delegate() + Thread t = new Thread(delegate() + { + try { - try - { - PrimSerializer s = new PrimSerializer(client); - string primsXmls = s.GetSerializedAttachmentPrims(client.Network.CurrentSim, attachment.LocalID); - System.IO.File.WriteAllText(dlg.FileName, primsXmls); - s.CleanUp(); - s = null; - MessageBox.Show(mainWindow, "Successfully saved " + dlg.FileName, "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); - } - catch (Exception excp) - { - MessageBox.Show(mainWindow, excp.Message, "Saving failed", MessageBoxButtons.OK, MessageBoxIcon.Error); - } + PrimSerializer s = new PrimSerializer(client); + string primsXmls = + s.GetSerializedAttachmentPrims(client.Network.CurrentSim, attachment.LocalID); + System.IO.File.WriteAllText(dlg.FileName, primsXmls); + s.CleanUp(); + s = null; + MessageBox.Show(mainWindow, "Successfully saved " + dlg.FileName, "Success", + MessageBoxButtons.OK, MessageBoxIcon.Information); } - )); - t.IsBackground = true; + catch (Exception excp) + { + MessageBox.Show(mainWindow, excp.Message, "Saving failed", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + }) {IsBackground = true}; t.Start(); } - } private void button1_Click(object sender, EventArgs e) diff --git a/Radegast/GUI/Consoles/AttachmentTab.cs b/Radegast/GUI/Consoles/AttachmentTab.cs index edffe35ae..83801818e 100644 --- a/Radegast/GUI/Consoles/AttachmentTab.cs +++ b/Radegast/GUI/Consoles/AttachmentTab.cs @@ -1,33 +1,23 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections.Generic; using System.Drawing; @@ -39,7 +29,7 @@ namespace Radegast public partial class AttachmentTab : UserControl { private RadegastInstance instance; - private GridClient client { get { return instance.Client; } } + private GridClient client => instance.Client; private Avatar av; public AttachmentTab(RadegastInstance instance, Avatar iav) @@ -51,7 +41,7 @@ public AttachmentTab(RadegastInstance instance, Avatar iav) InitializeComponent(); // TODO: Was this second initialization intentional...? - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } private void AttachmentTab_Load(object sender, EventArgs e) @@ -62,10 +52,7 @@ private void AttachmentTab_Load(object sender, EventArgs e) public void RefreshList() { List attachments = client.Network.CurrentSim.ObjectsPrimitives.FindAll( - delegate(Primitive prim) - { - return (prim.ParentID == av.LocalID); - } + prim => (prim.ParentID == av.LocalID) ); List toRemove = new List(); @@ -78,10 +65,10 @@ public void RefreshList() } } - for (int i = 0; i < toRemove.Count; i++) + foreach (var control in toRemove) { - Controls.Remove(toRemove[i]); - toRemove[i].Dispose(); + Controls.Remove(control); + control.Dispose(); } List added = new List(); diff --git a/Radegast/GUI/Consoles/AvatarPicker.cs b/Radegast/GUI/Consoles/AvatarPicker.cs index d005d8c9f..29d01d02a 100644 --- a/Radegast/GUI/Consoles/AvatarPicker.cs +++ b/Radegast/GUI/Consoles/AvatarPicker.cs @@ -1,41 +1,27 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections.Generic; using System.ComponentModel; -using System.Drawing; -using System.Data; -using System.Linq; -using System.Text; using System.Windows.Forms; using OpenMetaverse; @@ -44,7 +30,7 @@ namespace Radegast public partial class AvatarPicker : UserControl { RadegastInstance instance; - GridClient client { get { return instance.Client; } } + GridClient client => instance.Client; UUID searchID; public ListView currentList; @@ -71,26 +57,26 @@ public Dictionary SelectedAvatars public AvatarPicker(RadegastInstance instance) { InitializeComponent(); - Disposed += new EventHandler(AvatarPicker_Disposed); + Disposed += AvatarPicker_Disposed; this.instance = instance; // events - client.Avatars.AvatarPickerReply += new EventHandler(Avatars_AvatarPickerReply); + client.Avatars.AvatarPickerReply += Avatars_AvatarPickerReply; List nearAvatars = instance.TabConsole.NearbyAvatars; - for (int i = 0; i < nearAvatars.Count; i++) + foreach (var avatar in nearAvatars) { - string name = instance.Names.Get(nearAvatars[i].ID, nearAvatars[i].Name); - lvwNear.Items.Add(new ListViewItem() { Text = nearAvatars[i].Name, Tag = nearAvatars[i].ID }); + string name = instance.Names.Get(avatar.ID, avatar.Name); + lvwNear.Items.Add(new ListViewItem() { Text = avatar.Name, Tag = avatar.ID }); } - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } void AvatarPicker_Disposed(object sender, EventArgs e) { - client.Avatars.AvatarPickerReply -= new EventHandler(Avatars_AvatarPickerReply); + client.Avatars.AvatarPickerReply -= Avatars_AvatarPickerReply; } void Avatars_AvatarPickerReply(object sender, AvatarPickerReplyEventArgs e) @@ -126,15 +112,13 @@ private void txtSearch_TextChanged(object sender, EventArgs e) private void lvwNear_SelectedIndexChanged(object sender, EventArgs e) { currentList = lvwNear; - if (SelectionChaged != null) - SelectionChaged(this, EventArgs.Empty); + SelectionChaged?.Invoke(this, EventArgs.Empty); } private void lvwSearch_SelectedIndexChanged(object sender, EventArgs e) { currentList = lvwSearch; - if (SelectionChaged != null) - SelectionChaged(this, EventArgs.Empty); + SelectionChaged?.Invoke(this, EventArgs.Empty); } private void lvwSearch_SizeChanged(object sender, EventArgs e) diff --git a/Radegast/GUI/Consoles/ChatConsole.Designer.cs b/Radegast/GUI/Consoles/ChatConsole.Designer.cs index d813a4685..1db170d8e 100644 --- a/Radegast/GUI/Consoles/ChatConsole.Designer.cs +++ b/Radegast/GUI/Consoles/ChatConsole.Designer.cs @@ -1,4 +1,4 @@ -// +// // Radegast Metaverse Client // Copyright (c) 2009-2014, Radegast Development Team // All rights reserved. @@ -77,6 +77,7 @@ private void InitializeComponent() this.ctxPoint = new System.Windows.Forms.ToolStripMenuItem(); this.ctxOfferTP = new System.Windows.Forms.ToolStripMenuItem(); this.ctxTeleportTo = new System.Windows.Forms.ToolStripMenuItem(); + this.ctxReqestLure = new System.Windows.Forms.ToolStripMenuItem(); this.goToToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.faceToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.ctxEject = new System.Windows.Forms.ToolStripMenuItem(); @@ -84,6 +85,10 @@ private void InitializeComponent() this.ctxEstateEject = new System.Windows.Forms.ToolStripMenuItem(); this.muteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.pnlMovement = new System.Windows.Forms.Panel(); + this.btnRun = new System.Windows.Forms.Button(); + this.btnFly = new System.Windows.Forms.Button(); + this.btnJump = new System.Windows.Forms.Button(); + this.btnCrouch = new System.Windows.Forms.Button(); this.btnMoveBack = new System.Windows.Forms.Button(); this.btnFwd = new System.Windows.Forms.Button(); this.btnTurnRight = new System.Windows.Forms.Button(); @@ -91,7 +96,7 @@ private void InitializeComponent() this.pnlChatInput = new System.Windows.Forms.Panel(); this.cbChatType = new System.Windows.Forms.ComboBox(); this.cbxInput = new Radegast.ChatInputBox(); - this.ctxReqestLure = new System.Windows.Forms.ToolStripMenuItem(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout(); this.splitContainer1.SuspendLayout(); @@ -160,7 +165,7 @@ private void InitializeComponent() this.lvwObjects.Location = new System.Drawing.Point(0, 0); this.lvwObjects.MultiSelect = false; this.lvwObjects.Name = "lvwObjects"; - this.lvwObjects.Size = new System.Drawing.Size(127, 317); + this.lvwObjects.Size = new System.Drawing.Size(127, 310); this.lvwObjects.TabIndex = 0; this.lvwObjects.UseCompatibleStateImageBehavior = false; this.lvwObjects.View = System.Windows.Forms.View.List; @@ -191,13 +196,13 @@ private void InitializeComponent() this.ctxEstateEject, this.muteToolStripMenuItem}); this.avatarContext.Name = "avatarContext"; - this.avatarContext.Size = new System.Drawing.Size(164, 422); + this.avatarContext.Size = new System.Drawing.Size(163, 400); this.avatarContext.Opening += new System.ComponentModel.CancelEventHandler(this.avatarContext_Opening); // // ctxProfile // this.ctxProfile.Name = "ctxProfile"; - this.ctxProfile.Size = new System.Drawing.Size(163, 22); + this.ctxProfile.Size = new System.Drawing.Size(162, 22); this.ctxProfile.Text = "Profile"; this.ctxProfile.Click += new System.EventHandler(this.tbtnProfile_Click); // @@ -205,63 +210,63 @@ private void InitializeComponent() // this.ctxPay.Enabled = false; this.ctxPay.Name = "ctxPay"; - this.ctxPay.Size = new System.Drawing.Size(163, 22); + this.ctxPay.Size = new System.Drawing.Size(162, 22); this.ctxPay.Text = "Pay"; this.ctxPay.Click += new System.EventHandler(this.ctxPay_Click); // // ctxStartIM // this.ctxStartIM.Name = "ctxStartIM"; - this.ctxStartIM.Size = new System.Drawing.Size(163, 22); + this.ctxStartIM.Size = new System.Drawing.Size(162, 22); this.ctxStartIM.Text = "Start IM"; this.ctxStartIM.Click += new System.EventHandler(this.tbtnStartIM_Click); // // ctxFollow // this.ctxFollow.Name = "ctxFollow"; - this.ctxFollow.Size = new System.Drawing.Size(163, 22); + this.ctxFollow.Size = new System.Drawing.Size(162, 22); this.ctxFollow.Text = "Follow"; this.ctxFollow.Click += new System.EventHandler(this.tbtnFollow_Click); // // ctxTextures // this.ctxTextures.Name = "ctxTextures"; - this.ctxTextures.Size = new System.Drawing.Size(163, 22); + this.ctxTextures.Size = new System.Drawing.Size(162, 22); this.ctxTextures.Text = "Textures"; this.ctxTextures.Click += new System.EventHandler(this.dumpOufitBtn_Click); // // ctxAttach // this.ctxAttach.Name = "ctxAttach"; - this.ctxAttach.Size = new System.Drawing.Size(163, 22); + this.ctxAttach.Size = new System.Drawing.Size(162, 22); this.ctxAttach.Text = "Attachments"; this.ctxAttach.Click += new System.EventHandler(this.tbtnAttach_Click); // // ctxMaster // this.ctxMaster.Name = "ctxMaster"; - this.ctxMaster.Size = new System.Drawing.Size(163, 22); + this.ctxMaster.Size = new System.Drawing.Size(162, 22); this.ctxMaster.Text = "Master controls"; this.ctxMaster.Click += new System.EventHandler(this.tbtnMaster_Click); // // ctxAnim // this.ctxAnim.Name = "ctxAnim"; - this.ctxAnim.Size = new System.Drawing.Size(163, 22); + this.ctxAnim.Size = new System.Drawing.Size(162, 22); this.ctxAnim.Text = "Animations"; this.ctxAnim.Click += new System.EventHandler(this.tbtnAnim_Click); // // ctxPoint // this.ctxPoint.Name = "ctxPoint"; - this.ctxPoint.Size = new System.Drawing.Size(163, 22); + this.ctxPoint.Size = new System.Drawing.Size(162, 22); this.ctxPoint.Text = "Point at"; this.ctxPoint.Click += new System.EventHandler(this.ctxPoint_Click); // // ctxOfferTP // this.ctxOfferTP.Name = "ctxOfferTP"; - this.ctxOfferTP.Size = new System.Drawing.Size(163, 22); + this.ctxOfferTP.Size = new System.Drawing.Size(162, 22); this.ctxOfferTP.Text = "Offer Teleport"; this.ctxOfferTP.ToolTipText = " Offer Teleport "; this.ctxOfferTP.Click += new System.EventHandler(this.ctxOfferTP_Click); @@ -269,15 +274,23 @@ private void InitializeComponent() // ctxTeleportTo // this.ctxTeleportTo.Name = "ctxTeleportTo"; - this.ctxTeleportTo.Size = new System.Drawing.Size(163, 22); + this.ctxTeleportTo.Size = new System.Drawing.Size(162, 22); this.ctxTeleportTo.Text = "Teleport To"; this.ctxTeleportTo.ToolTipText = " Teleport To "; this.ctxTeleportTo.Click += new System.EventHandler(this.ctxTeleportTo_Click); // + // ctxReqestLure + // + this.ctxReqestLure.Name = "ctxReqestLure"; + this.ctxReqestLure.Size = new System.Drawing.Size(162, 22); + this.ctxReqestLure.Text = "Request Teleport"; + this.ctxReqestLure.ToolTipText = " Request Teleport "; + this.ctxReqestLure.Click += new System.EventHandler(this.ctxReqestLure_Click); + // // goToToolStripMenuItem // this.goToToolStripMenuItem.Name = "goToToolStripMenuItem"; - this.goToToolStripMenuItem.Size = new System.Drawing.Size(163, 22); + this.goToToolStripMenuItem.Size = new System.Drawing.Size(162, 22); this.goToToolStripMenuItem.Text = "Walk To"; this.goToToolStripMenuItem.ToolTipText = " Walk To "; this.goToToolStripMenuItem.Click += new System.EventHandler(this.goToToolStripMenuItem_Click); @@ -285,7 +298,7 @@ private void InitializeComponent() // faceToolStripMenuItem // this.faceToolStripMenuItem.Name = "faceToolStripMenuItem"; - this.faceToolStripMenuItem.Size = new System.Drawing.Size(163, 22); + this.faceToolStripMenuItem.Size = new System.Drawing.Size(162, 22); this.faceToolStripMenuItem.Text = "Face"; this.faceToolStripMenuItem.ToolTipText = " Face Avatar"; this.faceToolStripMenuItem.Click += new System.EventHandler(this.faceToolStripMenuItem_Click); @@ -293,7 +306,7 @@ private void InitializeComponent() // ctxEject // this.ctxEject.Name = "ctxEject"; - this.ctxEject.Size = new System.Drawing.Size(163, 22); + this.ctxEject.Size = new System.Drawing.Size(162, 22); this.ctxEject.Text = "Eject"; this.ctxEject.ToolTipText = " Eject "; this.ctxEject.Click += new System.EventHandler(this.ctxEject_Click); @@ -301,7 +314,7 @@ private void InitializeComponent() // ctxBan // this.ctxBan.Name = "ctxBan"; - this.ctxBan.Size = new System.Drawing.Size(163, 22); + this.ctxBan.Size = new System.Drawing.Size(162, 22); this.ctxBan.Text = "Ban"; this.ctxBan.ToolTipText = " Ban "; this.ctxBan.Click += new System.EventHandler(this.ctxBan_Click); @@ -309,7 +322,7 @@ private void InitializeComponent() // ctxEstateEject // this.ctxEstateEject.Name = "ctxEstateEject"; - this.ctxEstateEject.Size = new System.Drawing.Size(163, 22); + this.ctxEstateEject.Size = new System.Drawing.Size(162, 22); this.ctxEstateEject.Text = "Eject from estate"; this.ctxEstateEject.ToolTipText = " Eject from estate "; this.ctxEstateEject.Click += new System.EventHandler(this.ctxEstateEject_Click); @@ -317,77 +330,142 @@ private void InitializeComponent() // muteToolStripMenuItem // this.muteToolStripMenuItem.Name = "muteToolStripMenuItem"; - this.muteToolStripMenuItem.Size = new System.Drawing.Size(163, 22); + this.muteToolStripMenuItem.Size = new System.Drawing.Size(162, 22); this.muteToolStripMenuItem.Text = "Mute"; this.muteToolStripMenuItem.ToolTipText = " Mute "; this.muteToolStripMenuItem.Click += new System.EventHandler(this.muteToolStripMenuItem_Click); // // pnlMovement // + this.pnlMovement.Controls.Add(this.btnRun); + this.pnlMovement.Controls.Add(this.btnFly); + this.pnlMovement.Controls.Add(this.btnJump); + this.pnlMovement.Controls.Add(this.btnCrouch); this.pnlMovement.Controls.Add(this.btnMoveBack); this.pnlMovement.Controls.Add(this.btnFwd); this.pnlMovement.Controls.Add(this.btnTurnRight); this.pnlMovement.Controls.Add(this.btnTurnLeft); this.pnlMovement.Dock = System.Windows.Forms.DockStyle.Bottom; - this.pnlMovement.Location = new System.Drawing.Point(0, 317); + this.pnlMovement.Location = new System.Drawing.Point(0, 310); this.pnlMovement.Name = "pnlMovement"; - this.pnlMovement.Size = new System.Drawing.Size(127, 37); + this.pnlMovement.Size = new System.Drawing.Size(127, 44); this.pnlMovement.TabIndex = 11; - this.pnlMovement.Click += new System.EventHandler(this.pnlMovement_Click); + // + // btnRun + // + this.btnRun.AccessibleDescription = ""; + this.btnRun.AccessibleName = "Run"; + this.btnRun.Font = new System.Drawing.Font("Tahoma", 6F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnRun.Location = new System.Drawing.Point(64, 3); + this.btnRun.Margin = new System.Windows.Forms.Padding(0); + this.btnRun.Name = "btnRun"; + this.btnRun.Size = new System.Drawing.Size(29, 19); + this.btnRun.TabIndex = 9; + this.btnRun.TabStop = false; + this.btnRun.Text = "🏃"; + this.btnRun.Click += new System.EventHandler(this.btnRun_Click); + // + // btnFly + // + this.btnFly.AccessibleDescription = ""; + this.btnFly.AccessibleName = "Fly"; + this.btnFly.Font = new System.Drawing.Font("Tahoma", 6F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnFly.Location = new System.Drawing.Point(6, 3); + this.btnFly.Margin = new System.Windows.Forms.Padding(0); + this.btnFly.Name = "btnFly"; + this.btnFly.Size = new System.Drawing.Size(29, 19); + this.btnFly.TabIndex = 8; + this.btnFly.TabStop = false; + this.btnFly.Text = "✈️"; + this.btnFly.Click += new System.EventHandler(this.btnFly_Click); + // + // btnJump + // + this.btnJump.AccessibleDescription = ""; + this.btnJump.AccessibleName = "Jump/Up"; + this.btnJump.Font = new System.Drawing.Font("Tahoma", 6F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnJump.Location = new System.Drawing.Point(93, 3); + this.btnJump.Margin = new System.Windows.Forms.Padding(0); + this.btnJump.Name = "btnJump"; + this.btnJump.Size = new System.Drawing.Size(29, 19); + this.btnJump.TabIndex = 6; + this.btnJump.TabStop = false; + this.btnJump.Text = "↑"; + this.btnJump.MouseDown += new System.Windows.Forms.MouseEventHandler(this.btnMoveUp_MouseDown); + this.btnJump.MouseUp += new System.Windows.Forms.MouseEventHandler(this.btnMoveUp_MouseUp); + // + // btnCrouch + // + this.btnCrouch.AccessibleDescription = ""; + this.btnCrouch.AccessibleName = "Crouch/Down"; + this.btnCrouch.Font = new System.Drawing.Font("Tahoma", 6F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnCrouch.Location = new System.Drawing.Point(93, 22); + this.btnCrouch.Margin = new System.Windows.Forms.Padding(0); + this.btnCrouch.Name = "btnCrouch"; + this.btnCrouch.Size = new System.Drawing.Size(29, 19); + this.btnCrouch.TabIndex = 5; + this.btnCrouch.TabStop = false; + this.btnCrouch.Text = "↓"; + this.btnCrouch.MouseDown += new System.Windows.Forms.MouseEventHandler(this.btnMoveDown_MouseDown); + this.btnCrouch.MouseUp += new System.Windows.Forms.MouseEventHandler(this.btnMoveDown_MouseUp); // // btnMoveBack // + this.btnMoveBack.AccessibleDescription = ""; this.btnMoveBack.AccessibleName = "Walk backwards"; this.btnMoveBack.Font = new System.Drawing.Font("Tahoma", 6F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btnMoveBack.Location = new System.Drawing.Point(36, 15); + this.btnMoveBack.Location = new System.Drawing.Point(35, 22); this.btnMoveBack.Margin = new System.Windows.Forms.Padding(0); this.btnMoveBack.Name = "btnMoveBack"; - this.btnMoveBack.Size = new System.Drawing.Size(31, 19); + this.btnMoveBack.Size = new System.Drawing.Size(29, 19); this.btnMoveBack.TabIndex = 2; this.btnMoveBack.TabStop = false; - this.btnMoveBack.Text = "R"; + this.btnMoveBack.Text = "▼"; this.btnMoveBack.MouseDown += new System.Windows.Forms.MouseEventHandler(this.btnMoveBack_MouseDown); this.btnMoveBack.MouseUp += new System.Windows.Forms.MouseEventHandler(this.btnMoveBack_MouseUp); // // btnFwd // + this.btnFwd.AccessibleDescription = ""; this.btnFwd.AccessibleName = "Walk forward"; this.btnFwd.Font = new System.Drawing.Font("Tahoma", 6F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btnFwd.Location = new System.Drawing.Point(36, 0); + this.btnFwd.Location = new System.Drawing.Point(35, 3); this.btnFwd.Margin = new System.Windows.Forms.Padding(0); this.btnFwd.Name = "btnFwd"; - this.btnFwd.Size = new System.Drawing.Size(31, 19); + this.btnFwd.Size = new System.Drawing.Size(29, 19); this.btnFwd.TabIndex = 1; this.btnFwd.TabStop = false; - this.btnFwd.Text = "^"; + this.btnFwd.Text = "▲"; this.btnFwd.MouseDown += new System.Windows.Forms.MouseEventHandler(this.btnFwd_MouseDown); this.btnFwd.MouseUp += new System.Windows.Forms.MouseEventHandler(this.btnFwd_MouseUp); // // btnTurnRight // + this.btnTurnRight.AccessibleDescription = ""; this.btnTurnRight.AccessibleName = "Turn right"; this.btnTurnRight.Font = new System.Drawing.Font("Tahoma", 6F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btnTurnRight.Location = new System.Drawing.Point(67, 15); + this.btnTurnRight.Location = new System.Drawing.Point(64, 22); this.btnTurnRight.Margin = new System.Windows.Forms.Padding(0); this.btnTurnRight.Name = "btnTurnRight"; - this.btnTurnRight.Size = new System.Drawing.Size(31, 19); + this.btnTurnRight.Size = new System.Drawing.Size(29, 19); this.btnTurnRight.TabIndex = 4; this.btnTurnRight.TabStop = false; - this.btnTurnRight.Text = ">>"; + this.btnTurnRight.Text = "►"; this.btnTurnRight.MouseDown += new System.Windows.Forms.MouseEventHandler(this.btnTurnRight_MouseDown); this.btnTurnRight.MouseUp += new System.Windows.Forms.MouseEventHandler(this.btnTurnRight_MouseUp); // // btnTurnLeft // + this.btnTurnLeft.AccessibleDescription = ""; this.btnTurnLeft.AccessibleName = "Turn left"; this.btnTurnLeft.Font = new System.Drawing.Font("Tahoma", 6F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btnTurnLeft.Location = new System.Drawing.Point(5, 15); + this.btnTurnLeft.Location = new System.Drawing.Point(6, 22); this.btnTurnLeft.Margin = new System.Windows.Forms.Padding(0); this.btnTurnLeft.Name = "btnTurnLeft"; - this.btnTurnLeft.Size = new System.Drawing.Size(31, 19); + this.btnTurnLeft.Size = new System.Drawing.Size(29, 19); this.btnTurnLeft.TabIndex = 3; this.btnTurnLeft.TabStop = false; - this.btnTurnLeft.Text = "<<"; + this.btnTurnLeft.Text = "◄"; this.btnTurnLeft.MouseDown += new System.Windows.Forms.MouseEventHandler(this.btnTurnLeft_MouseDown); this.btnTurnLeft.MouseUp += new System.Windows.Forms.MouseEventHandler(this.btnTurnLeft_MouseUp); // @@ -432,14 +510,6 @@ private void InitializeComponent() this.cbxInput.TextChanged += new System.EventHandler(this.cbxInput_TextChanged); this.cbxInput.KeyDown += new System.Windows.Forms.KeyEventHandler(this.cbxInput_KeyDown); // - // ctxReqestLure - // - this.ctxReqestLure.Name = "ctxReqestLure"; - this.ctxReqestLure.Size = new System.Drawing.Size(163, 22); - this.ctxReqestLure.Text = "Request Teleport"; - this.ctxReqestLure.ToolTipText = " Request Teleport "; - this.ctxReqestLure.Click += new System.EventHandler(this.ctxReqestLure_Click); - // // ChatConsole // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -452,6 +522,7 @@ private void InitializeComponent() this.VisibleChanged += new System.EventHandler(this.ChatConsole_VisibleChanged); this.splitContainer1.Panel1.ResumeLayout(false); this.splitContainer1.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); this.splitContainer1.ResumeLayout(false); this.avatarContext.ResumeLayout(false); this.pnlMovement.ResumeLayout(false); @@ -494,5 +565,9 @@ private void InitializeComponent() private ToolStripMenuItem goToToolStripMenuItem; private ToolStripMenuItem faceToolStripMenuItem; private ToolStripMenuItem ctxReqestLure; + public Button btnJump; + public Button btnCrouch; + public Button btnFly; + public Button btnRun; } } diff --git a/Radegast/GUI/Consoles/ChatConsole.cs b/Radegast/GUI/Consoles/ChatConsole.cs index d211ff3b3..87f51f497 100644 --- a/Radegast/GUI/Consoles/ChatConsole.cs +++ b/Radegast/GUI/Consoles/ChatConsole.cs @@ -1,66 +1,54 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections.Generic; -using System.Collections; using System.ComponentModel; using System.Drawing; using System.Text.RegularExpressions; using System.Windows.Forms; -using Radegast.Netcom; +using Radegast; using OpenMetaverse; -using OpenMetaverse.StructuredData; +using Radegast.Core; namespace Radegast { public partial class ChatConsole : UserControl { private RadegastInstance instance; - private RadegastNetcom netcom { get { return instance.Netcom; } } - private GridClient client { get { return instance.Client; } } - private ChatTextManager chatManager; + private Radegast.Netcom netcom => instance.Netcom; + private GridClient client => instance.Client; private TabsConsole tabConsole; private Avatar currentAvatar; - private RadegastMovement movement { get { return instance.Movement; } } + private RadegastMovement movement => instance.Movement; private Regex chatRegex = new Regex(@"^/(\d+)\s*(.*)", RegexOptions.Compiled); private List chatHistory = new List(); private int chatPointer; public readonly Dictionary agentSimHandle = new Dictionary(); - public ChatInputBox ChatInputText { get { return cbxInput; } } + public ChatInputBox ChatInputText => cbxInput; public ChatConsole(RadegastInstance instance) { InitializeComponent(); - Disposed += new EventHandler(ChatConsole_Disposed); + Disposed += ChatConsole_Disposed; if (!instance.advancedDebugging) { @@ -69,38 +57,38 @@ public ChatConsole(RadegastInstance instance) } this.instance = instance; - this.instance.ClientChanged += new EventHandler(instance_ClientChanged); + this.instance.ClientChanged += instance_ClientChanged; - instance.GlobalSettings.OnSettingChanged += new Settings.SettingChangedCallback(GlobalSettings_OnSettingChanged); + instance.GlobalSettings.OnSettingChanged += GlobalSettings_OnSettingChanged; // Callbacks - netcom.ClientLoginStatus += new EventHandler(netcom_ClientLoginStatus); - netcom.ClientLoggedOut += new EventHandler(netcom_ClientLoggedOut); + netcom.ClientLoginStatus += netcom_ClientLoginStatus; + netcom.ClientLoggedOut += netcom_ClientLoggedOut; RegisterClientEvents(client); - chatManager = new ChatTextManager(instance, new RichTextBoxPrinter(rtbChat)); - chatManager.PrintStartupMessage(); + ChatManager = new ChatTextManager(instance, new RichTextBoxPrinter(rtbChat)); + ChatManager.PrintStartupMessage(); - this.instance.MainForm.Load += new EventHandler(MainForm_Load); + this.instance.MainForm.Load += MainForm_Load; lvwObjects.ListViewItemSorter = new SorterClass(instance); cbChatType.SelectedIndex = 1; - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } private void RegisterClientEvents(GridClient client) { - client.Grid.CoarseLocationUpdate += new EventHandler(Grid_CoarseLocationUpdate); - client.Self.TeleportProgress += new EventHandler(Self_TeleportProgress); - client.Network.SimDisconnected += new EventHandler(Network_SimDisconnected); + client.Grid.CoarseLocationUpdate += Grid_CoarseLocationUpdate; + client.Self.TeleportProgress += Self_TeleportProgress; + client.Network.SimDisconnected += Network_SimDisconnected; } private void UnregisterClientEvents(GridClient client) { - client.Grid.CoarseLocationUpdate -= new EventHandler(Grid_CoarseLocationUpdate); - client.Self.TeleportProgress -= new EventHandler(Self_TeleportProgress); - client.Network.SimDisconnected -= new EventHandler(Network_SimDisconnected); + client.Grid.CoarseLocationUpdate -= Grid_CoarseLocationUpdate; + client.Self.TeleportProgress -= Self_TeleportProgress; + client.Network.SimDisconnected -= Network_SimDisconnected; } void instance_ClientChanged(object sender, ClientChangedEventArgs e) @@ -111,20 +99,20 @@ void instance_ClientChanged(object sender, ClientChangedEventArgs e) void ChatConsole_Disposed(object sender, EventArgs e) { - instance.ClientChanged -= new EventHandler(instance_ClientChanged); - netcom.ClientLoginStatus -= new EventHandler(netcom_ClientLoginStatus); - netcom.ClientLoggedOut -= new EventHandler(netcom_ClientLoggedOut); + instance.ClientChanged -= instance_ClientChanged; + netcom.ClientLoginStatus -= netcom_ClientLoginStatus; + netcom.ClientLoggedOut -= netcom_ClientLoggedOut; UnregisterClientEvents(client); - chatManager.Dispose(); - chatManager = null; + ChatManager.Dispose(); + ChatManager = null; } - static public Font ChangeFontSize(Font font, float fontSize) + public static Font ChangeFontSize(Font font, float fontSize) { if (font != null) { float currentSize = font.Size; - if (currentSize != fontSize) + if (Math.Abs(currentSize - fontSize) > 0.01) { font = new Font(font.Name, fontSize, font.Style, font.Unit, @@ -145,8 +133,8 @@ public List GetAvatarList() List ret = new List(); foreach (ListViewItem item in lvwObjects.Items) { - if (item.Tag is UUID) - ret.Add((UUID)item.Tag); + if (item.Tag is UUID tag) + ret.Add(tag); } return ret; } @@ -189,7 +177,7 @@ private void Network_SimDisconnected(object sender, SimDisconnectedEventArgs e) agentSimHandle.Remove(key); try { - lvwObjects.Items.RemoveByKey("" + key); + lvwObjects.Items.RemoveByKey(key.ToString()); } catch (Exception) { @@ -205,7 +193,7 @@ private void Network_SimDisconnected(object sender, SimDisconnectedEventArgs e) } catch (Exception ex) { - Logger.DebugLog("Failed to update radar: " + ex.ToString()); + Logger.DebugLog("Failed to update radar: " + ex); } } @@ -256,7 +244,7 @@ void UpdateRadar(CoarseLocationUpdateEventArgs e) return; } - // later on we can set this with something from the GUI + // *TODO: later on we can set this with something from the GUI const double MAX_DISTANCE = 362.0; // one sim a corner to corner distance lock (agentSimHandle) try @@ -266,7 +254,7 @@ void UpdateRadar(CoarseLocationUpdateEventArgs e) ? StateManager.ToVector3D(e.Simulator.Handle, e.Simulator.AvatarPositions[client.Self.AgentID]) : client.Self.GlobalPosition; - // CoarseLocationUpdate gives us hight of 0 when actual height is + // CoarseLocationUpdate gives us height of 0 when actual height is // between 1024-4096m. if (mypos.Z < 0.1) { @@ -276,7 +264,7 @@ void UpdateRadar(CoarseLocationUpdateEventArgs e) List existing = new List(); List removed = new List(e.RemovedEntries); - e.Simulator.AvatarPositions.ForEach(delegate(KeyValuePair avi) + e.Simulator.AvatarPositions.ForEach(avi => { existing.Add(avi.Key); if (!lvwObjects.Items.ContainsKey(avi.Key.ToString())) @@ -322,12 +310,12 @@ void UpdateRadar(CoarseLocationUpdateEventArgs e) continue; } - Avatar foundAvi = e.Simulator.ObjectsAvatars.Find((Avatar av) => { return av.ID == key; }); + Avatar foundAvi = e.Simulator.ObjectsAvatars.Find(av => av.ID == key); - // CoarseLocationUpdate gives us hight of 0 when actual height is + // CoarseLocationUpdate gives us height of 0 when actual height is // between 1024-4096m on OpenSim grids. 1020 on SL - bool unkownAltitude = instance.Netcom.LoginOptions.Grid.Platform == "SecondLife" ? pos.Z == 1020f : pos.Z == 0f; - if (unkownAltitude) + bool unknownAltitude = instance.Netcom.LoginOptions.Grid.Platform == "SecondLife" ? pos.Z == 1020f : pos.Z == 0f; + if (unknownAltitude) { if (foundAvi != null) { @@ -353,13 +341,13 @@ void UpdateRadar(CoarseLocationUpdateEventArgs e) continue; } - if (unkownAltitude) + if (unknownAltitude) { item.Text = instance.Names.Get(key) + " (?m)"; } else { - item.Text = instance.Names.Get(key) + " (" + d + "m)"; + item.Text = instance.Names.Get(key) + $" ({d}m)"; } if (foundAvi != null) @@ -378,7 +366,7 @@ void UpdateRadar(CoarseLocationUpdateEventArgs e) } catch (Exception ex) { - Logger.Log("Grid_OnCoarseLocationUpdate: " + ex, OpenMetaverse.Helpers.LogLevel.Error, client); + Logger.Log("Grid_OnCoarseLocationUpdate: " + ex, Helpers.LogLevel.Error, client); } finally { @@ -472,15 +460,7 @@ public void ProcessChatInput(string input, ChatType type) string msg; - if (input.Length >= 1000) - { - msg = input.Substring(0, 1000); - } - else - { - msg = input; - } - + msg = input.Length >= 1000 ? input.Substring(0, 1000) : input; msg = msg.Replace(ChatInputBox.NewlineMarker, Environment.NewLine); if (instance.GlobalSettings["mu_emotes"].AsBoolean() && msg.StartsWith(":")) @@ -564,7 +544,11 @@ public void ProcessChatInput(string input, ChatType type) } #endregion - netcom.ChatOut(msg, type, ch); + var processedMessage = GestureManager.Instance.PreProcessChatMessage(msg).Trim(); + if (!string.IsNullOrEmpty(processedMessage)) + { + netcom.ChatOut(processedMessage, type, ch); + } } } @@ -600,10 +584,7 @@ private void cbxInput_TextChanged(object sender, EventArgs e) } } - public ChatTextManager ChatManager - { - get { return chatManager; } - } + public ChatTextManager ChatManager { get; private set; } private void tbtnStartIM_Click(object sender, EventArgs e) { @@ -621,7 +602,7 @@ private void tbtnFollow_Click(object sender, EventArgs e) if (instance.State.FollowName == string.Empty) { instance.State.Follow(av.Name, av.ID); - ctxFollow.Text = "Unfollow " + av.Name; + ctxFollow.Text = $"Unfollow {av.Name}"; } else { @@ -656,10 +637,8 @@ private void lvwObjects_SelectedIndexChanged(object sender, EventArgs e) } else { - currentAvatar = client.Network.CurrentSim.ObjectsAvatars.Find(delegate(Avatar a) - { - return a.ID == (UUID)lvwObjects.SelectedItems[0].Tag; - }); + currentAvatar = client.Network.CurrentSim.ObjectsAvatars.Find(a => + a.ID == (UUID) lvwObjects.SelectedItems[0].Tag); ctxPay.Enabled = ctxStartIM.Enabled = ctxProfile.Enabled = true; ctxPoint.Enabled = ctxFollow.Enabled = ctxTextures.Enabled = ctxMaster.Enabled = ctxAttach.Enabled = ctxAnim.Enabled = currentAvatar != null; @@ -718,12 +697,12 @@ private void tbtnAttach_Click(object sender, EventArgs e) Avatar av = currentAvatar; if (av == null) return; - if (!instance.TabConsole.TabExists("AT: " + av.ID.ToString())) + if (!instance.TabConsole.TabExists("AT: " + av.ID)) { - instance.TabConsole.AddTab("AT: " + av.ID.ToString(), "AT: " + av.Name, new AttachmentTab(instance, av)); + instance.TabConsole.AddTab("AT: " + av.ID, "AT: " + av.Name, new AttachmentTab(instance, av)); } - instance.TabConsole.SelectTab("AT: " + av.ID.ToString()); + instance.TabConsole.SelectTab("AT: " + av.ID); } private void tbtnAnim_Click(object sender, EventArgs e) @@ -780,11 +759,34 @@ private void btnMoveBack_MouseUp(object sender, MouseEventArgs e) movement.MovingBackward = false; } - private void pnlMovement_Click(object sender, EventArgs e) + private void btnMoveUp_MouseDown(object Sender, MouseEventArgs e) + { + movement.Jump = true; + } + + private void btnMoveUp_MouseUp(object Sender, MouseEventArgs e) + { + movement.Jump = false; + } + + private void btnMoveDown_MouseDown(object Sender, MouseEventArgs e) + { + movement.Crouch = true; + } + + private void btnMoveDown_MouseUp(object Sender, MouseEventArgs e) + { + movement.Crouch = false; + } + + private void btnFly_Click(object sender, EventArgs e) { - client.Self.Jump(true); - System.Threading.Thread.Sleep(500); - client.Self.Jump(false); + movement.ToggleFlight(); + } + + private void btnRun_Click(object sender, EventArgs e) + { + movement.ToggleAlwaysRun(); } private void lvwObjects_DragDrop(object sender, DragEventArgs e) @@ -795,16 +797,14 @@ private void lvwObjects_DragDrop(object sender, DragEventArgs e) TreeNode node = e.Data.GetData(typeof(TreeNode)) as TreeNode; if (node == null) return; - if (node.Tag is InventoryItem) + if (node.Tag is InventoryItem item) { - InventoryItem item = node.Tag as InventoryItem; client.Inventory.GiveItem(item.UUID, item.Name, item.AssetType, (UUID)litem.Tag, true); instance.TabConsole.DisplayNotificationInChat("Offered item " + item.Name + " to " + instance.Names.Get((UUID)litem.Tag) + "."); } - else if (node.Tag is InventoryFolder) + else if (node.Tag is InventoryFolder folder) { - InventoryFolder folder = node.Tag as InventoryFolder; - client.Inventory.GiveFolder(folder.UUID, folder.Name, AssetType.Folder, (UUID)litem.Tag, true); + client.Inventory.GiveFolder(folder.UUID, folder.Name, (UUID)litem.Tag, true); instance.TabConsole.DisplayNotificationInChat("Offered folder " + folder.Name + " to " + instance.Names.Get((UUID)litem.Tag) + "."); } } @@ -835,14 +835,7 @@ private void avatarContext_Opening(object sender, CancelEventArgs e) } bool isMuted = null != client.Self.MuteList.Find(me => me.Type == MuteType.Resident && me.ID == (UUID)lvwObjects.SelectedItems[0].Tag); - if (isMuted) - { - muteToolStripMenuItem.Text = "Unmute"; - } - else - { - muteToolStripMenuItem.Text = "Mute"; - } + muteToolStripMenuItem.Text = isMuted ? "Unmute" : "Mute"; instance.ContextActionManager.AddContributions( avatarContext, typeof(Avatar), lvwObjects.SelectedItems[0]); @@ -909,12 +902,12 @@ private void ctxTeleportTo_Click(object sender, EventArgs e) if (instance.State.TryFindAvatar(person, out sim, out pos)) { - tabConsole.DisplayNotificationInChat(string.Format("Teleporting to {0}", pname)); + tabConsole.DisplayNotificationInChat($"Teleporting to {pname}"); instance.State.MoveTo(sim, pos, true); } else { - tabConsole.DisplayNotificationInChat(string.Format("Could not locate {0}", pname)); + tabConsole.DisplayNotificationInChat($"Could not locate {pname}"); } } @@ -996,7 +989,7 @@ public class SorterClass : System.Collections.IComparer { private static Regex distanceRegex = new Regex(@"\((?\d+)\s*m\)", RegexOptions.Compiled); private Match match; - RadegastInstance instance; + readonly RadegastInstance instance; public SorterClass(RadegastInstance instance) { @@ -1008,13 +1001,13 @@ public SorterClass(RadegastInstance instance) public int Compare(object x, object y) { - System.Windows.Forms.ListViewItem item1 = (System.Windows.Forms.ListViewItem)x; - System.Windows.Forms.ListViewItem item2 = (System.Windows.Forms.ListViewItem)y; + ListViewItem item1 = (ListViewItem)x; + ListViewItem item2 = (ListViewItem)y; - if ((item1.Tag is UUID) && ((UUID)item1.Tag == instance.Client.Self.AgentID)) + if ((item1.Tag is UUID tag) && (tag == instance.Client.Self.AgentID)) return -1; - if ((item2.Tag is UUID) && ((UUID)item2.Tag == instance.Client.Self.AgentID)) + if ((item2.Tag is UUID uuid) && (uuid == instance.Client.Self.AgentID)) return 1; int distance1 = int.MaxValue, distance2 = int.MaxValue; @@ -1030,7 +1023,7 @@ public int Compare(object x, object y) else if (distance1 > distance2) return 1; else - return string.Compare(item1.Text, item2.Text); + return String.CompareOrdinal(item1.Text, item2.Text); } } diff --git a/Radegast/GUI/Consoles/ChatConsole.resx b/Radegast/GUI/Consoles/ChatConsole.resx index c25846522..37b82004b 100644 --- a/Radegast/GUI/Consoles/ChatConsole.resx +++ b/Radegast/GUI/Consoles/ChatConsole.resx @@ -112,12 +112,12 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + 122, 17 \ No newline at end of file diff --git a/Radegast/GUI/Consoles/ConferenceIMTabWindow.cs b/Radegast/GUI/Consoles/ConferenceIMTabWindow.cs index b59a70f6a..b8d99760a 100644 --- a/Radegast/GUI/Consoles/ConferenceIMTabWindow.cs +++ b/Radegast/GUI/Consoles/ConferenceIMTabWindow.cs @@ -1,38 +1,28 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections.Generic; using System.Windows.Forms; using System.Threading; -using Radegast.Netcom; +using Radegast; using OpenMetaverse; namespace Radegast @@ -40,9 +30,7 @@ namespace Radegast public partial class ConferenceIMTabWindow : UserControl { private RadegastInstance instance; - private RadegastNetcom netcom; - private UUID session; - private IMTextManager textManager; + private Radegast.Netcom netcom; private GridClient client; private List participants = new List(); ManualResetEvent WaitForSessionStart = new ManualResetEvent(false); @@ -54,35 +42,35 @@ public partial class ConferenceIMTabWindow : UserControl public ConferenceIMTabWindow(RadegastInstance instance, UUID session, string sessionName) { InitializeComponent(); - Disposed += new EventHandler(IMTabWindow_Disposed); + Disposed += IMTabWindow_Disposed; this.instance = instance; - this.client = instance.Client; - this.SessionName = sessionName; + client = instance.Client; + SessionName = sessionName; netcom = this.instance.Netcom; - this.session = session; + SessionId = session; - textManager = new IMTextManager(this.instance, new RichTextBoxPrinter(rtbIMText), IMTextManagerType.Conference, this.session, sessionName); + TextManager = new IMTextManager(this.instance, new RichTextBoxPrinter(rtbIMText), IMTextManagerType.Conference, SessionId, sessionName); // Callbacks - netcom.ClientLoginStatus += new EventHandler(netcom_ClientLoginStatus); - netcom.ClientDisconnected += new EventHandler(netcom_ClientDisconnected); - instance.GlobalSettings.OnSettingChanged += new Settings.SettingChangedCallback(GlobalSettings_OnSettingChanged); + netcom.ClientLoginStatus += netcom_ClientLoginStatus; + netcom.ClientDisconnected += netcom_ClientDisconnected; + instance.GlobalSettings.OnSettingChanged += GlobalSettings_OnSettingChanged; if (!client.Self.GroupChatSessions.ContainsKey(session)) { client.Self.ChatterBoxAcceptInvite(session); } - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } private void IMTabWindow_Disposed(object sender, EventArgs e) { - netcom.ClientLoginStatus -= new EventHandler(netcom_ClientLoginStatus); - netcom.ClientDisconnected -= new EventHandler(netcom_ClientDisconnected); - instance.GlobalSettings.OnSettingChanged -= new Settings.SettingChangedCallback(GlobalSettings_OnSettingChanged); + netcom.ClientLoginStatus -= netcom_ClientLoginStatus; + netcom.ClientDisconnected -= netcom_ClientDisconnected; + instance.GlobalSettings.OnSettingChanged -= GlobalSettings_OnSettingChanged; CleanUp(); } @@ -104,8 +92,8 @@ private void netcom_ClientDisconnected(object sender, DisconnectedEventArgs e) public void CleanUp() { - textManager.CleanUp(); - textManager = null; + TextManager.CleanUp(); + TextManager = null; } private void btnSend_Click(object sender, EventArgs e) @@ -113,7 +101,7 @@ private void btnSend_Click(object sender, EventArgs e) if (cbxInput.Text.Length == 0) return; SendMessage(cbxInput.Text); - this.ClearIMInput(); + ClearIMInput(); } private void cbxInput_TextChanged(object sender, EventArgs e) @@ -192,7 +180,7 @@ private void cbxInput_KeyDown(object sender, KeyEventArgs e) SendMessage(message); - this.ClearIMInput(); + ClearIMInput(); } private void SendMessage(string msg) @@ -217,7 +205,7 @@ private void SendMessage(string msg) } if (message.Length > 0) { - client.Self.InstantMessageGroup(session, message); + client.Self.InstantMessageGroup(SessionId, message); } } @@ -236,17 +224,9 @@ private void rtbIMText_LinkClicked(object sender, LinkClickedEventArgs e) instance.MainForm.ProcessLink(e.LinkText); } - public UUID SessionId - { - get { return session; } - set { session = value; } - } + public UUID SessionId { get; set; } - public IMTextManager TextManager - { - get { return textManager; } - set { textManager = value; } - } + public IMTextManager TextManager { get; set; } private void cbxInput_VisibleChanged(object sender, EventArgs e) { diff --git a/Radegast/GUI/Consoles/DebugConsole.cs b/Radegast/GUI/Consoles/DebugConsole.cs index b15a1844a..641ad267f 100644 --- a/Radegast/GUI/Consoles/DebugConsole.cs +++ b/Radegast/GUI/Consoles/DebugConsole.cs @@ -1,33 +1,23 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Drawing; using System.Windows.Forms; @@ -46,15 +36,15 @@ public DebugConsole(RadegastInstance instance) :base(instance) { InitializeComponent(); - Disposed += new EventHandler(DebugConsole_Disposed); - RadegastAppender.Log += new EventHandler(RadegastAppender_Log); + Disposed += DebugConsole_Disposed; + RadegastAppender.Log += RadegastAppender_Log; - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } void DebugConsole_Disposed(object sender, EventArgs e) { - RadegastAppender.Log -= new EventHandler(RadegastAppender_Log); + RadegastAppender.Log -= RadegastAppender_Log; } void RadegastAppender_Log(object sender, LogEventArgs e) @@ -68,7 +58,7 @@ void RadegastAppender_Log(object sender, LogEventArgs e) } rtbLog.SelectionColor = Color.FromKnownColor(KnownColor.WindowText); - rtbLog.AppendText(string.Format("{0} [", e.LogEntry.TimeStamp.ToString("HH:mm:ss"))); + rtbLog.AppendText(string.Format("{0:HH:mm:ss} [", e.LogEntry.TimeStamp)); if (e.LogEntry.Level == Level.Error) { @@ -89,7 +79,7 @@ void RadegastAppender_Log(object sender, LogEventArgs e) rtbLog.AppendText(e.LogEntry.Level.Name); rtbLog.SelectionColor = Color.FromKnownColor(KnownColor.WindowText); - rtbLog.AppendText(string.Format("]: - {0}{1}", e.LogEntry.MessageObject.ToString(), Environment.NewLine)); + rtbLog.AppendText(string.Format("]: - {0}{1}", e.LogEntry.MessageObject, Environment.NewLine)); } private void rtbLog_LinkClicked(object sender, LinkClickedEventArgs e) diff --git a/Radegast/GUI/Consoles/ExportCollada.cs b/Radegast/GUI/Consoles/ExportCollada.cs index d95acf9bf..71461522a 100644 --- a/Radegast/GUI/Consoles/ExportCollada.cs +++ b/Radegast/GUI/Consoles/ExportCollada.cs @@ -1,52 +1,27 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Drawing; -using System.Drawing.Imaging; -using System.Text; -#if (COGBOT_LIBOMV || USE_STHREADS) -using ThreadPoolUtil; -using Thread = ThreadPoolUtil.Thread; -using ThreadPool = ThreadPoolUtil.ThreadPool; -using Monitor = ThreadPoolUtil.Monitor; -#endif -using System.Threading; using System.Windows.Forms; using System.IO; using OpenMetaverse; -using OpenMetaverse.StructuredData; -using OpenMetaverse.Assets; -using OpenMetaverse.Imaging; namespace Radegast { @@ -62,11 +37,11 @@ public ExportCollada(RadegastInstance instance, Primitive prim) { InitializeComponent(); Exporter = new DAEExport(instance, prim); - Exporter.Progress += new EventHandler(Exporter_Progress); + Exporter.Progress += Exporter_Progress; UpdateInfo(); cbImageType.Text = "TGA"; - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } #endregion @@ -87,14 +62,7 @@ void LogMessage(string format, params object[] args) void UpdateInfo() { Primitive root = Exporter.Prims[0]; - if (root.Properties != null) - { - objectName.Text = root.Properties.Name; - } - else - { - objectName.Text = "Object"; - } + objectName.Text = root.Properties != null ? root.Properties.Name : "Object"; objectUUID.Text = root.ID.ToString(); primCount.Text = Exporter.Prims.Count.ToString(); exportablePrims.Text = Exporter.ExportablePrims.ToString(); @@ -103,22 +71,19 @@ void UpdateInfo() texturesPanel.Controls.Clear(); foreach (UUID textureID in Exporter.Textures) { - var img = new SLImageHandler(instance, textureID, string.Empty); - img.Height = 96; - img.Width = 96; - img.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + var img = new SLImageHandler(instance, textureID, string.Empty) + { + Height = 96, Width = 96, BorderStyle = BorderStyle.FixedSingle + }; texturesPanel.Controls.Add(img); } } void ValidatePath(string fname) - { - string path = Path.GetDirectoryName(fname); - if (Directory.Exists(path)) - btnExport.Enabled = true; - else - btnExport.Enabled = false; - } + { + string path = Path.GetDirectoryName(fname); + btnExport.Enabled = Directory.Exists(path); + } #endregion #region Event Handlers @@ -129,19 +94,16 @@ void TxtFileNameTextChanged(object sender, EventArgs e) void BtnBrowseClick(object sender, EventArgs e) { - SaveFileDialog dlg = new SaveFileDialog(); - dlg.Title = "Export Collada File"; - dlg.Filter = "Collada (*.dae)|*.dae|All Files (*.*)|*.*"; - if (txtFileName.Text.Trim() == string.Empty) + SaveFileDialog dlg = new SaveFileDialog { - dlg.FileName = RadegastInstance.SafeFileName(objectName.Text); - } - else - { - dlg.FileName = Path.GetFileName(txtFileName.Text); - } + Title = "Export Collada File", + Filter = "Collada (*.dae)|*.dae|All Files (*.*)|*.*", + FileName = txtFileName.Text.Trim() == string.Empty + ? RadegastInstance.SafeFileName(objectName.Text) + : Path.GetFileName(txtFileName.Text) + }; - DialogResult res = dlg.ShowDialog(); + DialogResult res = dlg.ShowDialog(); if (res == DialogResult.OK) { diff --git a/Radegast/GUI/Consoles/ExportConsole.cs b/Radegast/GUI/Consoles/ExportConsole.cs index 004f323e8..7a972df6b 100644 --- a/Radegast/GUI/Consoles/ExportConsole.cs +++ b/Radegast/GUI/Consoles/ExportConsole.cs @@ -1,54 +1,29 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections.Generic; -using System.ComponentModel; -using System.Drawing; -using System.Drawing.Imaging; -using System.Data; -using System.Linq; -using System.Text; -#if (COGBOT_LIBOMV || USE_STHREADS) -using ThreadPoolUtil; -using Thread = ThreadPoolUtil.Thread; -using ThreadPool = ThreadPoolUtil.ThreadPool; -using Monitor = ThreadPoolUtil.Monitor; -#endif using System.Threading; using System.Windows.Forms; using System.IO; using OpenMetaverse; -using OpenMetaverse.StructuredData; -using OpenMetaverse.Assets; -using OpenMetaverse.Imaging; namespace Radegast { @@ -70,7 +45,7 @@ public ExportConsole(GridClient client, uint localID) GatherInfo(); Exporter = new PrimExporter(client); - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } #endregion @@ -90,11 +65,10 @@ void LogMessage(string format, params object[] args) void GatherInfo() { - Primitive exportPrim; - uint localid; + uint localid; - exportPrim = Client.Network.CurrentSim.ObjectsPrimitives.Find( - delegate(Primitive prim) { return prim.LocalID == uLocalID; } + var exportPrim = Client.Network.CurrentSim.ObjectsPrimitives.Find( + prim => prim.LocalID == uLocalID ); if (exportPrim != null) @@ -105,55 +79,46 @@ void GatherInfo() localid = exportPrim.LocalID; List prims = Client.Network.CurrentSim.ObjectsPrimitives.FindAll( - delegate(Primitive prim) - { - return (prim.LocalID == localid || prim.ParentID == localid); - } - ); + prim => (prim.LocalID == localid || prim.ParentID == localid) + ); - for (int i = 0; i < prims.Count; i++) + foreach (Primitive prim in prims) { - Primitive prim = prims[i]; - UUID texture; - - if (prim.Textures.DefaultTexture.TextureID != Primitive.TextureEntry.WHITE_TEXTURE && - !Textures.Contains(prim.Textures.DefaultTexture.TextureID)) - { - texture = new UUID(prim.Textures.DefaultTexture.TextureID); - Textures.Add(texture); + if (prim.Textures.DefaultTexture.TextureID != Primitive.TextureEntry.WHITE_TEXTURE && + !Textures.Contains(prim.Textures.DefaultTexture.TextureID)) + { + var texture = new UUID(prim.Textures.DefaultTexture.TextureID); + Textures.Add(texture); - for (int j = 0; j < prim.Textures.FaceTextures.Length; j++) - { - if (prim.Textures.FaceTextures[j] != null && - prim.Textures.FaceTextures[j].TextureID != Primitive.TextureEntry.WHITE_TEXTURE && - !Textures.Contains(prim.Textures.FaceTextures[j].TextureID)) - { - texture = new UUID(prim.Textures.FaceTextures[j].TextureID); - Textures.Add(texture); - } - } + foreach (Primitive.TextureEntryFace face in prim.Textures.FaceTextures) + { + if (face != null && + face.TextureID != Primitive.TextureEntry.WHITE_TEXTURE && + !Textures.Contains(face.TextureID)) + { + texture = new UUID(face.TextureID); + Textures.Add(texture); + } + } - if (prim.Sculpt != null && prim.Sculpt.SculptTexture != UUID.Zero && !Textures.Contains(prim.Sculpt.SculptTexture)) - { - texture = new UUID(prim.Sculpt.SculptTexture); - Textures.Add(texture); - } - } + if (prim.Sculpt != null && prim.Sculpt.SculptTexture != UUID.Zero && !Textures.Contains(prim.Sculpt.SculptTexture)) + { + texture = new UUID(prim.Sculpt.SculptTexture); + Textures.Add(texture); + } + } } objectName.Text = exportPrim.Properties.Name; objectUUID.Text = exportPrim.ID.ToString(); primCount.Text = prims.Count.ToString(); - textureCount.Text = Textures.Count().ToString(); + textureCount.Text = Textures.Count.ToString(); } } void ValidatePath(string fname) { - string path = Path.GetDirectoryName(fname); - if (Directory.Exists(path)) - btnExport.Enabled = true; - else - btnExport.Enabled = false; + string path = Path.GetDirectoryName(fname); + btnExport.Enabled = Directory.Exists(path); } #endregion @@ -165,10 +130,8 @@ void TxtFileNameTextChanged(object sender, EventArgs e) void BtnBrowseClick(object sender, EventArgs e) { - SaveFileDialog dlg = new SaveFileDialog(); - dlg.Title = "Export object file"; - dlg.Filter = "XML File (*.xml)|*.xml"; - DialogResult res = dlg.ShowDialog(); + SaveFileDialog dlg = new SaveFileDialog {Title = "Export object file", Filter = "XML File (*.xml)|*.xml"}; + DialogResult res = dlg.ShowDialog(); if (res == DialogResult.OK) { @@ -179,28 +142,27 @@ void BtnBrowseClick(object sender, EventArgs e) void BtnExportClick(object sender, EventArgs e) { - this.Enabled = false; + Enabled = false; Exporter.LogMessage = LogMessage; - - Thread t = new Thread(new System.Threading.ThreadStart(delegate() - { - try - { - Exporter.ExportToFile(txtFileName.Text,uLocalID); - LogMessage("Export Successful."); - if (InvokeRequired) - { - BeginInvoke(new MethodInvoker(() => this.Enabled = true)); - } - } - catch (Exception ex) - { - LogMessage("Export failed. Reason: {0}",ex.Message); - } - })); - - t.IsBackground = true; - t.Start(); + + Thread t = new Thread(delegate() + { + try + { + Exporter.ExportToFile(txtFileName.Text, uLocalID); + LogMessage("Export Successful."); + if (InvokeRequired) + { + BeginInvoke(new MethodInvoker(() => Enabled = true)); + } + } + catch (Exception ex) + { + LogMessage("Export failed. Reason: {0}", ex.Message); + } + }) {IsBackground = true}; + + t.Start(); } #endregion } diff --git a/Radegast/GUI/Consoles/FindPeopleConsole.cs b/Radegast/GUI/Consoles/FindPeopleConsole.cs index 769216173..ecf5fe3ae 100644 --- a/Radegast/GUI/Consoles/FindPeopleConsole.cs +++ b/Radegast/GUI/Consoles/FindPeopleConsole.cs @@ -1,78 +1,65 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections.Generic; using System.Windows.Forms; using OpenMetaverse; -using Radegast.Netcom; +using Radegast; namespace Radegast { public partial class FindPeopleConsole : UserControl { private RadegastInstance instance; - private RadegastNetcom netcom; + private Radegast.Netcom netcom; private GridClient client; - private UUID queryID; - private Dictionary findPeopleResults; - public event EventHandler SelectedIndexChanged; public FindPeopleConsole(RadegastInstance instance, UUID queryID) { InitializeComponent(); - Disposed += new EventHandler(FindPeopleConsole_Disposed); + Disposed += FindPeopleConsole_Disposed; - findPeopleResults = new Dictionary(); - this.queryID = queryID; + LLUUIDs = new Dictionary(); + QueryID = queryID; this.instance = instance; netcom = this.instance.Netcom; client = this.instance.Client; // Callbacks - client.Directory.DirPeopleReply += new EventHandler(Directory_DirPeopleReply); + client.Directory.DirPeopleReply += Directory_DirPeopleReply; - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } void FindPeopleConsole_Disposed(object sender, EventArgs e) { - client.Directory.DirPeopleReply -= new EventHandler(Directory_DirPeopleReply); + client.Directory.DirPeopleReply -= Directory_DirPeopleReply; } void Directory_DirPeopleReply(object sender, DirPeopleReplyEventArgs e) { - if (e.QueryID != this.queryID) return; + if (e.QueryID != QueryID) return; if (InvokeRequired) { @@ -85,7 +72,7 @@ void Directory_DirPeopleReply(object sender, DirPeopleReplyEventArgs e) foreach (DirectoryManager.AgentSearchData person in e.MatchedPeople) { string fullName = person.FirstName + " " + person.LastName; - findPeopleResults.Add(fullName, person.AgentID); + LLUUIDs.Add(fullName, person.AgentID); ListViewItem item = lvwFindPeople.Items.Add(fullName); item.SubItems.Add(person.Online ? "Yes" : "No"); @@ -97,7 +84,7 @@ void Directory_DirPeopleReply(object sender, DirPeopleReplyEventArgs e) public void ClearResults() { - findPeopleResults.Clear(); + LLUUIDs.Clear(); lvwFindPeople.Items.Clear(); } @@ -108,57 +95,41 @@ private void lvwFindPeople_SelectedIndexChanged(object sender, EventArgs e) protected virtual void OnSelectedIndexChanged(EventArgs e) { - if (SelectedIndexChanged != null) SelectedIndexChanged(this, e); + SelectedIndexChanged?.Invoke(this, e); } - public Dictionary LLUUIDs - { - get { return findPeopleResults; } - } + public Dictionary LLUUIDs { get; } - public UUID QueryID - { - get { return queryID; } - set { queryID = value; } - } + public UUID QueryID { get; set; } public int SelectedIndex { get { - if (lvwFindPeople.SelectedItems == null) return -1; if (lvwFindPeople.SelectedItems.Count == 0) return -1; return lvwFindPeople.SelectedIndices[0]; } } - public string SelectedName - { - get - { - if (lvwFindPeople.SelectedItems == null) return string.Empty; - if (lvwFindPeople.SelectedItems.Count == 0) return string.Empty; - - return lvwFindPeople.SelectedItems[0].Text; - } - } + public string SelectedName => lvwFindPeople.SelectedItems.Count == 0 ? string.Empty : lvwFindPeople.SelectedItems[0].Text; public bool SelectedOnlineStatus { get { - if (lvwFindPeople.SelectedItems == null) return false; if (lvwFindPeople.SelectedItems.Count == 0) return false; string yesNo = lvwFindPeople.SelectedItems[0].SubItems[0].Text; - if (yesNo == "Yes") - return true; - else if (yesNo == "No") - return false; - else - return false; + switch (yesNo) + { + case "Yes": + return true; + case "No": + default: + return false; + } } } @@ -166,11 +137,10 @@ public UUID SelectedAgentUUID { get { - if (lvwFindPeople.SelectedItems == null) return UUID.Zero; if (lvwFindPeople.SelectedItems.Count == 0) return UUID.Zero; string name = lvwFindPeople.SelectedItems[0].Text; - return findPeopleResults[name]; + return LLUUIDs[name]; } } } diff --git a/Radegast/GUI/Consoles/FriendsConsole.cs b/Radegast/GUI/Consoles/FriendsConsole.cs index ab9cf954d..a1ffdbeca 100644 --- a/Radegast/GUI/Consoles/FriendsConsole.cs +++ b/Radegast/GUI/Consoles/FriendsConsole.cs @@ -1,44 +1,28 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; using OpenMetaverse.StructuredData; -#if (COGBOT_LIBOMV || USE_STHREADS) -using ThreadPoolUtil; -using Thread = ThreadPoolUtil.Thread; -using ThreadPool = ThreadPoolUtil.ThreadPool; -using Monitor = ThreadPoolUtil.Monitor; -#endif using System.Threading; using OpenMetaverse; @@ -47,7 +31,7 @@ namespace Radegast public partial class FriendsConsole : UserControl { private RadegastInstance instance; - private GridClient client { get { return instance.Client; } } + private GridClient client => instance.Client; private FriendInfo selectedFriend; private bool settingFriend = false; private readonly object lockOneAtaTime = new object(); @@ -55,7 +39,7 @@ public partial class FriendsConsole : UserControl public FriendsConsole(RadegastInstance instance) { InitializeComponent(); - Disposed += new EventHandler(FriendsConsole_Disposed); + Disposed += FriendsConsole_Disposed; this.instance = instance; @@ -70,15 +54,15 @@ public FriendsConsole(RadegastInstance instance) } // Callbacks - client.Friends.FriendOffline += new EventHandler(Friends_FriendOffline); - client.Friends.FriendOnline += new EventHandler(Friends_FriendOnline); - client.Friends.FriendshipTerminated += new EventHandler(Friends_FriendshipTerminated); - client.Friends.FriendshipResponse += new EventHandler(Friends_FriendshipResponse); - client.Friends.FriendNames += new EventHandler(Friends_FriendNames); - Load += new EventHandler(FriendsConsole_Load); - instance.Names.NameUpdated += new EventHandler(Names_NameUpdated); - - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + client.Friends.FriendOffline += Friends_FriendOffline; + client.Friends.FriendOnline += Friends_FriendOnline; + client.Friends.FriendshipTerminated += Friends_FriendshipTerminated; + client.Friends.FriendshipResponse += Friends_FriendshipResponse; + client.Friends.FriendNames += Friends_FriendNames; + Load += FriendsConsole_Load; + instance.Names.NameUpdated += Names_NameUpdated; + + GUI.GuiHelpers.ApplyGuiFixes(this); } void Names_NameUpdated(object sender, UUIDNameReplyEventArgs e) @@ -105,11 +89,11 @@ void Names_NameUpdated(object sender, UUIDNameReplyEventArgs e) void FriendsConsole_Disposed(object sender, EventArgs e) { - client.Friends.FriendOffline -= new EventHandler(Friends_FriendOffline); - client.Friends.FriendOnline -= new EventHandler(Friends_FriendOnline); - client.Friends.FriendshipTerminated -= new EventHandler(Friends_FriendshipTerminated); - client.Friends.FriendshipResponse -= new EventHandler(Friends_FriendshipResponse); - client.Friends.FriendNames -= new EventHandler(Friends_FriendNames); + client.Friends.FriendOffline -= Friends_FriendOffline; + client.Friends.FriendOnline -= Friends_FriendOnline; + client.Friends.FriendshipTerminated -= Friends_FriendshipTerminated; + client.Friends.FriendshipResponse -= Friends_FriendshipResponse; + client.Friends.FriendNames -= Friends_FriendNames; } void FriendsConsole_Load(object sender, EventArgs e) @@ -121,7 +105,7 @@ void FriendsConsole_Load(object sender, EventArgs e) private void InitializeFriendsList() { if (!Monitor.TryEnter(lockOneAtaTime)) return; - List friends = client.Friends.FriendList.FindAll(delegate(FriendInfo f) { return true; }); + List friends = client.Friends.FriendList.FindAll((FriendInfo f) => true); friends.Sort((fi1, fi2) => { @@ -130,7 +114,7 @@ private void InitializeFriendsList() else if (!fi1.IsOnline && fi2.IsOnline) return 1; else - return string.Compare(fi1.Name, fi2.Name); + return String.CompareOrdinal(fi1.Name, fi2.Name); } ); @@ -200,7 +184,7 @@ void Friends_FriendOffline(object sender, FriendInfoEventArgs e) { if (!instance.GlobalSettings["show_friends_online_notifications"]) return; - WorkPool.QueueUserWorkItem(sync => + ThreadPool.QueueUserWorkItem(sync => { string name = instance.Names.Get(e.Friend.UUID, true); MethodInvoker display = () => @@ -224,7 +208,7 @@ void Friends_FriendOnline(object sender, FriendInfoEventArgs e) { if (!instance.GlobalSettings["show_friends_online_notifications"]) return; - WorkPool.QueueUserWorkItem(sync => + ThreadPool.QueueUserWorkItem(sync => { string name = instance.Names.Get(e.Friend.UUID, true); MethodInvoker display = () => @@ -246,7 +230,7 @@ void Friends_FriendOnline(object sender, FriendInfoEventArgs e) void Friends_FriendshipTerminated(object sender, FriendshipTerminatedEventArgs e) { - WorkPool.QueueUserWorkItem(sync => + ThreadPool.QueueUserWorkItem(sync => { string name = instance.Names.Get(e.AgentID, true); MethodInvoker display = () => @@ -312,14 +296,14 @@ private void btnIM_Click(object sender, EventArgs e) instance.TabConsole.DisplayNotificationInChat(lblFriendName.Text, ChatBufferTextStyle.Invisible); btnIM.Enabled = false; - WorkPool.QueueUserWorkItem(sync => + ThreadPool.QueueUserWorkItem(sync => { using (ManualResetEvent started = new ManualResetEvent(false)) { UUID sessionID = UUID.Zero; string sessionName = string.Empty; - EventHandler handler = (object isender, GroupChatJoinedEventArgs ie) => + EventHandler handler = (isender, ie) => { if (ie.TmpSessionID == tmpID) { @@ -341,7 +325,7 @@ private void btnIM_Click(object sender, EventArgs e) )); } client.Self.GroupChatJoined -= handler; - BeginInvoke(new MethodInvoker(() => RefreshFriendsList())); + BeginInvoke(new MethodInvoker(RefreshFriendsList)); } } ); @@ -406,7 +390,7 @@ private void btnRemove_Click(object sender, EventArgs e) public void ShowContextMenu() { RadegastContextMenuStrip menu = GetContextMenu(); - if (menu.HasSelection) menu.Show(listFriends, listFriends.PointToClient(System.Windows.Forms.Control.MousePosition)); + if (menu.HasSelection) menu.Show(listFriends, listFriends.PointToClient(MousePosition)); } public RadegastContextMenuStrip GetContextMenu() diff --git a/Radegast/GUI/Consoles/GroupDetails.cs b/Radegast/GUI/Consoles/GroupDetails.cs index 83d63d24a..c35d06bde 100644 --- a/Radegast/GUI/Consoles/GroupDetails.cs +++ b/Radegast/GUI/Consoles/GroupDetails.cs @@ -1,44 +1,27 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections; using System.Collections.Generic; -#if (COGBOT_LIBOMV || USE_STHREADS) -using ThreadPoolUtil; -using Thread = ThreadPoolUtil.Thread; -using ThreadPool = ThreadPoolUtil.ThreadPool; -using Monitor = ThreadPoolUtil.Monitor; -#endif using System.Threading; -using System.Timers; using System.Windows.Forms; using OpenMetaverse; using OpenMetaverse.Packets; @@ -48,10 +31,10 @@ namespace Radegast public partial class GroupDetails : UserControl { private RadegastInstance instance; - private GridClient client { get { return instance.Client; } } + private GridClient client => instance.Client; private Group group; private Dictionary titles; - private Dictionary myGroups { get { return instance.Groups; } } + private Dictionary myGroups => instance.Groups; private List> roleMembers; private Dictionary roles; private bool isMember; @@ -63,15 +46,17 @@ public partial class GroupDetails : UserControl public GroupDetails(RadegastInstance instance, Group group) { InitializeComponent(); - Disposed += new EventHandler(GroupDetails_Disposed); + Disposed += GroupDetails_Disposed; this.instance = instance; this.group = group; if (group.InsigniaID != UUID.Zero) { - SLImageHandler insignia = new SLImageHandler(instance, group.InsigniaID, string.Empty); - insignia.Dock = DockStyle.Fill; + SLImageHandler insignia = new SLImageHandler(instance, group.InsigniaID, string.Empty) + { + Dock = DockStyle.Fill + }; pnlInsignia.Controls.Add(insignia); } @@ -106,40 +91,40 @@ public GroupDetails(RadegastInstance instance, Group group) lvwNoticeArchive.ListViewItemSorter = new GroupNoticeSorter(); // Callbacks - client.Groups.GroupTitlesReply += new EventHandler(Groups_GroupTitlesReply); - client.Groups.GroupMembersReply += new EventHandler(Groups_GroupMembersReply); - client.Groups.GroupProfile += new EventHandler(Groups_GroupProfile); - client.Groups.CurrentGroups += new EventHandler(Groups_CurrentGroups); - client.Groups.GroupNoticesListReply += new EventHandler(Groups_GroupNoticesListReply); - client.Groups.GroupJoinedReply += new EventHandler(Groups_GroupJoinedReply); - client.Groups.GroupLeaveReply += new EventHandler(Groups_GroupLeaveReply); - client.Groups.GroupRoleDataReply += new EventHandler(Groups_GroupRoleDataReply); - client.Groups.GroupMemberEjected += new EventHandler(Groups_GroupMemberEjected); - client.Groups.GroupRoleMembersReply += new EventHandler(Groups_GroupRoleMembersReply); - client.Self.IM += new EventHandler(Self_IM); - instance.Names.NameUpdated += new EventHandler(Names_NameUpdated); + client.Groups.GroupTitlesReply += Groups_GroupTitlesReply; + client.Groups.GroupMembersReply += Groups_GroupMembersReply; + client.Groups.GroupProfile += Groups_GroupProfile; + client.Groups.CurrentGroups += Groups_CurrentGroups; + client.Groups.GroupNoticesListReply += Groups_GroupNoticesListReply; + client.Groups.GroupJoinedReply += Groups_GroupJoinedReply; + client.Groups.GroupLeaveReply += Groups_GroupLeaveReply; + client.Groups.GroupRoleDataReply += Groups_GroupRoleDataReply; + client.Groups.GroupMemberEjected += Groups_GroupMemberEjected; + client.Groups.GroupRoleMembersReply += Groups_GroupRoleMembersReply; + client.Self.IM += Self_IM; + instance.Names.NameUpdated += Names_NameUpdated; RefreshControlsAvailability(); RefreshGroupInfo(); - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } void GroupDetails_Disposed(object sender, EventArgs e) { - client.Groups.GroupTitlesReply -= new EventHandler(Groups_GroupTitlesReply); - client.Groups.GroupMembersReply -= new EventHandler(Groups_GroupMembersReply); - client.Groups.GroupProfile -= new EventHandler(Groups_GroupProfile); - client.Groups.CurrentGroups -= new EventHandler(Groups_CurrentGroups); - client.Groups.GroupNoticesListReply -= new EventHandler(Groups_GroupNoticesListReply); - client.Groups.GroupJoinedReply -= new EventHandler(Groups_GroupJoinedReply); - client.Groups.GroupLeaveReply -= new EventHandler(Groups_GroupLeaveReply); - client.Groups.GroupRoleDataReply -= new EventHandler(Groups_GroupRoleDataReply); - client.Groups.GroupRoleMembersReply -= new EventHandler(Groups_GroupRoleMembersReply); - client.Groups.GroupMemberEjected -= new EventHandler(Groups_GroupMemberEjected); - client.Self.IM -= new EventHandler(Self_IM); - if (instance != null && instance.Names != null) - { - instance.Names.NameUpdated -= new EventHandler(Names_NameUpdated); + client.Groups.GroupTitlesReply -= Groups_GroupTitlesReply; + client.Groups.GroupMembersReply -= Groups_GroupMembersReply; + client.Groups.GroupProfile -= Groups_GroupProfile; + client.Groups.CurrentGroups -= Groups_CurrentGroups; + client.Groups.GroupNoticesListReply -= Groups_GroupNoticesListReply; + client.Groups.GroupJoinedReply -= Groups_GroupJoinedReply; + client.Groups.GroupLeaveReply -= Groups_GroupLeaveReply; + client.Groups.GroupRoleDataReply -= Groups_GroupRoleDataReply; + client.Groups.GroupRoleMembersReply -= Groups_GroupRoleMembersReply; + client.Groups.GroupMemberEjected -= Groups_GroupMemberEjected; + client.Self.IM -= Self_IM; + if (instance?.Names != null) + { + instance.Names.NameUpdated -= Names_NameUpdated; } if (nameUpdateTimer != null) { @@ -156,7 +141,7 @@ void Groups_GroupMemberEjected(object sender, GroupOperationEventArgs e) if (e.Success) { - BeginInvoke(new MethodInvoker(() => { RefreshGroupInfo(); })); + BeginInvoke(new MethodInvoker(RefreshGroupInfo)); instance.TabConsole.DisplayNotificationInChat("Group member ejected."); } else @@ -187,7 +172,7 @@ void Groups_GroupRoleDataReply(object sender, GroupRolesDataReplyEventArgs e) groupRolesMembersRequest = client.Groups.RequestGroupRolesMembers(group.ID); if (roles == null) roles = e.Roles; else lock (roles) roles = e.Roles; - BeginInvoke(new MethodInvoker(() => DisplayGroupRoles())); + BeginInvoke(new MethodInvoker(DisplayGroupRoles)); } } @@ -195,7 +180,7 @@ void Groups_GroupLeaveReply(object sender, GroupOperationEventArgs e) { if (e.GroupID == group.ID && e.Success) { - BeginInvoke(new MethodInvoker(() => RefreshGroupInfo())); + BeginInvoke(new MethodInvoker(RefreshGroupInfo)); } } @@ -203,7 +188,7 @@ void Groups_GroupJoinedReply(object sender, GroupOperationEventArgs e) { if (e.GroupID == group.ID && e.Success) { - BeginInvoke(new MethodInvoker(() => RefreshGroupInfo())); + BeginInvoke(new MethodInvoker(RefreshGroupInfo)); } } @@ -220,23 +205,15 @@ void Self_IM(object sender, InstantMessageEventArgs e) } InstantMessage msg = e.IM; - AssetType type; UUID groupID; - if (msg.BinaryBucket.Length >= 18) - { - groupID = new UUID(msg.BinaryBucket, 2); - } - else - { - groupID = msg.FromAgentID; - } + groupID = msg.BinaryBucket.Length >= 18 ? new UUID(msg.BinaryBucket, 2) : msg.FromAgentID; if (groupID != group.ID) return; if (msg.BinaryBucket.Length > 18 && msg.BinaryBucket[0] != 0) { - type = (AssetType)msg.BinaryBucket[1]; + var type = (AssetType)msg.BinaryBucket[1]; destinationFolderID = client.Inventory.FindFolderForType(type); int icoIndx = InventoryConsole.GetItemImageIndex(type.ToString().ToLower()); if (icoIndx >= 0) @@ -250,7 +227,7 @@ void Self_IM(object sender, InstantMessageEventArgs e) btnSave.Tag = msg; } - string text = msg.Message.Replace("\n", System.Environment.NewLine); + string text = msg.Message.Replace("\n", Environment.NewLine); int pos = msg.Message.IndexOf('|'); string title = msg.Message.Substring(0, pos); text = text.Remove(0, pos + 1); @@ -311,8 +288,10 @@ void Groups_GroupProfile(object sender, GroupProfileEventArgs e) group = e.Group; if (group.InsigniaID != UUID.Zero && pnlInsignia.Controls.Count == 0) { - SLImageHandler insignia = new SLImageHandler(instance, group.InsigniaID, string.Empty); - insignia.Dock = DockStyle.Fill; + SLImageHandler insignia = new SLImageHandler(instance, group.InsigniaID, string.Empty) + { + Dock = DockStyle.Fill + }; pnlInsignia.Controls.Add(insignia); } @@ -348,8 +327,8 @@ void Groups_GroupProfile(object sender, GroupProfileEventArgs e) { cbxReceiveNotices.Checked = myGroups[group.ID].AcceptNotices; cbxListInProfile.Checked = myGroups[group.ID].ListInProfile; - cbxReceiveNotices.CheckedChanged += new EventHandler(cbxListInProfile_CheckedChanged); - cbxListInProfile.CheckedChanged += new EventHandler(cbxListInProfile_CheckedChanged); + cbxReceiveNotices.CheckedChanged += cbxListInProfile_CheckedChanged; + cbxListInProfile.CheckedChanged += cbxListInProfile_CheckedChanged; } else if (group.OpenEnrollment) // I am not in this group, but I could join it { @@ -381,7 +360,7 @@ void ProcessNameUpdate(Dictionary Names) } } - WorkPool.QueueUserWorkItem(sync => + ThreadPool.QueueUserWorkItem(sync => { try { @@ -425,7 +404,7 @@ void Groups_GroupTitlesReply(object sender, GroupTitlesReplyEventArgs e) return; } - this.titles = e.Titles; + titles = e.Titles; foreach (GroupTitle title in titles.Values) { @@ -477,9 +456,7 @@ void lvwMemberDetails_RetrieveVirtualItem(object sender, RetrieveVirtualItemEven return; } - ListViewItem item = new ListViewItem(member.Name); - item.Tag = member; - item.Name = member.Base.ID.ToString(); + ListViewItem item = new ListViewItem(member.Name) {Tag = member, Name = member.Base.ID.ToString()}; item.SubItems.Add(new ListViewItem.ListViewSubItem(item, member.Base.Contribution.ToString())); if (member.LastOnline != DateTime.MinValue) { @@ -501,19 +478,13 @@ void lvwGeneralMembers_RetrieveVirtualItem(object sender, RetrieveVirtualItemEve e.Item = new ListViewItem(); return; } - ListViewItem item = new ListViewItem(member.Name); - item.Tag = member; - item.Name = member.Base.ID.ToString(); + ListViewItem item = new ListViewItem(member.Name) {Tag = member, Name = member.Base.ID.ToString()}; + item.SubItems.Add(new ListViewItem.ListViewSubItem(item, member.Base.Title)); - if (member.LastOnline != DateTime.MinValue) - { - item.SubItems.Add(new ListViewItem.ListViewSubItem(item, member.Base.OnlineStatus)); - } - else - { - item.SubItems.Add(new ListViewItem.ListViewSubItem(item, "N/A")); - } + item.SubItems.Add(member.LastOnline != DateTime.MinValue + ? new ListViewItem.ListViewSubItem(item, member.Base.OnlineStatus) + : new ListViewItem.ListViewSubItem(item, "N/A")); e.Item = item; } @@ -542,9 +513,7 @@ private void DisplayGroupRoles() { foreach (GroupRole role in roles.Values) { - ListViewItem item = new ListViewItem(); - item.Name = role.ID.ToString(); - item.Text = role.Name; + ListViewItem item = new ListViewItem {Name = role.ID.ToString(), Text = role.Name}; item.SubItems.Add(role.Title); item.SubItems.Add(role.ID.ToString()); item.Tag = role; @@ -599,8 +568,8 @@ private void RefreshGroupInfo() if (isMember) lvwMemberDetails.VirtualListSize = 0; cbxActiveTitle.SelectedIndexChanged -= cbxActiveTitle_SelectedIndexChanged; - cbxReceiveNotices.CheckedChanged -= new EventHandler(cbxListInProfile_CheckedChanged); - cbxListInProfile.CheckedChanged -= new EventHandler(cbxListInProfile_CheckedChanged); + cbxReceiveNotices.CheckedChanged -= cbxListInProfile_CheckedChanged; + cbxListInProfile.CheckedChanged -= cbxListInProfile_CheckedChanged; cbxActiveTitle.Items.Clear(); @@ -736,7 +705,7 @@ private void lvwNoticeArchive_ColumnClick(object sender, ColumnClickEventArgs e) private void btnClose_Click(object sender, EventArgs e) { - this.FindForm().Close(); + FindForm()?.Close(); } private void tcGroupDetails_SelectedIndexChanged(object sender, EventArgs e) @@ -842,8 +811,7 @@ private void lvwMemberDetails_SelectedIndexChanged(object sender, EventArgs e) lvwAssignedRoles.Items.Clear(); lvwAssignedRoles.Tag = m; - ListViewItem defaultItem = new ListViewItem(); - defaultItem.Name = "Everyone"; + ListViewItem defaultItem = new ListViewItem {Name = "Everyone"}; defaultItem.SubItems.Add(defaultItem.Name); defaultItem.Checked = true; lvwAssignedRoles.Items.Add(defaultItem); @@ -862,11 +830,10 @@ private void lvwMemberDetails_SelectedIndexChanged(object sender, EventArgs e) continue; } - ListViewItem item = new ListViewItem(); - item.Name = role.Name; + ListViewItem item = new ListViewItem {Name = role.Name}; item.SubItems.Add(new ListViewItem.ListViewSubItem(item, role.Name)); item.Tag = role; - var foundRole = roleMembers.Find((KeyValuePair kvp) => { return kvp.Value == m.Base.ID && kvp.Key == role.ID; }); + var foundRole = roleMembers.Find(kvp => kvp.Value == m.Base.ID && kvp.Key == role.ID); bool hasRole = foundRole.Value == m.Base.ID; item.Checked = hasRole; lvwAssignedRoles.Items.Add(item); @@ -898,10 +865,10 @@ private void lvwMemberDetails_SelectedIndexChanged(object sender, EventArgs e) private void UpdateMemberRoles() { EnhancedGroupMember m = (EnhancedGroupMember)lvwAssignedRoles.Tag; - GroupRoleChangesPacket p = new GroupRoleChangesPacket(); - p.AgentData.AgentID = client.Self.AgentID; - p.AgentData.SessionID = client.Self.SessionID; - p.AgentData.GroupID = group.ID; + GroupRoleChangesPacket p = new GroupRoleChangesPacket + { + AgentData = {AgentID = client.Self.AgentID, SessionID = client.Self.SessionID, GroupID = @group.ID} + }; List changes = new List(); foreach (ListViewItem item in lvwAssignedRoles.Items) @@ -910,7 +877,7 @@ private void UpdateMemberRoles() continue; GroupRole role = (GroupRole)item.Tag; - var foundRole = roleMembers.Find((KeyValuePair kvp) => { return kvp.Value == m.Base.ID && kvp.Key == role.ID; }); + var foundRole = roleMembers.Find(kvp => kvp.Value == m.Base.ID && kvp.Key == role.ID); bool hasRole = foundRole.Value == m.Base.ID; if (item.Checked != hasRole) @@ -920,10 +887,10 @@ private void UpdateMemberRoles() else roleMembers.Remove(foundRole); - var rc = new GroupRoleChangesPacket.RoleChangeBlock(); - rc.MemberID = m.Base.ID; - rc.RoleID = role.ID; - rc.Change = item.Checked ? 0u : 1u; + var rc = new GroupRoleChangesPacket.RoleChangeBlock + { + MemberID = m.Base.ID, RoleID = role.ID, Change = item.Checked ? 0u : 1u + }; changes.Add(rc); } } @@ -959,7 +926,7 @@ private void lvwAssignedRoles_ItemChecked(object sender, ItemCheckedEventArgs e) continue; GroupRole role = (GroupRole)item.Tag; - var foundRole = roleMembers.Find((KeyValuePair kvp) => { return kvp.Value == m.Base.ID && kvp.Key == role.ID; }); + var foundRole = roleMembers.Find(kvp => kvp.Value == m.Base.ID && kvp.Key == role.ID); bool hasRole = foundRole.Value == m.Base.ID; if (item.Checked != hasRole) @@ -1047,7 +1014,7 @@ private void lvwRoles_SelectedIndexChanged(object sender, EventArgs e) } else if (roleMembers != null) { - var mmb = roleMembers.FindAll((KeyValuePair kvp) => { return kvp.Key == role.ID; }); + var mmb = roleMembers.FindAll(kvp => kvp.Key == role.ID); foreach (var m in mmb) { lvwAssignedMembers.Items.Add(instance.Names.Get(m.Value)); @@ -1061,8 +1028,7 @@ private void lvwRoles_SelectedIndexChanged(object sender, EventArgs e) { if (p != GroupPowers.None) { - ListViewItem item = new ListViewItem(); - item.Tag = p; + ListViewItem item = new ListViewItem {Tag = p}; item.SubItems.Add(p.ToString()); item.Checked = (p & role.Powers) != 0; lvwRoleAbilitis.Items.Add(item); @@ -1082,18 +1048,16 @@ private void btnSaveRole_Click(object sender, EventArgs e) { if (btnSaveRole.Tag == null) // new role { - GroupRole role = new GroupRole(); - role.Name = txtRoleName.Text; - role.Title = txtRoleTitle.Text; - role.Description = txtRoleDescription.Text; + GroupRole role = new GroupRole + { + Name = txtRoleName.Text, Title = txtRoleTitle.Text, Description = txtRoleDescription.Text + }; client.Groups.CreateRole(group.ID, role); System.Threading.Thread.Sleep(100); RefreshRoles(); } - else if (btnSaveRole.Tag is GroupRole) // update role + else if (btnSaveRole.Tag is GroupRole role) // update role { - GroupRole role = (GroupRole)btnSaveRole.Tag; - if (HasPower(GroupPowers.ChangeActions)) { role.Powers = GroupPowers.None; @@ -1145,9 +1109,8 @@ private void btnNewNotice_Click(object sender, EventArgs e) private void btnPasteInv_Click(object sender, EventArgs e) { - if (instance.InventoryClipboard != null && instance.InventoryClipboard.Item is InventoryItem) + if (instance.InventoryClipboard?.Item is InventoryItem inv) { - InventoryItem inv = instance.InventoryClipboard.Item as InventoryItem; txtNewNoteAtt.Text = inv.Name; int icoIndx = InventoryConsole.GetItemImageIndex(inv.AssetType.ToString().ToLower()); if (icoIndx >= 0) @@ -1170,12 +1133,14 @@ private void btnRemoveAttachment_Click(object sender, EventArgs e) private void btnSend_Click(object sender, EventArgs e) { - GroupNotice ntc = new GroupNotice(); - ntc.Subject = txtNewNoticeTitle.Text; - ntc.Message = txtNewNoticeBody.Text; - if (txtNewNoteAtt.Tag != null && txtNewNoteAtt.Tag is InventoryItem) + GroupNotice ntc = new GroupNotice + { + Subject = txtNewNoticeTitle.Text, + Message = txtNewNoticeBody.Text + }; + + if (txtNewNoteAtt.Tag is InventoryItem inv) { - InventoryItem inv = txtNewNoteAtt.Tag as InventoryItem; ntc.OwnerID = inv.OwnerID; ntc.AttachmentID = inv.UUID; } @@ -1190,9 +1155,10 @@ private void btnSend_Click(object sender, EventArgs e) private void memberListContextMenuSave_Click(object sender, EventArgs e) { - SaveFileDialog saveMembers = new SaveFileDialog(); - saveMembers.Filter = "CSV|.csv|JSON|.json"; - saveMembers.Title = "Save visible group members"; + SaveFileDialog saveMembers = new SaveFileDialog + { + Filter = "CSV|.csv|JSON|.json", Title = "Save visible group members" + }; saveMembers.ShowDialog(); if (saveMembers.FileName != string.Empty) { @@ -1214,16 +1180,18 @@ private void memberListContextMenuSave_Click(object sender, EventArgs e) OpenMetaverse.StructuredData.OSDArray members = new OpenMetaverse.StructuredData.OSDArray(GroupMembers.Count); foreach (var item in GroupMembers) { - OpenMetaverse.StructuredData.OSDMap member = new OpenMetaverse.StructuredData.OSDMap(2); - member["UUID"] = item.Base.ID; - member["Name"] = item.Name; + OpenMetaverse.StructuredData.OSDMap member = new OpenMetaverse.StructuredData.OSDMap(2) + { + ["UUID"] = item.Base.ID, ["Name"] = item.Name + }; members.Add(member); } System.IO.File.WriteAllText(saveMembers.FileName, OpenMetaverse.StructuredData.OSDParser.SerializeJsonString(members)); break; } - instance.TabConsole.DisplayNotificationInChat(string.Format("Saved {0} members to {1}", GroupMembers.Count, saveMembers.FileName)); + instance.TabConsole.DisplayNotificationInChat( + $"Saved {GroupMembers.Count} members to {saveMembers.FileName}"); } catch (Exception ex) { @@ -1279,8 +1247,7 @@ void UpdateBannedAgents(BannedAgentsEventArgs e) foreach (var member in e.BannedAgents) { - var item = new ListViewItem(instance.Names.Get(member.Key)); - item.Name = member.Key.ToString(); + var item = new ListViewItem(instance.Names.Get(member.Key)) {Name = member.Key.ToString()}; item.SubItems.Add(member.Value.ToShortDateString()); lwBannedMembers.Items.Add(item); } @@ -1402,23 +1369,11 @@ public int Compare(EnhancedGroupMember member1, EnhancedGroupMember member2) switch (SortBy) { case SortByColumn.Name: - if (CurrentOrder == SortOrder.Ascending) - return string.Compare(member1.Name, member2.Name); - else - return string.Compare(member2.Name, member1.Name); - + return CurrentOrder == SortOrder.Ascending ? string.CompareOrdinal(member1.Name, member2.Name) : string.CompareOrdinal(member2.Name, member1.Name); case SortByColumn.Title: - if (CurrentOrder == SortOrder.Ascending) - return string.Compare(member1.Base.Title, member2.Base.Title); - else - return string.Compare(member2.Base.Title, member1.Base.Title); - + return CurrentOrder == SortOrder.Ascending ? string.CompareOrdinal(member1.Base.Title, member2.Base.Title) : string.CompareOrdinal(member2.Base.Title, member1.Base.Title); case SortByColumn.LastOnline: - if (CurrentOrder == SortOrder.Ascending) - return DateTime.Compare(member1.LastOnline, member2.LastOnline); - else - return DateTime.Compare(member2.LastOnline, member1.LastOnline); - + return CurrentOrder == SortOrder.Ascending ? DateTime.Compare(member1.LastOnline, member2.LastOnline) : DateTime.Compare(member2.LastOnline, member1.LastOnline); case SortByColumn.Contribution: if (member1.Base.Contribution < member2.Base.Contribution) return CurrentOrder == SortOrder.Ascending ? -1 : 1; @@ -1477,22 +1432,17 @@ public int Compare(object x, object y) switch (SortBy) { case SortByColumn.Subject: - if (CurrentOrder == SortOrder.Ascending) - return string.Compare(member1.Subject, member2.Subject); - else - return string.Compare(member2.Subject, member1.Subject); - + return CurrentOrder == SortOrder.Ascending + ? String.CompareOrdinal(member1.Subject, member2.Subject) + : String.CompareOrdinal(member2.Subject, member1.Subject); case SortByColumn.Sender: - if (CurrentOrder == SortOrder.Ascending) - return string.Compare(member1.FromName, member2.FromName); - else - return string.Compare(member2.FromName, member1.FromName); - + return CurrentOrder == SortOrder.Ascending + ? String.CompareOrdinal(member1.FromName, member2.FromName) + : String.CompareOrdinal(member2.FromName, member1.FromName); case SortByColumn.Date: - if (CurrentOrder == SortOrder.Ascending) - return IntCompare(member1.Timestamp, member2.Timestamp); - else - return IntCompare(member2.Timestamp, member1.Timestamp); + return CurrentOrder == SortOrder.Ascending + ? IntCompare(member1.Timestamp, member2.Timestamp) + : IntCompare(member2.Timestamp, member1.Timestamp); } return 0; diff --git a/Radegast/GUI/Consoles/GroupIMTabWindow.cs b/Radegast/GUI/Consoles/GroupIMTabWindow.cs index 2dbe6f915..d091a2fa8 100644 --- a/Radegast/GUI/Consoles/GroupIMTabWindow.cs +++ b/Radegast/GUI/Consoles/GroupIMTabWindow.cs @@ -1,39 +1,29 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Drawing; using System.Collections.Generic; using System.Windows.Forms; using System.Threading; -using Radegast.Netcom; +using Radegast; using OpenMetaverse; namespace Radegast @@ -41,10 +31,8 @@ namespace Radegast public partial class GroupIMTabWindow : UserControl { private RadegastInstance instance; - private GridClient client { get { return instance.Client; } } - private RadegastNetcom netcom { get { return instance.Netcom; } } - private UUID session; - private IMTextManager textManager; + private GridClient client => instance.Client; + private Radegast.Netcom netcom => instance.Netcom; private object AvatarListSyncRoot = new object(); private List chatHistory = new List(); private int chatPointer; @@ -54,12 +42,12 @@ public partial class GroupIMTabWindow : UserControl public GroupIMTabWindow(RadegastInstance instance, UUID session, string sessionName) { InitializeComponent(); - Disposed += new EventHandler(IMTabWindow_Disposed); + Disposed += IMTabWindow_Disposed; this.instance = instance; - this.session = session; + SessionId = session; - textManager = new IMTextManager(this.instance, new RichTextBoxPrinter(rtbIMText), IMTextManagerType.Group, this.session, sessionName); + TextManager = new IMTextManager(this.instance, new RichTextBoxPrinter(rtbIMText), IMTextManagerType.Group, SessionId, sessionName); btnShow.Text = "Show"; chatSplit.Panel2Collapsed = true; @@ -70,33 +58,33 @@ public GroupIMTabWindow(RadegastInstance instance, UUID session, string sessionN { client.Self.RequestJoinGroupChat(session); } - Load += new EventHandler(GroupIMTabWindow_Load); + Load += GroupIMTabWindow_Load; - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } private void RegisterClientEvents(GridClient client) { - client.Self.GroupChatJoined += new EventHandler(Self_GroupChatJoined); - client.Self.ChatSessionMemberAdded += new EventHandler(Self_ChatSessionMemberAdded); - client.Self.ChatSessionMemberLeft += new EventHandler(Self_ChatSessionMemberLeft); - instance.Names.NameUpdated += new EventHandler(Names_NameUpdated); - instance.Netcom.ClientConnected += new EventHandler(Netcom_Connected); - instance.Netcom.ClientDisconnected += new EventHandler(Netcom_Disconnected); - instance.GlobalSettings.OnSettingChanged += new Settings.SettingChangedCallback(GlobalSettings_OnSettingChanged); - instance.ClientChanged += new EventHandler(instance_ClientChanged); + client.Self.GroupChatJoined += Self_GroupChatJoined; + client.Self.ChatSessionMemberAdded += Self_ChatSessionMemberAdded; + client.Self.ChatSessionMemberLeft += Self_ChatSessionMemberLeft; + instance.Names.NameUpdated += Names_NameUpdated; + instance.Netcom.ClientConnected += Netcom_Connected; + instance.Netcom.ClientDisconnected += Netcom_Disconnected; + instance.GlobalSettings.OnSettingChanged += GlobalSettings_OnSettingChanged; + instance.ClientChanged += instance_ClientChanged; } private void UnregisterClientEvents(GridClient client) { - client.Self.GroupChatJoined -= new EventHandler(Self_GroupChatJoined); - client.Self.ChatSessionMemberAdded -= new EventHandler(Self_ChatSessionMemberAdded); - client.Self.ChatSessionMemberLeft -= new EventHandler(Self_ChatSessionMemberLeft); - instance.Names.NameUpdated -= new EventHandler(Names_NameUpdated); - instance.Netcom.ClientConnected -= new EventHandler(Netcom_Connected); - instance.Netcom.ClientDisconnected -= new EventHandler(Netcom_Disconnected); - instance.GlobalSettings.OnSettingChanged -= new Settings.SettingChangedCallback(GlobalSettings_OnSettingChanged); - instance.ClientChanged -= new EventHandler(instance_ClientChanged); + client.Self.GroupChatJoined -= Self_GroupChatJoined; + client.Self.ChatSessionMemberAdded -= Self_ChatSessionMemberAdded; + client.Self.ChatSessionMemberLeft -= Self_ChatSessionMemberLeft; + instance.Names.NameUpdated -= Names_NameUpdated; + instance.Netcom.ClientConnected -= Netcom_Connected; + instance.Netcom.ClientDisconnected -= Netcom_Disconnected; + instance.GlobalSettings.OnSettingChanged -= GlobalSettings_OnSettingChanged; + instance.ClientChanged -= instance_ClientChanged; } void instance_ClientChanged(object sender, ClientChangedEventArgs e) @@ -114,7 +102,7 @@ private void IMTabWindow_Disposed(object sender, EventArgs e) { if (instance.Netcom.IsLoggedIn) { - client.Self.RequestLeaveGroupChat(session); + client.Self.RequestLeaveGroupChat(SessionId); } UnregisterClientEvents(client); @@ -134,7 +122,7 @@ void Netcom_Disconnected(object sender, DisconnectedEventArgs e) void Netcom_Connected(object sender, EventArgs e) { - client.Self.RequestJoinGroupChat(session); + client.Self.RequestJoinGroupChat(SessionId); RefreshControls(); } @@ -165,13 +153,13 @@ void Names_NameUpdated(object sender, UUIDNameReplyEventArgs e) void Self_ChatSessionMemberLeft(object sender, ChatSessionMemberLeftEventArgs e) { - if (e.SessionID == session) + if (e.SessionID == SessionId) UpdateParticipantList(); } void Self_ChatSessionMemberAdded(object sender, ChatSessionMemberAddedEventArgs e) { - if (e.SessionID == session) + if (e.SessionID == SessionId) UpdateParticipantList(); } @@ -193,16 +181,17 @@ void UpdateParticipantList() List participants; - if (client.Self.GroupChatSessions.TryGetValue(session, out participants)) + if (client.Self.GroupChatSessions.TryGetValue(SessionId, out participants)) { ChatSessionMember[] members = participants.ToArray(); - for (int i = 0; i < members.Length; i++) + foreach (var participant in members) { - ChatSessionMember participant = members[i]; - ListViewItem item = new ListViewItem(); - item.Name = participant.AvatarKey.ToString(); - item.Text = instance.Names.Get(participant.AvatarKey); - item.Tag = participant.AvatarKey; + ListViewItem item = new ListViewItem + { + Name = participant.AvatarKey.ToString(), + Text = instance.Names.Get(participant.AvatarKey), + Tag = participant.AvatarKey + }; if (participant.IsModerator) item.Font = new Font(item.Font, FontStyle.Bold); @@ -222,7 +211,7 @@ void UpdateParticipantList() void Self_GroupChatJoined(object sender, GroupChatJoinedEventArgs e) { - if (e.SessionID != session && e.TmpSessionID != session) + if (e.SessionID != SessionId && e.TmpSessionID != SessionId) { return; } @@ -236,26 +225,26 @@ void Self_GroupChatJoined(object sender, GroupChatJoinedEventArgs e) if (e.Success) { - textManager.TextPrinter.PrintTextLine("Join Group Chat Success!", Color.Green); + TextManager.TextPrinter.PrintTextLine("Join Group Chat Success!", Color.Green); WaitForSessionStart.Set(); } else { - textManager.TextPrinter.PrintTextLine("Join Group Chat failed.", Color.Red); + TextManager.TextPrinter.PrintTextLine("Join Group Chat failed.", Color.Red); } } public void CleanUp() { - textManager.CleanUp(); - textManager = null; + TextManager.CleanUp(); + TextManager = null; instance = null; } private void btnSend_Click(object sender, EventArgs e) { SendMsg(); - this.ClearIMInput(); + ClearIMInput(); } private void btnShow_Click(object sender, EventArgs e) @@ -372,16 +361,16 @@ private void SendMsg() message = "/me " + message.Substring(1); } - this.ClearIMInput(); + ClearIMInput(); if (instance.RLV.RestictionActive("sendim")) return; if (message.Length > 1023) message = message.Remove(1023); - if (!client.Self.GroupChatSessions.ContainsKey(session)) + if (!client.Self.GroupChatSessions.ContainsKey(SessionId)) { WaitForSessionStart.Reset(); - client.Self.RequestJoinGroupChat(session); + client.Self.RequestJoinGroupChat(SessionId); } else { @@ -390,11 +379,11 @@ private void SendMsg() if (WaitForSessionStart.WaitOne(10000, false)) { - client.Self.InstantMessageGroup(session, message); + client.Self.InstantMessageGroup(SessionId, message); } else { - textManager.TextPrinter.PrintTextLine("Cannot send group IM.", Color.Red); + TextManager.TextPrinter.PrintTextLine("Cannot send group IM.", Color.Red); } } @@ -413,17 +402,9 @@ private void rtbIMText_LinkClicked(object sender, LinkClickedEventArgs e) instance.MainForm.ProcessLink(e.LinkText); } - public UUID SessionId - { - get { return session; } - set { session = value; } - } + public UUID SessionId { get; set; } - public IMTextManager TextManager - { - get { return textManager; } - set { textManager = value; } - } + public IMTextManager TextManager { get; set; } private void Participants_MouseDoubleClick(object sender, MouseEventArgs e) { @@ -516,7 +497,7 @@ private void ctxEject_Click(object sender, EventArgs e) { if (Participants.SelectedItems.Count != 1) return; UUID av = (UUID)Participants.SelectedItems[0].Tag; - instance.Client.Groups.EjectUser(session, av); + instance.Client.Groups.EjectUser(SessionId, av); } private void ctxBan_Click(object sender, EventArgs e) diff --git a/Radegast/GUI/Consoles/GroupsConsole.cs b/Radegast/GUI/Consoles/GroupsConsole.cs index 3cda654cc..d9acb2ae1 100644 --- a/Radegast/GUI/Consoles/GroupsConsole.cs +++ b/Radegast/GUI/Consoles/GroupsConsole.cs @@ -1,35 +1,24 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; -using System.Collections.Generic; using System.Windows.Forms; using System.Drawing; using OpenMetaverse; @@ -45,25 +34,25 @@ public partial class GroupsConsole : UserControl public GroupsConsole(RadegastInstance instance) { InitializeComponent(); - Disposed += new EventHandler(GroupsDialog_Disposed); - this.client = instance.Client; + Disposed += GroupsDialog_Disposed; + client = instance.Client; this.instance = instance; - client.Groups.CurrentGroups += new EventHandler(Groups_CurrentGroups); - client.Groups.GroupCreatedReply += new EventHandler(Groups_GroupCreatedReply); - client.Groups.GroupRoleDataReply += new EventHandler(Groups_GroupRoleDataReply); - client.Self.MuteListUpdated += new EventHandler(Self_MuteListUpdated); + client.Groups.CurrentGroups += Groups_CurrentGroups; + client.Groups.GroupCreatedReply += Groups_GroupCreatedReply; + client.Groups.GroupRoleDataReply += Groups_GroupRoleDataReply; + client.Self.MuteListUpdated += Self_MuteListUpdated; client.Groups.RequestCurrentGroups(); UpdateDisplay(); - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } void GroupsDialog_Disposed(object sender, EventArgs e) { - client.Groups.CurrentGroups -= new EventHandler(Groups_CurrentGroups); - client.Groups.GroupCreatedReply -= new EventHandler(Groups_GroupCreatedReply); - client.Groups.GroupRoleDataReply += new EventHandler(Groups_GroupRoleDataReply); - client.Self.MuteListUpdated -= new EventHandler(Self_MuteListUpdated); + client.Groups.CurrentGroups -= Groups_CurrentGroups; + client.Groups.GroupCreatedReply -= Groups_GroupCreatedReply; + client.Groups.GroupRoleDataReply += Groups_GroupRoleDataReply; + client.Self.MuteListUpdated -= Self_MuteListUpdated; } void Groups_GroupRoleDataReply(object sender, GroupRolesDataReplyEventArgs e) @@ -117,9 +106,7 @@ public void UpdateDisplay() lock (DisplaySyncRoot) { - Group none = new Group(); - none.Name = "(none)"; - none.ID = UUID.Zero; + Group none = new Group {Name = "(none)", ID = UUID.Zero}; listBox1.Items.Clear(); listBox1.Items.Add(none); @@ -253,10 +240,12 @@ private void txtNewGroupName_KeyDown(object sender, KeyEventArgs e) private void btnCreateGroup_Click(object sender, EventArgs e) { - Group g = new Group(); - g.Name = txtNewGroupName.Text; - g.Charter = txtNewGroupCharter.Text; - g.FounderID = client.Self.AgentID; + Group g = new Group + { + Name = txtNewGroupName.Text, + Charter = txtNewGroupCharter.Text, + FounderID = client.Self.AgentID + }; lblCreateStatus.Text = "Creating group..."; client.Groups.RequestCreateGroup(g); } diff --git a/Radegast/GUI/Consoles/IMTabWindow.cs b/Radegast/GUI/Consoles/IMTabWindow.cs index 4591d9595..3bfb22200 100644 --- a/Radegast/GUI/Consoles/IMTabWindow.cs +++ b/Radegast/GUI/Consoles/IMTabWindow.cs @@ -1,37 +1,27 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections.Generic; using System.Windows.Forms; -using Radegast.Netcom; +using Radegast; using OpenMetaverse; namespace Radegast @@ -39,11 +29,8 @@ namespace Radegast public partial class IMTabWindow : UserControl { private RadegastInstance instance; - private RadegastNetcom netcom { get { return instance.Netcom; } } + private Radegast.Netcom netcom => instance.Netcom; private UUID target; - private UUID session; - private string toName; - private IMTextManager textManager; private bool typing = false; private List chatHistory = new List(); private int chatPointer; @@ -51,19 +38,19 @@ public partial class IMTabWindow : UserControl public IMTabWindow(RadegastInstance instance, UUID target, UUID session, string toName) { InitializeComponent(); - Disposed += new EventHandler(IMTabWindow_Disposed); + Disposed += IMTabWindow_Disposed; this.instance = instance; this.target = target; - this.session = session; - this.toName = toName; + SessionId = session; + TargetName = toName; - textManager = new IMTextManager(this.instance, new RichTextBoxPrinter(rtbIMText), IMTextManagerType.Agent, this.session, toName); + TextManager = new IMTextManager(this.instance, new RichTextBoxPrinter(rtbIMText), IMTextManagerType.Agent, SessionId, toName); AddNetcomEvents(); - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } private void IMTabWindow_Disposed(object sender, EventArgs e) @@ -73,16 +60,16 @@ private void IMTabWindow_Disposed(object sender, EventArgs e) private void AddNetcomEvents() { - netcom.ClientLoginStatus += new EventHandler(netcom_ClientLoginStatus); - netcom.ClientDisconnected += new EventHandler(netcom_ClientDisconnected); - instance.GlobalSettings.OnSettingChanged += new Settings.SettingChangedCallback(GlobalSettings_OnSettingChanged); + netcom.ClientLoginStatus += netcom_ClientLoginStatus; + netcom.ClientDisconnected += netcom_ClientDisconnected; + instance.GlobalSettings.OnSettingChanged += GlobalSettings_OnSettingChanged; } private void RemoveNetcomEvents() { - netcom.ClientLoginStatus -= new EventHandler(netcom_ClientLoginStatus); - netcom.ClientDisconnected -= new EventHandler(netcom_ClientDisconnected); - instance.GlobalSettings.OnSettingChanged -= new Settings.SettingChangedCallback(GlobalSettings_OnSettingChanged); + netcom.ClientLoginStatus -= netcom_ClientLoginStatus; + netcom.ClientDisconnected -= netcom_ClientDisconnected; + instance.GlobalSettings.OnSettingChanged -= GlobalSettings_OnSettingChanged; } void GlobalSettings_OnSettingChanged(object sender, SettingsEventArgs e) @@ -104,8 +91,8 @@ private void netcom_ClientDisconnected(object sender, DisconnectedEventArgs e) public void CleanUp() { instance.TabConsole.RemoveTab(SessionId.ToString()); - textManager.CleanUp(); - textManager = null; + TextManager.CleanUp(); + TextManager = null; RemoveNetcomEvents(); } @@ -136,14 +123,14 @@ private void RefreshControls() if (!typing) { - netcom.SendIMStartTyping(target, session); + netcom.SendIMStartTyping(target, SessionId); typing = true; } } else { btnSend.Enabled = false; - netcom.SendIMStopTyping(target, session); + netcom.SendIMStopTyping(target, SessionId); typing = false; } } @@ -165,8 +152,8 @@ private void ProcessInput() if (instance.RLV.RestictionActive("sendim", target.ToString())) msg = "*** IM blocked by sender's viewer"; - netcom.SendInstantMessage(msg, target, session); - this.ClearIMInput(); + netcom.SendInstantMessage(msg, target, SessionId); + ClearIMInput(); } void ChatHistoryPrev() @@ -233,7 +220,7 @@ private void rtbIMText_LinkClicked(object sender, LinkClickedEventArgs e) private void tbtnProfile_Click(object sender, EventArgs e) { - instance.MainForm.ShowAgentProfile(toName, target); + instance.MainForm.ShowAgentProfile(TargetName, target); } private void btnOfferTeleport_Click(object sender, EventArgs e) @@ -243,32 +230,20 @@ private void btnOfferTeleport_Click(object sender, EventArgs e) private void btnPay_Click(object sender, EventArgs e) { - (new frmPay(instance, target, toName, false)).ShowDialog(); + (new frmPay(instance, target, TargetName, false)).ShowDialog(); } public UUID TargetId { - get { return target; } - set { target = value; } + get => target; + set => target = value; } - public string TargetName - { - get { return toName; } - set { toName = value; } - } + public string TargetName { get; set; } - public UUID SessionId - { - get { return session; } - set { session = value; } - } + public UUID SessionId { get; set; } - public IMTextManager TextManager - { - get { return textManager; } - set { textManager = value; } - } + public IMTextManager TextManager { get; set; } private void cbxInput_VisibleChanged(object sender, EventArgs e) { @@ -282,7 +257,7 @@ private void cbxInput_SizeChanged(object sender, EventArgs e) private void cbAlwaysDing_CheckedChanged(object sender, EventArgs e) { - textManager.DingOnAllIncoming = ((CheckBox)sender).Checked; + TextManager.DingOnAllIncoming = ((CheckBox)sender).Checked; } } } diff --git a/Radegast/GUI/Consoles/ImageUploadConsole.Designer.cs b/Radegast/GUI/Consoles/ImageUploadConsole.Designer.cs index 7d8d0b422..48ef49b15 100644 --- a/Radegast/GUI/Consoles/ImageUploadConsole.Designer.cs +++ b/Radegast/GUI/Consoles/ImageUploadConsole.Designer.cs @@ -68,7 +68,6 @@ private void InitializeComponent() this.label1 = new System.Windows.Forms.Label(); this.txtAssetID = new System.Windows.Forms.TextBox(); this.label2 = new System.Windows.Forms.Label(); - this.chkTemp = new System.Windows.Forms.CheckBox(); ((System.ComponentModel.ISupportInitialize)(this.pbPreview)).BeginInit(); this.SuspendLayout(); // @@ -136,6 +135,7 @@ private void InitializeComponent() this.chkLossless.TabIndex = 4; this.chkLossless.Text = "Lossless"; this.chkLossless.UseVisualStyleBackColor = true; + this.chkLossless.Click += new System.EventHandler(this.chkLossless_Click); // // lblSize // @@ -175,21 +175,10 @@ private void InitializeComponent() this.label2.Text = "Set this checkbox\r\nbefore clicking on\r\nLoad image...\r\nOnly useful for\r\npixel perf" + "ect small\r\nimages (sculpties).\r\n"; // - // chkTemp - // - this.chkTemp.AutoSize = true; - this.chkTemp.Location = new System.Drawing.Point(3, 214); - this.chkTemp.Name = "chkTemp"; - this.chkTemp.Size = new System.Drawing.Size(76, 17); - this.chkTemp.TabIndex = 5; - this.chkTemp.Text = "Temporary"; - this.chkTemp.UseVisualStyleBackColor = true; - // // ImageUploadConsole // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.chkTemp); this.Controls.Add(this.label2); this.Controls.Add(this.txtAssetID); this.Controls.Add(this.label1); @@ -220,7 +209,6 @@ private void InitializeComponent() public System.Windows.Forms.CheckBox chkLossless; public System.Windows.Forms.Label lblSize; private System.Windows.Forms.Label label2; - private System.Windows.Forms.CheckBox chkTemp; } } diff --git a/Radegast/GUI/Consoles/ImageUploadConsole.cs b/Radegast/GUI/Consoles/ImageUploadConsole.cs index 607e31717..80f3f3531 100644 --- a/Radegast/GUI/Consoles/ImageUploadConsole.cs +++ b/Radegast/GUI/Consoles/ImageUploadConsole.cs @@ -1,46 +1,36 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; -using System.Collections.Generic; -using System.ComponentModel; using System.Drawing; -using System.Drawing.Imaging; -using System.Data; -using System.Linq; -using System.Text; using System.Windows.Forms; using System.IO; +using System.Runtime.InteropServices; +using CoreJ2K; using OpenMetaverse; -using OpenMetaverse.Assets; using OpenMetaverse.Imaging; +using Pfim; +using SkiaSharp; +using SkiaSharp.Views.Desktop; +using ImageFormat = System.Drawing.Imaging.ImageFormat; +using PixelFormat = System.Drawing.Imaging.PixelFormat; namespace Radegast { @@ -56,7 +46,7 @@ public ImageUploadConsole() { InitializeComponent(); - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } public ImageUploadConsole(RadegastInstance instance) @@ -64,19 +54,19 @@ public ImageUploadConsole(RadegastInstance instance) { InitializeComponent(); - Disposed += new EventHandler(ImageUploadConsole_Disposed); - instance.Netcom.ClientConnected += new EventHandler(Netcom_ClientConnected); - instance.Netcom.ClientDisconnected += new EventHandler(Netcom_ClientDisconnected); - client.Assets.AssetUploaded += new EventHandler(Assets_AssetUploaded); + Disposed += ImageUploadConsole_Disposed; + instance.Netcom.ClientConnected += Netcom_ClientConnected; + instance.Netcom.ClientDisconnected += Netcom_ClientDisconnected; + client.Assets.AssetUploaded += Assets_AssetUploaded; UpdateButtons(); OriginalCapsTimeout = client.Settings.CAPS_TIMEOUT; - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } void ImageUploadConsole_Disposed(object sender, EventArgs e) { - client.Assets.AssetUploaded -= new EventHandler(Assets_AssetUploaded); + client.Assets.AssetUploaded -= Assets_AssetUploaded; } void Assets_AssetUploaded(object sender, AssetUploadEventArgs e) @@ -145,42 +135,51 @@ public void LoadImage(string fname) { FileName = fname; - if (String.IsNullOrEmpty(FileName)) + if (string.IsNullOrEmpty(FileName)) return; - txtStatus.AppendText("Loading...\n"); + txtStatus.AppendText("Loading..." + Environment.NewLine); - string extension = System.IO.Path.GetExtension(FileName).ToLower(); - Bitmap bitmap = null; + string extension = Path.GetExtension(FileName).ToLower(); try { - if (extension == ".jp2" || extension == ".j2c") + Bitmap bitmap = null; + switch (extension) { - Image image; - ManagedImage managedImage; - - // Upload JPEG2000 images untouched - UploadData = System.IO.File.ReadAllBytes(FileName); - - OpenJPEG.DecodeToImage(UploadData, out managedImage, out image); - bitmap = (Bitmap)image; - - txtStatus.AppendText("Loaded raw JPEG2000 data " + FileName + "\n"); + case ".jp2": + case ".j2c": + // Upload JPEG2000 images untouched + UploadData = File.ReadAllBytes(FileName); + bitmap = J2kImage.FromBytes(UploadData).As().ToBitmap(); + + txtStatus.AppendText("Loaded raw JPEG2000 data " + FileName + Environment.NewLine); + break; + case ".tga": + var tga = Pfimage.FromFile(FileName); + var handle = GCHandle.Alloc(tga.Data, GCHandleType.Pinned); + try + { + var data = Marshal.UnsafeAddrOfPinnedArrayElement(tga.Data, 0); + bitmap = new Bitmap(tga.Width, tga.Height, tga.Stride, PixelFormat.Format32bppArgb, data); + } + finally + { + handle.Free(); + } + break; + default: + bitmap = Image.FromFile(FileName) as Bitmap; + break; } - else + + if (bitmap == null) { - if (extension == ".tga") - { - bitmap = LoadTGAClass.LoadTGA(FileName); - } - else - { - bitmap = (Bitmap)System.Drawing.Image.FromFile(FileName); - } + txtStatus.AppendText("Failed to load image " + FileName + Environment.NewLine); + return; } - txtStatus.AppendText("Loaded image " + FileName + "\n"); + txtStatus.AppendText("Loaded image " + FileName + Environment.NewLine); int width = bitmap.Width; int height = bitmap.Height; @@ -188,7 +187,7 @@ public void LoadImage(string fname) // Handle resizing to prevent excessively large images and irregular dimensions if (!IsPowerOfTwo((uint)width) || !IsPowerOfTwo((uint)height) || width > 1024 || height > 1024) { - txtStatus.AppendText("Image has irregular dimensions " + width + "x" + height + "\n"); + txtStatus.AppendText("Image has irregular dimensions " + width + "x" + height + Environment.NewLine); width = ClosestPowerOwTwo(width); height = ClosestPowerOwTwo(height); @@ -196,7 +195,7 @@ public void LoadImage(string fname) width = width > 1024 ? 1024 : width; height = height > 1024 ? 1024 : height; - txtStatus.AppendText("Resizing to " + width + "x" + height + "\n"); + txtStatus.AppendText("Resizing to " + width + "x" + height + Environment.NewLine); Bitmap resized = new Bitmap(width, height, bitmap.PixelFormat); Graphics graphics = Graphics.FromImage(resized); @@ -210,59 +209,48 @@ public void LoadImage(string fname) bitmap = resized; } - txtStatus.AppendText("Encoding image...\n"); + txtStatus.AppendText("Encoding image..." + Environment.NewLine); - UploadData = OpenJPEG.EncodeFromImage(bitmap, chkLossless.Checked); + var plist = J2K.GetDefaultEncoderParameterList(); + plist.Add(chkLossless.Checked ? "lossless" : "Mct", "on"); + UploadData = J2kImage.ToBytes(bitmap.ToSKBitmap(), plist); - txtStatus.AppendText("Finished encoding.\n"); + txtStatus.AppendText("Finished encoding." + Environment.NewLine); ImageLoaded = true; UpdateButtons(); txtAssetID.Text = UUID.Zero.ToString(); pbPreview.Image = bitmap; - lblSize.Text = string.Format("{0}x{1} {2} KB", bitmap.Width, bitmap.Height, Math.Round((double)UploadData.Length / 1024.0d, 2)); + lblSize.Text = + $"{bitmap.Width}x{bitmap.Height} {Math.Round((double)UploadData.Length / 1024.0d, 2)} KB"; } catch (Exception ex) { UploadData = null; btnSave.Enabled = false; btnUpload.Enabled = false; - txtStatus.AppendText(string.Format("Failed to load the image:\n{0}\n", ex.Message)); - return; + txtStatus.AppendText(string.Format("Failed to load the image:" + Environment.NewLine + + "{0}" + Environment.NewLine, ex.Message)); } } void UpdateButtons() { btnLoad.Enabled = true; - - if (ImageLoaded) - { - btnSave.Enabled = true; - } - else - { - btnSave.Enabled = false; - } - - if (ImageLoaded && client.Network.Connected) - { - btnUpload.Enabled = true; - } - else - { - btnUpload.Enabled = false; - } + btnSave.Enabled = ImageLoaded; + btnUpload.Enabled = ImageLoaded && client.Network.Connected; } private void btnLoad_Click(object sender, EventArgs e) { - OpenFileDialog dialog = new OpenFileDialog(); - dialog.Filter = - "Image Files (*.jp2,*.j2c,*.jpg,*.jpeg,*.gif,*.png,*.bmp,*.tga,*.tif,*.tiff,*.ico,*.wmf,*.emf)|" + - "*.jp2;*.j2c;*.jpg;*.jpeg;*.gif;*.png;*.bmp;*.tga;*.tif;*.tiff;*.ico;*.wmf;*.emf|" + - "All files (*.*)|*.*"; + OpenFileDialog dialog = new OpenFileDialog + { + Filter = + "Image Files (*.jp2,*.j2c,*.jpg,*.jpeg,*.gif,*.png,*.bmp,*.tga,*.tif,*.tiff,*.ico,*.wmf,*.emf)|" + + "*.jp2;*.j2c;*.jpg;*.jpeg;*.gif;*.png;*.bmp;*.tga;*.tif;*.tiff;*.ico;*.wmf;*.emf|" + + "All files (*.*)|*.*" + }; if (dialog.ShowDialog() == DialogResult.OK) { @@ -273,11 +261,14 @@ private void btnLoad_Click(object sender, EventArgs e) private void btnSave_Click(object sender, EventArgs e) { - SaveFileDialog dlg = new SaveFileDialog(); - dlg.AddExtension = true; - dlg.RestoreDirectory = true; - dlg.Title = "Save image as..."; - dlg.Filter = "PNG (*.png)|*.png|Targa (*.tga)|*.tga|Jpeg2000 (*.j2c)|*.j2c|Jpeg (*.jpg)|*.jpg|Bitmap (*.bmp)|*.bmp"; + SaveFileDialog dlg = new SaveFileDialog + { + AddExtension = true, + RestoreDirectory = true, + Title = "Save image as...", + Filter = + "PNG (*.png)|*.png|Targa (*.tga)|*.tga|Jpeg2000 (*.j2c)|*.j2c|Jpeg (*.jpg)|*.jpg|Bitmap (*.bmp)|*.bmp" + }; @@ -290,9 +281,8 @@ private void btnSave_Click(object sender, EventArgs e) } else if (type == 2) { // targa - ManagedImage imgManaged; - OpenJPEG.DecodeToImage(UploadData, out imgManaged); - File.WriteAllBytes(dlg.FileName, imgManaged.ExportTGA()); + var mgimg = new ManagedImage(J2kImage.FromBytes(UploadData)); + File.WriteAllBytes(dlg.FileName, OpenMetaverse.Imaging.Targa.Encode(mgimg)); } else if (type == 1) { // png @@ -311,6 +301,11 @@ private void btnSave_Click(object sender, EventArgs e) dlg.Dispose(); } + private void chkLossless_Click(object sender, EventArgs e) + { + LoadImage(FileName); + } + private void TempUploadHandler(bool success, InventoryItem item) { if (InvokeRequired) @@ -329,12 +324,12 @@ private void TempUploadHandler(bool success, InventoryItem item) if (!success) { - txtStatus.AppendText("Upload failed.\n"); + txtStatus.AppendText("Upload failed." + Environment.NewLine); return; } - txtStatus.AppendText("Upload success.\n"); - txtStatus.AppendText("New image ID: " + AssetID.ToString() + "\n"); + txtStatus.AppendText("Upload success." + Environment.NewLine); + txtStatus.AppendText("New image ID: " + AssetID + Environment.NewLine); } private void UploadHandler(bool success, string status, UUID itemID, UUID assetID) @@ -358,41 +353,31 @@ private void UploadHandler(bool success, string status, UUID itemID, UUID assetI if (!success) { - txtStatus.AppendText("Upload failed: " + status + "\n"); + txtStatus.AppendText("Upload failed: " + status + Environment.NewLine); return; } - txtStatus.AppendText("Upload success.\n"); - txtStatus.AppendText("New image ID: " + AssetID.ToString() + "\n"); + txtStatus.AppendText("Upload success." + Environment.NewLine); + txtStatus.AppendText("New image ID: " + AssetID + Environment.NewLine); } private void btnUpload_Click(object sender, EventArgs e) { - bool tmp = chkTemp.Checked; - txtStatus.AppendText("Uploading..."); + txtStatus.AppendText("Uploading..." + Environment.NewLine); btnLoad.Enabled = false; btnUpload.Enabled = false; AssetID = InventoryID = UUID.Zero; TextureName = Path.GetFileNameWithoutExtension(FileName); - if (tmp) TextureName += " (temp)"; - TextureDescription = string.Format("Uploaded with Radegast on {0}", DateTime.Now.ToLongDateString()); + TextureDescription = $"Uploaded with Radegast on {DateTime.Now.ToLongDateString()}"; - Permissions perms = new Permissions(); - perms.EveryoneMask = PermissionMask.All; - perms.NextOwnerMask = PermissionMask.All; + Permissions perms = new Permissions {EveryoneMask = PermissionMask.All, NextOwnerMask = PermissionMask.All}; - if (!tmp) - { - client.Settings.CAPS_TIMEOUT = 180 * 1000; - client.Inventory.RequestCreateItemFromAsset(UploadData, TextureName, TextureDescription, AssetType.Texture, InventoryType.Texture, - client.Inventory.FindFolderForType(AssetType.Texture), perms, UploadHandler); - } - else - { - TransactionID = UUID.Random(); - client.Assets.RequestUpload(out AssetID, AssetType.Texture, UploadData, true, TransactionID); - } + + client.Settings.CAPS_TIMEOUT = 180 * 1000; + client.Inventory.RequestCreateItemFromAsset(UploadData, TextureName, TextureDescription, + AssetType.Texture, InventoryType.Texture, + client.Inventory.FindFolderForType(AssetType.Texture), perms, UploadHandler); } } } diff --git a/Radegast/GUI/Consoles/ImportConsole.cs b/Radegast/GUI/Consoles/ImportConsole.cs index 86fd871fe..5282a49d3 100644 --- a/Radegast/GUI/Consoles/ImportConsole.cs +++ b/Radegast/GUI/Consoles/ImportConsole.cs @@ -1,54 +1,31 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections.Generic; -using System.ComponentModel; -using System.Drawing; -using System.Drawing.Imaging; -using System.Data; using System.Linq; -using System.Text; -#if (COGBOT_LIBOMV || USE_STHREADS) -using ThreadPoolUtil; -using Thread = ThreadPoolUtil.Thread; -using ThreadPool = ThreadPoolUtil.ThreadPool; -using Monitor = ThreadPoolUtil.Monitor; -#endif using System.Threading; using System.Windows.Forms; using System.IO; using OpenMetaverse; using OpenMetaverse.StructuredData; -using OpenMetaverse.Assets; -using OpenMetaverse.Imaging; namespace Radegast { @@ -67,14 +44,13 @@ public ImportConsole(GridClient client) { InitializeComponent(); Client = client; - Importer = new PrimImporter(client); - Importer.LogMessage = LogMessage; - sFileName = ""; + Importer = new PrimImporter(client) {LogMessage = LogMessage}; + sFileName = ""; objectName.Text = ""; primCount.Text = ""; textureCount.Text = ""; - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } #endregion @@ -101,7 +77,7 @@ void ValidateFileName() LogMessage("Loading {0}...",fileName); string xml = File.ReadAllText(fileName); List prims = Helpers.OSDToPrimList(OSDParser.DeserializeLLSDXml(xml)); - int count = prims.Count(); + int count = prims.Count; string name = ""; string desc = ""; Importer.Textures = new Dictionary(); @@ -119,13 +95,13 @@ void ValidateFileName() !Importer.Textures.ContainsKey(prim.Textures.DefaultTexture.TextureID)) Importer.Textures.Add(prim.Textures.DefaultTexture.TextureID,UUID.Zero); - for (int j = 0; j < prim.Textures.FaceTextures.Length; j++) - { - if (prim.Textures.FaceTextures[j] != null && - prim.Textures.FaceTextures[j].TextureID != Primitive.TextureEntry.WHITE_TEXTURE && - !Importer.Textures.ContainsKey(prim.Textures.FaceTextures[j].TextureID)) - Importer.Textures.Add(prim.Textures.FaceTextures[j].TextureID,UUID.Zero); - } + foreach (var tex in prim.Textures.FaceTextures) + { + if (tex != null && + tex.TextureID != Primitive.TextureEntry.WHITE_TEXTURE && + !Importer.Textures.ContainsKey(tex.TextureID)) + Importer.Textures.Add(tex.TextureID,UUID.Zero); + } if (prim.Sculpt != null && prim.Sculpt.SculptTexture != UUID.Zero && !Importer.Textures.ContainsKey(prim.Sculpt.SculptTexture)) Importer.Textures.Add(prim.Sculpt.SculptTexture,UUID.Zero); @@ -135,7 +111,7 @@ void ValidateFileName() } objectName.Text = name; primCount.Text = prims.Count.ToString(); - textureCount.Text = Importer.Textures.Count().ToString(); + textureCount.Text = Importer.Textures.Count.ToString(); LogMessage("Reading complete, Ready to import..."); } } @@ -174,7 +150,7 @@ void UploadImages() { if (texture == UUID.Zero) continue; - string file = Path.Combine(path,texture.ToString() + ".jp2"); + string file = Path.Combine(path,texture + ".jp2"); if (!File.Exists(file)) { LogMessage("Failed to find texture {0}",texture.ToString()); @@ -213,7 +189,7 @@ void UploadImagesRetry() foreach(UUID texture in textures) { - string file = Path.Combine(path,texture.ToString() + ".jp2"); + string file = Path.Combine(path,texture + ".jp2"); LogMessage("Uploading texture {0}...",texture.ToString()); bool ret = upldr.UploadImage(file,"Import of " + Path.GetFileNameWithoutExtension(txtFileName.Text),uploaddir); if (ret) @@ -235,7 +211,7 @@ void UploadImagesRetry() void EnableWindow() { - this.Enabled = true; + Enabled = true; } #endregion @@ -249,12 +225,17 @@ void ChckRezAtLocCheckedChanged(object sender, EventArgs e) void BtnBrowseClick(object sender, EventArgs e) { - WindowWrapper mainWindow = new WindowWrapper(frmMain.ActiveForm.Handle); - System.Windows.Forms.OpenFileDialog dlg = new OpenFileDialog(); - dlg.Title = "Open object file"; - dlg.Filter = "XML file (*.xml)|*.xml"; - dlg.Multiselect = false; - DialogResult res = dlg.ShowDialog(); + if (Form.ActiveForm != null) + { + WindowWrapper mainWindow = new WindowWrapper(Form.ActiveForm.Handle); + } + OpenFileDialog dlg = new OpenFileDialog + { + Title = "Open object file", + Filter = "XML file (*.xml)|*.xml", + Multiselect = false + }; + DialogResult res = dlg.ShowDialog(); if (res != DialogResult.OK) return; @@ -273,11 +254,11 @@ void TxtFileNameLeave(object sender, EventArgs e) void BtnUploadClick(object sender, EventArgs e) { - this.Enabled = false; + Enabled = false; if (cmbImageOptions.SelectedIndex == -1) { MessageBox.Show("You must select an Image Option before you can import an object.","Import Object Error",MessageBoxButtons.OK,MessageBoxIcon.Error); - this.Enabled = true; + Enabled = true; return; } switch(cmbImageOptions.SelectedIndex) @@ -303,19 +284,19 @@ void BtnUploadClick(object sender, EventArgs e) if (!float.TryParse(txtX.Text,out x)) { MessageBox.Show("X Coordinate needs to be a Float position! Example: 1.500","Import Object Error",MessageBoxButtons.OK,MessageBoxIcon.Error); - this.Enabled = true; + Enabled = true; return; } if (!float.TryParse(txtY.Text,out y)) { MessageBox.Show("Y Coordinate needs to be a Float position! Example: 1.500","Import Object Error",MessageBoxButtons.OK,MessageBoxIcon.Error); - this.Enabled = true; + Enabled = true; return; } if (!float.TryParse(txtZ.Text,out z)) { MessageBox.Show("Z Coordinate needs to be a Float position! Example: 1.500","Import Object Error",MessageBoxButtons.OK,MessageBoxIcon.Error); - this.Enabled = true; + Enabled = true; return; } Importer.RezAt = new Vector3(x,y,z); @@ -325,50 +306,53 @@ void BtnUploadClick(object sender, EventArgs e) Importer.RezAt = Client.Self.SimPosition; Importer.RezAt.Z += 3.5f; } - - Thread t = new Thread(new System.Threading.ThreadStart(delegate() - { - try - { - start = DateTime.Now; - // First upload Images that will be needed by the Importer, if required by user. - if (Importer.TextureUse == PrimImporter.TextureSet.NewUUID || Importer.TextureUse == PrimImporter.TextureSet.SculptUUID) - UploadImages(); - - // Check to see if there are any failed uploads. - if (FailedUploads.Count > 0) - { - DialogResult res = MessageBox.Show(String.Format("Failed to upload {0} textures, which to try again?",FailedUploads.Count), - "Import - Upload Texture Error",MessageBoxButtons.YesNo, MessageBoxIcon.Error); - if (res == DialogResult.Yes) - UploadImagesRetry(); - - if (FailedUploads.Count != 0) - { - MessageBox.Show(String.Format("Failed to upload {0} textures on second try, aborting!",FailedUploads.Count), - "Import - Upload Texture Error",MessageBoxButtons.OK,MessageBoxIcon.Error); - LogMessage("Failed to import object, due to texture error, review the log for further information"); - return; - } - } - - LogMessage("Texture Upload completed"); - LogMessage("Importing Prims..."); - // If we get here, then we successfully uploaded the textures, continue with the upload of the Prims. - Importer.ImportFromFile(txtFileName.Text); - LogMessage("Import successful."); - LogMessage("Total Time: {0}",DateTime.Now.Subtract(start)); - } - catch (Exception ex) - { - LogMessage("Import failed. Reason: {0}",ex.Message); - MessageBox.Show(ex.Message,"Importing failed.",MessageBoxButtons.OK,MessageBoxIcon.Error); - } - - BeginInvoke(new MethodInvoker(() => EnableWindow())); - })); - t.IsBackground = true; - t.Start(); + + Thread t = new Thread(delegate() + { + try + { + start = DateTime.Now; + // First upload Images that will be needed by the Importer, if required by user. + if (Importer.TextureUse == PrimImporter.TextureSet.NewUUID || + Importer.TextureUse == PrimImporter.TextureSet.SculptUUID) + UploadImages(); + + // Check to see if there are any failed uploads. + if (FailedUploads.Count > 0) + { + DialogResult res = MessageBox.Show( + $"Failed to upload {FailedUploads.Count} textures, which to try again?", + "Import - Upload Texture Error", MessageBoxButtons.YesNo, MessageBoxIcon.Error); + if (res == DialogResult.Yes) + UploadImagesRetry(); + + if (FailedUploads.Count != 0) + { + MessageBox.Show( + $"Failed to upload {FailedUploads.Count} textures on second try, aborting!", + "Import - Upload Texture Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + LogMessage( + "Failed to import object, due to texture error, review the log for further information"); + return; + } + } + + LogMessage("Texture Upload completed"); + LogMessage("Importing Prims..."); + // If we get here, then we successfully uploaded the textures, continue with the upload of the Prims. + Importer.ImportFromFile(txtFileName.Text); + LogMessage("Import successful."); + LogMessage("Total Time: {0}", DateTime.Now.Subtract(start)); + } + catch (Exception ex) + { + LogMessage("Import failed. Reason: {0}", ex.Message); + MessageBox.Show(ex.Message, "Importing failed.", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + BeginInvoke(new MethodInvoker(EnableWindow)); + }) {IsBackground = true}; + t.Start(); } #endregion } diff --git a/Radegast/GUI/Consoles/Inventory/CurrentOutfitFolder.cs b/Radegast/GUI/Consoles/Inventory/CurrentOutfitFolder.cs index 28ac5fd7d..a350b0df6 100644 --- a/Radegast/GUI/Consoles/Inventory/CurrentOutfitFolder.cs +++ b/Radegast/GUI/Consoles/Inventory/CurrentOutfitFolder.cs @@ -1,52 +1,41 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2022, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; -using System.Collections; using System.Collections.Generic; using System.Linq; using System.Threading; using OpenMetaverse; -using OpenMetaverse.StructuredData; namespace Radegast { public class CurrentOutfitFolder : IDisposable { #region Fields - GridClient Client; - RadegastInstance Instance; - bool InitiCOF = false; - bool AppearanceSent = false; - bool COFReady = false; - bool InitialUpdateDone = false; + + private GridClient Client; + private readonly RadegastInstance Instance; + private bool InitiCOF = false; + private bool AppearanceSent = false; + private bool COFReady = false; + private bool InitialUpdateDone = false; public Dictionary Content = new Dictionary(); public InventoryFolder COF; @@ -55,43 +44,44 @@ public class CurrentOutfitFolder : IDisposable #region Construction and disposal public CurrentOutfitFolder(RadegastInstance instance) { - this.Instance = instance; - this.Client = instance.Client; - Instance.ClientChanged += new EventHandler(instance_ClientChanged); + Instance = instance; + Client = instance.Client; + Instance.ClientChanged += instance_ClientChanged; RegisterClientEvents(Client); } public void Dispose() { UnregisterClientEvents(Client); - Instance.ClientChanged -= new EventHandler(instance_ClientChanged); + Instance.ClientChanged -= instance_ClientChanged; } #endregion Construction and disposal #region Event handling - void instance_ClientChanged(object sender, ClientChangedEventArgs e) + + private void instance_ClientChanged(object sender, ClientChangedEventArgs e) { UnregisterClientEvents(Client); Client = e.Client; RegisterClientEvents(Client); } - void RegisterClientEvents(GridClient client) + private void RegisterClientEvents(GridClient client) { - client.Network.EventQueueRunning += new EventHandler(Network_EventQueueRunning); - client.Inventory.FolderUpdated += new EventHandler(Inventory_FolderUpdated); - client.Inventory.ItemReceived += new EventHandler(Inventory_ItemReceived); - client.Appearance.AppearanceSet += new EventHandler(Appearance_AppearanceSet); - client.Objects.KillObject += new EventHandler(Objects_KillObject); + client.Network.EventQueueRunning += Network_EventQueueRunning; + client.Inventory.FolderUpdated += Inventory_FolderUpdated; + client.Inventory.ItemReceived += Inventory_ItemReceived; + client.Appearance.AppearanceSet += Appearance_AppearanceSet; + client.Objects.KillObject += Objects_KillObject; } - void UnregisterClientEvents(GridClient client) + private void UnregisterClientEvents(GridClient client) { - client.Network.EventQueueRunning -= new EventHandler(Network_EventQueueRunning); - client.Inventory.FolderUpdated -= new EventHandler(Inventory_FolderUpdated); - client.Inventory.ItemReceived -= new EventHandler(Inventory_ItemReceived); - client.Appearance.AppearanceSet -= new EventHandler(Appearance_AppearanceSet); - client.Objects.KillObject -= new EventHandler(Objects_KillObject); + client.Network.EventQueueRunning -= Network_EventQueueRunning; + client.Inventory.FolderUpdated -= Inventory_FolderUpdated; + client.Inventory.ItemReceived -= Inventory_ItemReceived; + client.Appearance.AppearanceSet -= Appearance_AppearanceSet; + client.Objects.KillObject -= Objects_KillObject; lock (Content) Content.Clear(); InitiCOF = false; AppearanceSent = false; @@ -99,7 +89,7 @@ void UnregisterClientEvents(GridClient client) InitialUpdateDone = false; } - void Appearance_AppearanceSet(object sender, AppearanceSetEventArgs e) + private void Appearance_AppearanceSet(object sender, AppearanceSetEventArgs e) { AppearanceSent = true; if (COFReady) @@ -108,18 +98,10 @@ void Appearance_AppearanceSet(object sender, AppearanceSetEventArgs e) } } - void Inventory_ItemReceived(object sender, ItemReceivedEventArgs e) + private void Inventory_ItemReceived(object sender, ItemReceivedEventArgs e) { - bool partOfCOF = false; var links = ContentLinks(); - foreach (var cofItem in links) - { - if (cofItem.AssetUUID == e.Item.UUID) - { - partOfCOF = true; - break; - } - } + bool partOfCOF = links.Any(cofItem => cofItem.AssetUUID == e.Item.UUID); if (partOfCOF) { @@ -129,32 +111,25 @@ void Inventory_ItemReceived(object sender, ItemReceivedEventArgs e) } } - if (Content.Count == links.Count) + if (Content.Count != links.Count) return; + COFReady = true; + if (AppearanceSent) { - COFReady = true; - if (AppearanceSent) - { - InitialUpdate(); - } - lock (Content) - { - foreach (InventoryItem link in Content.Values) - { - if (link.InventoryType == InventoryType.Wearable) - { - InventoryWearable w = (InventoryWearable)link; - InventoryItem lk = links.Find(l => l.AssetUUID == w.UUID); - // Logger.DebugLog(string.Format("\nName: {0}\nDescription: {1}\nType: {2} - {3}", w.Name, lk == null ? "" : lk.Description, w.Flags.ToString(), w.WearableType.ToString())); ; - } - } - - } + InitialUpdate(); + } + lock (Content) + { + foreach (var lk in from link in Content.Values + where link.InventoryType == InventoryType.Wearable + select (InventoryWearable)link into w + select links.Find(l => l.AssetUUID == w.UUID)) + { } } } - object FolderSync = new object(); + private readonly object FolderSync = new object(); - void Inventory_FolderUpdated(object sender, FolderUpdatedEventArgs e) + private void Inventory_FolderUpdated(object sender, FolderUpdatedEventArgs e) { if (COF == null) return; @@ -187,7 +162,7 @@ void Inventory_FolderUpdated(object sender, FolderUpdatedEventArgs e) } } - void Objects_KillObject(object sender, KillObjectEventArgs e) + private void Objects_KillObject(object sender, KillObjectEventArgs e) { if (Client.Network.CurrentSim != e.Simulator) return; @@ -202,7 +177,7 @@ void Objects_KillObject(object sender, KillObjectEventArgs e) } } - void Network_EventQueueRunning(object sender, EventQueueRunningEventArgs e) + private void Network_EventQueueRunning(object sender, EventQueueRunningEventArgs e) { if (e.Simulator == Client.Network.CurrentSim && !InitiCOF) { @@ -213,19 +188,20 @@ void Network_EventQueueRunning(object sender, EventQueueRunningEventArgs e) #endregion Event handling #region Private methods - void RequestDescendants(UUID folderID) + + private void RequestDescendants(UUID folderID) { Client.Inventory.RequestFolderContents(folderID, Client.Self.AgentID, true, true, InventorySortOrder.ByDate); } - void InitCOF() + private void InitCOF() { - List rootContent = Client.Inventory.Store.GetContents(Client.Inventory.Store.RootFolder.UUID); - foreach (InventoryBase baseItem in rootContent) + var rootContent = Client.Inventory.Store.GetContents(Client.Inventory.Store.RootFolder.UUID); + foreach (var baseItem in rootContent) { - if (baseItem is InventoryFolder && ((InventoryFolder)baseItem).PreferredType == FolderType.CurrentOutfit) + if (baseItem is InventoryFolder folder && folder.PreferredType == FolderType.CurrentOutfit) { - COF = (InventoryFolder)baseItem; + COF = folder; break; } } @@ -240,12 +216,12 @@ void InitCOF() } } - void CreateCOF() + private void CreateCOF() { UUID cofID = Client.Inventory.CreateFolder(Client.Inventory.Store.RootFolder.UUID, "Current Outfit", FolderType.CurrentOutfit); - if (Client.Inventory.Store.Items.ContainsKey(cofID) && Client.Inventory.Store.Items[cofID].Data is InventoryFolder) + if (Client.Inventory.Store.Items.ContainsKey(cofID) && Client.Inventory.Store.Items[cofID].Data is InventoryFolder folder) { - COF = (InventoryFolder)Client.Inventory.Store.Items[cofID].Data; + COF = folder; COFReady = true; if (AppearanceSent) { @@ -254,23 +230,19 @@ void CreateCOF() } } - void InitialUpdate() + private void InitialUpdate() { if (InitialUpdateDone) return; InitialUpdateDone = true; lock (Content) { - List myAtt = Client.Network.CurrentSim.ObjectsPrimitives.FindAll((Primitive p) => p.ParentID == Client.Self.LocalID); + var myAtt = Client.Network.CurrentSim.ObjectsPrimitives.FindAll(p => p.ParentID == Client.Self.LocalID); - foreach (InventoryItem item in Content.Values) + foreach (var item in Content.Values + .Where(item => item is InventoryObject || item is InventoryAttachment) + .Where(item => !IsAttached(myAtt, item))) { - if (item is InventoryObject || item is InventoryAttachment) - { - if (!IsAttached(myAtt, item)) - { - Client.Appearance.Attach(item, AttachmentPoint.Default, false); - } - } + Client.Appearance.Attach(item, AttachmentPoint.Default, false); } } } @@ -283,7 +255,7 @@ void InitialUpdate() /// List if InventoryItems that can be part of appearance (attachments, wearables) public List ContentLinks() { - List ret = new List(); + var ret = new List(); if (COF == null) return ret; Client.Inventory.Store.GetContents(COF) @@ -302,7 +274,7 @@ public static UUID GetAttachmentItem(Primitive prim) { if (prim.NameValues == null) return UUID.Zero; - for (int i = 0; i < prim.NameValues.Length; i++) + for (var i = 0; i < prim.NameValues.Length; i++) { if (prim.NameValues[i].Name == "AttachItemID") { @@ -320,15 +292,7 @@ public static UUID GetAttachmentItem(Primitive prim) /// True if the inventory item is attached to avatar public static bool IsAttached(List attachments, InventoryItem item) { - foreach (Primitive prim in attachments) - { - if (GetAttachmentItem(prim) == item.UUID) - { - return true; - } - } - - return false; + return attachments.Any(prim => GetAttachmentItem(prim) == item.UUID); } /// @@ -337,16 +301,9 @@ public static bool IsAttached(List attachments, InventoryItem item) /// Current outfit /// Item to check /// True if the item is worn - public static bool IsWorn(Dictionary currentlyWorn, InventoryItem item) + public static bool IsWorn(List currentlyWorn, InventoryItem item) { - foreach (var n in currentlyWorn.Values) - { - if (n.ItemID == item.UUID) - { - return true; - } - } - return false; + return currentlyWorn.Any(worn => worn.ItemID == item.UUID); } /// @@ -379,9 +336,9 @@ public void AddLink(InventoryItem item) { if (item.InventoryType == InventoryType.Wearable && !IsBodyPart(item)) { - InventoryWearable w = (InventoryWearable)item; + var w = (InventoryWearable)item; int layer = 0; - string desc = string.Format("@{0}{1:00}", (int)w.WearableType, layer); + string desc = $"@{(int) w.WearableType}{layer:00}"; AddLink(item, desc); } else @@ -399,13 +356,13 @@ public void AddLink(InventoryItem item, string newDescription) { if (COF == null) return; - bool linkExists = false; - - linkExists = null != ContentLinks().Find(itemLink => itemLink.AssetUUID == item.UUID); + bool linkExists = null != ContentLinks().Find(itemLink => itemLink.AssetUUID == item.UUID); if (!linkExists) { - Client.Inventory.CreateLink(COF.UUID, item.UUID, item.Name, newDescription, AssetType.Link, item.InventoryType, UUID.Random(), (success, newItem) => + Client.Inventory.CreateLink(COF.UUID, item.UUID, item.Name, newDescription, + AssetType.Link, item.InventoryType, UUID.Random(), + (success, newItem) => { if (success) { @@ -432,15 +389,11 @@ public void RemoveLink(List itemIDs) { if (COF == null) return; - List toRemove = new List(); - - foreach (UUID itemID in itemIDs) + foreach (var links in itemIDs.Select(itemID => ContentLinks() + .FindAll(itemLink => itemLink.AssetUUID == itemID))) { - var links = ContentLinks().FindAll(itemLink => itemLink.AssetUUID == itemID); - links.ForEach(item => toRemove.Add(item.UUID)); + links.ForEach(item => Client.Inventory.RemoveItem(item.UUID)); } - - Client.Inventory.Remove(toRemove, null); } /// @@ -450,11 +403,10 @@ public void RemoveLink(List itemIDs) public void Detach(InventoryItem item) { var realItem = RealInventoryItem(item); - if (Instance.RLV.AllowDetach(realItem)) - { - Client.Appearance.Detach(item); - RemoveLink(item.UUID); - } + if (!Instance.RLV.AllowDetach(realItem)) return; + + Client.Appearance.Detach(item); + RemoveLink(item.UUID); } public List GetWornAt(WearableType type) @@ -463,13 +415,11 @@ public List GetWornAt(WearableType type) ContentLinks().ForEach(link => { var item = RealInventoryItem(link); - if (item is InventoryWearable) + if (!(item is InventoryWearable wearable)) return; + + if (wearable.WearableType == type) { - var w = (InventoryWearable)item; - if (w.WearableType == type) - { - ret.Add(item); - } + ret.Add(wearable); } }); @@ -484,9 +434,10 @@ public List GetWornAt(WearableType type) /// public InventoryItem RealInventoryItem(InventoryItem item) { - if (item.IsLink() && Client.Inventory.Store.Contains(item.AssetUUID) && Client.Inventory.Store[item.AssetUUID] is InventoryItem) + if (item.IsLink() && Client.Inventory.Store.Contains(item.AssetUUID) + && Client.Inventory.Store[item.AssetUUID] is InventoryItem invItem) { - return (InventoryItem)Client.Inventory.Store[item.AssetUUID]; + return invItem; } return item; @@ -495,37 +446,21 @@ public InventoryItem RealInventoryItem(InventoryItem item) /// /// Replaces the current outfit and updates COF links accordingly /// - /// List of new wearables and attachments that comprise the new outfit + /// List of new wearables and attachments that comprise the new outfit public void ReplaceOutfit(List newOutfit) { // Resolve inventory links - List outfit = new List(); - foreach (var item in newOutfit) - { - outfit.Add(RealInventoryItem(item)); - } + var outfit = newOutfit.Select(RealInventoryItem).ToList(); // Remove links to all exiting items - List toRemove = new List(); + var toRemove = new List(); ContentLinks().ForEach(item => { if (IsBodyPart(item)) { WearableType linkType = ((InventoryWearable)RealInventoryItem(item)).WearableType; - bool hasBodyPart = false; - - foreach (var newItemTmp in newOutfit) - { - var newItem = RealInventoryItem(newItemTmp); - if (IsBodyPart(newItem)) - { - if (((InventoryWearable)newItem).WearableType == linkType) - { - hasBodyPart = true; - break; - } - } - } + bool hasBodyPart = newOutfit.Select(RealInventoryItem).Where(IsBodyPart).Any(newItem => + ((InventoryWearable) newItem).WearableType == linkType); if (hasBodyPart) { @@ -538,17 +473,20 @@ public void ReplaceOutfit(List newOutfit) } }); - Client.Inventory.Remove(toRemove, null); + foreach (var item in toRemove) + { + Client.Inventory.RemoveItem(item); + } // Add links to new items - List newItems = outfit.FindAll(item => CanBeWorn(item)); + var newItems = outfit.FindAll(CanBeWorn); foreach (var item in newItems) { AddLink(item); } Client.Appearance.ReplaceOutfit(outfit, false); - WorkPool.QueueUserWorkItem(sync => + ThreadPool.QueueUserWorkItem(sync => { Thread.Sleep(2000); Client.Appearance.RequestSetAppearance(true); @@ -572,16 +510,16 @@ public void AddToOutfit(InventoryItem item, bool replace) /// Should existing wearable of the same type be removed public void AddToOutfit(List items, bool replace) { - List current = ContentLinks(); - List toRemove = new List(); + var current = ContentLinks(); + var toRemove = new List(); // Resolve inventory links and remove wearables of the same type from COF - List outfit = new List(); + var outfit = new List(); foreach (var item in items) { - InventoryItem realItem = RealInventoryItem(item); - if (realItem is InventoryWearable) + var realItem = RealInventoryItem(item); + if (replace && realItem is InventoryWearable wearable) { foreach (var link in current) { @@ -590,10 +528,10 @@ public void AddToOutfit(List items, bool replace) { toRemove.Add(link.UUID); } - else if (currentItem is InventoryWearable) + else { - var w = (InventoryWearable)currentItem; - if (w.WearableType == ((InventoryWearable)realItem).WearableType) + var w = currentItem as InventoryWearable; + if (w?.WearableType == wearable.WearableType) { toRemove.Add(link.UUID); } @@ -603,17 +541,21 @@ public void AddToOutfit(List items, bool replace) outfit.Add(realItem); } - Client.Inventory.Remove(toRemove, null); + + foreach (var item in toRemove) + { + Client.Inventory.RemoveItem(item); + } // Add links to new items - List newItems = outfit.FindAll(item => CanBeWorn(item)); + var newItems = outfit.FindAll(CanBeWorn); foreach (var item in newItems) { AddLink(item); } Client.Appearance.AddToOutfit(outfit, replace); - WorkPool.QueueUserWorkItem(sync => + ThreadPool.QueueUserWorkItem(sync => { Thread.Sleep(2000); Client.Appearance.RequestSetAppearance(true); @@ -623,7 +565,7 @@ public void AddToOutfit(List items, bool replace) /// /// Remove an item from the current outfit /// - /// Item to remove + /// Item to remove public void RemoveFromOutfit(InventoryItem item) { RemoveFromOutfit(new List(1) { item }); @@ -636,22 +578,10 @@ public void RemoveFromOutfit(InventoryItem item) public void RemoveFromOutfit(List items) { // Resolve inventory links - List outfit = new List(); - foreach (var item in items) - { - var realItem = RealInventoryItem(item); - if (Instance.RLV.AllowDetach(realItem)) - { - outfit.Add(realItem); - } - } + var outfit = items.Select(RealInventoryItem).Where(realItem => Instance.RLV.AllowDetach(realItem)).ToList(); // Remove links to all items that were removed - List toRemove = new List(); - foreach (InventoryItem item in outfit.FindAll(item => CanBeWorn(item) && !IsBodyPart(item))) - { - toRemove.Add(item.UUID); - } + var toRemove = outfit.FindAll(item => CanBeWorn(item) && !IsBodyPart(item)).Select(item => item.UUID).ToList(); RemoveLink(toRemove); Client.Appearance.RemoveFromOutfit(outfit); @@ -660,19 +590,13 @@ public void RemoveFromOutfit(List items) public bool IsBodyPart(InventoryItem item) { var realItem = RealInventoryItem(item); - if (realItem is InventoryWearable) - { - var w = (InventoryWearable)realItem; - var t = w.WearableType; - if (t == WearableType.Shape || - t == WearableType.Skin || - t == WearableType.Eyes || - t == WearableType.Hair) - { - return true; - } - } - return false; + if (!(realItem is InventoryWearable wearable)) return false; + + var t = wearable.WearableType; + return t == WearableType.Shape || + t == WearableType.Skin || + t == WearableType.Eyes || + t == WearableType.Hair; } /// diff --git a/Radegast/GUI/Consoles/Inventory/FolderCopy.cs b/Radegast/GUI/Consoles/Inventory/FolderCopy.cs index f08a24c91..7cea20c12 100644 --- a/Radegast/GUI/Consoles/Inventory/FolderCopy.cs +++ b/Radegast/GUI/Consoles/Inventory/FolderCopy.cs @@ -1,7 +1,23 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System.Threading; using OpenMetaverse; @@ -15,8 +31,8 @@ public class FolderCopy public FolderCopy(RadegastInstance instance) { - this.Instance = instance; - this.Client = this.Instance.Client; + Instance = instance; + Client = Instance.Client; } public void GetFolders(string folder) @@ -29,7 +45,7 @@ public void GetFolders(string folder) var destFolder = (InventoryFolder)Client.Inventory.Store[dest]; - WorkPool.QueueUserWorkItem(sync => + ThreadPool.QueueUserWorkItem(sync => { Instance.TabConsole.DisplayNotificationInChat("Starting copy operation..."); foreach (var node in f.Nodes.Values) @@ -56,7 +72,7 @@ public void CopyFolder(InventoryFolder dest, InventoryFolder folder) if (item is InventoryItem) { copied.Reset(); - Client.Inventory.RequestCopyItem(item.UUID, newFolderID, item.Name, folder.OwnerID, (InventoryBase target) => + Client.Inventory.RequestCopyItem(item.UUID, newFolderID, item.Name, folder.OwnerID, target => { Instance.TabConsole.DisplayNotificationInChat(string.Format(" * Copied {0} to {1}", item.Name, dest.Name)); copied.Set(); diff --git a/Radegast/GUI/Consoles/Inventory/InventoryBackup.cs b/Radegast/GUI/Consoles/Inventory/InventoryBackup.cs index 686368b6d..f899ebe8d 100644 --- a/Radegast/GUI/Consoles/Inventory/InventoryBackup.cs +++ b/Radegast/GUI/Consoles/Inventory/InventoryBackup.cs @@ -1,44 +1,28 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id: RadegastInstance.cs 152 2009-08-24 14:19:58Z latifer@gmail.com $ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; -using System.Collections; using System.Collections.Generic; using System.IO; -#if (COGBOT_LIBOMV || USE_STHREADS) -using ThreadPoolUtil; -using Thread = ThreadPoolUtil.Thread; -using ThreadPool = ThreadPoolUtil.ThreadPool; -using Monitor = ThreadPoolUtil.Monitor; -#endif using System.Threading; +using System.Threading.Tasks; using System.Windows.Forms; using OpenMetaverse; using OpenMetaverse.Assets; @@ -49,19 +33,19 @@ namespace Radegast public partial class InventoryBackup : Form { private RadegastInstance instance; - GridClient client { get { return instance.Client; } } + GridClient client => instance.Client; private Inventory inv; - private Thread backupThread; private string folderName; private int fetched = 0; private TextWriter csvFile = null; private int traversed = 0; private InventoryNode rootNode; + private CancellationTokenSource backupTaskCancelToken; public InventoryBackup(RadegastInstance instance, UUID rootFolder) { InitializeComponent(); - Disposed += new System.EventHandler(InventoryBackup_Disposed); + Disposed += InventoryBackup_Disposed; this.instance = instance; @@ -72,12 +56,18 @@ public InventoryBackup(RadegastInstance instance, UUID rootFolder) rootNode = inv.GetNodeFor(rootFolder); } - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + backupTaskCancelToken = new CancellationTokenSource(); + + GUI.GuiHelpers.ApplyGuiFixes(this); } - void InventoryBackup_Disposed(object sender, System.EventArgs e) + void InventoryBackup_Disposed(object sender, EventArgs e) { - + try + { + backupTaskCancelToken.Cancel(); + backupTaskCancelToken.Dispose(); + } catch (ObjectDisposedException) { } } private void WriteCSVLine(params object[] args) @@ -99,7 +89,7 @@ private void WriteCSVLine(params object[] args) } } - private void btnFolder_Click(object sender, System.EventArgs e) + private void btnFolder_Click(object sender, EventArgs e) { openFileDialog1.CheckFileExists = false; DialogResult res = openFileDialog1.ShowDialog(); @@ -130,14 +120,7 @@ private void btnFolder_Click(object sender, System.EventArgs e) sbrProgress.Style = ProgressBarStyle.Marquee; fetched = 0; - if (backupThread != null) - { - if (backupThread.IsAlive) - backupThread.Abort(); - backupThread = null; - } - - backupThread = new Thread(new ThreadStart(() => + Task backupTask = Task.Run(() => { TraverseDir(rootNode, Path.DirectorySeparatorChar.ToString()); if (csvFile != null) @@ -147,22 +130,19 @@ private void btnFolder_Click(object sender, System.EventArgs e) csvFile.Close(); csvFile.Dispose(); } - catch { } + catch + { + } } + if (backupTaskCancelToken.IsCancellationRequested) { return; } BeginInvoke(new MethodInvoker(() => - { - lblStatus.Text = string.Format("Done ({0} items saved).", fetched); - sbrProgress.Style = ProgressBarStyle.Blocks; - btnFolder.Enabled = true; - } + { + lblStatus.Text = $"Done ({fetched} items saved)."; + sbrProgress.Style = ProgressBarStyle.Blocks; + btnFolder.Enabled = true; + } )); - } - )); - - backupThread.IsBackground = false; - backupThread.Name = "Inventory Backup"; - backupThread.Start(); - + }, backupTaskCancelToken.Token); } } @@ -175,6 +155,7 @@ private void TraverseDir(InventoryNode node, string path) traversed++; try { + backupTaskCancelToken.Token.ThrowIfCancellationRequested(); if (IsHandleCreated && (traversed % 13 == 0)) { BeginInvoke(new MethodInvoker(() => @@ -223,10 +204,10 @@ private void TraverseDir(InventoryNode node, string path) (item.AssetType == AssetType.Texture && cbImages.Checked) ) { - ListViewItem lvi = new ListViewItem(); - lvi.Text = n.Data.Name; - lvi.Tag = n.Data; - lvi.Name = n.Data.UUID.ToString(); + ListViewItem lvi = new ListViewItem + { + Text = n.Data.Name, Tag = n.Data, Name = n.Data.UUID.ToString() + }; ListViewItem.ListViewSubItem fileName = new ListViewItem.ListViewSubItem(lvi, filePartial); lvi.SubItems.Add(fileName); @@ -241,6 +222,8 @@ private void TraverseDir(InventoryNode node, string path) // status.Text = "Cached"; //} + backupTaskCancelToken.Token.ThrowIfCancellationRequested(); + BeginInvoke(new MethodInvoker(() => { lvwFiles.Items.Add(lvi); @@ -248,6 +231,7 @@ private void TraverseDir(InventoryNode node, string path) })); //if (cached) continue; + backupTaskCancelToken.Token.ThrowIfCancellationRequested(); Asset receivedAsset = null; using (AutoResetEvent done = new AutoResetEvent(false)) @@ -265,9 +249,10 @@ private void TraverseDir(InventoryNode node, string path) } else { - client.Assets.RequestInventoryAsset(item, true, (AssetDownload transfer, Asset asset) => + var transferID = UUID.Random(); + client.Assets.RequestInventoryAsset(item, true, transferID, (transfer, asset) => { - if (transfer.Success) + if (transfer.Success && transfer.ID == transferID) { receivedAsset = asset; } @@ -276,11 +261,13 @@ private void TraverseDir(InventoryNode node, string path) ); } + backupTaskCancelToken.Token.ThrowIfCancellationRequested(); done.WaitOne(30 * 1000, false); } client.Settings.USE_ASSET_CACHE = true; + backupTaskCancelToken.Token.ThrowIfCancellationRequested(); if (receivedAsset == null) { BeginInvoke(new MethodInvoker(() => status.Text = "Failed to fetch asset")); @@ -291,6 +278,7 @@ private void TraverseDir(InventoryNode node, string path) try { + backupTaskCancelToken.Token.ThrowIfCancellationRequested(); if (!Directory.Exists(dirName)) { Directory.CreateDirectory(dirName); @@ -336,8 +324,8 @@ private void TraverseDir(InventoryNode node, string path) case AssetType.Texture: AssetTexture imgAsset = (AssetTexture)receivedAsset; - var img = LoadTGAClass.LoadTGA(new MemoryStream(imgAsset.Image.ExportTGA())); - img.Save(fullName, System.Drawing.Imaging.ImageFormat.Png); + var img = Targa.Encode(imgAsset.Image); + File.WriteAllBytes(fullName, img); if (dateOK) { File.SetCreationTimeUtc(fullName, item.CreationDate); @@ -351,10 +339,15 @@ private void TraverseDir(InventoryNode node, string path) { fileName.Text = fullName; status.Text = "Saved"; - lblStatus.Text = string.Format("Saved {0} items", ++fetched); + lblStatus.Text = $"Saved {++fetched} items"; })); } + catch (OperationCanceledException) + { + BeginInvoke(new MethodInvoker(() => status.Text = "Operation cancelled.")); + return; + } catch (Exception ex) { BeginInvoke(new MethodInvoker(() => status.Text = "Failed to save " + Path.GetFileName(fullName) + ": " + ex.Message)); @@ -364,21 +357,21 @@ private void TraverseDir(InventoryNode node, string path) } } } + catch (OperationCanceledException) + { + return; + } catch { } } } private void InventoryBackup_FormClosing(object sender, FormClosingEventArgs e) { - if (backupThread != null) + try { - if (backupThread.IsAlive) - { - backupThread.Abort(); - Thread.Sleep(1000); - } - backupThread = null; - } + backupTaskCancelToken.Cancel(); + backupTaskCancelToken.Dispose(); + } catch (ObjectDisposedException) { } } private void lvwFiles_DoubleClick(object sender, EventArgs e) diff --git a/Radegast/GUI/Consoles/Inventory/InventoryClipboard.cs b/Radegast/GUI/Consoles/Inventory/InventoryClipboard.cs index 26d330bdc..dc8f3c215 100644 --- a/Radegast/GUI/Consoles/Inventory/InventoryClipboard.cs +++ b/Radegast/GUI/Consoles/Inventory/InventoryClipboard.cs @@ -1,38 +1,24 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id: InventoryConsole.cs 446 2009-11-11 15:31:11Z latifer $ -// -using System; -using System.Collections.Generic; -using System.Text; +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using OpenMetaverse; -using System.Windows.Forms; namespace Radegast { diff --git a/Radegast/GUI/Consoles/Inventory/InventoryConsole.Designer.cs b/Radegast/GUI/Consoles/Inventory/InventoryConsole.Designer.cs index d0540d40f..d5ad05ce6 100644 --- a/Radegast/GUI/Consoles/Inventory/InventoryConsole.Designer.cs +++ b/Radegast/GUI/Consoles/Inventory/InventoryConsole.Designer.cs @@ -47,11 +47,8 @@ protected override void Dispose(bool disposing) { if (disposing && (components != null)) { - if (InventoryUpdate != null) - { - InventoryUpdate.Abort(); - InventoryUpdate = null; - } + inventoryUpdateCancelToken.Cancel(); + inventoryUpdateCancelToken.Dispose(); if (_EditTimer != null) { @@ -81,7 +78,7 @@ private void InitializeComponent() this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(InventoryConsole)); this.splitContainer1 = new System.Windows.Forms.SplitContainer(); - this.invTree = new System.Windows.Forms.TreeView(); + this.invTree = new Radegast.WinForms.BufferedTreeView(); this.ctxInv = new Radegast.RadegastContextMenuStrip(this.components); this.tstripInventory = new System.Windows.Forms.ToolStrip(); this.tlabelStatus = new System.Windows.Forms.ToolStripLabel(); @@ -102,6 +99,7 @@ private void InitializeComponent() this.groupBox2 = new System.Windows.Forms.GroupBox(); this.cbSrchRecent = new System.Windows.Forms.RadioButton(); this.cbSrchWorn = new System.Windows.Forms.RadioButton(); + this.cbSrchGestures = new System.Windows.Forms.RadioButton(); this.rbSrchAll = new System.Windows.Forms.RadioButton(); this.lblSearchStatus = new System.Windows.Forms.Label(); this.groupBox1 = new System.Windows.Forms.GroupBox(); @@ -319,7 +317,7 @@ private void InitializeComponent() this.tabSearch.Location = new System.Drawing.Point(4, 22); this.tabSearch.Name = "tabSearch"; this.tabSearch.Padding = new System.Windows.Forms.Padding(3); - this.tabSearch.Size = new System.Drawing.Size(433, 457); + this.tabSearch.Size = new System.Drawing.Size(458, 457); this.tabSearch.TabIndex = 1; this.tabSearch.Text = "Search"; this.tabSearch.UseVisualStyleBackColor = true; @@ -338,7 +336,7 @@ private void InitializeComponent() this.lstInventorySearch.Name = "lstInventorySearch"; this.lstInventorySearch.OwnerDraw = true; this.lstInventorySearch.ShowGroups = false; - this.lstInventorySearch.Size = new System.Drawing.Size(427, 363); + this.lstInventorySearch.Size = new System.Drawing.Size(452, 363); this.lstInventorySearch.Sorting = System.Windows.Forms.SortOrder.Ascending; this.lstInventorySearch.TabIndex = 30; this.lstInventorySearch.UseCompatibleStateImageBehavior = false; @@ -366,11 +364,12 @@ private void InitializeComponent() this.pnlSearchOptions.Dock = System.Windows.Forms.DockStyle.Top; this.pnlSearchOptions.Location = new System.Drawing.Point(3, 3); this.pnlSearchOptions.Name = "pnlSearchOptions"; - this.pnlSearchOptions.Size = new System.Drawing.Size(427, 88); + this.pnlSearchOptions.Size = new System.Drawing.Size(452, 88); this.pnlSearchOptions.TabIndex = 20; // // groupBox2 // + this.groupBox2.Controls.Add(this.cbSrchGestures); this.groupBox2.Controls.Add(this.cbSrchRecent); this.groupBox2.Controls.Add(this.cbSrchWorn); this.groupBox2.Controls.Add(this.rbSrchAll); @@ -381,6 +380,17 @@ private void InitializeComponent() this.groupBox2.TabStop = false; this.groupBox2.Text = "Filter"; // + // cbSrchGestures + // + this.cbSrchGestures.AutoSize = true; + this.cbSrchGestures.Location = new System.Drawing.Point(167, 19); + this.cbSrchGestures.Name = "cbSrchGestures"; + this.cbSrchGestures.Size = new System.Drawing.Size(60, 17); + this.cbSrchGestures.TabIndex = 3; + this.cbSrchGestures.Text = "Gestures"; + this.cbSrchGestures.UseVisualStyleBackColor = true; + this.cbSrchGestures.CheckedChanged += new System.EventHandler(this.rbSrchAll_CheckedChanged); + // // cbSrchRecent // this.cbSrchRecent.AutoSize = true; @@ -419,7 +429,7 @@ private void InitializeComponent() // lblSearchStatus // this.lblSearchStatus.AutoSize = true; - this.lblSearchStatus.Location = new System.Drawing.Point(335, 6); + this.lblSearchStatus.Location = new System.Drawing.Point(401, 6); this.lblSearchStatus.Name = "lblSearchStatus"; this.lblSearchStatus.Size = new System.Drawing.Size(46, 13); this.lblSearchStatus.TabIndex = 3; @@ -432,7 +442,7 @@ private void InitializeComponent() this.groupBox1.Controls.Add(this.cbSrchName); this.groupBox1.Location = new System.Drawing.Point(236, 30); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(154, 49); + this.groupBox1.Size = new System.Drawing.Size(213, 49); this.groupBox1.TabIndex = 3; this.groupBox1.TabStop = false; this.groupBox1.Text = "Search in"; @@ -478,14 +488,14 @@ private void InitializeComponent() this.txtSearch.AccessibleName = "Search input"; this.txtSearch.Location = new System.Drawing.Point(3, 3); this.txtSearch.Name = "txtSearch"; - this.txtSearch.Size = new System.Drawing.Size(227, 20); + this.txtSearch.Size = new System.Drawing.Size(293, 20); this.txtSearch.TabIndex = 0; this.txtSearch.TextChanged += new System.EventHandler(this.txtSearch_TextChanged); this.txtSearch.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtSearch_KeyDown); // // btnInvSearch // - this.btnInvSearch.Location = new System.Drawing.Point(236, 1); + this.btnInvSearch.Location = new System.Drawing.Point(302, 1); this.btnInvSearch.Name = "btnInvSearch"; this.btnInvSearch.Size = new System.Drawing.Size(96, 23); this.btnInvSearch.TabIndex = 1; @@ -676,6 +686,7 @@ private void InitializeComponent() // // txtCreator // + this.txtCreator.AgentID = ((OpenMetaverse.UUID)(resources.GetObject("txtCreator.AgentID"))); this.txtCreator.BackColor = System.Drawing.SystemColors.Window; this.txtCreator.Location = new System.Drawing.Point(80, 55); this.txtCreator.Name = "txtCreator"; @@ -768,6 +779,7 @@ private void InitializeComponent() this.splitContainer1.Panel1.ResumeLayout(false); this.splitContainer1.Panel1.PerformLayout(); this.splitContainer1.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); this.splitContainer1.ResumeLayout(false); this.tstripInventory.ResumeLayout(false); this.tstripInventory.PerformLayout(); @@ -810,8 +822,9 @@ private void InitializeComponent() public System.Windows.Forms.RadioButton rbSrchAll; public System.Windows.Forms.RadioButton cbSrchRecent; public System.Windows.Forms.RadioButton cbSrchWorn; + public System.Windows.Forms.RadioButton cbSrchGestures; public System.Windows.Forms.GroupBox gbxPerms; - public System.Windows.Forms.TreeView invTree; + public Radegast.WinForms.BufferedTreeView invTree; public System.Windows.Forms.SplitContainer splitContainer1; public RadegastContextMenuStrip ctxInv; public System.Windows.Forms.Panel pnlItemProperties; diff --git a/Radegast/GUI/Consoles/Inventory/InventoryConsole.cs b/Radegast/GUI/Consoles/Inventory/InventoryConsole.cs index 87faa8f79..0ed7f36de 100644 --- a/Radegast/GUI/Consoles/Inventory/InventoryConsole.cs +++ b/Radegast/GUI/Consoles/Inventory/InventoryConsole.cs @@ -1,87 +1,75 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/* + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2021, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; -using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; +using System.Globalization; using System.Linq; using System.Windows.Forms; -#if (COGBOT_LIBOMV || USE_STHREADS) -using ThreadPoolUtil; -using Thread = ThreadPoolUtil.Thread; -using ThreadPool = ThreadPoolUtil.ThreadPool; -using Monitor = ThreadPoolUtil.Monitor; -#endif using System.Threading; +using System.Threading.Tasks; using OpenMetaverse; using OpenMetaverse.StructuredData; +using Radegast.Core; +using Radegast.WinForms; namespace Radegast { public partial class InventoryConsole : UserControl { - RadegastInstance instance; - GridClient client { get { return instance.Client; } } - Dictionary FolderNodes = new Dictionary(); + private const int updateInterval = 1000; + + private readonly RadegastInstance instance; + GridClient Client => instance.Client; private InventoryManager Manager; - private OpenMetaverse.Inventory Inventory; + private readonly Inventory Inventory; private TreeNode invRootNode; private string newItemName = string.Empty; - private List fetchedFolders = new List(); + private readonly List fetchedFolders = new List(); private System.Threading.Timer _EditTimer; private TreeNode _EditNode; - private Dictionary attachments = new Dictionary(); + private readonly Dictionary attachments = new Dictionary(); private System.Timers.Timer TreeUpdateTimer; - private Queue ItemsToAdd = new Queue(); - private Queue ItemsToUpdate = new Queue(); + private readonly Queue ItemsToAdd = new Queue(); + private readonly Queue ItemsToUpdate = new Queue(); private bool TreeUpdateInProgress = false; - private Dictionary UUID2NodeCache = new Dictionary(); - private int updateInterval = 1000; - private Thread InventoryUpdate; - private List WornItems = new List(); - private bool appearnceWasBusy; + private readonly Dictionary UUID2NodeCache = new Dictionary(); + private readonly List WornItems = new List(); + private bool appearanceWasBusy; private InvNodeSorter sorter; - private List QueuedFolders = new List(); - private Dictionary FolderFetchRetries = new Dictionary(); - AutoResetEvent trashCreated = new AutoResetEvent(false); + private readonly List QueuedFolders = new List(); + private readonly Dictionary FolderFetchRetries = new Dictionary(); + private readonly AutoResetEvent trashCreated = new AutoResetEvent(false); + private Task inventoryUpdateTask; + private CancellationTokenSource inventoryUpdateCancelToken; #region Construction and disposal public InventoryConsole(RadegastInstance instance) { InitializeComponent(); - Disposed += new EventHandler(InventoryConsole_Disposed); + Disposed += InventoryConsole_Disposed; TreeUpdateTimer = new System.Timers.Timer() { @@ -92,22 +80,22 @@ public InventoryConsole(RadegastInstance instance) TreeUpdateTimer.Elapsed += TreeUpdateTimerTick; this.instance = instance; - Manager = client.Inventory; + Manager = Client.Inventory; Inventory = Manager.Store; - Inventory.RootFolder.OwnerID = client.Self.AgentID; + Inventory.RootFolder.OwnerID = Client.Self.AgentID; invTree.ImageList = frmMain.ResourceImages; invRootNode = AddDir(null, Inventory.RootFolder); UpdateStatus("Reading cache"); Init1(); - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } public void Init1() { - WorkPool.QueueUserWorkItem(sync => + ThreadPool.QueueUserWorkItem(sync => { - Logger.Log("Reading inventory cache from " + instance.InventoryCacheFileName, Helpers.LogLevel.Debug, client); + Logger.Log($"Reading inventory cache from {instance.InventoryCacheFileName}", Helpers.LogLevel.Debug, Client); Inventory.RestoreFromDisk(instance.InventoryCacheFileName); Init2(); }); @@ -117,7 +105,7 @@ public void Init2() { if (instance.MainForm.InvokeRequired) { - instance.MainForm.BeginInvoke(new MethodInvoker(() => Init2())); + instance.MainForm.BeginInvoke(new MethodInvoker(Init2)); return; } @@ -143,66 +131,73 @@ public void Init2() { invTree.BackColor = Color.FromKnownColor(KnownColor.Window); invTree.ForeColor = invTree.LineColor = Color.FromKnownColor(KnownColor.WindowText); - InventoryFolder f = new InventoryFolder(UUID.Random()); - f.Name = ""; - f.ParentUUID = UUID.Zero; - f.PreferredType = FolderType.None; - TreeNode dirNode = new TreeNode(); - dirNode.Name = f.UUID.ToString(); - dirNode.Text = f.Name; - dirNode.Tag = f; - dirNode.ImageIndex = GetDirImageIndex(f.PreferredType.ToString().ToLower()); + InventoryFolder f = new InventoryFolder(UUID.Random()) + { + Name = "", + ParentUUID = UUID.Zero, + PreferredType = FolderType.None + }; + TreeNode dirNode = new TreeNode + { + Name = f.UUID.ToString(), + Text = f.Name, + Tag = f, + ImageIndex = GetDirImageIndex(f.PreferredType.ToString().ToLower()) + }; dirNode.SelectedImageIndex = dirNode.ImageIndex; invTree.Nodes.Add(dirNode); invTree.Sort(); } saveAllTToolStripMenuItem.Enabled = false; - InventoryUpdate = new Thread(new ThreadStart(StartTraverseNodes)); - InventoryUpdate.Name = "InventoryUpdate"; - InventoryUpdate.IsBackground = true; - InventoryUpdate.Start(); + + inventoryUpdateCancelToken = new CancellationTokenSource(); + + inventoryUpdateTask = Task.Factory.StartNew(StartTraverseNodes, + inventoryUpdateCancelToken.Token, TaskCreationOptions.LongRunning, TaskScheduler.Current); invRootNode.Expand(); - invTree.AfterExpand += new TreeViewEventHandler(TreeView_AfterExpand); - invTree.NodeMouseClick += new TreeNodeMouseClickEventHandler(invTree_MouseClick); - invTree.NodeMouseDoubleClick += new TreeNodeMouseClickEventHandler(invTree_NodeMouseDoubleClick); + invTree.AfterExpand += TreeView_AfterExpand; + invTree.NodeMouseClick += invTree_MouseClick; + invTree.NodeMouseDoubleClick += invTree_NodeMouseDoubleClick; - _EditTimer = new System.Threading.Timer(OnLabelEditTimer, null, System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite); + _EditTimer = new System.Threading.Timer(OnLabelEditTimer, null, Timeout.Infinite, Timeout.Infinite); // Callbacks - Inventory.InventoryObjectAdded += new EventHandler(Inventory_InventoryObjectAdded); - Inventory.InventoryObjectUpdated += new EventHandler(Inventory_InventoryObjectUpdated); - Inventory.InventoryObjectRemoved += new EventHandler(Inventory_InventoryObjectRemoved); + Inventory.InventoryObjectAdded += Inventory_InventoryObjectAdded; + Inventory.InventoryObjectUpdated += Inventory_InventoryObjectUpdated; + Inventory.InventoryObjectRemoved += Inventory_InventoryObjectRemoved; - client.Objects.ObjectUpdate += new EventHandler(Objects_AttachmentUpdate); - client.Objects.KillObject += new EventHandler(Objects_KillObject); - client.Appearance.AppearanceSet += new EventHandler(Appearance_AppearanceSet); + Client.Objects.ObjectUpdate += Objects_AttachmentUpdate; + Client.Objects.KillObject += Objects_KillObject; + Client.Appearance.AppearanceSet += Appearance_AppearanceSet; } void InventoryConsole_Disposed(object sender, EventArgs e) { + GestureManager.Instance.StopMonitoring(); + if (TreeUpdateTimer != null) { TreeUpdateTimer.Stop(); TreeUpdateTimer.Dispose(); TreeUpdateTimer = null; } - if (InventoryUpdate != null) + try { - if (InventoryUpdate.IsAlive) - InventoryUpdate.Abort(); - InventoryUpdate = null; + inventoryUpdateCancelToken.Cancel(); + inventoryUpdateCancelToken.Dispose(); } + catch (ObjectDisposedException) { } - Inventory.InventoryObjectAdded -= new EventHandler(Inventory_InventoryObjectAdded); - Inventory.InventoryObjectUpdated -= new EventHandler(Inventory_InventoryObjectUpdated); - Inventory.InventoryObjectRemoved -= new EventHandler(Inventory_InventoryObjectRemoved); + Inventory.InventoryObjectAdded -= Inventory_InventoryObjectAdded; + Inventory.InventoryObjectUpdated -= Inventory_InventoryObjectUpdated; + Inventory.InventoryObjectRemoved -= Inventory_InventoryObjectRemoved; - client.Objects.ObjectUpdate -= new EventHandler(Objects_AttachmentUpdate); - client.Objects.KillObject -= new EventHandler(Objects_KillObject); - client.Appearance.AppearanceSet -= new EventHandler(Appearance_AppearanceSet); + Client.Objects.ObjectUpdate -= Objects_AttachmentUpdate; + Client.Objects.KillObject -= Objects_KillObject; + Client.Appearance.AppearanceSet -= Appearance_AppearanceSet; } #endregion @@ -210,10 +205,10 @@ void InventoryConsole_Disposed(object sender, EventArgs e) void Appearance_AppearanceSet(object sender, AppearanceSetEventArgs e) { UpdateWornLabels(); - if (appearnceWasBusy) + if (appearanceWasBusy) { - appearnceWasBusy = false; - client.Appearance.RequestSetAppearance(true); + appearanceWasBusy = false; + Client.Appearance.RequestSetAppearance(true); } } @@ -231,11 +226,10 @@ void Objects_KillObject(object sender, KillObjectEventArgs e) } } - if (attachment != null) - { - attachments.Remove(attachment.InventoryID); - UpdateNodeLabel(attachment.InventoryID); - } + if (attachment == null) return; + + attachments.Remove(attachment.InventoryID); + UpdateNodeLabel(attachment.InventoryID); } } @@ -243,66 +237,68 @@ void Objects_AttachmentUpdate(object sender, PrimEventArgs e) { Primitive prim = e.Prim; - if (client.Self.LocalID == 0 || - prim.ParentID != client.Self.LocalID || + if (Client.Self.LocalID == 0 || + prim.ParentID != Client.Self.LocalID || prim.NameValues == null) return; for (int i = 0; i < prim.NameValues.Length; i++) { - if (prim.NameValues[i].Name == "AttachItemID") + if (prim.NameValues[i].Name != "AttachItemID") continue; + + AttachmentInfo attachment = new AttachmentInfo { - AttachmentInfo attachment = new AttachmentInfo(); - attachment.Prim = prim; - attachment.InventoryID = new UUID(prim.NameValues[i].Value.ToString()); - attachment.PrimID = prim.ID; + Prim = prim, + InventoryID = new UUID(prim.NameValues[i].Value.ToString()), + PrimID = prim.ID + }; - lock (attachments) + lock (attachments) + { + // Add new attachment info + if (!attachments.ContainsKey(attachment.InventoryID)) { - // Add new attachment info - if (!attachments.ContainsKey(attachment.InventoryID)) - { - attachments.Add(attachment.InventoryID, attachment); + attachments.Add(attachment.InventoryID, attachment); - } - else + } + else + { + attachment = attachments[attachment.InventoryID]; + if (attachment.Prim == null) { - attachment = attachments[attachment.InventoryID]; - if (attachment.Prim == null) - { - attachment.Prim = prim; - } + attachment.Prim = prim; } + } - // Don't update the tree yet if we're still updating invetory tree from server - if (!TreeUpdateInProgress) + // Don't update the tree yet if we're still updating invetory tree from server + if (!TreeUpdateInProgress) + { + if (Inventory.Contains(attachment.InventoryID)) { - if (Inventory.Contains(attachment.InventoryID)) + if (attachment.Item == null) { - if (attachment.Item == null) - { - InventoryItem item = (InventoryItem)Inventory[attachment.InventoryID]; - attachment.Item = item; - } - if (!attachment.MarkedAttached) - { - attachment.MarkedAttached = true; - UpdateNodeLabel(attachment.InventoryID); - } + InventoryItem item = (InventoryItem)Inventory[attachment.InventoryID]; + attachment.Item = item; } - else + if (!attachment.MarkedAttached) { - client.Inventory.RequestFetchInventory(attachment.InventoryID, client.Self.AgentID); + attachment.MarkedAttached = true; + UpdateNodeLabel(attachment.InventoryID); } } + else + { + Client.Inventory.RequestFetchInventory(attachment.InventoryID, Client.Self.AgentID); + } } - break; } + break; } } void Inventory_InventoryObjectAdded(object sender, InventoryObjectAddedEventArgs e) { - if (e.Obj is InventoryFolder && ((InventoryFolder)e.Obj).PreferredType == FolderType.Trash) + if (e.Obj is InventoryFolder folder + && folder.PreferredType == FolderType.Trash) { trashCreated.Set(); } @@ -463,57 +459,54 @@ public static int GetDirImageIndex(string t) { t = System.Text.RegularExpressions.Regex.Replace(t, @"folder$", ""); int res = frmMain.ImageNames.IndexOf("inv_folder_" + t); - if (res == -1) + if (res != -1) return res; + + switch (t) { - switch (t) - { - case "currentoutfit": - case "myoutfits": - return frmMain.ImageNames.IndexOf("inv_folder_outfit"); - case "lsltext": - return frmMain.ImageNames.IndexOf("inv_folder_script"); - } - return frmMain.ImageNames.IndexOf("inv_folder_plain_closed"); + case "currentoutfit": + case "myoutfits": + return frmMain.ImageNames.IndexOf("inv_folder_outfit"); + case "lsltext": + return frmMain.ImageNames.IndexOf("inv_folder_script"); } - return res; + return frmMain.ImageNames.IndexOf("inv_folder_plain_closed"); } public static int GetItemImageIndex(string t) { int res = frmMain.ImageNames.IndexOf("inv_item_" + t); - if (res == -1) + if (res != -1) return res; + + if (t == "lsltext") { - if (t == "lsltext") - { - return frmMain.ImageNames.IndexOf("inv_item_script"); - } - else if (t == "callingcard") - { - return frmMain.ImageNames.IndexOf("inv_item_callingcard_offline"); - } + return frmMain.ImageNames.IndexOf("inv_item_script"); + } + else if (t == "callingcard") + { + return frmMain.ImageNames.IndexOf("inv_item_callingcard_offline"); } return res; } TreeNode AddBase(TreeNode parent, InventoryBase obj) { - if (obj is InventoryItem) - { - return AddItem(parent, (InventoryItem)obj); - } - else + if (obj is InventoryItem item) { - return AddDir(parent, (InventoryFolder)obj); + return AddItem(parent, item); } + + return AddDir(parent, (InventoryFolder)obj); } TreeNode AddDir(TreeNode parentNode, InventoryFolder f) { - TreeNode dirNode = new TreeNode(); - dirNode.Name = f.UUID.ToString(); - dirNode.Text = f.Name; - dirNode.Tag = f; - dirNode.ImageIndex = GetDirImageIndex(f.PreferredType.ToString().ToLower()); + TreeNode dirNode = new TreeNode + { + Name = f.UUID.ToString(), + Text = f.Name, + Tag = f, + ImageIndex = GetDirImageIndex(f.PreferredType.ToString().ToLower()) + }; dirNode.SelectedImageIndex = dirNode.ImageIndex; if (parentNode == null) { @@ -533,10 +526,12 @@ TreeNode AddDir(TreeNode parentNode, InventoryFolder f) TreeNode AddItem(TreeNode parent, InventoryItem item) { - TreeNode itemNode = new TreeNode(); - itemNode.Name = item.UUID.ToString(); - itemNode.Text = ItemLabel(item, false); - itemNode.Tag = item; + TreeNode itemNode = new TreeNode + { + Name = item.UUID.ToString(), + Text = ItemLabel(item, false), + Tag = item + }; int img = -1; InventoryItem linkedItem = null; @@ -549,10 +544,9 @@ TreeNode AddItem(TreeNode parent, InventoryItem item) linkedItem = item; } - if (linkedItem is InventoryWearable) + if (linkedItem is InventoryWearable wearable) { - InventoryWearable w = linkedItem as InventoryWearable; - img = GetItemImageIndex(w.WearableType.ToString().ToLower()); + img = GetItemImageIndex(wearable.WearableType.ToString().ToLower()); } else { @@ -584,16 +578,15 @@ TreeNode findNodeForItem(UUID itemID) void cacheNode(TreeNode node) { InventoryBase item = (InventoryBase)node.Tag; - if (item != null) + if (item == null) return; + + foreach (TreeNode child in node.Nodes) { - foreach (TreeNode child in node.Nodes) - { - cacheNode(child); - } - lock (UUID2NodeCache) - { - UUID2NodeCache[item.UUID] = node; - } + cacheNode(child); + } + lock (UUID2NodeCache) + { + UUID2NodeCache[item.UUID] = node; } } @@ -604,7 +597,8 @@ void removeNode(TreeNode node) { foreach (TreeNode child in node.Nodes) { - removeNode(child); + if (child != null) + removeNode(child); } lock (UUID2NodeCache) @@ -655,25 +649,16 @@ private void AddFolderFromStore(TreeNode parent, InventoryFolder f) foreach (InventoryBase item in contents) { TreeNode node = AddBase(parent, item); - if (item is InventoryFolder) + if (item is InventoryFolder folder) { - AddFolderFromStore(node, (InventoryFolder)item); + AddFolderFromStore(node, folder); } } } private void TraverseAndQueueNodes(InventoryNode start) { - bool has_items = false; - - foreach (InventoryNode node in start.Nodes.Values) - { - if (node.Data is InventoryItem) - { - has_items = true; - break; - } - } + bool has_items = start.Nodes.Values.Any(node => node.Data is InventoryItem); if (!has_items || start.NeedsUpdate) { @@ -706,16 +691,7 @@ private void TraverseAndQueueNodes(InventoryNode start) private void TraverseNodes(InventoryNode start) { - bool has_items = false; - - foreach (InventoryNode node in start.Nodes.Values) - { - if (node.Data is InventoryItem) - { - has_items = true; - break; - } - } + bool has_items = start.Nodes.Values.Any(node => node.Data is InventoryItem); if (!has_items || start.NeedsUpdate) { @@ -723,26 +699,26 @@ private void TraverseNodes(InventoryNode start) AutoResetEvent gotFolderEvent = new AutoResetEvent(false); bool success = false; - EventHandler callback = delegate(object sender, FolderUpdatedEventArgs ea) + void FolderUpdatedCB(object sender, FolderUpdatedEventArgs ea) { - if (f.UUID == ea.FolderID) - { - if (((InventoryFolder)Inventory.Items[ea.FolderID].Data).DescendentCount <= Inventory.Items[ea.FolderID].Nodes.Count) - { - success = true; - gotFolderEvent.Set(); - } - } - }; + if (f.UUID != ea.FolderID) return; + if (((InventoryFolder) Inventory.Items[ea.FolderID].Data).DescendentCount > + Inventory.Items[ea.FolderID].Nodes.Count) return; - client.Inventory.FolderUpdated += callback; - fetchFolder(f.UUID, f.OwnerID, true); + success = true; + gotFolderEvent.Set(); + } + + Client.Inventory.FolderUpdated += FolderUpdatedCB; + FetchFolder(f.UUID, f.OwnerID, true); gotFolderEvent.WaitOne(30 * 1000, false); - client.Inventory.FolderUpdated -= callback; + Client.Inventory.FolderUpdated -= FolderUpdatedCB; if (!success) { - Logger.Log(string.Format("Failed fetching folder {0}, got {1} items out of {2}", f.Name, Inventory.Items[f.UUID].Nodes.Count, ((InventoryFolder)Inventory.Items[f.UUID].Data).DescendentCount), Helpers.LogLevel.Error, client); + Logger.Log( + $"Failed fetching folder {f.Name}, got {Inventory.Items[f.UUID].Nodes.Count} items out of {((InventoryFolder) Inventory.Items[f.UUID].Data).DescendentCount}", + Helpers.LogLevel.Error, Client); } } @@ -757,19 +733,21 @@ private void TraverseNodes(InventoryNode start) private void StartTraverseNodes() { - if (!client.Network.CurrentSim.Caps.IsEventQueueRunning) + if (!Client.Network.CurrentSim.Caps.IsEventQueueRunning) { AutoResetEvent EQRunning = new AutoResetEvent(false); - EventHandler handler = (sender, e) => - { - EQRunning.Set(); - }; - client.Network.EventQueueRunning += handler; + + void RunningHandler(object sender, EventQueueRunningEventArgs e) + { + EQRunning.Set(); + } + + Client.Network.EventQueueRunning += RunningHandler; EQRunning.WaitOne(10 * 1000, false); - client.Network.EventQueueRunning -= handler; + Client.Network.EventQueueRunning -= RunningHandler; } - if (!client.Network.CurrentSim.Caps.IsEventQueueRunning) + if (!Client.Network.CurrentSim.Caps.IsEventQueueRunning) { return; } @@ -791,29 +769,29 @@ private void StartTraverseNodes() } TraverseAndQueueNodes(Inventory.RootNode); if (QueuedFolders.Count == 0) break; - Logger.DebugLog(string.Format("Queued {0} folders for update", QueuedFolders.Count)); + Logger.DebugLog($"Queued {QueuedFolders.Count} folders for update"); System.Threading.Tasks.Parallel.ForEach(QueuedFolders, folderID => { bool success = false; AutoResetEvent gotFolder = new AutoResetEvent(false); - EventHandler handler = (sender, ev) => - { - if (ev.FolderID == folderID) - { - success = ev.Success; - gotFolder.Set(); - } - }; - client.Inventory.FolderUpdated += handler; - client.Inventory.RequestFolderContents(folderID, client.Self.AgentID, true, true, InventorySortOrder.ByDate); + void updateHandler(object sender, FolderUpdatedEventArgs ev) + { + if (ev.FolderID != folderID) return; + + success = ev.Success; + gotFolder.Set(); + } + + Client.Inventory.FolderUpdated += updateHandler; + Client.Inventory.RequestFolderContents(folderID, Client.Self.AgentID, true, true, InventorySortOrder.ByDate); if (!gotFolder.WaitOne(15 * 1000, false)) { success = false; } - client.Inventory.FolderUpdated -= handler; + Client.Inventory.FolderUpdated -= updateHandler; }); } while (QueuedFolders.Count > 0); @@ -827,11 +805,11 @@ private void StartTraverseNodes() UpdateStatus("OK"); instance.TabConsole.DisplayNotificationInChat("Inventory update completed."); - if ((client.Network.LoginResponseData.FirstLogin) && !string.IsNullOrEmpty(client.Network.LoginResponseData.InitialOutfit)) + if ((Client.Network.LoginResponseData.FirstLogin) && !string.IsNullOrEmpty(Client.Network.LoginResponseData.InitialOutfit)) { - client.Self.SetAgentAccess("A"); - var initOufit = new InitialOutfit(instance); - initOufit.SetInitialOutfit(client.Network.LoginResponseData.InitialOutfit); + Client.Self.SetAgentAccess("A"); + var initOutfit = new InitialOutfit(instance); + initOutfit.SetInitialOutfit(Client.Network.LoginResponseData.InitialOutfit); } // Updated labels on clothes that we are wearing @@ -842,25 +820,25 @@ private void StartTraverseNodes() { foreach (AttachmentInfo a in attachments.Values) { - if (a.Item == null) + if (a.Item != null) continue; + if (Inventory.Contains(a.InventoryID)) { - if (Inventory.Contains(a.InventoryID)) - { - a.MarkedAttached = true; - a.Item = (InventoryItem)Inventory[a.InventoryID]; - UpdateNodeLabel(a.InventoryID); - } - else - { - client.Inventory.RequestFetchInventory(a.InventoryID, client.Self.AgentID); - return; - } + a.MarkedAttached = true; + a.Item = (InventoryItem)Inventory[a.InventoryID]; + UpdateNodeLabel(a.InventoryID); + } + else + { + Client.Inventory.RequestFetchInventory(a.InventoryID, Client.Self.AgentID); + return; } } } - Logger.Log("Finished updating invenory folders, saving cache...", Helpers.LogLevel.Debug, client); - WorkPool.QueueUserWorkItem((object state) => Inventory.SaveToDisk(instance.InventoryCacheFileName)); + Logger.Log("Finished updating inventory folders, saving cache...", Helpers.LogLevel.Debug, Client); + GestureManager.Instance.BeginMonitoring(); + + ThreadPool.QueueUserWorkItem(state => Inventory.SaveToDisk(instance.InventoryCacheFileName)); if (!instance.MonoRuntime || IsHandleCreated) Invoke(new MethodInvoker(() => @@ -877,8 +855,7 @@ public void ReloadInventory() if (TreeUpdateInProgress) { TreeUpdateTimer.Stop(); - InventoryUpdate.Abort(); - InventoryUpdate = null; + inventoryUpdateCancelToken.Cancel(); } saveAllTToolStripMenuItem.Enabled = false; @@ -891,10 +868,9 @@ public void ReloadInventory() invRootNode = AddDir(null, Inventory.RootFolder); Inventory.RootNode.NeedsUpdate = true; - InventoryUpdate = new Thread(new ThreadStart(StartTraverseNodes)); - InventoryUpdate.Name = "InventoryUpdate"; - InventoryUpdate.IsBackground = true; - InventoryUpdate.Start(); + Task inventoryUpdateTask = Task.Factory.StartNew(StartTraverseNodes, + inventoryUpdateCancelToken.Token, TaskCreationOptions.LongRunning, TaskScheduler.Current); + invRootNode.Expand(); } @@ -903,7 +879,7 @@ private void reloadInventoryToolStripMenuItem_Click(object sender, EventArgs e) ReloadInventory(); } - private void TreeUpdateTimerTick(Object sender, EventArgs e) + private void TreeUpdateTimerTick(object sender, EventArgs e) { lock (ItemsToAdd) { @@ -937,7 +913,7 @@ private void TreeUpdateTimerTick(Object sender, EventArgs e) } } - UpdateStatus("Loading... " + UUID2NodeCache.Count.ToString() + " items"); + UpdateStatus("Loading... " + UUID2NodeCache.Count + " items"); } #endregion @@ -968,16 +944,9 @@ void UpdateItemInfo(InventoryItem item) txtItemDescription.Text = item.Description; txtCreator.AgentID = item.CreatorID; txtCreator.Tag = item.CreatorID; - txtCreated.Text = item.CreationDate.ToString(); + txtCreated.Text = item.CreationDate.ToString(CultureInfo.InvariantCulture); - if (item.AssetUUID != UUID.Zero) - { - txtAssetID.Text = item.AssetUUID.ToString(); - } - else - { - txtAssetID.Text = String.Empty; - } + txtAssetID.Text = item.AssetUUID != UUID.Zero ? item.AssetUUID.ToString() : string.Empty; txtInvID.Text = item.UUID.ToString(); @@ -1031,7 +1000,7 @@ void UpdateItemInfo(InventoryItem item) break; case AssetType.Gesture: - Guesture gesture = new Guesture(instance, (InventoryGesture)item); + Gesture gesture = new Gesture(instance, (InventoryGesture)item); gesture.Dock = DockStyle.Fill; pnlDetail.Controls.Add(gesture); break; @@ -1044,9 +1013,9 @@ void UpdateItemInfo(InventoryItem item) void cbNextOwnerUpdate_CheckedChanged(object sender, EventArgs e) { InventoryItem item = null; - if (pnlItemProperties.Tag != null && pnlItemProperties.Tag is InventoryItem) + if (pnlItemProperties.Tag is InventoryItem tag) { - item = (InventoryItem)pnlItemProperties.Tag; + item = tag; } if (item == null) return; @@ -1056,101 +1025,97 @@ void cbNextOwnerUpdate_CheckedChanged(object sender, EventArgs e) if (cbNextOwnTransfer.Checked) pm |= PermissionMask.Transfer; item.Permissions.NextOwnerMask = pm; - client.Inventory.RequestUpdateItem(item); - client.Inventory.RequestFetchInventory(item.UUID, item.OwnerID); + Client.Inventory.RequestUpdateItem(item); + Client.Inventory.RequestFetchInventory(item.UUID, item.OwnerID); } private void txtItemName_Leave(object sender, EventArgs e) { InventoryItem item = null; - if (pnlItemProperties.Tag != null && pnlItemProperties.Tag is InventoryItem) + if (pnlItemProperties.Tag is InventoryItem tag) { - item = (InventoryItem)pnlItemProperties.Tag; + item = tag; } if (item == null) return; item.Name = txtItemName.Text; - client.Inventory.RequestUpdateItem(item); - client.Inventory.RequestFetchInventory(item.UUID, item.OwnerID); + Client.Inventory.RequestUpdateItem(item); + Client.Inventory.RequestFetchInventory(item.UUID, item.OwnerID); } private void txtItemDescription_Leave(object sender, EventArgs e) { InventoryItem item = null; - if (pnlItemProperties.Tag != null && pnlItemProperties.Tag is InventoryItem) + if (pnlItemProperties.Tag is InventoryItem tag) { - item = (InventoryItem)pnlItemProperties.Tag; + item = tag; } if (item == null) return; item.Description = txtItemDescription.Text; - client.Inventory.RequestUpdateItem(item); - client.Inventory.RequestFetchInventory(item.UUID, item.OwnerID); + Client.Inventory.RequestUpdateItem(item); + Client.Inventory.RequestFetchInventory(item.UUID, item.OwnerID); } void invTree_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) { - if (invTree.SelectedNode.Tag is InventoryItem) - { - InventoryItem item = invTree.SelectedNode.Tag as InventoryItem; - item = instance.COF.RealInventoryItem(item); + if (!(invTree.SelectedNode.Tag is InventoryItem item)) { return; } + item = instance.COF.RealInventoryItem(item); - switch (item.AssetType) - { - - case AssetType.Landmark: - instance.TabConsole.DisplayNotificationInChat("Teleporting to " + item.Name); - client.Self.RequestTeleport(item.AssetUUID); - break; + switch (item.AssetType) + { + case AssetType.Landmark: + instance.TabConsole.DisplayNotificationInChat($"Teleporting to {item.Name}"); + Client.Self.RequestTeleport(item.AssetUUID); + break; - case AssetType.Gesture: - client.Self.PlayGesture(item.AssetUUID); - break; + case AssetType.Gesture: + Client.Self.PlayGesture(item.AssetUUID); + break; - case AssetType.Notecard: - Notecard note = new Notecard(instance, (InventoryNotecard)item); - note.Dock = DockStyle.Fill; - note.ShowDetached(); - break; + case AssetType.Notecard: + Notecard note = new Notecard(instance, (InventoryNotecard)item); + note.Dock = DockStyle.Fill; + note.ShowDetached(); + break; - case AssetType.LSLText: - ScriptEditor script = new ScriptEditor(instance, (InventoryLSL)item); - script.Dock = DockStyle.Fill; - script.ShowDetached(); - break; + case AssetType.LSLText: + ScriptEditor script = new ScriptEditor(instance, (InventoryLSL)item); + script.Dock = DockStyle.Fill; + script.ShowDetached(); + break; - case AssetType.Object: - if (IsAttached(item)) - { - instance.COF.Detach(item); - } - else - { - instance.COF.Attach(item, AttachmentPoint.Default, true); - } - break; + case AssetType.Object: + if (IsAttached(item)) + { + instance.COF.Detach(item); + } + else + { + instance.COF.Attach(item, AttachmentPoint.Default, true); + } + break; - case AssetType.Bodypart: - case AssetType.Clothing: - if (IsWorn(item)) - { - if (item.AssetType == AssetType.Clothing) - { - instance.COF.RemoveFromOutfit(item); - } - } - else + case AssetType.Bodypart: + case AssetType.Clothing: + if (IsWorn(item)) + { + if (item.AssetType == AssetType.Clothing) { - instance.COF.AddToOutfit(item, true); + instance.COF.RemoveFromOutfit(item); } - break; - } + } + else + { + instance.COF.AddToOutfit(item, true); + } + break; } } - private void fetchFolder(UUID folderID, UUID ownerID, bool force) + private void FetchFolder(UUID folderID, UUID ownerID, bool force) { if (force || !fetchedFolders.Contains(folderID)) { @@ -1159,13 +1124,13 @@ private void fetchFolder(UUID folderID, UUID ownerID, bool force) fetchedFolders.Add(folderID); } - client.Inventory.RequestFolderContents(folderID, ownerID, true, true, InventorySortOrder.ByDate); + Client.Inventory.RequestFolderContents(folderID, ownerID, true, true, InventorySortOrder.ByDate); } } public bool IsWorn(InventoryItem item) { - bool worn = client.Appearance.IsItemWorn(item) != WearableType.Invalid; + bool worn = Client.Appearance.IsItemWorn(item) != WearableType.Invalid; lock (WornItems) { @@ -1190,7 +1155,7 @@ public AttachmentPoint AttachedTo(InventoryItem item) public bool IsAttached(InventoryItem item) { - List myAtt = client.Network.CurrentSim.ObjectsPrimitives.FindAll((Primitive p) => p.ParentID == client.Self.LocalID); + var myAtt = Client.Network.CurrentSim.ObjectsPrimitives.FindAll(p => p.ParentID == Client.Self.LocalID); foreach (Primitive prim in myAtt) { if (prim.NameValues == null) continue; @@ -1207,18 +1172,19 @@ public bool IsAttached(InventoryItem item) { lock (attachments) { - AttachmentInfo inf = new AttachmentInfo(); - inf.InventoryID = item.UUID; - inf.Item = item; - inf.MarkedAttached = true; - inf.Prim = prim; - inf.PrimID = prim.ID; + AttachmentInfo inf = new AttachmentInfo + { + InventoryID = item.UUID, + Item = item, + MarkedAttached = true, + Prim = prim, + PrimID = prim.ID + }; attachments[invID] = inf; } return true; } } - return false; } @@ -1226,12 +1192,10 @@ public InventoryItem AttachmentAt(AttachmentPoint point) { lock (attachments) { - foreach (KeyValuePair att in attachments) + foreach (var att in attachments + .Where(att => att.Value.Point == point)) { - if (att.Value.Point == point) - { - return att.Value.Item; - } + return att.Value.Item; } } return null; @@ -1262,21 +1226,32 @@ public string ItemLabel(InventoryBase invBase, bool returnRaw) } } + if (item is InventoryGesture) + { + if (instance.Client.Self.ActiveGestures.ContainsKey(item.UUID)) + { + raw += " (active)"; + } + } if ((item.Permissions.OwnerMask & PermissionMask.Modify) == 0) + { raw += " (no modify)"; - + } if ((item.Permissions.OwnerMask & PermissionMask.Copy) == 0) + { raw += " (no copy)"; - + } if ((item.Permissions.OwnerMask & PermissionMask.Transfer) == 0) + { raw += " (no transfer)"; - + } if (IsWorn(item)) + { raw += " (worn)"; - + } if (IsAttached(item)) { - raw += " (worn on " + AttachedTo(item).ToString() + ")"; + raw += " (worn on " + AttachedTo(item) + ")"; } return raw; @@ -1284,18 +1259,9 @@ public string ItemLabel(InventoryBase invBase, bool returnRaw) public static bool IsFullPerm(InventoryItem item) { - if ( - ((item.Permissions.OwnerMask & PermissionMask.Modify) != 0) && - ((item.Permissions.OwnerMask & PermissionMask.Copy) != 0) && - ((item.Permissions.OwnerMask & PermissionMask.Transfer) != 0) - ) - { - return true; - } - else - { - return false; - } + return (item.Permissions.OwnerMask & PermissionMask.Modify) != 0 && + (item.Permissions.OwnerMask & PermissionMask.Copy) != 0 && + (item.Permissions.OwnerMask & PermissionMask.Transfer) != 0; } void invTree_MouseClick(object sender, TreeNodeMouseClickEventArgs e) @@ -1305,9 +1271,9 @@ void invTree_MouseClick(object sender, TreeNodeMouseClickEventArgs e) if (e.Button == MouseButtons.Left) { invTree.SelectedNode = node; - if (node.Tag is InventoryItem) + if (node.Tag is InventoryItem tag) { - UpdateItemInfo(instance.COF.RealInventoryItem(node.Tag as InventoryItem)); + UpdateItemInfo(instance.COF.RealInventoryItem(tag)); } else { @@ -1342,88 +1308,78 @@ private void ctxInv_Opening(object sender, CancelEventArgs e) if (folder.PreferredType >= FolderType.EnsembleStart && folder.PreferredType <= FolderType.EnsembleEnd) { - ctxItem = new ToolStripMenuItem("Fix type", null, OnInvContextClick); - ctxItem.Name = "fix_type"; + ctxItem = new ToolStripMenuItem("Fix type", null, OnInvContextClick) {Name = "fix_type"}; ctxInv.Items.Add(ctxItem); ctxInv.Items.Add(new ToolStripSeparator()); } - ctxItem = new ToolStripMenuItem("New Folder", null, OnInvContextClick); - ctxItem.Name = "new_folder"; + ctxItem = new ToolStripMenuItem("New Folder", null, OnInvContextClick) {Name = "new_folder"}; ctxInv.Items.Add(ctxItem); - ctxItem = new ToolStripMenuItem("New Note", null, OnInvContextClick); - ctxItem.Name = "new_notecard"; + ctxItem = new ToolStripMenuItem("New Note", null, OnInvContextClick) {Name = "new_notecard"}; ctxInv.Items.Add(ctxItem); - ctxItem = new ToolStripMenuItem("New Script", null, OnInvContextClick); - ctxItem.Name = "new_script"; + ctxItem = new ToolStripMenuItem("New Script", null, OnInvContextClick) {Name = "new_script"}; ctxInv.Items.Add(ctxItem); - ctxItem = new ToolStripMenuItem("Refresh", null, OnInvContextClick); - ctxItem.Name = "refresh"; + ctxItem = new ToolStripMenuItem("Refresh", null, OnInvContextClick) {Name = "refresh"}; ctxInv.Items.Add(ctxItem); - ctxItem = new ToolStripMenuItem("Backup...", null, OnInvContextClick); - ctxItem.Name = "backup"; + ctxItem = new ToolStripMenuItem("Backup...", null, OnInvContextClick) {Name = "backup"}; ctxInv.Items.Add(ctxItem); ctxInv.Items.Add(new ToolStripSeparator()); - ctxItem = new ToolStripMenuItem("Expand", null, OnInvContextClick); - ctxItem.Name = "expand"; + ctxItem = new ToolStripMenuItem("Expand", null, OnInvContextClick) {Name = "expand"}; ctxInv.Items.Add(ctxItem); - ctxItem = new ToolStripMenuItem("Expand All", null, OnInvContextClick); - ctxItem.Name = "expand_all"; + ctxItem = new ToolStripMenuItem("Expand All", null, OnInvContextClick) {Name = "expand_all"}; ctxInv.Items.Add(ctxItem); - ctxItem = new ToolStripMenuItem("Collapse", null, OnInvContextClick); - ctxItem.Name = "collapse"; + ctxItem = new ToolStripMenuItem("Collapse", null, OnInvContextClick) {Name = "collapse"}; ctxInv.Items.Add(ctxItem); if (folder.PreferredType == FolderType.Trash) { - ctxItem = new ToolStripMenuItem("Empty Trash", null, OnInvContextClick); - ctxItem.Name = "empty_trash"; + ctxItem = new ToolStripMenuItem("Empty Trash", null, OnInvContextClick) {Name = "empty_trash"}; ctxInv.Items.Add(ctxItem); } if (folder.PreferredType == FolderType.LostAndFound) { - ctxItem = new ToolStripMenuItem("Empty Lost and Found", null, OnInvContextClick); - ctxItem.Name = "empty_lost_found"; + ctxItem = new ToolStripMenuItem("Empty Lost and Found", null, OnInvContextClick) + { + Name = "empty_lost_found" + }; ctxInv.Items.Add(ctxItem); } if (folder.PreferredType == FolderType.None || folder.PreferredType == FolderType.Outfit) { - ctxItem = new ToolStripMenuItem("Rename", null, OnInvContextClick); - ctxItem.Name = "rename_folder"; + ctxItem = new ToolStripMenuItem("Rename", null, OnInvContextClick) {Name = "rename_folder"}; ctxInv.Items.Add(ctxItem); ctxInv.Items.Add(new ToolStripSeparator()); - ctxItem = new ToolStripMenuItem("Cut", null, OnInvContextClick); - ctxItem.Name = "cut_folder"; + ctxItem = new ToolStripMenuItem("Cut", null, OnInvContextClick) {Name = "cut_folder"}; ctxInv.Items.Add(ctxItem); - ctxItem = new ToolStripMenuItem("Copy", null, OnInvContextClick); - ctxItem.Name = "copy_folder"; + ctxItem = new ToolStripMenuItem("Copy", null, OnInvContextClick) {Name = "copy_folder"}; ctxInv.Items.Add(ctxItem); } if (instance.InventoryClipboard != null) { - ctxItem = new ToolStripMenuItem("Paste", null, OnInvContextClick); - ctxItem.Name = "paste_folder"; + ctxItem = new ToolStripMenuItem("Paste", null, OnInvContextClick) {Name = "paste_folder"}; ctxInv.Items.Add(ctxItem); if (instance.InventoryClipboard.Item is InventoryItem) { - ctxItem = new ToolStripMenuItem("Paste as Link", null, OnInvContextClick); - ctxItem.Name = "paste_folder_link"; + ctxItem = new ToolStripMenuItem("Paste as Link", null, OnInvContextClick) + { + Name = "paste_folder_link" + }; ctxInv.Items.Add(ctxItem); } } @@ -1431,8 +1387,7 @@ private void ctxInv_Opening(object sender, CancelEventArgs e) if (folder.PreferredType == FolderType.None || folder.PreferredType == FolderType.Outfit) { - ctxItem = new ToolStripMenuItem("Delete", null, OnInvContextClick); - ctxItem.Name = "delete_folder"; + ctxItem = new ToolStripMenuItem("Delete", null, OnInvContextClick) {Name = "delete_folder"}; ctxInv.Items.Add(ctxItem); ctxInv.Items.Add(new ToolStripSeparator()); @@ -1440,126 +1395,133 @@ private void ctxInv_Opening(object sender, CancelEventArgs e) if (folder.PreferredType == FolderType.None || folder.PreferredType == FolderType.Outfit) { - ctxItem = new ToolStripMenuItem("Take off Items", null, OnInvContextClick); - ctxItem.Name = "outfit_take_off"; + ctxItem = new ToolStripMenuItem("Take off Items", null, OnInvContextClick) + { + Name = "outfit_take_off" + }; ctxInv.Items.Add(ctxItem); - ctxItem = new ToolStripMenuItem("Add to Outfit", null, OnInvContextClick); - ctxItem.Name = "outfit_add"; + ctxItem = new ToolStripMenuItem("Add to Outfit", null, OnInvContextClick) {Name = "outfit_add"}; ctxInv.Items.Add(ctxItem); - ctxItem = new ToolStripMenuItem("Replace Outfit", null, OnInvContextClick); - ctxItem.Name = "outfit_replace"; + ctxItem = new ToolStripMenuItem("Replace Outfit", null, OnInvContextClick) + { + Name = "outfit_replace" + }; ctxInv.Items.Add(ctxItem); } instance.ContextActionManager.AddContributions(ctxInv, folder); #endregion Folder context menu } - else if (node.Tag is InventoryItem) + else if (node.Tag is InventoryItem tag) { #region Item context menu - InventoryItem item = instance.COF.RealInventoryItem((InventoryItem)node.Tag); + InventoryItem item = instance.COF.RealInventoryItem(tag); ctxInv.Items.Clear(); ToolStripMenuItem ctxItem; if (item.InventoryType == InventoryType.LSL) { - ctxItem = new ToolStripMenuItem("Edit script", null, OnInvContextClick); - ctxItem.Name = "edit_script"; + ctxItem = new ToolStripMenuItem("Edit script", null, OnInvContextClick) {Name = "edit_script"}; ctxInv.Items.Add(ctxItem); } if (item.AssetType == AssetType.Texture) { - ctxItem = new ToolStripMenuItem("View", null, OnInvContextClick); - ctxItem.Name = "view_image"; + ctxItem = new ToolStripMenuItem("View", null, OnInvContextClick) {Name = "view_image"}; ctxInv.Items.Add(ctxItem); } if (item.InventoryType == InventoryType.Landmark) { - ctxItem = new ToolStripMenuItem("Teleport", null, OnInvContextClick); - ctxItem.Name = "lm_teleport"; + ctxItem = new ToolStripMenuItem("Teleport", null, OnInvContextClick) {Name = "lm_teleport"}; ctxInv.Items.Add(ctxItem); - ctxItem = new ToolStripMenuItem("Info", null, OnInvContextClick); - ctxItem.Name = "lm_info"; + ctxItem = new ToolStripMenuItem("Info", null, OnInvContextClick) {Name = "lm_info"}; ctxInv.Items.Add(ctxItem); } if (item.InventoryType == InventoryType.Notecard) { - ctxItem = new ToolStripMenuItem("Open", null, OnInvContextClick); - ctxItem.Name = "notecard_open"; + ctxItem = new ToolStripMenuItem("Open", null, OnInvContextClick) {Name = "notecard_open"}; ctxInv.Items.Add(ctxItem); } if (item.InventoryType == InventoryType.Gesture) { - ctxItem = new ToolStripMenuItem("Play", null, OnInvContextClick); - ctxItem.Name = "gesture_play"; + ctxItem = new ToolStripMenuItem("Play", null, OnInvContextClick) {Name = "gesture_play"}; ctxInv.Items.Add(ctxItem); - ctxItem = new ToolStripMenuItem("Info", null, OnInvContextClick); - ctxItem.Name = "gesture_info"; + ctxItem = new ToolStripMenuItem("Info", null, OnInvContextClick) {Name = "gesture_info"}; ctxInv.Items.Add(ctxItem); + + if (instance.Client.Self.ActiveGestures.ContainsKey(item.UUID)) + { + ctxItem = new ToolStripMenuItem("Deactivate", null, OnInvContextClick) + { + Name = "gesture_deactivate" + }; + ctxInv.Items.Add(ctxItem); + } + else + { + ctxItem = new ToolStripMenuItem("Activate", null, OnInvContextClick) + { + Name = "gesture_activate" + }; + ctxInv.Items.Add(ctxItem); + } } if (item.InventoryType == InventoryType.Animation) { - if (!client.Self.SignaledAnimations.ContainsKey(item.AssetUUID)) + if (!Client.Self.SignaledAnimations.ContainsKey(item.AssetUUID)) { - ctxItem = new ToolStripMenuItem("Play", null, OnInvContextClick); - ctxItem.Name = "animation_play"; + ctxItem = new ToolStripMenuItem("Play", null, OnInvContextClick) {Name = "animation_play"}; ctxInv.Items.Add(ctxItem); } else { - ctxItem = new ToolStripMenuItem("Stop", null, OnInvContextClick); - ctxItem.Name = "animation_stop"; + ctxItem = new ToolStripMenuItem("Stop", null, OnInvContextClick) {Name = "animation_stop"}; ctxInv.Items.Add(ctxItem); } } if (item.InventoryType == InventoryType.Object) { - ctxItem = new ToolStripMenuItem("Rez inworld", null, OnInvContextClick); - ctxItem.Name = "rez_inworld"; + ctxItem = new ToolStripMenuItem("Rez inworld", null, OnInvContextClick) {Name = "rez_inworld"}; ctxInv.Items.Add(ctxItem); } - ctxItem = new ToolStripMenuItem("Rename", null, OnInvContextClick); - ctxItem.Name = "rename_item"; + ctxItem = new ToolStripMenuItem("Rename", null, OnInvContextClick) {Name = "rename_item"}; ctxInv.Items.Add(ctxItem); ctxInv.Items.Add(new ToolStripSeparator()); - ctxItem = new ToolStripMenuItem("Cut", null, OnInvContextClick); - ctxItem.Name = "cut_item"; + ctxItem = new ToolStripMenuItem("Cut", null, OnInvContextClick) {Name = "cut_item"}; ctxInv.Items.Add(ctxItem); - ctxItem = new ToolStripMenuItem("Copy", null, OnInvContextClick); - ctxItem.Name = "copy_item"; + ctxItem = new ToolStripMenuItem("Copy", null, OnInvContextClick) {Name = "copy_item"}; ctxInv.Items.Add(ctxItem); if (instance.InventoryClipboard != null) { - ctxItem = new ToolStripMenuItem("Paste", null, OnInvContextClick); - ctxItem.Name = "paste_item"; + ctxItem = new ToolStripMenuItem("Paste", null, OnInvContextClick) {Name = "paste_item"}; ctxInv.Items.Add(ctxItem); if (instance.InventoryClipboard.Item is InventoryItem) { - ctxItem = new ToolStripMenuItem("Paste as Link", null, OnInvContextClick); - ctxItem.Name = "paste_item_link"; + ctxItem = new ToolStripMenuItem("Paste as Link", null, OnInvContextClick) + { + Name = "paste_item_link" + }; ctxInv.Items.Add(ctxItem); } } - ctxItem = new ToolStripMenuItem("Delete", null, OnInvContextClick); - ctxItem.Name = "delete_item"; + ctxItem = new ToolStripMenuItem("Delete", null, OnInvContextClick) {Name = "delete_item"}; if (IsAttached(item) || IsWorn(item)) { @@ -1567,10 +1529,18 @@ private void ctxInv_Opening(object sender, CancelEventArgs e) } ctxInv.Items.Add(ctxItem); + if (item.InventoryType == InventoryType.Object && IsAttached(item)) + { + ctxItem = new ToolStripMenuItem("Touch", null, OnInvContextClick) { Name = "touch" }; + //TODO: add RLV support + if ((attachments[item.UUID].Prim.Flags & PrimFlags.Touch) == 0) ctxItem.Enabled = false; + ctxInv.Items.Add(ctxItem); + } + if (IsAttached(item) && instance.RLV.AllowDetach(attachments[item.UUID])) { - ctxItem = new ToolStripMenuItem("Detach from yourself", null, OnInvContextClick); - ctxItem.Name = "detach"; + ctxItem = + new ToolStripMenuItem("Detach from yourself", null, OnInvContextClick) {Name = "detach"}; ctxInv.Items.Add(ctxItem); } @@ -1594,9 +1564,12 @@ private void ctxInv_Opening(object sender, CancelEventArgs e) name += " (" + alreadyAttached.Name + ")"; } - ToolStripMenuItem ptItem = new ToolStripMenuItem(name, null, OnInvContextClick); - ptItem.Name = pt.ToString(); - ptItem.Tag = pt; + ToolStripMenuItem ptItem = + new ToolStripMenuItem(name, null, OnInvContextClick) + { + Name = pt.ToString(), + Tag = pt + }; ptItem.Name = "attach_to"; ctxItemAttach.DropDownItems.Add(ptItem); } @@ -1610,38 +1583,65 @@ private void ctxInv_Opening(object sender, CancelEventArgs e) name += " (" + alreadyAttached.Name + ")"; } - ToolStripMenuItem ptItem = new ToolStripMenuItem(name, null, OnInvContextClick); - ptItem.Name = pt.ToString(); - ptItem.Tag = pt; + ToolStripMenuItem ptItem = + new ToolStripMenuItem(name, null, OnInvContextClick) + { + Name = pt.ToString(), + Tag = pt + }; ptItem.Name = "attach_to"; ctxItemAttachHUD.DropDownItems.Add(ptItem); } } - ctxItem = new ToolStripMenuItem("Add to Worn", null, OnInvContextClick); - ctxItem.Name = "wear_attachment_add"; + ctxItem = new ToolStripMenuItem("Add to Worn", null, OnInvContextClick) + { + Name = "wear_attachment_add" + }; ctxInv.Items.Add(ctxItem); - ctxItem = new ToolStripMenuItem("Wear", null, OnInvContextClick); - ctxItem.Name = "wear_attachment"; + ctxItem = new ToolStripMenuItem("Wear", null, OnInvContextClick) {Name = "wear_attachment"}; ctxInv.Items.Add(ctxItem); } - if (item is InventoryWearable) + if (item is InventoryWearable wearable) { ctxInv.Items.Add(new ToolStripSeparator()); - if (IsWorn(item)) + if (IsWorn(wearable)) { - ctxItem = new ToolStripMenuItem("Take off", null, OnInvContextClick); - ctxItem.Name = "item_take_off"; + ctxItem = + new ToolStripMenuItem("Take off", null, OnInvContextClick) {Name = "wearable_take_off"}; ctxInv.Items.Add(ctxItem); } else { - ctxItem = new ToolStripMenuItem("Wear", null, OnInvContextClick); - ctxItem.Name = "item_wear"; - ctxInv.Items.Add(ctxItem); + switch (wearable.WearableType) + { + case WearableType.Invalid: + break; + case WearableType.Alpha: + case WearableType.Gloves: + case WearableType.Jacket: + case WearableType.Pants: + case WearableType.Physics: + case WearableType.Shirt: + case WearableType.Shoes: + case WearableType.Socks: + case WearableType.Skirt: + case WearableType.Tattoo: + case WearableType.Underpants: + case WearableType.Undershirt: + case WearableType.Universal: + ctxItem = new ToolStripMenuItem("Add to Worn", null, OnInvContextClick) { Name = "wearable_add" }; + ctxInv.Items.Add(ctxItem); + goto default; + default: + ctxItem = new ToolStripMenuItem("Wear", null, OnInvContextClick) { Name = "wearable_wear" }; + ctxInv.Items.Add(ctxItem); + break; + } + } } @@ -1654,33 +1654,32 @@ private void ctxInv_Opening(object sender, CancelEventArgs e) #region Context menu folder private void OnInvContextClick(object sender, EventArgs e) { - if (invTree.SelectedNode == null || !(invTree.SelectedNode.Tag is InventoryBase)) + if (!(invTree.SelectedNode?.Tag is InventoryBase)) { return; } string cmd = ((ToolStripMenuItem)sender).Name; - if (invTree.SelectedNode.Tag is InventoryFolder) + if (invTree.SelectedNode.Tag is InventoryFolder folder) { #region Folder actions - InventoryFolder f = (InventoryFolder)invTree.SelectedNode.Tag; switch (cmd) { case "refresh": foreach (TreeNode old in invTree.SelectedNode.Nodes) { - if (!(old.Tag is InventoryFolder)) + if (old != null && !(old.Tag is InventoryFolder)) { removeNode(old); } } - fetchFolder(f.UUID, f.OwnerID, true); + FetchFolder(folder.UUID, folder.OwnerID, true); break; case "backup": - (new InventoryBackup(instance, f.UUID)).Show(); + (new InventoryBackup(instance, folder.UUID)).Show(); break; case "expand": @@ -1697,30 +1696,30 @@ private void OnInvContextClick(object sender, EventArgs e) case "new_folder": newItemName = "New folder"; - client.Inventory.CreateFolder(f.UUID, "New folder"); + Client.Inventory.CreateFolder(folder.UUID, "New folder"); break; case "fix_type": - client.Inventory.UpdateFolderProperties(f.UUID, f.ParentUUID, f.Name, FolderType.None); + Client.Inventory.UpdateFolderProperties(folder.UUID, folder.ParentUUID, folder.Name, FolderType.None); invTree.Sort(); break; case "new_notecard": - client.Inventory.RequestCreateItem(f.UUID, "New Note", "Radegast note: " + DateTime.Now.ToString(), + Client.Inventory.RequestCreateItem(folder.UUID, "New Note", "Radegast note: " + DateTime.Now.ToString(CultureInfo.InvariantCulture), AssetType.Notecard, UUID.Zero, InventoryType.Notecard, PermissionMask.All, NotecardCreated); break; case "new_script": - client.Inventory.RequestCreateItem(f.UUID, "New script", "Radegast script: " + DateTime.Now.ToString(), + Client.Inventory.RequestCreateItem(folder.UUID, "New script", "Radegast script: " + DateTime.Now.ToString(CultureInfo.InvariantCulture), AssetType.LSLText, UUID.Zero, InventoryType.LSL, PermissionMask.All, ScriptCreated); break; case "cut_folder": - instance.InventoryClipboard = new InventoryClipboard(ClipboardOperation.Cut, f); + instance.InventoryClipboard = new InventoryClipboard(ClipboardOperation.Cut, folder); break; case "copy_folder": - instance.InventoryClipboard = new InventoryClipboard(ClipboardOperation.Copy, f); + instance.InventoryClipboard = new InventoryClipboard(ClipboardOperation.Copy, folder); break; case "paste_folder": @@ -1733,21 +1732,21 @@ private void OnInvContextClick(object sender, EventArgs e) case "delete_folder": - var trash = client.Inventory.FindFolderForType(FolderType.Trash); + var trash = Client.Inventory.FindFolderForType(FolderType.Trash); if (trash == Inventory.RootFolder.UUID) { - WorkPool.QueueUserWorkItem(sync => + ThreadPool.QueueUserWorkItem(sync => { trashCreated.Reset(); - trash = client.Inventory.CreateFolder(Inventory.RootFolder.UUID, "Trash", FolderType.Trash); + trash = Client.Inventory.CreateFolder(Inventory.RootFolder.UUID, "Trash", FolderType.Trash); trashCreated.WaitOne(20 * 1000, false); Thread.Sleep(200); - client.Inventory.MoveFolder(f.UUID, trash, f.Name); + Client.Inventory.MoveFolder(folder.UUID, trash); }); return; } - client.Inventory.MoveFolder(f.UUID, trash, f.Name); + Client.Inventory.MoveFolder(folder.UUID, trash); break; case "empty_trash": @@ -1755,7 +1754,7 @@ private void OnInvContextClick(object sender, EventArgs e) DialogResult res = MessageBox.Show("Are you sure you want to empty your trash?", "Confirmation", MessageBoxButtons.OKCancel); if (res == DialogResult.OK) { - client.Inventory.EmptyTrash(); + Client.Inventory.EmptyTrash(); } } break; @@ -1765,7 +1764,7 @@ private void OnInvContextClick(object sender, EventArgs e) DialogResult res = MessageBox.Show("Are you sure you want to empty your lost and found folder?", "Confirmation", MessageBoxButtons.OKCancel); if (res == DialogResult.OK) { - client.Inventory.EmptyLostAndFound(); + Client.Inventory.EmptyLostAndFound(); } } break; @@ -1775,47 +1774,31 @@ private void OnInvContextClick(object sender, EventArgs e) break; case "outfit_replace": - List newOutfit = new List(); - foreach (InventoryBase item in Inventory.GetContents(f)) - { - if (item is InventoryItem) - newOutfit.Add((InventoryItem)item); - } - appearnceWasBusy = client.Appearance.ManagerBusy; + List newOutfit = GetInventoryItemsForOutFit(folder); + appearanceWasBusy = Client.Appearance.ManagerBusy; instance.COF.ReplaceOutfit(newOutfit); UpdateWornLabels(); break; case "outfit_add": - List addToOutfit = new List(); - foreach (InventoryBase item in Inventory.GetContents(f)) - { - if (item is InventoryItem) - addToOutfit.Add((InventoryItem)item); - } - appearnceWasBusy = client.Appearance.ManagerBusy; - instance.COF.AddToOutfit(addToOutfit, true); + List addToOutfit = GetInventoryItemsForOutFit(folder); + appearanceWasBusy = Client.Appearance.ManagerBusy; + instance.COF.AddToOutfit(addToOutfit, false); UpdateWornLabels(); break; case "outfit_take_off": - List removeFromOutfit = new List(); - foreach (InventoryBase item in Inventory.GetContents(f)) - { - if (item is InventoryItem) - removeFromOutfit.Add((InventoryItem)item); - } - appearnceWasBusy = client.Appearance.ManagerBusy; + List removeFromOutfit = GetInventoryItemsForOutFit(folder); + appearanceWasBusy = Client.Appearance.ManagerBusy; instance.COF.RemoveFromOutfit(removeFromOutfit); UpdateWornLabels(); break; } #endregion } - else if (invTree.SelectedNode.Tag is InventoryItem) + else if (invTree.SelectedNode.Tag is InventoryItem item) { #region Item actions - InventoryItem item = (InventoryItem)invTree.SelectedNode.Tag; // Copy, cut, and delete works on links directly // The rest operate on the item that is pointed by the link @@ -1843,27 +1826,39 @@ private void OnInvContextClick(object sender, EventArgs e) break; case "delete_item": - var trash = client.Inventory.FindFolderForType(FolderType.Trash); + var trash = Client.Inventory.FindFolderForType(FolderType.Trash); if (trash == Inventory.RootFolder.UUID) { - WorkPool.QueueUserWorkItem(sync => + ThreadPool.QueueUserWorkItem(sync => { trashCreated.Reset(); - trash = client.Inventory.CreateFolder(Inventory.RootFolder.UUID, "Trash", FolderType.Trash); + trash = Client.Inventory.CreateFolder(Inventory.RootFolder.UUID, "Trash", FolderType.Trash); trashCreated.WaitOne(20 * 1000, false); Thread.Sleep(200); - client.Inventory.MoveItem(item.UUID, trash, item.Name); + Client.Inventory.MoveItem(item.UUID, trash, item.Name); }); return; } - client.Inventory.MoveItem(item.UUID, client.Inventory.FindFolderForType(FolderType.Trash), item.Name); + Client.Inventory.MoveItem(item.UUID, Client.Inventory.FindFolderForType(FolderType.Trash), item.Name); break; case "rename_item": invTree.SelectedNode.BeginEdit(); break; + case "touch": + lock (attachments[item.UUID]) + { + AttachmentInfo aInfo = attachments[item.UUID]; + Client.Self.Grab(aInfo.Prim.LocalID, Vector3.Zero, Vector3.Zero, Vector3.Zero, 0, + Vector3.Zero, Vector3.Zero, Vector3.Zero); + Thread.Sleep(100); + Client.Self.DeGrab(aInfo.Prim.LocalID, Vector3.Zero, Vector3.Zero, 0, Vector3.Zero, + Vector3.Zero, Vector3.Zero); + } + break; + case "detach": instance.COF.Detach(item); lock (attachments) attachments.Remove(item.UUID); @@ -1892,8 +1887,8 @@ private void OnInvContextClick(object sender, EventArgs e) UpdateItemInfo(item); break; - case "item_take_off": - appearnceWasBusy = client.Appearance.ManagerBusy; + case "wearable_take_off": + appearanceWasBusy = Client.Appearance.ManagerBusy; instance.COF.RemoveFromOutfit(item); invTree.SelectedNode.Text = ItemLabel(item, false); lock (WornItems) @@ -1905,15 +1900,21 @@ private void OnInvContextClick(object sender, EventArgs e) } break; - case "item_wear": - appearnceWasBusy = client.Appearance.ManagerBusy; + case "wearable_wear": + appearanceWasBusy = Client.Appearance.ManagerBusy; instance.COF.AddToOutfit(item, true); invTree.SelectedNode.Text = ItemLabel(item, false); break; + case "wearable_add": + appearanceWasBusy = Client.Appearance.ManagerBusy; + instance.COF.AddToOutfit(item, false); + invTree.SelectedNode.Text = ItemLabel(item, false); + break; + case "lm_teleport": - instance.TabConsole.DisplayNotificationInChat("Teleporting to " + item.Name); - client.Self.RequestTeleport(item.AssetUUID); + instance.TabConsole.DisplayNotificationInChat($"Teleporting to {item.Name}"); + Client.Self.RequestTeleport(item.AssetUUID); break; case "lm_info": @@ -1929,31 +1930,55 @@ private void OnInvContextClick(object sender, EventArgs e) break; case "gesture_play": - client.Self.PlayGesture(item.AssetUUID); + Client.Self.PlayGesture(item.AssetUUID); + break; + + case "gesture_activate": + instance.Client.Self.ActivateGesture(item.UUID, item.AssetUUID); + invTree.SelectedNode.Text = ItemLabel(item, false); + break; + + case "gesture_deactivate": + instance.Client.Self.DeactivateGesture(item.UUID); + invTree.SelectedNode.Text = ItemLabel(item, false); break; case "animation_play": - Dictionary anim = new Dictionary(); - anim.Add(item.AssetUUID, true); - client.Self.Animate(anim, true); + Dictionary anim = new Dictionary { { item.AssetUUID, true } }; + Client.Self.Animate(anim, true); break; case "animation_stop": - Dictionary animStop = new Dictionary(); - animStop.Add(item.AssetUUID, false); - client.Self.Animate(animStop, true); + Dictionary animStop = new Dictionary { { item.AssetUUID, false } }; + Client.Self.Animate(animStop, true); break; case "rez_inworld": instance.MediaManager.PlayUISound(UISounds.ObjectRez); Vector3 rezpos = new Vector3(2, 0, 0); - rezpos = client.Self.SimPosition + rezpos * client.Self.Movement.BodyRotation; - client.Inventory.RequestRezFromInventory(client.Network.CurrentSim, Quaternion.Identity, rezpos, item); + rezpos = Client.Self.SimPosition + rezpos * Client.Self.Movement.BodyRotation; + Client.Inventory.RequestRezFromInventory(Client.Network.CurrentSim, Quaternion.Identity, rezpos, item); break; } #endregion } } + List GetInventoryItemsForOutFit(InventoryFolder folder) + { + List outfitItems = new List(); + foreach (InventoryBase item in Inventory.GetContents(folder)) + { + if (item is InventoryItem inventoryItem) + { + outfitItems.Add(inventoryItem); + } + if (item is InventoryFolder inventoryFolder) + { + outfitItems.AddRange(GetInventoryItemsForOutFit(inventoryFolder)); + } + } + return outfitItems; + } void NotecardCreated(bool success, InventoryItem item) { @@ -1971,7 +1996,7 @@ void NotecardCreated(bool success, InventoryItem item) instance.TabConsole.DisplayNotificationInChat("New notecard created, enter notecard name and press enter", ChatBufferTextStyle.Invisible); var node = findNodeForItem(item.ParentUUID); - if (node != null) node.Expand(); + node?.Expand(); node = findNodeForItem(item.UUID); if (node != null) { @@ -1996,7 +2021,7 @@ void ScriptCreated(bool success, InventoryItem item) instance.TabConsole.DisplayNotificationInChat("New script created, enter script name and press enter", ChatBufferTextStyle.Invisible); var node = findNodeForItem(item.ParentUUID); - if (node != null) node.Expand(); + node?.Expand(); node = findNodeForItem(item.UUID); if (node != null) { @@ -2011,71 +2036,86 @@ void PerformClipboardOperation(InventoryFolder dest) if (dest == null) return; - if (instance.InventoryClipboard.Operation == ClipboardOperation.Cut) + switch (instance.InventoryClipboard.Operation) { - if (instance.InventoryClipboard.Item is InventoryItem) + case ClipboardOperation.Cut: { - client.Inventory.MoveItem(instance.InventoryClipboard.Item.UUID, dest.UUID, instance.InventoryClipboard.Item.Name); - } - else if (instance.InventoryClipboard.Item is InventoryFolder) - { - if (instance.InventoryClipboard.Item.UUID != dest.UUID) + switch (instance.InventoryClipboard.Item) { - client.Inventory.MoveFolder(instance.InventoryClipboard.Item.UUID, dest.UUID, instance.InventoryClipboard.Item.Name); + case InventoryItem _: + Client.Inventory.MoveItem(instance.InventoryClipboard.Item.UUID, dest.UUID, instance.InventoryClipboard.Item.Name); + break; + case InventoryFolder _: + { + if (instance.InventoryClipboard.Item.UUID != dest.UUID) + { + Client.Inventory.MoveFolder(instance.InventoryClipboard.Item.UUID, dest.UUID); + } + + break; + } } + + instance.InventoryClipboard = null; + break; } - instance.InventoryClipboard = null; - } - else if (instance.InventoryClipboard.Operation == ClipboardOperation.Copy) - { - if (instance.InventoryClipboard.Item is InventoryItem) - { - client.Inventory.RequestCopyItem(instance.InventoryClipboard.Item.UUID, dest.UUID, instance.InventoryClipboard.Item.Name, instance.InventoryClipboard.Item.OwnerID, (InventoryBase target) => - { - } + case ClipboardOperation.Copy when instance.InventoryClipboard.Item is InventoryItem: + Client.Inventory.RequestCopyItem(instance.InventoryClipboard.Item.UUID, dest.UUID, instance.InventoryClipboard.Item.Name, instance.InventoryClipboard.Item.OwnerID, target => + { + } ); - } - else if (instance.InventoryClipboard.Item is InventoryFolder) + break; + case ClipboardOperation.Copy: { - WorkPool.QueueUserWorkItem((object state) => - { - UUID newFolderID = client.Inventory.CreateFolder(dest.UUID, instance.InventoryClipboard.Item.Name, FolderType.None); - Thread.Sleep(500); + if (instance.InventoryClipboard.Item is InventoryFolder) + { + ThreadPool.QueueUserWorkItem(state => + { + UUID newFolderID = Client.Inventory.CreateFolder(dest.UUID, instance.InventoryClipboard.Item.Name, FolderType.None); + Thread.Sleep(500); - // FIXME: for some reason copying a bunch of items in one operation does not work + // FIXME: for some reason copying a bunch of items in one operation does not work - //List items = new List(); - //List folders = new List(); - //List names = new List(); - //UUID oldOwner = UUID.Zero; + //List items = new List(); + //List folders = new List(); + //List names = new List(); + //UUID oldOwner = UUID.Zero; - foreach (InventoryBase oldItem in Inventory.GetContents((InventoryFolder)instance.InventoryClipboard.Item)) - { - //folders.Add(newFolderID); - //names.Add(oldItem.Name); - //items.Add(oldItem.UUID); - //oldOwner = oldItem.OwnerID; - client.Inventory.RequestCopyItem(oldItem.UUID, newFolderID, oldItem.Name, oldItem.OwnerID, (InventoryBase target) => { }); + foreach (InventoryBase oldItem in Inventory.GetContents((InventoryFolder)instance.InventoryClipboard.Item)) + { + //folders.Add(newFolderID); + //names.Add(oldItem.Name); + //items.Add(oldItem.UUID); + //oldOwner = oldItem.OwnerID; + Client.Inventory.RequestCopyItem(oldItem.UUID, newFolderID, oldItem.Name, oldItem.OwnerID, target => { }); + } + + //if (folders.Count > 0) + //{ + // Client.Inventory.RequestCopyItems(items, folders, names, oldOwner, (InventoryBase target) => { }); + //} } + ); + } - //if (folders.Count > 0) - //{ - // client.Inventory.RequestCopyItems(items, folders, names, oldOwner, (InventoryBase target) => { }); - //} - } - ); + break; } } } void PerformLinkOperation(InventoryFolder dest) { - if (instance.InventoryClipboard == null) return; - - if (dest == null) return; + if (instance.InventoryClipboard == null || dest == null) return; - client.Inventory.CreateLink(dest.UUID, instance.InventoryClipboard.Item, (bool success, InventoryItem item) => { }); + Client.Inventory.CreateLink(dest.UUID, instance.InventoryClipboard.Item, + (success, item) => + { + if (success) + { + Client.Inventory.RequestFetchInventory(item.UUID, item.OwnerID); + } + }); } #endregion @@ -2089,22 +2129,19 @@ private void UpdateWornLabels() } invTree.BeginUpdate(); - foreach (UUID itemID in WornItems) + foreach (var node in WornItems.Select(findNodeForItem).Where(node => node != null)) { - TreeNode node = findNodeForItem(itemID); - if (node != null) - { - node.Text = ItemLabel((InventoryBase)node.Tag, false); - } + node.Text = ItemLabel((InventoryBase)node.Tag, false); } WornItems.Clear(); - foreach (AppearanceManager.WearableData wearable in client.Appearance.GetWearables().Values) + foreach (var wearable in Client.Appearance.GetWearables()) { TreeNode node = findNodeForItem(wearable.ItemID); if (node != null) { - node.Text = ItemLabel((InventoryBase)node.Tag, false); + node.Text = ItemLabel((InventoryBase) node.Tag, false); } + } invTree.EndUpdate(); } @@ -2112,25 +2149,22 @@ private void UpdateWornLabels() void TreeView_AfterExpand(object sender, TreeViewEventArgs e) { // Check if we need to go into edit mode for new items - if (newItemName != string.Empty) + if (newItemName == string.Empty) return; + foreach (TreeNode n in e.Node.Nodes) { - foreach (TreeNode n in e.Node.Nodes) - { - if (n.Name == newItemName) - { - n.BeginEdit(); - break; - } - } - newItemName = string.Empty; + if (n.Name != newItemName) continue; + + n.BeginEdit(); + break; } + newItemName = string.Empty; } private bool _EditingNode = false; private void OnLabelEditTimer(object sender) { - if (_EditNode == null || !(_EditNode.Tag is InventoryBase)) + if (!(_EditNode?.Tag is InventoryBase)) return; if (InvokeRequired) @@ -2150,12 +2184,9 @@ private void OnLabelEditTimer(object sender) private void invTree_BeforeLabelEdit(object sender, NodeLabelEditEventArgs e) { - if (e.Node == null || - !(e.Node.Tag is InventoryBase) || - (e.Node.Tag is InventoryFolder && - ((InventoryFolder)e.Node.Tag).PreferredType != FolderType.None && - ((InventoryFolder)e.Node.Tag).PreferredType != FolderType.Outfit) - ) + if (!(e.Node?.Tag is InventoryBase) || (e.Node.Tag is InventoryFolder folder + && folder.PreferredType != FolderType.None + && folder.PreferredType != FolderType.Outfit)) { e.CancelEdit = true; return; @@ -2169,7 +2200,7 @@ private void invTree_BeforeLabelEdit(object sender, NodeLabelEditEventArgs e) { e.CancelEdit = true; _EditNode = e.Node; - _EditTimer.Change(20, System.Threading.Timeout.Infinite); + _EditTimer.Change(20, Timeout.Infinite); } } @@ -2177,26 +2208,24 @@ private void invTree_AfterLabelEdit(object sender, NodeLabelEditEventArgs e) { if (string.IsNullOrEmpty(e.Label)) { - if (e.Node.Tag is InventoryBase) + if (e.Node.Tag is InventoryBase tag) { - e.Node.Text = ItemLabel((InventoryBase)e.Node.Tag, false); + e.Node.Text = ItemLabel(tag, false); } e.CancelEdit = true; return; } - if (e.Node.Tag is InventoryFolder) + if (e.Node.Tag is InventoryFolder folder) { - InventoryFolder f = (InventoryFolder)e.Node.Tag; - f.Name = e.Label; - client.Inventory.MoveFolder(f.UUID, f.ParentUUID, f.Name); + folder.Name = e.Label; + Client.Inventory.UpdateFolderProperties(folder.UUID, folder.ParentUUID, folder.Name, folder.PreferredType); } - else if (e.Node.Tag is InventoryItem) + else if (e.Node.Tag is InventoryItem item) { - InventoryItem item = (InventoryItem)e.Node.Tag; item.Name = e.Label; e.Node.Text = ItemLabel((InventoryBase)item, false); - client.Inventory.MoveItem(item.UUID, item.ParentUUID, item.Name); + Client.Inventory.MoveItem(item.UUID, item.ParentUUID, item.Name); UpdateItemInfo(item); } @@ -2210,30 +2239,28 @@ private void invTree_KeyUp(object sender, KeyEventArgs e) } else if (e.KeyCode == Keys.F5 && invTree.SelectedNode != null) { - if (invTree.SelectedNode.Tag is InventoryFolder) + if (invTree.SelectedNode.Tag is InventoryFolder folder) { - InventoryFolder f = (InventoryFolder)invTree.SelectedNode.Tag; - fetchFolder(f.UUID, f.OwnerID, true); + FetchFolder(folder.UUID, folder.OwnerID, true); } } else if (e.KeyCode == Keys.Delete && invTree.SelectedNode != null) { - var trash = client.Inventory.FindFolderForType(FolderType.Trash); + var trash = Client.Inventory.FindFolderForType(FolderType.Trash); if (trash == Inventory.RootFolder.UUID) { - trash = client.Inventory.CreateFolder(Inventory.RootFolder.UUID, "Trash", FolderType.Trash); + trash = Client.Inventory.CreateFolder(Inventory.RootFolder.UUID, "Trash", FolderType.Trash); Thread.Sleep(2000); } - if (invTree.SelectedNode.Tag is InventoryItem) + switch (invTree.SelectedNode.Tag) { - InventoryItem item = invTree.SelectedNode.Tag as InventoryItem; - client.Inventory.MoveItem(item.UUID, trash, item.Name); - } - else if (invTree.SelectedNode.Tag is InventoryFolder) - { - InventoryFolder f = invTree.SelectedNode.Tag as InventoryFolder; - client.Inventory.MoveFolder(f.UUID, trash, f.Name); + case InventoryItem item: + Client.Inventory.MoveItem(item.UUID, trash); + break; + case InventoryFolder folder: + Client.Inventory.MoveFolder(folder.UUID, trash); + break; } } else if (e.KeyCode == Keys.Apps && invTree.SelectedNode != null) @@ -2246,7 +2273,7 @@ private void invTree_KeyUp(object sender, KeyEventArgs e) private void invTree_ItemDrag(object sender, ItemDragEventArgs e) { invTree.SelectedNode = e.Item as TreeNode; - if (invTree.SelectedNode.Tag is InventoryFolder && ((InventoryFolder)invTree.SelectedNode.Tag).PreferredType != FolderType.None) + if (invTree.SelectedNode?.Tag is InventoryFolder folder && folder.PreferredType != FolderType.None) { return; } @@ -2264,8 +2291,8 @@ private void invTree_DragDrop(object sender, DragEventArgs e) TreeNode sourceNode = e.Data.GetData(typeof(TreeNode)) as TreeNode; if (sourceNode == null) return; - Point pt = ((TreeView)sender).PointToClient(new Point(e.X, e.Y)); - TreeNode destinationNode = ((TreeView)sender).GetNodeAt(pt); + Point pt = ((BufferedTreeView)sender).PointToClient(new Point(e.X, e.Y)); + TreeNode destinationNode = ((BufferedTreeView)sender).GetNodeAt(pt); if (destinationNode == null) return; @@ -2277,19 +2304,15 @@ private void invTree_DragDrop(object sender, DragEventArgs e) destinationNode = destinationNode.Parent; } - InventoryFolder dest = destinationNode.Tag as InventoryFolder; - - if (dest == null) return; + if (!(destinationNode.Tag is InventoryFolder dest)) return; - if (sourceNode.Tag is InventoryItem) + if (sourceNode.Tag is InventoryItem item) { - InventoryItem item = (InventoryItem)sourceNode.Tag; - client.Inventory.MoveItem(item.UUID, dest.UUID, item.Name); + Client.Inventory.MoveItem(item.UUID, dest.UUID, item.Name); } - else if (sourceNode.Tag is InventoryFolder) + else if (sourceNode.Tag is InventoryFolder folder) { - InventoryFolder f = (InventoryFolder)sourceNode.Tag; - client.Inventory.MoveFolder(f.UUID, dest.UUID, f.Name); + Client.Inventory.MoveFolder(folder.UUID, dest.UUID); } } @@ -2316,8 +2339,8 @@ private void invTree_DragOver(object sender, DragEventArgs e) e.Effect = DragDropEffects.None; } - Point pt = ((TreeView)sender).PointToClient(new Point(e.X, e.Y)); - TreeNode destinationNode = ((TreeView)sender).GetNodeAt(pt); + Point pt = ((BufferedTreeView)sender).PointToClient(new Point(e.X, e.Y)); + TreeNode destinationNode = ((BufferedTreeView)sender).GetNodeAt(pt); if (highlightedNode != destinationNode) { @@ -2388,14 +2411,14 @@ public class SearchResult public SearchResult(InventoryBase inv, int level) { - this.Inv = inv; - this.Level = level; + Inv = inv; + Level = level; } } List searchRes; string searchString; - Dictionary searchItemCache = new Dictionary(); + readonly Dictionary searchItemCache = new Dictionary(); ListViewItem emptyItem = null; int found; @@ -2405,7 +2428,7 @@ void PerformRecursiveSearch(int level, UUID folderID) searchRes.Add(new SearchResult(me, level)); var sorted = Inventory.GetContents(folderID); - sorted.Sort((InventoryBase b1, InventoryBase b2) => + sorted.Sort((b1, b2) => { if (b1 is InventoryFolder && !(b2 is InventoryFolder)) { @@ -2417,7 +2440,7 @@ void PerformRecursiveSearch(int level, UUID folderID) } else { - return string.Compare(b1.Name, b2.Name); + return string.CompareOrdinal(b1.Name, b2.Name); } }); @@ -2442,11 +2465,15 @@ void PerformRecursiveSearch(int level, UUID folderID) } if (cbSrchWorn.Checked && add && - !( - (it.InventoryType == InventoryType.Wearable && IsWorn(it)) || - ((it.InventoryType == InventoryType.Attachment || it.InventoryType == InventoryType.Object) && IsAttached(it)) - ) - ) + !(it.InventoryType == InventoryType.Wearable && IsWorn(it) + || (it.InventoryType == InventoryType.Attachment + || it.InventoryType == InventoryType.Object) && IsAttached(it))) + { + add = false; + } + + if (cbSrchGestures.Checked && add && + it.InventoryType != InventoryType.Gesture) { add = false; } @@ -2464,7 +2491,7 @@ void PerformRecursiveSearch(int level, UUID folderID) } } - if (searchRes[searchRes.Count - 1].Inv == me) + if (searchRes[searchRes.Count - 1].Inv.Equals(me)) { searchRes.RemoveAt(searchRes.Count - 1); } @@ -2499,7 +2526,7 @@ public void UpdateSearch() searchItemCache.Clear(); PerformRecursiveSearch(0, Inventory.RootFolder.UUID); lstInventorySearch.VirtualListSize = searchRes.Count; - lblSearchStatus.Text = string.Format("{0} results", found); + lblSearchStatus.Text = $"{found} results"; } private void lstInventorySearch_RetrieveVirtualItem(object sender, RetrieveVirtualItemEventArgs e) @@ -2512,12 +2539,12 @@ private void lstInventorySearch_RetrieveVirtualItem(object sender, RetrieveVirtu { InventoryBase inv = searchRes[e.ItemIndex].Inv; string desc = inv.Name; - if (inv is InventoryItem) + if (inv is InventoryItem inventoryItem) { - desc += string.Format(" - {0}", ((InventoryItem)inv).Description); + desc += $" - {inventoryItem.Description}"; } - ListViewItem item = new ListViewItem(desc); - item.Tag = searchRes[e.ItemIndex]; + + ListViewItem item = new ListViewItem(desc) {Tag = searchRes[e.ItemIndex]}; e.Item = item; searchItemCache[e.ItemIndex] = item; } @@ -2541,11 +2568,6 @@ private void cbSrchName_CheckedChanged(object sender, EventArgs e) UpdateSearch(); } - private void cbSrchWorn_CheckedChanged(object sender, EventArgs e) - { - UpdateSearch(); - } - private void txtSearch_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) @@ -2563,7 +2585,7 @@ private void lstInventorySearch_DrawItem(object sender, DrawListViewItemEventArg Graphics g = e.Graphics; e.DrawBackground(); - if (!(e.Item.Tag is SearchResult)) + if (!(e.Item.Tag is SearchResult result)) return; if (e.Item.Selected) @@ -2571,24 +2593,22 @@ private void lstInventorySearch_DrawItem(object sender, DrawListViewItemEventArg g.FillRectangle(SystemBrushes.Highlight, e.Bounds); } - SearchResult res = e.Item.Tag as SearchResult; - int offset = 20 * (res.Level + 1); + int offset = 20 * (result.Level + 1); Rectangle rec = new Rectangle(e.Bounds.X + offset, e.Bounds.Y, e.Bounds.Width - offset, e.Bounds.Height); - Image icon = null; int iconIx = 0; - if (res.Inv is InventoryFolder) - { - iconIx = GetDirImageIndex(((InventoryFolder)res.Inv).PreferredType.ToString().ToLower()); - } - else if (res.Inv is InventoryWearable) + switch (result.Inv) { - iconIx = GetItemImageIndex(((InventoryWearable)res.Inv).WearableType.ToString().ToLower()); - } - else if (res.Inv is InventoryItem) - { - iconIx = GetItemImageIndex(((InventoryItem)res.Inv).AssetType.ToString().ToLower()); + case InventoryFolder folder: + iconIx = GetDirImageIndex(folder.PreferredType.ToString().ToLower()); + break; + case InventoryWearable wearable: + iconIx = GetItemImageIndex(wearable.WearableType.ToString().ToLower()); + break; + case InventoryItem item: + iconIx = GetItemImageIndex(item.AssetType.ToString().ToLower()); + break; } if (iconIx < 0) @@ -2598,37 +2618,36 @@ private void lstInventorySearch_DrawItem(object sender, DrawListViewItemEventArg try { - icon = frmMain.ResourceImages.Images[iconIx]; + var icon = frmMain.ResourceImages.Images[iconIx]; g.DrawImageUnscaled(icon, e.Bounds.X + offset - 18, e.Bounds.Y); } catch { } using (StringFormat sf = new StringFormat(StringFormatFlags.NoWrap | StringFormatFlags.LineLimit)) { - string label = ItemLabel(res.Inv, false); + string label = ItemLabel(result.Inv, false); SizeF len = e.Graphics.MeasureString(label, lstInventorySearch.Font, rec.Width, sf); e.Graphics.DrawString( - ItemLabel(res.Inv, false), + ItemLabel(result.Inv, false), lstInventorySearch.Font, e.Item.Selected ? SystemBrushes.HighlightText : SystemBrushes.WindowText, rec, sf); - if (res.Inv is InventoryItem) + if (result.Inv is InventoryItem inv) { - string desc = ((InventoryItem)res.Inv).Description.Trim(); - if (desc != string.Empty) + string desc = inv.Description.Trim(); + if (desc == string.Empty) return; + + using (Font descFont = new Font(lstInventorySearch.Font, FontStyle.Italic)) { - using (Font descFont = new Font(lstInventorySearch.Font, FontStyle.Italic)) - { - e.Graphics.DrawString(desc, - descFont, - e.Item.Selected ? SystemBrushes.HighlightText : SystemBrushes.GrayText, - rec.X + len.Width + 5, - rec.Y, - sf); - } + e.Graphics.DrawString(desc, + descFont, + e.Item.Selected ? SystemBrushes.HighlightText : SystemBrushes.GrayText, + rec.X + len.Width + 5, + rec.Y, + sf); } } } @@ -2659,7 +2678,7 @@ private void lstInventorySearch_KeyDown(object sender, KeyEventArgs e) } /// - /// Finds and higlights inventory node + /// Finds and highlights inventory node /// /// Inventory of ID of the item to select public void SelectInventoryNode(UUID itemID) @@ -2668,9 +2687,9 @@ public void SelectInventoryNode(UUID itemID) if (node == null) return; invTree.SelectedNode = node; - if (node.Tag is InventoryItem) + if (node.Tag is InventoryItem tag) { - UpdateItemInfo(node.Tag as InventoryItem); + UpdateItemInfo(tag); } } @@ -2736,44 +2755,37 @@ private void copyInitialOutfitsToolStripMenuItem_Click(object sender, EventArgs // Create a node sorter that implements the IComparer interface. public class InvNodeSorter : System.Collections.IComparer { - bool _sysfirst = true; - bool _bydate = true; - int CompareFolders(InventoryFolder x, InventoryFolder y) { - if (_sysfirst) + if (!SystemFoldersFirst) return string.CompareOrdinal(x.Name, y.Name); + + if (x.PreferredType != FolderType.None && y.PreferredType == FolderType.None) { - if (x.PreferredType != FolderType.None && y.PreferredType == FolderType.None) - { - return -1; - } - else if (x.PreferredType == FolderType.None && y.PreferredType != FolderType.None) - { - return 1; - } + return -1; } - return String.Compare(x.Name, y.Name); + else if (x.PreferredType == FolderType.None && y.PreferredType != FolderType.None) + { + return 1; + } + return String.CompareOrdinal(x.Name, y.Name); } - public bool SystemFoldersFirst { set { _sysfirst = value; } get { return _sysfirst; } } - public bool ByDate { set { _bydate = value; } get { return _bydate; } } + public bool SystemFoldersFirst { set; get; } = true; + public bool ByDate { set; get; } = true; public int Compare(object x, object y) { TreeNode tx = x as TreeNode; TreeNode ty = y as TreeNode; - if (tx.Tag is InventoryFolder && ty.Tag is InventoryFolder) + switch (tx.Tag) { - return CompareFolders(tx.Tag as InventoryFolder, ty.Tag as InventoryFolder); - } - else if (tx.Tag is InventoryFolder && ty.Tag is InventoryItem) - { - return -1; - } - else if (tx.Tag is InventoryItem && ty.Tag is InventoryFolder) - { - return 1; + case InventoryFolder x_folder when ty.Tag is InventoryFolder y_folder: + return CompareFolders(x_folder, y_folder); + case InventoryFolder _ when ty.Tag is InventoryItem: + return -1; + case InventoryItem _ when ty.Tag is InventoryFolder: + return 1; } // Two items @@ -2785,18 +2797,18 @@ public int Compare(object x, object y) InventoryItem item1 = (InventoryItem)tx.Tag; InventoryItem item2 = (InventoryItem)ty.Tag; - if (_bydate) + if (!ByDate) return string.CompareOrdinal(item1.Name, item2.Name); + + if (item1.CreationDate < item2.CreationDate) { - if (item1.CreationDate < item2.CreationDate) - { - return 1; - } - else if (item1.CreationDate > item2.CreationDate) - { - return -1; - } + return 1; + } + + if (item1.CreationDate > item2.CreationDate) + { + return -1; } - return string.Compare(item1.Name, item2.Name); + return string.CompareOrdinal(item1.Name, item2.Name); } } #endregion @@ -2807,22 +2819,8 @@ public class AttachmentInfo public InventoryItem Item; public UUID InventoryID; public UUID PrimID; - public bool MarkedAttached = false; - - public AttachmentPoint Point - { - get - { - if (Prim != null) - { - return Prim.PrimData.AttachmentPoint; - } - else - { - return AttachmentPoint.Default; - } - } - } + public bool MarkedAttached; + public AttachmentPoint Point => Prim != null ? Prim.PrimData.AttachmentPoint : AttachmentPoint.Default; } diff --git a/Radegast/GUI/Consoles/Inventory/InventoryConsole.resx b/Radegast/GUI/Consoles/Inventory/InventoryConsole.resx index 2e5b3a13b..0ee23367e 100644 --- a/Radegast/GUI/Consoles/Inventory/InventoryConsole.resx +++ b/Radegast/GUI/Consoles/Inventory/InventoryConsole.resx @@ -112,46 +112,55 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + 17, 17 - + 100, 17 - + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIISURBVDhPpZP7S1NxGMbPPxKaXVUkMEq8IpKUCoY/hGgI - ymqkDYYXcCjDZOANURSjCNGFQUTsl4GXVMxKk62YU4fXQpaIlygHQxBRH8/zwvyaIAYe+HLgnPN8nue9 - HA3nvDTq63oW/jm13XOwvPTB3DYFY5MH+bXfcN8ygfTSMSSXfESicQDxBqdYHwH29g9w2tnZ3UcguIvN - rR3417exuBJE5N1n/wfwLgXEOc38Bc6xNRHb+/y4nm49G0Bnit2zf9H6bkliE/jKuYxrd6oVgDWfjB+K - TWeKMyrGEVfowITvD9re/9ABVQrAhh0HHK+ZselMMaN/mvwtDb+aVqkA7HYIwIj3ysfluPTorJnP6Ezx - oHsD1s5ZXEktUwCOioB5f1CEPR9+wTG6iuiserTo8dkwng7HT/R+XUPF8xlcTjErAOdMcW6NW8STiwG8 - 7vej8oUPN/PsEv3t8Ao0TZP3T1u8uJRkUgAuSYHtO97oLxmXd5t9Ho8aPTK+GzntqNfrLm2fFoihwYOI - xGIF4KjoGBLzY1OrF9k6OOFxnwDC4wxIMX1G0pMhgVyMNyoA13PAtS7OrJk1PrC69LUdQWxuF6IybHrX - LRI7JrtZdoDAo1XmbjMyD+tjSXxGcXRmnYg5ttD9QuxDhN0uUgDOmbvNTpPOJaGAo2K36cyaGZvOFIfd - KlSA8/zRh9ABIDUG+1JpAAAAAElFTkSuQmCC + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG + YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9 + 0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw + bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc + VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9 + c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32 + Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo + mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+ + kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D + TgDQASA1MVpwzwAAAABJRU5ErkJggg== iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIISURBVDhPpZP7S1NxGMbPPxKaXVUkMEq8IpKUCoY/hGgI - ymqkDYYXcCjDZOANURSjCNGFQUTsl4GXVMxKk62YU4fXQpaIlygHQxBRH8/zwvyaIAYe+HLgnPN8nue9 - HA3nvDTq63oW/jm13XOwvPTB3DYFY5MH+bXfcN8ygfTSMSSXfESicQDxBqdYHwH29g9w2tnZ3UcguIvN - rR3417exuBJE5N1n/wfwLgXEOc38Bc6xNRHb+/y4nm49G0Bnit2zf9H6bkliE/jKuYxrd6oVgDWfjB+K - TWeKMyrGEVfowITvD9re/9ABVQrAhh0HHK+ZselMMaN/mvwtDb+aVqkA7HYIwIj3ysfluPTorJnP6Ezx - oHsD1s5ZXEktUwCOioB5f1CEPR9+wTG6iuiserTo8dkwng7HT/R+XUPF8xlcTjErAOdMcW6NW8STiwG8 - 7vej8oUPN/PsEv3t8Ao0TZP3T1u8uJRkUgAuSYHtO97oLxmXd5t9Ho8aPTK+GzntqNfrLm2fFoihwYOI - xGIF4KjoGBLzY1OrF9k6OOFxnwDC4wxIMX1G0pMhgVyMNyoA13PAtS7OrJk1PrC69LUdQWxuF6IybHrX - LRI7JrtZdoDAo1XmbjMyD+tjSXxGcXRmnYg5ttD9QuxDhN0uUgDOmbvNTpPOJaGAo2K36cyaGZvOFIfd - KlSA8/zRh9ABIDUG+1JpAAAAAElFTkSuQmCC + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG + YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9 + 0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw + bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc + VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9 + c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32 + Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo + mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+ + kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D + TgDQASA1MVpwzwAAAABJRU5ErkJggg== + + + + + AAEAAAD/////AQAAAAAAAAAMAgAAAEtMaWJyZU1ldGF2ZXJzZS5UeXBlcywgVmVyc2lvbj0xLjIuMC4w + LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPW51bGwFAQAAABJPcGVuTWV0YXZlcnNlLlVV + SUQBAAAAFTxHdWlkPmtfX0JhY2tpbmdGaWVsZAMLU3lzdGVtLkd1aWQCAAAABP3///8LU3lzdGVtLkd1 + aWQLAAAAAl9hAl9iAl9jAl9kAl9lAl9mAl9nAl9oAl9pAl9qAl9rAAAAAAAAAAAAAAAIBwcCAgICAgIC + AgAAAAAAAAAAAAAAAAAAAAAL \ No newline at end of file diff --git a/Radegast/GUI/Consoles/LoginConsole.Designer.cs b/Radegast/GUI/Consoles/LoginConsole.Designer.cs index f540d038f..8f4627559 100644 --- a/Radegast/GUI/Consoles/LoginConsole.Designer.cs +++ b/Radegast/GUI/Consoles/LoginConsole.Designer.cs @@ -243,8 +243,8 @@ private void InitializeComponent() // // proLogin // - this.proLogin.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.proLogin.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.proLogin.Location = new System.Drawing.Point(0, 62); this.proLogin.MarqueeAnimationSpeed = 50; this.proLogin.Name = "proLogin"; @@ -254,8 +254,8 @@ private void InitializeComponent() // // lblLoginStatus // - this.lblLoginStatus.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.lblLoginStatus.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.lblLoginStatus.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lblLoginStatus.Location = new System.Drawing.Point(3, 0); this.lblLoginStatus.Name = "lblLoginStatus"; @@ -282,9 +282,9 @@ private void InitializeComponent() this.lblVersion.AutoSize = true; this.lblVersion.Location = new System.Drawing.Point(3, 3); this.lblVersion.Name = "lblVersion"; - this.lblVersion.Size = new System.Drawing.Size(94, 13); + this.lblVersion.Size = new System.Drawing.Size(94, 39); this.lblVersion.TabIndex = 18; - this.lblVersion.Text = "Radegast 2.0.000"; + this.lblVersion.Text = "Radegast 2.0.000\r\n.NET 4.8\r\nWindows 10\r\n"; // // pnlSplash // @@ -320,9 +320,9 @@ private void InitializeComponent() // // txtTOS // - this.txtTOS.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.txtTOS.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.txtTOS.Location = new System.Drawing.Point(0, 0); this.txtTOS.Multiline = true; this.txtTOS.Name = "txtTOS"; diff --git a/Radegast/GUI/Consoles/LoginConsole.cs b/Radegast/GUI/Consoles/LoginConsole.cs index ad2b43251..c6b85765a 100644 --- a/Radegast/GUI/Consoles/LoginConsole.cs +++ b/Radegast/GUI/Consoles/LoginConsole.cs @@ -1,77 +1,69 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2022, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Drawing; +using System.Reflection; +using System.Runtime.InteropServices; using System.Windows.Forms; using OpenMetaverse; using OpenMetaverse.StructuredData; -using Radegast.Netcom; +using Radegast.GUI; namespace Radegast { public partial class LoginConsole : UserControl, IRadegastTabControl { - private RadegastInstance instance; - private RadegastNetcom netcom { get { return instance.Netcom; } } + private readonly RadegastInstance instance; + private Netcom netcom => instance.Netcom; + private GridClient client => instance.Client; public LoginConsole(RadegastInstance instance) { InitializeComponent(); - Disposed += new EventHandler(MainConsole_Disposed); + Disposed += MainConsole_Disposed; this.instance = instance; AddNetcomEvents(); - if (instance.GlobalSettings["hide_login_graphics"].AsBoolean()) - pnlSplash.BackgroundImage = null; - else - pnlSplash.BackgroundImage = Properties.Resources.radegast_main_screen2; + pnlSplash.BackgroundImage = instance.GlobalSettings["hide_login_graphics"].AsBoolean() + ? null : Properties.Resources.radegast_main_screen2; if (!instance.GlobalSettings.ContainsKey("remember_login")) { instance.GlobalSettings["remember_login"] = true; } - instance.GlobalSettings.OnSettingChanged += new Settings.SettingChangedCallback(GlobalSettings_OnSettingChanged); + instance.GlobalSettings.OnSettingChanged += GlobalSettings_OnSettingChanged; - lblVersion.Text = Properties.Resources.RadegastTitle + " " + RadegastBuild.VersionString; + lblVersion.Text = $"{Properties.Resources.RadegastTitle} {Assembly.GetExecutingAssembly().GetName().Version}\n" + + $"{RuntimeInformation.FrameworkDescription}"; - Load += new EventHandler(LoginConsole_Load); + Load += LoginConsole_Load; - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } private void MainConsole_Disposed(object sender, EventArgs e) { - instance.GlobalSettings.OnSettingChanged -= new Settings.SettingChangedCallback(GlobalSettings_OnSettingChanged); + instance.GlobalSettings.OnSettingChanged -= GlobalSettings_OnSettingChanged; RemoveNetcomEvents(); } @@ -79,7 +71,7 @@ void LoginConsole_Load(object sender, EventArgs e) { if (!instance.GlobalSettings["theme_compatibility_mode"] && instance.PlainColors) { - panel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(210)))), ((int)(((byte)(210)))), ((int)(((byte)(225))))); + panel1.BackColor = Color.FromArgb(((int)(((byte)(210)))), ((int)(((byte)(210)))), ((int)(((byte)(225))))); } cbxLocation.SelectedIndex = 0; @@ -89,98 +81,105 @@ void LoginConsole_Load(object sender, EventArgs e) private void AddNetcomEvents() { - netcom.ClientLoggingIn += new EventHandler(netcom_ClientLoggingIn); - netcom.ClientLoginStatus += new EventHandler(netcom_ClientLoginStatus); - netcom.ClientLoggingOut += new EventHandler(netcom_ClientLoggingOut); - netcom.ClientLoggedOut += new EventHandler(netcom_ClientLoggedOut); + netcom.ClientLoggingIn += netcom_ClientLoggingIn; + netcom.ClientLoginStatus += netcom_ClientLoginStatus; + netcom.ClientLoggingOut += netcom_ClientLoggingOut; + netcom.ClientLoggedOut += netcom_ClientLoggedOut; + client.Network.RegisterLoginResponseCallback(network_OnLoginResponseCallback); } private void RemoveNetcomEvents() { - netcom.ClientLoggingIn -= new EventHandler(netcom_ClientLoggingIn); - netcom.ClientLoginStatus -= new EventHandler(netcom_ClientLoginStatus); - netcom.ClientLoggingOut -= new EventHandler(netcom_ClientLoggingOut); - netcom.ClientLoggedOut -= new EventHandler(netcom_ClientLoggedOut); + netcom.ClientLoggingIn -= netcom_ClientLoggingIn; + netcom.ClientLoginStatus -= netcom_ClientLoginStatus; + netcom.ClientLoggingOut -= netcom_ClientLoggingOut; + netcom.ClientLoggedOut -= netcom_ClientLoggedOut; + client.Network.UnregisterLoginResponseCallback(network_OnLoginResponseCallback); } void GlobalSettings_OnSettingChanged(object sender, SettingsEventArgs e) { if (e.Key == "hide_login_graphics") { - if (e.Value.AsBoolean()) - pnlSplash.BackgroundImage = null; - else - pnlSplash.BackgroundImage = Properties.Resources.radegast_main_screen2; + pnlSplash.BackgroundImage = e.Value.AsBoolean() + ? null : Properties.Resources.radegast_main_screen2; } } private void SaveConfig() { - Settings s = instance.GlobalSettings; - SavedLogin sl = new SavedLogin(); + var globalSettings = instance.GlobalSettings; + var savedLogin = new SavedLogin(); - string username = cbxUsername.Text; + var username = cbxUsername.Text; + var passTxt = txtPassword.Text; - if (cbxUsername.SelectedIndex > 0 && cbxUsername.SelectedItem is SavedLogin) + if (cbxUsername.SelectedIndex > 0 && cbxUsername.SelectedItem is SavedLogin login) { - username = ((SavedLogin)cbxUsername.SelectedItem).Username; + username = login.Username; } if (cbxGrid.SelectedIndex == cbxGrid.Items.Count - 1) // custom login uri { - sl.GridID = "custom_login_uri"; - sl.CustomURI = txtCustomLoginUri.Text; + savedLogin.GridID = "custom_login_uri"; + savedLogin.CustomURI = txtCustomLoginUri.Text; } else { - sl.GridID = (cbxGrid.SelectedItem as Grid).ID; - sl.CustomURI = string.Empty; + savedLogin.GridID = (cbxGrid.SelectedItem as Grid)?.ID; + savedLogin.CustomURI = string.Empty; } - string savedLoginsKey = string.Format("{0}%{1}", username, sl.GridID); + var savedLoginsKey = $"{username}%{savedLogin.GridID}"; - if (!(s["saved_logins"] is OSDMap)) + if (!(globalSettings["saved_logins"] is OSDMap)) { - s["saved_logins"] = new OSDMap(); + globalSettings["saved_logins"] = new OSDMap(); } if (cbRemember.Checked) { + savedLogin.Username = globalSettings["username"] = username; - sl.Username = s["username"] = username; - - if (LoginOptions.IsPasswordMD5(txtPassword.Text)) + if (LoginOptions.IsPasswordMD5(passTxt)) { - sl.Password = txtPassword.Text; - s["password"] = txtPassword.Text; + savedLogin.Password = passTxt; + globalSettings["password"] = passTxt; } else { - sl.Password =Utils.MD5(txtPassword.Text); - s["password"] = Utils.MD5(txtPassword.Text); + var passwd = Utils.MD5(passTxt.Length > 16 + ? passTxt.Substring(0, 16) : passTxt); + savedLogin.Password = passwd; + globalSettings["password"] = passwd; } - if (cbxLocation.SelectedIndex == -1) - { - sl.CustomStartLocation = cbxLocation.Text; - } - else + + savedLogin.CustomStartLocation = cbxLocation.SelectedIndex == -1 + ? cbxLocation.Text : string.Empty; + savedLogin.StartLocationType = cbxLocation.SelectedIndex; + var savedLogins = (OSDMap)globalSettings["saved_logins"]; + if (savedLogins.ContainsKey(savedLoginsKey)) { - sl.CustomStartLocation = string.Empty; + var sl = SavedLogin.FromOSD(savedLogins[savedLoginsKey]); + if (!string.IsNullOrWhiteSpace(sl.MfaHash)) + { + savedLogin.MfaHash = sl.MfaHash; + } } - sl.StartLocationType = cbxLocation.SelectedIndex; - ((OSDMap)s["saved_logins"])[savedLoginsKey] = sl.ToOSD(); + ((OSDMap)globalSettings["saved_logins"])[savedLoginsKey] = savedLogin.ToOSD(); } - else if (((OSDMap)s["saved_logins"]).ContainsKey(savedLoginsKey)) + else if (((OSDMap)globalSettings["saved_logins"]).ContainsKey(savedLoginsKey)) { - ((OSDMap)s["saved_logins"]).Remove(savedLoginsKey); + ((OSDMap)globalSettings["saved_logins"]).Remove(savedLoginsKey); } - s["login_location_type"] = OSD.FromInteger(cbxLocation.SelectedIndex); - s["login_location"] = OSD.FromString(cbxLocation.Text); + globalSettings["login_location_type"] = OSD.FromInteger(cbxLocation.SelectedIndex); + globalSettings["login_location"] = OSD.FromString(cbxLocation.Text); - s["login_grid"] = OSD.FromInteger(cbxGrid.SelectedIndex); - s["login_uri"] = OSD.FromString(txtCustomLoginUri.Text); - s["remember_login"] = cbRemember.Checked; + globalSettings["login_grid"] = OSD.FromString(savedLogin.GridID); + globalSettings["login_grid_idx"] = OSD.FromInteger(cbxGrid.SelectedIndex); + globalSettings["login_uri"] = OSD.FromString(txtCustomLoginUri.Text); + globalSettings["remember_login"] = cbRemember.Checked; } private void ClearConfig() @@ -192,14 +191,14 @@ private void ClearConfig() private void InitializeConfig() { - // Initilize grid dropdown - int gridIx = -1; + // Initialize grid dropdown + var gridIx = -1; cbxGrid.Items.Clear(); - for (int i = 0; i < instance.GridManger.Count; i++) + for (var i = 0; i < instance.GridManger.Count; i++) { cbxGrid.Items.Add(instance.GridManger[i]); - if (MainProgram.CommandLine.Grid == instance.GridManger[i].ID) + if (MainProgram.s_CommandLineOpts.Grid == instance.GridManger[i].ID) gridIx = i; } cbxGrid.Items.Add("Custom"); @@ -216,13 +215,13 @@ private void InitializeConfig() // Setup login name string savedUsername; - if (string.IsNullOrEmpty(MainProgram.CommandLine.Username)) + if (string.IsNullOrEmpty(MainProgram.s_CommandLineOpts.Username)) { savedUsername = s["username"]; } else { - savedUsername = MainProgram.CommandLine.Username; + savedUsername = MainProgram.s_CommandLineOpts.Username; } cbxUsername.Items.Add(savedUsername); @@ -232,7 +231,7 @@ private void InitializeConfig() if (s["saved_logins"] is OSDMap) { OSDMap savedLogins = (OSDMap)s["saved_logins"]; - foreach (string loginKey in savedLogins.Keys) + foreach (var loginKey in savedLogins.Keys) { SavedLogin sl = SavedLogin.FromOSD(savedLogins[loginKey]); cbxUsername.Items.Add(sl); @@ -248,19 +247,13 @@ private void InitializeConfig() cbxUsername.SelectedIndex = 0; // Fill in saved password or use one specified on the command line - if (string.IsNullOrEmpty(MainProgram.CommandLine.Password)) - { - txtPassword.Text = s["password"].AsString(); - } - else - { - txtPassword.Text = MainProgram.CommandLine.Password; - } + txtPassword.Text = string.IsNullOrEmpty(MainProgram.s_CommandLineOpts.Password) + ? s["password"].AsString() : MainProgram.s_CommandLineOpts.Password; // Setup login location either from the last used or // override from the command line - if (string.IsNullOrEmpty(MainProgram.CommandLine.Location)) + if (string.IsNullOrEmpty(MainProgram.s_CommandLineOpts.Location)) { // Use last location as default if (s["login_location_type"].Type == OSDType.Unknown) @@ -276,7 +269,7 @@ private void InitializeConfig() } else { - switch (MainProgram.CommandLine.Location) + switch (MainProgram.s_CommandLineOpts.Location) { case "home": cbxLocation.SelectedIndex = 0; @@ -288,20 +281,20 @@ private void InitializeConfig() default: cbxLocation.SelectedIndex = -1; - cbxLocation.Text = MainProgram.CommandLine.Location; + cbxLocation.Text = MainProgram.s_CommandLineOpts.Location; break; } } // Set grid dropdown to last used, or override from command line - if (string.IsNullOrEmpty(MainProgram.CommandLine.Grid)) + if (string.IsNullOrEmpty(MainProgram.s_CommandLineOpts.Grid)) { - cbxGrid.SelectedIndex = s["login_grid"].AsInteger(); + cbxGrid.SelectedIndex = s["login_grid_idx"].AsInteger(); } else if (gridIx == -1) // --grid specified but not found { - MessageBox.Show(string.Format("Grid specified with --grid {0} not found", MainProgram.CommandLine.Grid), + MessageBox.Show($"Grid specified with --grid {MainProgram.s_CommandLineOpts.Grid} not found", "Grid not found", MessageBoxButtons.OK, MessageBoxIcon.Warning @@ -309,18 +302,18 @@ private void InitializeConfig() } // Restore login uri from settings, or command line - if (string.IsNullOrEmpty(MainProgram.CommandLine.LoginUri)) + if (string.IsNullOrEmpty(MainProgram.s_CommandLineOpts.LoginUri)) { txtCustomLoginUri.Text = s["login_uri"].AsString(); } else { - txtCustomLoginUri.Text = MainProgram.CommandLine.LoginUri; + txtCustomLoginUri.Text = MainProgram.s_CommandLineOpts.LoginUri; cbxGrid.SelectedIndex = cbxGrid.Items.Count - 1; } // Start logging in if autologin enabled from command line - if (MainProgram.CommandLine.AutoLogin) + if (MainProgram.s_CommandLineOpts.AutoLogin) { BeginLogin(); } @@ -351,7 +344,7 @@ private void netcom_ClientLoginStatus(object sender, LoginProgressEventArgs e) break; case LoginStatus.Success: - lblLoginStatus.Text = "Logged in as " + netcom.LoginOptions.FullName; + lblLoginStatus.Text = $"Logged in as {netcom.LoginOptions.FullName}"; lblLoginStatus.ForeColor = Color.FromArgb(0, 128, 128, 255); proLogin.Visible = false; @@ -369,15 +362,29 @@ private void netcom_ClientLoginStatus(object sender, LoginProgressEventArgs e) txtTOS.Text = e.Message.Replace("\n", "\r\n"); btnLogin.Enabled = false; } + else if (e.FailReason == "mfa_challenge") + { + var prompt = new MfaPrompt(instance); + if (prompt.ShowDialog() != DialogResult.OK) + { + lblLoginStatus.Text = e.Message; + btnLogin.Enabled = true; + } + prompt.Dispose(); + } else { lblLoginStatus.Text = e.Message; + netcom.loginOptions.MfaToken = string.Empty; btnLogin.Enabled = true; } proLogin.Visible = false; btnLogin.Text = "Retry"; break; + case LoginStatus.None: + default: + throw new ArgumentOutOfRangeException(); } } @@ -412,13 +419,39 @@ private void netcom_ClientLoggingIn(object sender, OverrideEventArgs e) btnLogin.Enabled = false; } + private void network_OnLoginResponseCallback(bool loginSuccess, bool redirect, string message, string reason, LoginResponseData replyData) + { + if (!loginSuccess || redirect) { return; } + + if (!string.IsNullOrWhiteSpace(replyData.MfaHash)) + { + var settings = instance.GlobalSettings; + if (settings.ContainsKey("saved_logins") + && settings.ContainsKey("username") + && settings.ContainsKey("login_grid")) + { + string username = settings["username"]; + string grid = settings["login_grid"]; + var savedLoginsKey = $"{username}%{grid}"; + + var loginsMap = (OSDMap)settings["saved_logins"]; + if (loginsMap.ContainsKey(savedLoginsKey)) + { + var sl = (OSDMap)loginsMap[savedLoginsKey]; + sl["mfa_hash"] = replyData.MfaHash; + } + } + } + } + private void BeginLogin() { string username = cbxUsername.Text; - if (cbxUsername.SelectedIndex > 0 && cbxUsername.SelectedItem is SavedLogin) + if (cbxUsername.SelectedIndex > 0 && cbxUsername.SelectedItem is SavedLogin login) { - username = ((SavedLogin)cbxUsername.SelectedItem).Username; + username = login.Username; + netcom.loginOptions.MfaHash = login.MfaHash; } string[] parts = System.Text.RegularExpressions.Regex.Split(username.Trim(), @"[. ]+"); @@ -459,7 +492,8 @@ private void BeginLogin() { if (txtCustomLoginUri.TextLength == 0 || txtCustomLoginUri.Text.Trim().Length == 0) { - MessageBox.Show("You must specify the Login Uri to connect to a custom grid.", Properties.Resources.ProgramName, MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show("You must specify the Login Uri to connect to a custom grid.", + Properties.Resources.ProgramName, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } @@ -471,16 +505,17 @@ private void BeginLogin() netcom.LoginOptions.Grid = cbxGrid.SelectedItem as Grid; } - if (netcom.LoginOptions.Grid.Platform != "SecondLife") + if (instance.GlobalSettings.ContainsKey("saved_logins")) { - instance.Client.Settings.MULTIPLE_SIMS = true; - instance.Client.Settings.HTTP_INVENTORY = !instance.GlobalSettings["disable_http_inventory"]; - } - else - { - // UDP inventory is deprecated as of 2015-03-30 and no longer supported. - // https://community.secondlife.com/t5/Second-Life-Server/Deploy-for-the-week-of-2015-03-30/td-p/2919194 - instance.Client.Settings.HTTP_INVENTORY = true; + var logins = (OSDMap)instance.GlobalSettings["saved_logins"]; + var gridId = cbxGrid.SelectedIndex == cbxGrid.Items.Count - 1 + ? "custom_login_uri" : (cbxGrid.SelectedItem as Grid)?.ID; + var savedLoginsKey = $"{username}%{gridId}"; + if (logins.ContainsKey(savedLoginsKey)) + { + var sl = SavedLogin.FromOSD(logins[savedLoginsKey]); + netcom.LoginOptions.MfaHash = sl.MfaHash; + } } netcom.Login(); @@ -491,8 +526,9 @@ private void btnLogin_Click(object sender, EventArgs e) { switch (btnLogin.Text) { - case "Login": BeginLogin(); break; - + case "Login": + BeginLogin(); + break; case "Retry": pnlLoginPrompt.Visible = true; pnlLoggingIn.Visible = false; @@ -542,30 +578,29 @@ private void cbxUsername_SelectedIndexChanged(object sender, EventArgs e) cbxUsername.SelectedIndexChanged -= cbxUsername_SelectedIndexChanged; if (cbxUsername.SelectedIndex > 0 - && cbxUsername.SelectedItem is SavedLogin) + && cbxUsername.SelectedItem is SavedLogin savedLogin) { - SavedLogin sl = (SavedLogin)cbxUsername.SelectedItem; - cbxUsername.Text = sl.Username; - cbxUsername.Items[0] = sl.Username; + cbxUsername.Text = savedLogin.Username; + cbxUsername.Items[0] = savedLogin.Username; cbxUsername.SelectedIndex = 0; - txtPassword.Text = sl.Password; - cbxLocation.SelectedIndex = sl.StartLocationType; - if (sl.StartLocationType == -1) + txtPassword.Text = savedLogin.Password; + cbxLocation.SelectedIndex = savedLogin.StartLocationType; + if (savedLogin.StartLocationType == -1) { - cbxLocation.Text = sl.CustomStartLocation; + cbxLocation.Text = savedLogin.CustomStartLocation; } - if (sl.GridID == "custom_login_uri") + if (savedLogin.GridID == "custom_login_uri") { cbxGrid.SelectedIndex = cbxGrid.Items.Count - 1; - txtCustomLoginUri.Text = sl.CustomURI; + txtCustomLoginUri.Text = savedLogin.CustomURI; } else { foreach (var item in cbxGrid.Items) { - if (item is Grid && ((Grid)item).ID == sl.GridID) + if (item is Grid grid && grid.ID == savedLogin.GridID) { - cbxGrid.SelectedItem = item; + cbxGrid.SelectedItem = grid; break; } } @@ -580,6 +615,7 @@ public class SavedLogin { public string Username; public string Password; + public string MfaHash; public string GridID; public string CustomURI; public int StartLocationType; @@ -587,34 +623,42 @@ public class SavedLogin public OSDMap ToOSD() { - OSDMap ret = new OSDMap(4); - ret["username"] = Username; - ret["password"] = Password; - ret["grid"] = GridID; - ret["custom_url"] = CustomURI; - ret["location_type"] = StartLocationType; - ret["custom_location"] = CustomStartLocation; + OSDMap ret = new OSDMap(4) + { + ["username"] = Username, + ["password"] = Password, + ["mfa_hash"] = MfaHash, + ["grid"] = GridID, + ["custom_url"] = CustomURI, + ["location_type"] = StartLocationType, + ["custom_location"] = CustomStartLocation + }; return ret; } public static SavedLogin FromOSD(OSD data) { - if (!(data is OSDMap)) return null; - OSDMap map = (OSDMap)data; - SavedLogin ret = new SavedLogin(); - ret.Username = map["username"]; - ret.Password = map["password"]; - ret.GridID = map["grid"]; - ret.CustomURI = map["custom_url"]; - if (map.ContainsKey("location_type")) + if (!(data is OSDMap osd)) return null; + SavedLogin ret = new SavedLogin + { + Username = osd["username"], + Password = osd["password"], + GridID = osd["grid"], + CustomURI = osd["custom_url"] + }; + if (osd.ContainsKey("mfa_hash")) + { + ret.MfaHash = osd["mfa_hash"]; + } + if (osd.ContainsKey("location_type")) { - ret.StartLocationType = map["location_type"]; + ret.StartLocationType = osd["location_type"]; } else { ret.StartLocationType = 1; } - ret.CustomStartLocation = map["custom_location"]; + ret.CustomStartLocation = osd["custom_location"]; return ret; } @@ -634,7 +678,7 @@ public override string ToString() { gridName = GridID; } - return string.Format("{0} -- {1}", Username, gridName); + return $"{Username} -- {gridName}"; } } } diff --git a/Radegast/GUI/Consoles/LoginConsole.resx b/Radegast/GUI/Consoles/LoginConsole.resx index ff31a6db5..c7e0d4bdf 100644 --- a/Radegast/GUI/Consoles/LoginConsole.resx +++ b/Radegast/GUI/Consoles/LoginConsole.resx @@ -112,9 +112,9 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file diff --git a/Radegast/GUI/Consoles/MapConsole.cs b/Radegast/GUI/Consoles/MapConsole.cs index cee49e8d1..06689a545 100644 --- a/Radegast/GUI/Consoles/MapConsole.cs +++ b/Radegast/GUI/Consoles/MapConsole.cs @@ -1,42 +1,26 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.IO; using System.Text.RegularExpressions; -#if (COGBOT_LIBOMV || USE_STHREADS) -using ThreadPoolUtil; -using Thread = ThreadPoolUtil.Thread; -using ThreadPool = ThreadPoolUtil.ThreadPool; -using Monitor = ThreadPoolUtil.Monitor; -#endif using System.Threading; using System.Collections.Generic; using System.Windows.Forms; @@ -47,8 +31,8 @@ namespace Radegast public partial class MapConsole : UserControl { RadegastInstance instance; - GridClient client { get { return instance.Client; } } - bool Active { get { return client.Network.Connected; } } + GridClient client => instance.Client; + bool Active => client.Network.Connected; WebBrowser map; MapControl mmap; Regex slscheme = new Regex("^secondlife://(.+)/([0-9]+)/([0-9]+)"); @@ -59,34 +43,34 @@ public partial class MapConsole : UserControl public MapConsole(RadegastInstance inst) { InitializeComponent(); - Disposed += new EventHandler(frmMap_Disposed); + Disposed += frmMap_Disposed; - this.instance = inst; - instance.ClientChanged += new EventHandler(instance_ClientChanged); + instance = inst; + instance.ClientChanged += instance_ClientChanged; Visible = false; - VisibleChanged += new EventHandler(MapConsole_VisibleChanged); + VisibleChanged += MapConsole_VisibleChanged; // Register callbacks RegisterClientEvents(client); - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } private void RegisterClientEvents(GridClient client) { - client.Grid.GridRegion += new EventHandler(Grid_GridRegion); - client.Self.TeleportProgress += new EventHandler(Self_TeleportProgress); - client.Network.SimChanged += new EventHandler(Network_SimChanged); - client.Friends.FriendFoundReply += new EventHandler(Friends_FriendFoundReply); + client.Grid.GridRegion += Grid_GridRegion; + client.Self.TeleportProgress += Self_TeleportProgress; + client.Network.SimChanged += Network_SimChanged; + client.Friends.FriendFoundReply += Friends_FriendFoundReply; } private void UnregisterClientEvents(GridClient client) { - client.Grid.GridRegion -= new EventHandler(Grid_GridRegion); - client.Self.TeleportProgress -= new EventHandler(Self_TeleportProgress); - client.Network.SimChanged -= new EventHandler(Network_SimChanged); - client.Friends.FriendFoundReply -= new EventHandler(Friends_FriendFoundReply); + client.Grid.GridRegion -= Grid_GridRegion; + client.Self.TeleportProgress -= Self_TeleportProgress; + client.Network.SimChanged -= Network_SimChanged; + client.Friends.FriendFoundReply -= Friends_FriendFoundReply; } void instance_ClientChanged(object sender, ClientChangedEventArgs e) @@ -100,7 +84,7 @@ void createMap() if (map == null) { mmap = new MapControl(instance); - mmap.MapTargetChanged += (object sender, MapTargetChangedEventArgs e) => + mmap.MapTargetChanged += (sender, e) => { txtRegion.Text = e.Region.Name; nudX.Value = e.LocalX; @@ -108,7 +92,7 @@ void createMap() lblStatus.Text = "Ready for " + e.Region.Name; }; - mmap.ZoomChanged += new EventHandler(mmap_ZoomChaged); + mmap.ZoomChanged += mmap_ZoomChaged; if (instance.Netcom.Grid.ID == "agni") { @@ -131,7 +115,7 @@ void mmap_ZoomChaged(object sender, EventArgs e) void map_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { - map.DocumentCompleted -= new WebBrowserDocumentCompletedEventHandler(map_DocumentCompleted); + map.DocumentCompleted -= map_DocumentCompleted; map.AllowWebBrowserDrop = false; map.WebBrowserShortcutsEnabled = false; map.ScriptErrorsSuppressed = true; @@ -140,10 +124,10 @@ void map_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e if (instance.MonoRuntime) { - map.Navigating += new WebBrowserNavigatingEventHandler(map_Navigating); + map.Navigating += map_Navigating; } - WorkPool.QueueUserWorkItem(sync => + ThreadPool.QueueUserWorkItem(sync => { Thread.Sleep(1000); if (InvokeRequired && (!instance.MonoRuntime || IsHandleCreated)) @@ -167,13 +151,13 @@ void frmMap_Disposed(object sender, EventArgs e) { // Unregister callbacks UnregisterClientEvents(client); - instance.ClientChanged -= new EventHandler(instance_ClientChanged); + instance.ClientChanged -= instance_ClientChanged; if (map != null) { if (instance.MonoRuntime) { - map.Navigating -= new WebBrowserNavigatingEventHandler(map_Navigating); + map.Navigating -= map_Navigating; } else { @@ -265,7 +249,7 @@ void Network_SimChanged(object sender, SimChangedEventArgs e) } gotoRegion(client.Network.CurrentSim.Name, (int)client.Self.SimPosition.X, (int)client.Self.SimPosition.Y); - lblStatus.Text = "Now in " + client.Network.CurrentSim.Name; + lblStatus.Text = $"Now in {client.Network.CurrentSim.Name}"; } int lastTick = 0; @@ -306,10 +290,7 @@ void Self_TeleportProgress(object sender, TeleportEventArgs e) lastTick = Environment.TickCount; InTeleport = false; Network_SimChanged(null, null); - if (mmap != null) - { - mmap.ClearTarget(); - } + mmap?.ClearTarget(); break; default: @@ -342,9 +323,7 @@ void Grid_GridRegion(object sender, GridRegionEventArgs e) && e.Region.Name.ToLower().Contains(txtRegion.Text.ToLower()) && !lstRegions.Items.ContainsKey(e.Region.Name)) { - ListViewItem item = new ListViewItem(e.Region.Name); - item.Tag = e.Region; - item.Name = e.Region.Name; + ListViewItem item = new ListViewItem(e.Region.Name) {Tag = e.Region, Name = e.Region.Name}; lstRegions.Items.Add(item); } @@ -393,15 +372,15 @@ public void DoTeleport() { if (!Active) return; - if (instance.MonoRuntime && map != null) + if (instance.MonoRuntime) { - map.Navigate(Path.GetDirectoryName(Application.ExecutablePath) + @"/worldmap.html"); + map?.Navigate(Path.GetDirectoryName(Application.ExecutablePath) + @"/worldmap.html"); } lblStatus.Text = "Teleporting to " + txtRegion.Text; prgTeleport.Style = ProgressBarStyle.Marquee; - WorkPool.QueueUserWorkItem((object state) => + ThreadPool.QueueUserWorkItem(state => { if (!client.Self.Teleport(txtRegion.Text, new Vector3((int)nudX.Value, (int)nudY.Value, (int)nudZ.Value))) { @@ -428,10 +407,10 @@ void gotoRegion(string regionName, int simX, int simY) { if (!regionHandles.ContainsKey(regionName)) { - WorkPool.QueueUserWorkItem(sync => + ThreadPool.QueueUserWorkItem(sync => { ManualResetEvent done = new ManualResetEvent(false); - EventHandler handler = (object sender, GridRegionEventArgs e) => + EventHandler handler = (sender, e) => { regionHandles[e.Region.Name] = Utils.UIntsToLong((uint)e.Region.X, (uint)e.Region.Y); if (e.Region.Name == regionName) @@ -546,7 +525,7 @@ private void MapConsole_VisibleChanged(object sender, EventArgs e) ddOnlineFriends.Items.Add("Online Friends"); ddOnlineFriends.SelectedIndex = 0; - var friends = client.Friends.FriendList.FindAll((FriendInfo f) => { return f.CanSeeThemOnMap && f.IsOnline; }); + var friends = client.Friends.FriendList.FindAll(f => f.CanSeeThemOnMap && f.IsOnline); if (friends != null) { foreach (var f in friends) @@ -574,16 +553,13 @@ private void zoomTracker_Scroll(object sender, EventArgs e) { if (mmap != null) { - mmap.Zoom = mmap.MinZoom + (mmap.MaxZoom - mmap.MinZoom) * (float)((float)zoomTracker.Value / 100f); + mmap.Zoom = mmap.MinZoom + (mmap.MaxZoom - mmap.MinZoom) * ((float)zoomTracker.Value / 100f); } } private void btnRefresh_Click(object sender, EventArgs e) { - if (mmap != null) - { - mmap.RefreshRegionAgents(); - } + mmap?.RefreshRegionAgents(); } #endregion GUIEvents @@ -629,7 +605,7 @@ void Friends_FriendFoundReply(object sender, FriendFoundReplyEventArgs e) private void ddOnlineFriends_SelectedIndexChanged(object sender, EventArgs e) { if (ddOnlineFriends.SelectedIndex < 1) return; - mapFriend = client.Friends.FriendList.Find((FriendInfo f) => { return f.Name == ddOnlineFriends.SelectedItem.ToString(); }); + mapFriend = client.Friends.FriendList.Find(f => f.Name == ddOnlineFriends.SelectedItem.ToString()); if (mapFriend != null) { targetRegionHandle = 0; diff --git a/Radegast/GUI/Consoles/MasterTab.cs b/Radegast/GUI/Consoles/MasterTab.cs index 6d54bfd8d..d246ccaa0 100644 --- a/Radegast/GUI/Consoles/MasterTab.cs +++ b/Radegast/GUI/Consoles/MasterTab.cs @@ -1,47 +1,30 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; -using OpenMetaverse.StructuredData; -#if (COGBOT_LIBOMV || USE_STHREADS) -using ThreadPoolUtil; -using Thread = ThreadPoolUtil.Thread; -using ThreadPool = ThreadPoolUtil.ThreadPool; -using Monitor = ThreadPoolUtil.Monitor; -#endif using System.Threading; -using Radegast.Netcom; +using Radegast; using OpenMetaverse; namespace Radegast @@ -49,8 +32,8 @@ namespace Radegast public partial class MasterTab : UserControl { private RadegastInstance instance; - private GridClient client { get { return instance.Client; } } - private RadegastNetcom netcom { get { return instance.Netcom; } } + private GridClient client => instance.Client; + private Radegast.Netcom netcom => instance.Netcom; private Avatar avatar; public UUID selectedID; public Primitive selectedPrim; @@ -58,7 +41,7 @@ public partial class MasterTab : UserControl public MasterTab(RadegastInstance instance, Avatar avatar) { InitializeComponent(); - Disposed += new EventHandler(MasterTab_Disposed); + Disposed += MasterTab_Disposed; if (!instance.advancedDebugging) { @@ -70,16 +53,16 @@ public MasterTab(RadegastInstance instance, Avatar avatar) this.avatar = avatar; // Callbacks - client.Avatars.ViewerEffectPointAt += new EventHandler(Avatars_ViewerEffectPointAt); - client.Objects.ObjectProperties += new EventHandler(Objects_ObjectProperties); + client.Avatars.ViewerEffectPointAt += Avatars_ViewerEffectPointAt; + client.Objects.ObjectProperties += Objects_ObjectProperties; - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } void MasterTab_Disposed(object sender, EventArgs e) { - client.Avatars.ViewerEffectPointAt -= new EventHandler(Avatars_ViewerEffectPointAt); - client.Objects.ObjectProperties -= new EventHandler(Objects_ObjectProperties); + client.Avatars.ViewerEffectPointAt -= Avatars_ViewerEffectPointAt; + client.Objects.ObjectProperties -= Objects_ObjectProperties; } void Objects_ObjectProperties(object sender, ObjectPropertiesEventArgs e) @@ -95,10 +78,7 @@ void Objects_ObjectProperties(object sender, ObjectPropertiesEventArgs e) void UpdateDisplay() { if (InvokeRequired) { - Invoke(new MethodInvoker(delegate() - { - UpdateDisplay(); - })); + Invoke(new MethodInvoker(UpdateDisplay)); return; } lastPrimName.Text = selectedPrim.Properties.Name; @@ -108,10 +88,7 @@ void UpdateDisplay() void UpdateLLUUID() { if (InvokeRequired) { - Invoke(new MethodInvoker(delegate() - { - UpdateLLUUID(); - })); + Invoke(new MethodInvoker(UpdateLLUUID)); return; } lastPrimLLUUID.Text = selectedID.ToString(); @@ -143,7 +120,7 @@ void Avatars_ViewerEffectPointAt(object sender, ViewerEffectPointAtEventArgs e) if (e.SourceID == avatar.ID && e.TargetID != UUID.Zero) { selectedID = e.TargetID; selectedPrim = client.Network.CurrentSim.ObjectsPrimitives.Find( - delegate(Primitive prim) { return prim.ID == selectedID; } + prim => prim.ID == selectedID ); if (selectedPrim != null) { client.Objects.SelectObject(client.Network.CurrentSim, selectedPrim.LocalID); @@ -155,7 +132,7 @@ void Avatars_ViewerEffectPointAt(object sender, ViewerEffectPointAtEventArgs e) private void objInfoBtn_Click(object sender, EventArgs e) { selectedPrim = client.Network.CurrentSim.ObjectsPrimitives.Find( - delegate(Primitive prim) { return prim.LocalID == selectedPrim.ParentID; } + prim => prim.LocalID == selectedPrim.ParentID ); selectedID = selectedPrim.ID; UpdateLLUUID(); @@ -188,20 +165,19 @@ private void texturesBtn_Click(object sender, EventArgs e) { pnlImages.Controls.Clear(); - List textures = new List(); - - textures.Add(selectedPrim.Textures.DefaultTexture.TextureID); + List textures = new List {selectedPrim.Textures.DefaultTexture.TextureID}; - for (int i = 0; i < selectedPrim.Textures.FaceTextures.Length; i++) { - if (selectedPrim.Textures.FaceTextures[i] != null && (!textures.Contains(selectedPrim.Textures.FaceTextures[i].TextureID))) { - textures.Add(selectedPrim.Textures.FaceTextures[i].TextureID); + foreach (var te in selectedPrim.Textures.FaceTextures) + { + if (te != null && (!textures.Contains(te.TextureID))) { + textures.Add(te.TextureID); } } int nTextures = 0; foreach (UUID textureID in textures) { - SLImageHandler img = new SLImageHandler(instance, textureID, "Texture " + (nTextures + 1).ToString()); + SLImageHandler img = new SLImageHandler(instance, textureID, "Texture " + (nTextures + 1)); img.Location = new Point(0, nTextures++ * img.Height); img.Dock = DockStyle.Top; img.Height = 450; @@ -223,33 +199,37 @@ private void texturesBtn_Click(object sender, EventArgs e) private void saveBtn_Click(object sender, EventArgs e) { - WindowWrapper mainWindow = new WindowWrapper(frmMain.ActiveForm.Handle); - System.Windows.Forms.SaveFileDialog dlg = new SaveFileDialog(); - dlg.AddExtension = true; - dlg.RestoreDirectory = true; - dlg.Title = "Save object as..."; - dlg.Filter = "XML file (*.xml)|*.xml"; + if (Form.ActiveForm == null) return; + WindowWrapper mainWindow = new WindowWrapper(Form.ActiveForm.Handle); + SaveFileDialog dlg = new SaveFileDialog + { + AddExtension = true, + RestoreDirectory = true, + Title = "Save object as...", + Filter = "XML file (*.xml)|*.xml" + }; DialogResult res = dlg.ShowDialog(); if (res == DialogResult.OK) { - Thread t = new Thread(new ThreadStart(delegate() + Thread t = new Thread(delegate() + { + try + { + PrimSerializer s = new PrimSerializer(client); + string primsXmls = s.GetSerializedPrims(client.Network.CurrentSim, selectedPrim.LocalID); + System.IO.File.WriteAllText(dlg.FileName, primsXmls); + s.CleanUp(); + s = null; + MessageBox.Show(mainWindow, "Successfully saved " + dlg.FileName, "Success", + MessageBoxButtons.OK, MessageBoxIcon.Information); + } + catch (Exception excp) { - try - { - PrimSerializer s = new PrimSerializer(client); - string primsXmls = s.GetSerializedPrims(client.Network.CurrentSim, selectedPrim.LocalID); - System.IO.File.WriteAllText(dlg.FileName, primsXmls); - s.CleanUp(); - s = null; - MessageBox.Show(mainWindow, "Successfully saved " + dlg.FileName, "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); - } - catch (Exception excp) - { - MessageBox.Show(mainWindow, excp.Message, "Saving failed", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - })); - t.IsBackground = true; + MessageBox.Show(mainWindow, excp.Message, "Saving failed", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + }) {IsBackground = true}; t.Start(); } } @@ -275,19 +255,14 @@ private void btnPoint_Click(object sender, EventArgs e) } - public class WindowWrapper : System.Windows.Forms.IWin32Window + public class WindowWrapper : IWin32Window { public WindowWrapper(IntPtr handle) { - _hwnd = handle; - } - - public IntPtr Handle - { - get { return _hwnd; } + Handle = handle; } - private IntPtr _hwnd; + public IntPtr Handle { get; } } } diff --git a/Radegast/GUI/Consoles/MediaConsole.cs b/Radegast/GUI/Consoles/MediaConsole.cs index 5ae3caae1..4f2a120d4 100644 --- a/Radegast/GUI/Consoles/MediaConsole.cs +++ b/Radegast/GUI/Consoles/MediaConsole.cs @@ -1,9 +1,24 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Drawing; -using System.Data; -using System.Text; +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + +using System; using System.Windows.Forms; using OpenMetaverse; using OpenMetaverse.StructuredData; @@ -14,16 +29,13 @@ namespace Radegast public partial class MediaConsole : DettachableControl { private RadegastInstance instance; - private GridClient client { get { return instance.Client; } } + private GridClient client => instance.Client; private Settings s; private float m_audioVolume; private float audioVolume { - get - { - return m_audioVolume; - } + get => m_audioVolume; set { if (value >= 0f && value < 1f) @@ -37,7 +49,7 @@ private float audioVolume private const int saveConfigTimeout = 1000; private bool playing; private string currentURL; - private Media.Stream parcelStream; + private Stream parcelStream; private readonly object parcelMusicLock = new object(); @@ -47,10 +59,10 @@ public MediaConsole(RadegastInstance instance) DisposeOnDetachedClose = false; Text = "Media"; - Disposed += new EventHandler(MediaConsole_Disposed); + Disposed += MediaConsole_Disposed; this.instance = instance; - this.parcelStream = new Media.Stream(); + parcelStream = new Stream(); s = instance.GlobalSettings; @@ -93,27 +105,27 @@ public MediaConsole(RadegastInstance instance) } // GUI Events - volAudioStream.Scroll += new EventHandler(volAudioStream_Scroll); - txtAudioURL.TextChanged += new EventHandler(txtAudioURL_TextChanged); - cbKeep.CheckedChanged += new EventHandler(cbKeep_CheckedChanged); - cbPlayAudioStream.CheckedChanged += new EventHandler(cbPlayAudioStream_CheckedChanged); + volAudioStream.Scroll += volAudioStream_Scroll; + txtAudioURL.TextChanged += txtAudioURL_TextChanged; + cbKeep.CheckedChanged += cbKeep_CheckedChanged; + cbPlayAudioStream.CheckedChanged += cbPlayAudioStream_CheckedChanged; lblStation.Tag = lblStation.Text = string.Empty; - lblStation.Click += new EventHandler(lblStation_Click); + lblStation.Click += lblStation_Click; - objVolume.Scroll += new EventHandler(volObject_Scroll); - cbObjSoundEnable.CheckedChanged += new EventHandler(cbObjEnableChanged); + objVolume.Scroll += volObject_Scroll; + cbObjSoundEnable.CheckedChanged += cbObjEnableChanged; // Network callbacks - client.Parcels.ParcelProperties += new EventHandler(Parcels_ParcelProperties); + client.Parcels.ParcelProperties += Parcels_ParcelProperties; - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } private void MediaConsole_Disposed(object sender, EventArgs e) { Stop(); - client.Parcels.ParcelProperties -= new EventHandler(Parcels_ParcelProperties); + client.Parcels.ParcelProperties -= Parcels_ParcelProperties; if (configTimer != null) { @@ -156,8 +168,7 @@ private void Stop() lock (parcelMusicLock) { playing = false; - if (parcelStream != null) - parcelStream.Dispose(); + parcelStream?.Dispose(); parcelStream = null; lblStation.Tag = lblStation.Text = string.Empty; txtSongTitle.Text = string.Empty; @@ -170,10 +181,9 @@ private void Play() { Stop(); playing = true; - parcelStream = new Media.Stream(); - parcelStream.Volume = audioVolume; + parcelStream = new Stream {Volume = audioVolume}; parcelStream.PlayStream(currentURL); - parcelStream.OnStreamInfo += new Media.Stream.StreamInfoCallback(ParcelMusic_OnStreamInfo); + parcelStream.OnStreamInfo += ParcelMusic_OnStreamInfo; } } @@ -217,9 +227,9 @@ private void SaveConfig(object state) s["parcel_audio_vol"] = OSD.FromReal(audioVolume); s["parcel_audio_play"] = OSD.FromBoolean(cbPlayAudioStream.Checked); s["parcel_audio_keep_url"] = OSD.FromBoolean(cbKeep.Checked); - s["object_audio_vol"] = OSD.FromReal(this.instance.MediaManager.ObjectVolume); + s["object_audio_vol"] = OSD.FromReal(instance.MediaManager.ObjectVolume); s["object_audio_enable"] = OSD.FromBoolean(cbObjSoundEnable.Checked); - s["ui_audio_vol"] = OSD.FromReal(this.instance.MediaManager.UIVolume); + s["ui_audio_vol"] = OSD.FromReal(instance.MediaManager.UIVolume); } #region GUI event handlers @@ -269,19 +279,19 @@ void cbKeep_CheckedChanged(object sender, EventArgs e) private void btnPlay_Click(object sender, EventArgs e) { lock (parcelMusicLock) if (!playing) - { - currentURL = txtAudioURL.Text; - Play(); - } + { + currentURL = txtAudioURL.Text; + Play(); + } } private void btnStop_Click(object sender, EventArgs e) { lock (parcelMusicLock) if (playing) - { - currentURL = string.Empty; - Stop(); - } + { + currentURL = string.Empty; + Stop(); + } } private void UIVolume_Scroll(object sender, EventArgs e) diff --git a/Radegast/GUI/Consoles/MeshUploadConsole.cs b/Radegast/GUI/Consoles/MeshUploadConsole.cs index c7e9bae06..77b1dbe92 100644 --- a/Radegast/GUI/Consoles/MeshUploadConsole.cs +++ b/Radegast/GUI/Consoles/MeshUploadConsole.cs @@ -1,45 +1,31 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections.Generic; -using System.ComponentModel; -using System.Drawing; -using System.Drawing.Imaging; -using System.Data; -using System.Linq; -using System.Text; +using System.Globalization; using System.Windows.Forms; using System.IO; using System.Threading; using OpenMetaverse; +using System.Threading.Tasks; namespace Radegast { @@ -48,13 +34,13 @@ public partial class MeshUploadConsole : RadegastTabControl bool Running = false; bool UploadImages; Queue FileNames = new Queue(); - Thread UploadThread; + CancellationTokenSource uploadCancelToken; public MeshUploadConsole() { InitializeComponent(); - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } public MeshUploadConsole(RadegastInstance instance) @@ -62,26 +48,24 @@ public MeshUploadConsole(RadegastInstance instance) { InitializeComponent(); - Disposed += new EventHandler(MeshUploadConsole_Disposed); - instance.Netcom.ClientConnected += new EventHandler(Netcom_ClientConnected); - instance.Netcom.ClientDisconnected += new EventHandler(Netcom_ClientDisconnected); + Disposed += MeshUploadConsole_Disposed; + instance.Netcom.ClientConnected += Netcom_ClientConnected; + instance.Netcom.ClientDisconnected += Netcom_ClientDisconnected; UpdateButtons(); - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + uploadCancelToken = new CancellationTokenSource(); + + GUI.GuiHelpers.ApplyGuiFixes(this); } void MeshUploadConsole_Disposed(object sender, EventArgs e) { - if (UploadThread != null && UploadThread.IsAlive) + try { - try - { - UploadThread.Abort(); - } - catch { } - UploadThread = null; - Running = false; - } + uploadCancelToken.Cancel(); + uploadCancelToken.Dispose(); + } catch (ObjectDisposedException) { } + Running = false; } void Netcom_ClientDisconnected(object sender, DisconnectedEventArgs e) @@ -94,17 +78,13 @@ void Netcom_ClientDisconnected(object sender, DisconnectedEventArgs e) } return; } - - if (UploadThread != null && UploadThread.IsAlive) + try { - try - { - UploadThread.Abort(); - } - catch { } - UploadThread = null; - Running = false; + uploadCancelToken.Cancel(); + uploadCancelToken.Dispose(); } + catch (ObjectDisposedException) { } + Running = false; UpdateButtons(); } @@ -142,7 +122,7 @@ void UpdateButtons() { if (!instance.MonoRuntime || IsHandleCreated) { - BeginInvoke(new MethodInvoker(() => UpdateButtons())); + BeginInvoke(new MethodInvoker(UpdateButtons)); } return; } @@ -179,12 +159,14 @@ void UpdateButtons() private void btnBrowse_Click(object sender, EventArgs e) { - var o = new OpenFileDialog(); - o.Filter = "Collada files (*.dae)|*.dae|All files (*.*)|*.*"; - o.Multiselect = true; + var o = new OpenFileDialog + { + Filter = "Collada files (*.dae)|*.dae|All files (*.*)|*.*", + Multiselect = true + }; var res = o.ShowDialog(); - if (res != System.Windows.Forms.DialogResult.OK) + if (res != DialogResult.OK) return; lock (FileNames) @@ -211,64 +193,71 @@ private void btnStart_Click(object sender, EventArgs e) } } - UploadThread = new Thread(new ThreadStart(PerformUpload)); - UploadThread.Name = "Mesh Upload Thread"; - UploadThread.IsBackground = true; - UploadThread.Start(); + Task uploadTask = Task.Run(PerformUpload, uploadCancelToken.Token); + txtUploadLog.Clear(); } void PerformUpload() { - Running = true; - UpdateButtons(); - - while (FileNames.Count > 0) + try { - Msg(string.Empty); + Running = true; + UpdateButtons(); - string filename; - lock (FileNames) + while (FileNames.Count > 0) { - filename = FileNames.Dequeue(); - } - Msg(string.Format("Processing: {0}", filename)); + Msg(string.Empty); - var parser = new OpenMetaverse.ImportExport.ColladaLoader(); - var prims = parser.Load(filename, UploadImages); - if (prims == null || prims.Count == 0) - { - Msg("Error: Failed to parse collada file"); - continue; - } + string filename; + lock (FileNames) + { + filename = FileNames.Dequeue(); + } + Msg($"Processing: {filename}"); - Msg(string.Format("Parse collada file success, found {0} objects", prims.Count)); - Msg("Uploading..."); + var parser = new OpenMetaverse.ImportExport.ColladaLoader(); + var prims = parser.Load(filename, UploadImages); + if (prims == null || prims.Count == 0) + { + Msg("Error: Failed to parse collada file"); + continue; + } - var uploader = new OpenMetaverse.ImportExport.ModelUploader(client, prims, Path.GetFileNameWithoutExtension(filename), "Radegast " + DateTime.Now.ToString()); - var uploadDone = new AutoResetEvent(false); + Msg($"Parse collada file success, found {prims.Count} objects"); + Msg("Uploading..."); - uploader.IncludePhysicsStub = true; - uploader.UseModelAsPhysics = false; + uploadCancelToken.Token.ThrowIfCancellationRequested(); - uploader.Upload((res => - { - if (res == null) + var uploader = new OpenMetaverse.ImportExport.ModelUploader(client, prims, Path.GetFileNameWithoutExtension(filename), "Radegast " + DateTime.Now.ToString(CultureInfo.InvariantCulture)); + var uploadDone = new AutoResetEvent(false); + + uploader.IncludePhysicsStub = true; + uploader.UseModelAsPhysics = false; + + uploader.Upload((res => { - Msg("Upload failed."); - } - else + if (res == null) + { + Msg("Upload failed."); + } + else + { + Msg("Upload success."); + } + + uploadDone.Set(); + })); + + if (!uploadDone.WaitOne(4 * 60 * 1000)) { - Msg("Upload success."); + Msg("Message upload timeout"); } - - uploadDone.Set(); - })); - - if (!uploadDone.WaitOne(4 * 60 * 1000)) - { - Msg("Message upload timeout"); } + } + catch (OperationCanceledException) + { + Msg("Operation cancelled"); } Running = false; diff --git a/Radegast/GUI/Consoles/MuteList.cs b/Radegast/GUI/Consoles/MuteList.cs index c1276c3e9..cb1e37169 100644 --- a/Radegast/GUI/Consoles/MuteList.cs +++ b/Radegast/GUI/Consoles/MuteList.cs @@ -1,40 +1,25 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections.Generic; -using System.ComponentModel; -using System.Drawing; -using System.Data; -using System.Linq; -using System.Text; using System.Windows.Forms; using OpenMetaverse; @@ -46,19 +31,19 @@ public MuteList() { InitializeComponent(); - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } public MuteList(RadegastInstance instance) : base(instance) { InitializeComponent(); - Disposed += new EventHandler(MuteList_Disposed); + Disposed += MuteList_Disposed; RegisterClientEvents(client); - instance.ClientChanged += new EventHandler(instance_ClientChanged); + instance.ClientChanged += instance_ClientChanged; RefreshMuteList(); - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } void instance_ClientChanged(object sender, ClientChangedEventArgs e) @@ -75,13 +60,13 @@ void MuteList_Disposed(object sender, EventArgs e) void RegisterClientEvents(GridClient client) { if (null == client) return; - client.Self.MuteListUpdated += new EventHandler(Self_MuteListUpdated); + client.Self.MuteListUpdated += Self_MuteListUpdated; } void UnregisterClientEvents(GridClient client) { if (null == client) return; - client.Self.MuteListUpdated -= new EventHandler(Self_MuteListUpdated); + client.Self.MuteListUpdated -= Self_MuteListUpdated; } void Self_MuteListUpdated(object sender, EventArgs e) @@ -105,7 +90,7 @@ public void RefreshMuteList() lvMuteList.BeginUpdate(); lvMuteList.Items.Clear(); - client.Self.MuteList.ForEach((MuteEntry me) => + client.Self.MuteList.ForEach(me => { string type = ""; switch (me.Type) @@ -116,8 +101,7 @@ public void RefreshMuteList() case MuteType.Group: type = "Group"; break; } - var item = new ListViewItem(type); - item.Tag = me; + var item = new ListViewItem(type) {Tag = me}; item.SubItems.Add(new ListViewItem.ListViewSubItem(item, me.Name)); lvMuteList.Items.Add(item); } diff --git a/Radegast/GUI/Consoles/ObjectsConsole.cs b/Radegast/GUI/Consoles/ObjectsConsole.cs index a16c098f7..25867b5e6 100644 --- a/Radegast/GUI/Consoles/ObjectsConsole.cs +++ b/Radegast/GUI/Consoles/ObjectsConsole.cs @@ -1,49 +1,32 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2021, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; -using System.Collections; using System.Collections.Generic; +using System.Linq; using System.Text; using System.Timers; using System.Windows.Forms; -#if (COGBOT_LIBOMV || USE_STHREADS) -using ThreadPoolUtil; -using Thread = ThreadPoolUtil.Thread; -using ThreadPool = ThreadPoolUtil.ThreadPool; -using Monitor = ThreadPoolUtil.Monitor; -#endif using System.Threading; -using System.Drawing; using OpenMetaverse; -using OpenMetaverse.Assets; +using System.Threading.Tasks; namespace Radegast { @@ -52,26 +35,25 @@ public partial class ObjectsConsole : UserControl, IContextMenuProvider public List Prims = new List(); private RadegastInstance instance; - private GridClient client { get { return instance.Client; } } - private Primitive currentPrim = new Primitive(); + private GridClient client => instance.Client; + private float searchRadius = 40.0f; - //public List subitems; PropertiesQueue propRequester; - private Thread ContentsThread; private ObjectConsoleFilter filter; private ObjectSorter PrimSorter; + CancellationTokenSource contentsDownloadCancelToken; - public Primitive CurrentPrim { get { return currentPrim; } } + public Primitive CurrentPrim { get; private set; } = new Primitive(); public ObjectsConsole(RadegastInstance instance) { InitializeComponent(); - Disposed += new EventHandler(frmObjects_Disposed); + Disposed += frmObjects_Disposed; this.instance = instance; propRequester = new PropertiesQueue(instance); - propRequester.OnTick += new PropertiesQueue.TickCallback(propRequester_OnTick); + propRequester.OnTick += propRequester_OnTick; btnPointAt.Text = (this.instance.State.IsPointing ? "Unpoint" : "Point At"); State_SitStateChanged(this, new SitEventArgs(instance.State.IsSitting)); @@ -98,45 +80,42 @@ public ObjectsConsole(RadegastInstance instance) btnRefresh_Click(null, null); }; - //if (instance.MonoRuntime) - //{ - // btnView.Visible = false; - //} + contentsDownloadCancelToken = new CancellationTokenSource(); // Callbacks - instance.Netcom.ClientDisconnected += new EventHandler(Netcom_ClientDisconnected); - instance.State.SitStateChanged += new EventHandler(State_SitStateChanged); - client.Objects.ObjectUpdate += new EventHandler(Objects_ObjectUpdate); - client.Objects.KillObjects += new EventHandler(Objects_KillObjects); - client.Objects.ObjectProperties += new EventHandler(Objects_ObjectProperties); - client.Objects.ObjectPropertiesFamily += new EventHandler(Objects_ObjectPropertiesFamily); - client.Network.SimChanged += new EventHandler(Network_SimChanged); - client.Self.MuteListUpdated += new EventHandler(Self_MuteListUpdated); - instance.Names.NameUpdated += new EventHandler(Avatars_UUIDNameReply); - instance.State.OnWalkStateCanged += new StateManager.WalkStateCanged(State_OnWalkStateCanged); + instance.Netcom.ClientDisconnected += Netcom_ClientDisconnected; + instance.State.SitStateChanged += State_SitStateChanged; + client.Objects.ObjectUpdate += Objects_ObjectUpdate; + client.Objects.KillObjects += Objects_KillObjects; + client.Objects.ObjectProperties += Objects_ObjectProperties; + client.Objects.ObjectPropertiesFamily += Objects_ObjectPropertiesFamily; + client.Network.SimChanged += Network_SimChanged; + client.Self.MuteListUpdated += Self_MuteListUpdated; + instance.Names.NameUpdated += Avatars_UUIDNameReply; + instance.State.OnWalkStateCanged += State_OnWalkStateCanged; - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } void frmObjects_Disposed(object sender, EventArgs e) { - if (ContentsThread != null) + try { - if (ContentsThread.IsAlive) ContentsThread.Abort(); - ContentsThread = null; - } + contentsDownloadCancelToken.Cancel(); + contentsDownloadCancelToken.Dispose(); + } catch (ObjectDisposedException) { } propRequester.Dispose(); - instance.Netcom.ClientDisconnected -= new EventHandler(Netcom_ClientDisconnected); - instance.State.SitStateChanged -= new EventHandler(State_SitStateChanged); - client.Objects.ObjectUpdate -= new EventHandler(Objects_ObjectUpdate); - client.Objects.KillObjects -= new EventHandler(Objects_KillObjects); - client.Objects.ObjectProperties -= new EventHandler(Objects_ObjectProperties); - client.Objects.ObjectPropertiesFamily -= new EventHandler(Objects_ObjectPropertiesFamily); - client.Network.SimChanged -= new EventHandler(Network_SimChanged); - client.Self.MuteListUpdated -= new EventHandler(Self_MuteListUpdated); - instance.Names.NameUpdated -= new EventHandler(Avatars_UUIDNameReply); - instance.State.OnWalkStateCanged -= new StateManager.WalkStateCanged(State_OnWalkStateCanged); + instance.Netcom.ClientDisconnected -= Netcom_ClientDisconnected; + instance.State.SitStateChanged -= State_SitStateChanged; + client.Objects.ObjectUpdate -= Objects_ObjectUpdate; + client.Objects.KillObjects -= Objects_KillObjects; + client.Objects.ObjectProperties -= Objects_ObjectProperties; + client.Objects.ObjectPropertiesFamily -= Objects_ObjectPropertiesFamily; + client.Network.SimChanged -= Network_SimChanged; + client.Self.MuteListUpdated -= Self_MuteListUpdated; + instance.Names.NameUpdated -= Avatars_UUIDNameReply; + instance.State.OnWalkStateCanged -= State_OnWalkStateCanged; } void State_SitStateChanged(object sender, SitEventArgs e) @@ -150,7 +129,7 @@ void State_SitStateChanged(object sender, SitEventArgs e) return; } - btnSitOn.Text = (this.instance.State.IsSitting ? "Stand Up" : "Sit On"); + btnSitOn.Text = (instance.State.IsSitting ? "Stand Up" : "Sit On"); } public void RefreshObjectList() @@ -270,13 +249,15 @@ void UpdateProperties(Primitive.ObjectProperties props) { if (lstChildren.Items.ContainsKey(props.ObjectID.ToString())) { - Primitive prim = lstChildren.Items[props.ObjectID.ToString()].Tag as Primitive; - prim.Properties = props; - lstChildren.Items[props.ObjectID.ToString()].Text = prim.Properties.Name; + if (lstChildren.Items[props.ObjectID.ToString()].Tag is Primitive prim) + { + prim.Properties = props; + lstChildren.Items[props.ObjectID.ToString()].Text = prim.Properties.Name; + } } } - if (props.ObjectID == currentPrim.ID) + if (props.ObjectID == CurrentPrim.ID) { UpdateCurrentObject(false); } @@ -317,27 +298,18 @@ void Objects_ObjectPropertiesFamily(object sender, ObjectPropertiesFamilyEventAr void UpdateObjectContents() { - if (ContentsThread != null) - { - if (ContentsThread.IsAlive) ContentsThread.Abort(); - ContentsThread = null; - } - lstContents.Items.Clear(); ListViewItem entry = new ListViewItem(); entry.SubItems.Add("Loading..."); lstContents.Items.Add(entry); - ContentsThread = new Thread(new ThreadStart(() => - { - lstContents.Tag = currentPrim; - List items = client.Inventory.GetTaskInventory(currentPrim.ID, currentPrim.LocalID, 1000 * 30); - lstContents.Invoke(new MethodInvoker(() => UpdateContentsList(items))); - })); - - ContentsThread.IsBackground = true; - ContentsThread.Start(); - + Task contentsTask = Task.Run(() => + { + lstContents.Tag = CurrentPrim; + List items = + client.Inventory.GetTaskInventory(CurrentPrim.ID, CurrentPrim.LocalID, 1000 * 30); + lstContents.Invoke(new MethodInvoker(() => UpdateContentsList(items))); + }, contentsDownloadCancelToken.Token); } void UpdateContentsList(List items) @@ -351,7 +323,7 @@ void UpdateContentsList(List items) if (items == null) { ListViewItem entry = new ListViewItem(); - entry.SubItems.Add("(failied to fetch contents)"); + entry.SubItems.Add("(failed to fetch contents)"); entry.SubItems[0].Font = new System.Drawing.Font(entry.SubItems[0].Font, System.Drawing.FontStyle.Italic); lstContents.Items.Add(entry); } @@ -368,15 +340,17 @@ void UpdateContentsList(List items) { btnOpen.Enabled = prim.Properties != null && prim.Properties.OwnerID == client.Self.AgentID; - for (int i = 0; i < items.Count; i++) + foreach (var i in items) { - if (items[i] is InventoryItem) + if (i is InventoryItem item) { - InventoryItem item = (InventoryItem)items[i]; - ListViewItem entry = new ListViewItem(); + ListViewItem entry = new ListViewItem + { + ImageIndex = + InventoryConsole.GetItemImageIndex(item.AssetType.ToString().ToLower()), + Tag = item + }; - entry.ImageIndex = InventoryConsole.GetItemImageIndex(item.AssetType.ToString().ToLower()); - entry.Tag = item; ListViewItem.ListViewSubItem sub; @@ -395,7 +369,7 @@ void UpdateContentsList(List items) if ((item.Permissions.OwnerMask & PermissionMask.Transfer) == 0) sub.Text += " (no transfer)"; - sub.Text += " (" + item.InventoryType.ToString() + ")"; + sub.Text += " (" + item.InventoryType + ")"; entry.ToolTipText = sub.Text; lstContents.Items.Add(entry); @@ -423,16 +397,14 @@ private void ctxContents_Opening(object sender, System.ComponentModel.CancelEven { ListViewItem entry = lstContents.SelectedItems[0]; - if (entry.Tag is InventoryItem) + if (entry.Tag is InventoryItem item) { - InventoryItem item = (InventoryItem)entry.Tag; - if (canModify) { switch (item.InventoryType) { case InventoryType.Notecard: - ctxContents.Items.Add("Edit Notecard", null, (object sd, EventArgs ev) => + ctxContents.Items.Add("Edit Notecard", null, (sd, ev) => { InventoryNotecard inv = (InventoryNotecard)entry.Tag; new Notecard(instance, inv, prim) { Detached = true }; @@ -441,7 +413,7 @@ private void ctxContents_Opening(object sender, System.ComponentModel.CancelEven break; case InventoryType.LSL: - ctxContents.Items.Add("Edit Script", null, (object sd, EventArgs ev) => + ctxContents.Items.Add("Edit Script", null, (sd, ev) => { InventoryLSL inv = (InventoryLSL)entry.Tag; new ScriptEditor(instance, inv, prim) { Detached = true }; @@ -456,11 +428,11 @@ private void ctxContents_Opening(object sender, System.ComponentModel.CancelEven if (lstContents.SelectedItems.Count > 0) { - ctxContents.Items.Add("Delete", null, (object sd, EventArgs ev) => + ctxContents.Items.Add("Delete", null, (sd, ev) => { foreach (ListViewItem i in lstContents.SelectedItems) - if (i.Tag is InventoryItem) - client.Inventory.RemoveTaskInventory(prim.LocalID, ((InventoryItem)i.Tag).UUID, client.Network.CurrentSim); + if (i.Tag is InventoryItem it) + client.Inventory.RemoveTaskInventory(prim.LocalID, it.UUID, client.Network.CurrentSim); }); } @@ -473,7 +445,7 @@ private void ctxContents_Opening(object sender, System.ComponentModel.CancelEven { if (instance.InventoryClipboard.Item is InventoryItem) { - ctxContents.Items.Add("Paste from Inventory", null, (object sd, EventArgs ev) => + ctxContents.Items.Add("Paste from Inventory", null, (sd, ev) => { if (instance.InventoryClipboard.Item is InventoryLSL) { @@ -487,20 +459,19 @@ private void ctxContents_Opening(object sender, System.ComponentModel.CancelEven } else if (instance.InventoryClipboard.Item is InventoryFolder) { - ctxContents.Items.Add("Paste Folder Contents", null, (object sd, EventArgs ev) => + ctxContents.Items.Add("Paste Folder Contents", null, (sd, ev) => { foreach (InventoryBase oldItem in client.Inventory.Store.GetContents((InventoryFolder)instance.InventoryClipboard.Item)) { - if (oldItem is InventoryItem) + if (!(oldItem is InventoryItem item)) continue; + + if (item is InventoryLSL) { - if (oldItem is InventoryLSL) - { - client.Inventory.CopyScriptToTask(prim.LocalID, (InventoryItem)oldItem, true); - } - else - { - client.Inventory.UpdateTaskInventory(prim.LocalID, (InventoryItem)oldItem); - } + client.Inventory.CopyScriptToTask(prim.LocalID, item, true); + } + else + { + client.Inventory.UpdateTaskInventory(prim.LocalID, item); } } }); @@ -517,40 +488,33 @@ private void ctxContents_Opening(object sender, System.ComponentModel.CancelEven void OpenObject(object sender, EventArgs e) { - if (!(lstContents.Tag is Primitive)) return; - - Primitive prim = (Primitive)lstContents.Tag; - if (prim.Properties == null) return; + Primitive prim = lstContents.Tag as Primitive; + if (prim?.Properties == null) return; List items = new List(); foreach (ListViewItem item in lstContents.Items) { - if (item.Tag is InventoryItem) - items.Add(item.Tag as InventoryItem); + if (item.Tag is InventoryItem tag) + items.Add(tag); } if (items.Count == 0) return; UUID folderID = client.Inventory.CreateFolder(client.Inventory.Store.RootFolder.UUID, prim.Properties.Name); - for (int i = 0; i < items.Count; i++) + foreach (var item in items) { - client.Inventory.MoveTaskInventory(prim.LocalID, items[i].UUID, folderID, client.Network.CurrentSim); + client.Inventory.MoveTaskInventory(prim.LocalID, item.UUID, folderID, client.Network.CurrentSim); } instance.TabConsole.DisplayNotificationInChat("Items from object contents copied to new inventory folder " + prim.Properties.Name); } - void UpdateCurrentObject() - { - UpdateCurrentObject(true); - } - - void UpdateCurrentObject(bool updateContents) + void UpdateCurrentObject(bool updateContents = true) { - if (currentPrim.Properties == null) return; + if (CurrentPrim.Properties == null) return; if (InvokeRequired) { @@ -560,9 +524,9 @@ void UpdateCurrentObject(bool updateContents) // currentItem.Text = GetObjectName(currentPrim); - txtObjectName.Text = currentPrim.Properties.Name; - txtDescription.Text = currentPrim.Properties.Description; - if ((currentPrim.Flags & PrimFlags.ObjectModify) == PrimFlags.ObjectModify) + txtObjectName.Text = CurrentPrim.Properties.Name; + txtDescription.Text = CurrentPrim.Properties.Description; + if ((CurrentPrim.Flags & PrimFlags.ObjectModify) == PrimFlags.ObjectModify) { txtObjectName.ReadOnly = txtDescription.ReadOnly = false; gbxObjectDetails.Text = "Object details (you can modify)"; @@ -573,11 +537,11 @@ void UpdateCurrentObject(bool updateContents) gbxObjectDetails.Text = "Object details"; } - txtHover.Text = currentPrim.Text; - txtOwner.AgentID = currentPrim.Properties.OwnerID; - txtCreator.AgentID = currentPrim.Properties.CreatorID; + txtHover.Text = CurrentPrim.Text; + txtOwner.AgentID = CurrentPrim.Properties.OwnerID; + txtCreator.AgentID = CurrentPrim.Properties.CreatorID; - Permissions p = currentPrim.Properties.Permissions; + Permissions p = CurrentPrim.Properties.Permissions; cbOwnerModify.Checked = (p.OwnerMask & PermissionMask.Modify) != 0; cbOwnerCopy.Checked = (p.OwnerMask & PermissionMask.Copy) != 0; cbOwnerTransfer.Checked = (p.OwnerMask & PermissionMask.Transfer) != 0; @@ -594,7 +558,7 @@ void UpdateCurrentObject(bool updateContents) cbNextOwnCopy.CheckedChanged += cbNextOwnerUpdate_CheckedChanged; cbNextOwnTransfer.CheckedChanged += cbNextOwnerUpdate_CheckedChanged; - if (currentPrim.Properties.OwnerID == client.Self.AgentID) + if (CurrentPrim.Properties.OwnerID == client.Self.AgentID) { cbNextOwnModify.Enabled = cbNextOwnCopy.Enabled = cbNextOwnTransfer.Enabled = true; } @@ -604,23 +568,13 @@ void UpdateCurrentObject(bool updateContents) } txtPrims.Text = (client.Network.CurrentSim.ObjectsPrimitives.FindAll( - delegate(Primitive prim) - { - return prim.ParentID == currentPrim.LocalID || prim.LocalID == currentPrim.LocalID; - })).Count.ToString(); + prim => prim.ParentID == CurrentPrim.LocalID || prim.LocalID == CurrentPrim.LocalID)).Count.ToString(); - if ((currentPrim.Flags & PrimFlags.Money) != 0) - { - btnPay.Enabled = true; - } - else - { - btnPay.Enabled = false; - } + btnPay.Enabled = (CurrentPrim.Flags & PrimFlags.Money) != 0; - if (currentPrim.Properties.SaleType != SaleType.Not) + if (CurrentPrim.Properties.SaleType != SaleType.Not) { - btnBuy.Text = string.Format("Buy $L{0}", currentPrim.Properties.SalePrice); + btnBuy.Text = string.Format("Buy $L{0}", CurrentPrim.Properties.SalePrice); btnBuy.Enabled = true; } else @@ -667,19 +621,17 @@ private string GetObjectName(Primitive prim, int distance) PrimFlags.ObjectGroupOwned == (prim.Flags & PrimFlags.ObjectGroupOwned) && UUID.Zero != prim.Properties.GroupID) { - System.Threading.AutoResetEvent nameReceivedSignal = new System.Threading.AutoResetEvent(false); - EventHandler cbGroupName = new EventHandler( - delegate(object sender, GroupNamesEventArgs e) + AutoResetEvent nameReceivedSignal = new AutoResetEvent(false); + EventHandler cbGroupName = delegate(object sender, GroupNamesEventArgs e) + { + if (e.GroupNames.ContainsKey(prim.Properties.GroupID)) { - if (e.GroupNames.ContainsKey(prim.Properties.GroupID)) - { - e.GroupNames.TryGetValue(prim.Properties.GroupID, out ownerName); - if (string.IsNullOrEmpty(ownerName)) - ownerName = "Loading..."; - if (null != nameReceivedSignal) - nameReceivedSignal.Set(); - } - }); + e.GroupNames.TryGetValue(prim.Properties.GroupID, out ownerName); + if (string.IsNullOrEmpty(ownerName)) + ownerName = "Loading..."; + nameReceivedSignal.Set(); + } + }; client.Groups.GroupNamesReply += cbGroupName; client.Groups.RequestGroupName(prim.Properties.GroupID); nameReceivedSignal.WaitOne(5000, false); @@ -692,7 +644,7 @@ private string GetObjectName(Primitive prim, int distance) if (prim.ParentID == client.Self.LocalID) { - return string.Format("{0} attached to {1}", name, prim.PrimData.AttachmentPoint.ToString()); + return string.Format("{0} attached to {1}", name, prim.PrimData.AttachmentPoint); } else if (ownerName != "Loading...") { @@ -717,7 +669,9 @@ private void AddPrim(Primitive prim) lock (Prims) { string name = GetObjectName(prim); - if (!Prims.Contains(prim) && (txtSearch.Text.Length == 0 || name.ToLower().Contains(txtSearch.Text.ToLower()))) + if (!Prims.Contains(prim) + && txtSearch.IsHandleCreated + && (txtSearch.Text.Length == 0 || name.ToLower().Contains(txtSearch.Text.ToLower()))) { Prims.Add(prim); if (prim.Properties == null) @@ -748,9 +702,9 @@ void Objects_ObjectUpdate(object sender, PrimEventArgs e) } } - if (e.Prim.ID == currentPrim.ID) + if (e.Prim.ID == CurrentPrim.ID) { - if (currentPrim.Properties != null) + if (CurrentPrim.Properties != null) { UpdateCurrentObject(false); } @@ -765,14 +719,7 @@ void Objects_KillObjects(object sender, KillObjectsEventArgs e) { List killed = Prims.FindAll((p) => { - for (int i = 0; i < e.ObjectLocalIDs.Length; i++) - { - if (p.LocalID == e.ObjectLocalIDs[i]) - { - return true; - } - } - return false; + return e.ObjectLocalIDs.Any(t => p.LocalID == t); }); foreach (Primitive prim in killed) @@ -856,7 +803,7 @@ private void btnPointAt_Click(object sender, EventArgs e) { if (btnPointAt.Text == "Point At") { - instance.State.SetPointing(currentPrim, 3); + instance.State.SetPointing(CurrentPrim, 3); btnPointAt.Text = "Unpoint"; } else if (btnPointAt.Text == "Unpoint") @@ -868,19 +815,12 @@ private void btnPointAt_Click(object sender, EventArgs e) private void btnSitOn_Click(object sender, EventArgs e) { - if (!instance.State.IsSitting) - { - instance.State.SetSitting(true, currentPrim.ID); - } - else - { - instance.State.SetSitting(false, currentPrim.ID); - } + instance.State.SetSitting(!instance.State.IsSitting, CurrentPrim.ID); } private void btnTouch_Click(object sender, EventArgs e) { - client.Self.Touch(currentPrim.LocalID); + client.Self.Touch(CurrentPrim.LocalID); } private void txtSearch_TextChanged(object sender, EventArgs e) @@ -913,7 +853,7 @@ private void lstPrims_SelectedIndexChanged(object sender, EventArgs e) { try { - currentPrim = Prims[lstPrims.SelectedIndices[0]]; + CurrentPrim = Prims[lstPrims.SelectedIndices[0]]; } catch { @@ -923,11 +863,11 @@ private void lstPrims_SelectedIndexChanged(object sender, EventArgs e) } gbxInworld.Enabled = true; - btnBuy.Tag = currentPrim; + btnBuy.Tag = CurrentPrim; - if (currentPrim.Properties == null || currentPrim.OwnerID == UUID.Zero || (currentPrim.Properties != null && currentPrim.Properties.CreatorID == UUID.Zero)) + if (CurrentPrim.Properties == null || CurrentPrim.OwnerID == UUID.Zero || (CurrentPrim.Properties != null && CurrentPrim.Properties.CreatorID == UUID.Zero)) { - client.Objects.SelectObject(client.Network.CurrentSim, currentPrim.LocalID); + client.Objects.SelectObject(client.Network.CurrentSim, CurrentPrim.LocalID); } UpdateCurrentObject(); @@ -945,12 +885,12 @@ private void lstChildren_SelectedIndexChanged(object sender, EventArgs e) if (lstChildren.SelectedItems.Count == 1) { gbxInworld.Enabled = true; - currentPrim = lstChildren.SelectedItems[0].Tag as Primitive; - btnBuy.Tag = currentPrim; + CurrentPrim = lstChildren.SelectedItems[0].Tag as Primitive; + btnBuy.Tag = CurrentPrim; - if (currentPrim.Properties == null || (currentPrim.Properties != null && currentPrim.Properties.CreatorID == UUID.Zero)) + if (CurrentPrim.Properties == null || (CurrentPrim.Properties != null && CurrentPrim.Properties.CreatorID == UUID.Zero)) { - client.Objects.SelectObject(client.Network.CurrentSim, currentPrim.LocalID); + client.Objects.SelectObject(client.Network.CurrentSim, CurrentPrim.LocalID); } UpdateCurrentObject(); @@ -963,8 +903,8 @@ private void lstChildren_SelectedIndexChanged(object sender, EventArgs e) void UpdateChildren() { - if (currentPrim == null) return; - var prims = client.Network.CurrentSim.ObjectsPrimitives.FindAll((Primitive p) => p.ParentID == currentPrim.LocalID); + if (CurrentPrim == null) return; + var prims = client.Network.CurrentSim.ObjectsPrimitives.FindAll(p => p.ParentID == CurrentPrim.LocalID); if (prims == null || prims.Count == 0) return; List toGetNames = new List(); @@ -1001,30 +941,29 @@ void UpdateChildren() private void btnPay_Click(object sender, EventArgs e) { - (new frmPay(instance, currentPrim.ID, currentPrim.Properties.Name, true)).ShowDialog(); + (new frmPay(instance, CurrentPrim.ID, CurrentPrim.Properties.Name, true)).ShowDialog(); } private void btnDetach_Click(object sender, EventArgs e) { - var toDetach = CurrentOutfitFolder.GetAttachmentItem(currentPrim); - if (toDetach != UUID.Zero) + var toDetach = CurrentOutfitFolder.GetAttachmentItem(CurrentPrim); + if (toDetach == UUID.Zero) return; + + if (client.Inventory.Store.Contains(toDetach)) { - if (client.Inventory.Store.Contains(toDetach)) - { - instance.COF.Detach(client.Inventory.Store[toDetach] as InventoryItem); - } + instance.COF.Detach(client.Inventory.Store[toDetach] as InventoryItem); } } private void btnView_Click(object sender, EventArgs e) { - if (currentPrim.PrimData.PCode != PCode.Prim) + if (CurrentPrim.PrimData.PCode != PCode.Prim) { instance.TabConsole.DisplayNotificationInChat("Cannot display objects of that type", ChatBufferTextStyle.Error); return; } - Rendering.frmPrimWorkshop pw = new Rendering.frmPrimWorkshop(instance, currentPrim.LocalID); + Rendering.frmPrimWorkshop pw = new Rendering.frmPrimWorkshop(instance, CurrentPrim.LocalID); pw.Show(); } @@ -1038,7 +977,7 @@ private void btnBuy_Click(object sender, EventArgs e) { if (lstPrims.SelectedIndices.Count != 1) return; btnBuy.Enabled = false; - client.Objects.BuyObject(client.Network.CurrentSim, currentPrim.LocalID, currentPrim.Properties.SaleType, currentPrim.Properties.SalePrice, client.Self.ActiveGroup, client.Inventory.FindFolderForType(AssetType.Object)); + client.Objects.BuyObject(client.Network.CurrentSim, CurrentPrim.LocalID, CurrentPrim.Properties.SaleType, CurrentPrim.Properties.SalePrice, client.Self.ActiveGroup, client.Inventory.FindFolderForType(AssetType.Object)); } private void rbDistance_CheckedChanged(object sender, EventArgs e) @@ -1064,7 +1003,7 @@ private void rbName_CheckedChanged(object sender, EventArgs e) private void btnTurnTo_Click(object sender, EventArgs e) { if (lstPrims.SelectedIndices.Count != 1) return; - client.Self.Movement.TurnToward(currentPrim.Position); + client.Self.Movement.TurnToward(CurrentPrim.Position); } private void btnWalkTo_Click(object sender, EventArgs e) @@ -1077,7 +1016,7 @@ private void btnWalkTo_Click(object sender, EventArgs e) } else { - instance.State.WalkTo(currentPrim); + instance.State.WalkTo(CurrentPrim); } } @@ -1129,54 +1068,54 @@ private void ctxMenuObjects_Opening(object sender, System.ComponentModel.CancelE ctxMenuObjects.Items.Clear(); ctxMenuObjects.Items.Add("Click/Touch", null, btnTouch_Click); - if (currentPrim.ParentID == client.Self.LocalID) + if (CurrentPrim.ParentID == client.Self.LocalID) ctxMenuObjects.Items.Add("Detach", null, btnDetach_Click); - if ((currentPrim.Flags & PrimFlags.Money) != 0) + if ((CurrentPrim.Flags & PrimFlags.Money) != 0) ctxMenuObjects.Items.Add("Pay", null, btnPay_Click); - if (currentPrim.Properties != null && currentPrim.Properties.SaleType != SaleType.Not) - ctxMenuObjects.Items.Add(string.Format("Buy for ${0}", currentPrim.Properties.SalePrice), null, btnBuy_Click); + if (CurrentPrim.Properties != null && CurrentPrim.Properties.SaleType != SaleType.Not) + ctxMenuObjects.Items.Add(string.Format("Buy for ${0}", CurrentPrim.Properties.SalePrice), null, btnBuy_Click); if (gbxInworld.Visible) ctxMenuObjects.Items.Add("Show Contents", null, btnContents_Click); else ctxMenuObjects.Items.Add("Hide Contents", null, btnCloseContents_Click); - ctxMenuObjects.Items.Add(this.instance.State.IsSitting ? "Stand Up" : "Sit On", null, btnSitOn_Click); + ctxMenuObjects.Items.Add(instance.State.IsSitting ? "Stand Up" : "Sit On", null, btnSitOn_Click); ctxMenuObjects.Items.Add("Turn To", null, btnTurnTo_Click); ctxMenuObjects.Items.Add("Walk To", null, btnWalkTo_Click); - ctxMenuObjects.Items.Add(this.instance.State.IsPointing ? "Unpoint" : "Point At", null, btnPointAt_Click); + ctxMenuObjects.Items.Add(instance.State.IsPointing ? "Unpoint" : "Point At", null, btnPointAt_Click); ctxMenuObjects.Items.Add("3D View", null, btnView_Click); ctxMenuObjects.Items.Add("Take", null, btnTake_Click); ctxMenuObjects.Items.Add("Delete", null, btnDelete_Click); ctxMenuObjects.Items.Add("Return", null, btnReturn_Click); - if (currentPrim.Properties != null) + if (CurrentPrim.Properties != null) { - if (currentPrim.Properties.CreatorID == client.Self.AgentID && - currentPrim.Properties.OwnerID == client.Self.AgentID) + if (CurrentPrim.Properties.CreatorID == client.Self.AgentID && + CurrentPrim.Properties.OwnerID == client.Self.AgentID) { ctxMenuObjects.Items.Add("Export", null, btnExport_Click); } } - if (currentPrim.Properties != null) + if (CurrentPrim.Properties != null) { - bool isMuted = null != client.Self.MuteList.Find(me => me.Type == MuteType.Object && me.ID == currentPrim.ID); + bool isMuted = null != client.Self.MuteList.Find(me => me.Type == MuteType.Object && me.ID == CurrentPrim.ID); if (isMuted) { ctxMenuObjects.Items.Add("Unmute", null, (a, b) => { - client.Self.RemoveMuteListEntry(currentPrim.ID, currentPrim.Properties.Name); + client.Self.RemoveMuteListEntry(CurrentPrim.ID, CurrentPrim.Properties.Name); }); } else { ctxMenuObjects.Items.Add("Mute", null, (a, b) => { - client.Self.UpdateMuteListEntry(MuteType.Object, currentPrim.ID, currentPrim.Properties.Name); + client.Self.UpdateMuteListEntry(MuteType.Object, CurrentPrim.ID, CurrentPrim.Properties.Name); }); } } @@ -1194,7 +1133,7 @@ private void ctxMenuObjects_Opening(object sender, System.ComponentModel.CancelE // ); //} - instance.ContextActionManager.AddContributions(ctxMenuObjects, currentPrim); + instance.ContextActionManager.AddContributions(ctxMenuObjects, CurrentPrim); } public RadegastContextMenuStrip GetContextMenu() @@ -1205,24 +1144,24 @@ public RadegastContextMenuStrip GetContextMenu() private void btnTake_Click(object sender, EventArgs e) { instance.MediaManager.PlayUISound(UISounds.ObjectDelete); - client.Inventory.RequestDeRezToInventory(currentPrim.LocalID); + client.Inventory.RequestDeRezToInventory(CurrentPrim.LocalID); } private void btnDelete_Click(object sender, EventArgs e) { - if (currentPrim.Properties != null && currentPrim.Properties.OwnerID != client.Self.AgentID) + if (CurrentPrim.Properties != null && CurrentPrim.Properties.OwnerID != client.Self.AgentID) btnReturn_Click(sender, e); else { instance.MediaManager.PlayUISound(UISounds.ObjectDelete); - client.Inventory.RequestDeRezToInventory(currentPrim.LocalID, DeRezDestination.AgentInventoryTake, client.Inventory.FindFolderForType(FolderType.Trash), UUID.Random()); + client.Inventory.RequestDeRezToInventory(CurrentPrim.LocalID, DeRezDestination.AgentInventoryTake, client.Inventory.FindFolderForType(FolderType.Trash), UUID.Random()); } } private void btnReturn_Click(object sender, EventArgs e) { instance.MediaManager.PlayUISound(UISounds.ObjectDelete); - client.Inventory.RequestDeRezToInventory(currentPrim.LocalID, DeRezDestination.ReturnToOwner, UUID.Zero, UUID.Random()); + client.Inventory.RequestDeRezToInventory(CurrentPrim.LocalID, DeRezDestination.ReturnToOwner, UUID.Zero, UUID.Random()); } private void btnCloseContents_Click(object sender, EventArgs e) @@ -1242,7 +1181,7 @@ private void btnContents_Click(object sender, EventArgs e) private void btnExport_Click(object sender, EventArgs e) { - instance.MainForm.DisplayExportConsole(currentPrim.LocalID); + instance.MainForm.DisplayExportConsole(CurrentPrim.LocalID); } private void lstContents_MouseDoubleClick(object sender, MouseEventArgs e) @@ -1251,15 +1190,13 @@ private void lstContents_MouseDoubleClick(object sender, MouseEventArgs e) ListViewItem contentItem = lstContents.SelectedItems[0]; - if (contentItem.Tag is InventoryLSL) + if (contentItem.Tag is InventoryLSL inv1) { - InventoryLSL inv = (InventoryLSL)contentItem.Tag; Primitive prim = (Primitive)lstContents.Tag; - new ScriptEditor(instance, inv, prim) { Detached = true }; + new ScriptEditor(instance, inv1, prim) { Detached = true }; } - else if (contentItem.Tag is InventoryNotecard) + else if (contentItem.Tag is InventoryNotecard inv) { - InventoryNotecard inv = (InventoryNotecard)contentItem.Tag; Primitive prim = (Primitive)lstContents.Tag; new Notecard(instance, inv, prim) { Detached = true }; } @@ -1273,7 +1210,6 @@ private void lstContents_KeyDown(object sender, KeyEventArgs e) lstContents_MouseDoubleClick(null, null); e.SuppressKeyPress = e.Handled = true; - return; } //else if (e.KeyCode == Keys.Apps) //{ @@ -1311,49 +1247,42 @@ void Self_MuteListUpdated(object sender, EventArgs e) void UpdateMuteButton() { - bool isMuted = null != client.Self.MuteList.Find(me => me.Type == MuteType.Object && me.ID == currentPrim.ID); + bool isMuted = null != client.Self.MuteList.Find(me => me.Type == MuteType.Object && me.ID == CurrentPrim.ID); - if (isMuted) - { - btnMute.Text = "Unmute"; - } - else - { - btnMute.Text = "Mute"; - } + btnMute.Text = isMuted ? "Unmute" : "Mute"; } private void btnMute_Click(object sender, EventArgs e) { if (lstPrims.SelectedIndices.Count != 1) return; - if (currentPrim.Properties == null) return; + if (CurrentPrim.Properties == null) return; if (btnMute.Text == "Mute") { - client.Self.UpdateMuteListEntry(MuteType.Object, currentPrim.ID, currentPrim.Properties.Name); + client.Self.UpdateMuteListEntry(MuteType.Object, CurrentPrim.ID, CurrentPrim.Properties.Name); } else { - client.Self.RemoveMuteListEntry(currentPrim.ID, currentPrim.Properties.Name); + client.Self.RemoveMuteListEntry(CurrentPrim.ID, CurrentPrim.Properties.Name); } } private void txtObjectName_Leave(object sender, EventArgs e) { - if (currentPrim == null) return; - if (currentPrim.Properties == null || (currentPrim.Properties != null && currentPrim.Properties.Name != txtObjectName.Text)) + if (CurrentPrim == null) return; + if (CurrentPrim.Properties == null || (CurrentPrim.Properties != null && CurrentPrim.Properties.Name != txtObjectName.Text)) { - client.Objects.SetName(client.Network.CurrentSim, currentPrim.LocalID, txtObjectName.Text); + client.Objects.SetName(client.Network.CurrentSim, CurrentPrim.LocalID, txtObjectName.Text); } } private void txtDescription_Leave(object sender, EventArgs e) { - if (currentPrim == null) return; - if (currentPrim.Properties == null || (currentPrim.Properties != null && currentPrim.Properties.Description != txtDescription.Text)) + if (CurrentPrim == null) return; + if (CurrentPrim.Properties == null || (CurrentPrim.Properties != null && CurrentPrim.Properties.Description != txtDescription.Text)) { - client.Objects.SetDescription(client.Network.CurrentSim, currentPrim.LocalID, txtDescription.Text); + client.Objects.SetDescription(client.Network.CurrentSim, CurrentPrim.LocalID, txtDescription.Text); } } @@ -1368,7 +1297,7 @@ private void cbNextOwnerUpdate_CheckedChanged(object sender, EventArgs e) if (pm == PermissionMask.None) return; - client.Objects.SetPermissions(client.Network.CurrentSim, new List() { currentPrim.LocalID }, PermissionWho.NextOwner, pm, cb.Checked); + client.Objects.SetPermissions(client.Network.CurrentSim, new List() { CurrentPrim.LocalID }, PermissionWho.NextOwner, pm, cb.Checked); } private void lstPrims_Enter(object sender, EventArgs e) @@ -1403,15 +1332,13 @@ private void lstPrims_RetrieveVirtualItem(object sender, RetrieveVirtualItemEven } string name = GetObjectName(prim); - var item = new ListViewItem(name); - item.Tag = prim; - item.Name = prim.ID.ToString(); + var item = new ListViewItem(name) {Tag = prim, Name = prim.ID.ToString()}; e.Item = item; } } - public enum ObjectConsoleFilter : int + public enum ObjectConsoleFilter { Rezzed = 0, Attached = 1, @@ -1421,9 +1348,8 @@ public enum ObjectConsoleFilter : int public class ObjectSorter : IComparer { private AgentManager me; - private bool sortByName = false; - public bool SortByName { get { return sortByName; } set { sortByName = value; } } + public bool SortByName { get; set; } = false; public ObjectSorter(AgentManager me) { @@ -1445,13 +1371,13 @@ private int NameCompare(Primitive prim1, Primitive prim2) return 1; } - return string.Compare(prim1.Properties.Name, prim2.Properties.Name); + return string.CompareOrdinal(prim1.Properties.Name, prim2.Properties.Name); } //this routine should return -1 if xy and 0 if x==y. // for our sample we'll just use string comparison public int Compare(Primitive prim1, Primitive prim2) { - if (sortByName) + if (SortByName) { return NameCompare(prim1, prim2); } @@ -1487,9 +1413,8 @@ public class PropertiesQueue : IDisposable public PropertiesQueue(RadegastInstance instance) { this.instance = instance; - qTimer = new System.Timers.Timer(2500); - qTimer.Enabled = true; - qTimer.Elapsed += new ElapsedEventHandler(qTimer_Elapsed); + qTimer = new System.Timers.Timer(2500) {Enabled = true}; + qTimer.Elapsed += qTimer_Elapsed; } public void RequestProps(Primitive prim) @@ -1522,10 +1447,7 @@ void qTimer_Elapsed(object sender, ElapsedEventArgs e) } } - if (OnTick != null) - { - OnTick(props.Count); - } + OnTick?.Invoke(props.Count); } } @@ -1533,7 +1455,7 @@ public void Dispose() { if (qTimer != null) { - qTimer.Elapsed -= new ElapsedEventHandler(qTimer_Elapsed); + qTimer.Elapsed -= qTimer_Elapsed; qTimer.Enabled = false; qTimer = null; } diff --git a/Radegast/GUI/Consoles/OutfitTextures.cs b/Radegast/GUI/Consoles/OutfitTextures.cs index 3999a5746..48b648c8d 100644 --- a/Radegast/GUI/Consoles/OutfitTextures.cs +++ b/Radegast/GUI/Consoles/OutfitTextures.cs @@ -1,35 +1,23 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// -using System.Drawing; -using System.Collections.Generic; +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System.Windows.Forms; using OpenMetaverse; @@ -47,14 +35,14 @@ public OutfitTextures(RadegastInstance instance, Avatar avatar) this.instance = instance; this.avatar = avatar; - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } public void GetTextures() { if (avatar.Textures == null) return; - lblName.Text = this.avatar.Name; + lblName.Text = avatar.Name; for (int j = 0; j < avatar.Textures.FaceTextures.Length; j++) { @@ -66,10 +54,7 @@ public void GetTextures() { SLImageHandler img = new SLImageHandler(instance, face.TextureID, ((AvatarTextureIndex)j).ToString()); - GroupBox gbx = new GroupBox(); - gbx.Dock = DockStyle.Top; - gbx.Text = img.Text; - gbx.Height = 550; + GroupBox gbx = new GroupBox {Dock = DockStyle.Top, Text = img.Text, Height = 550}; img.Dock = DockStyle.Fill; gbx.Controls.Add(img); diff --git a/Radegast/GUI/Consoles/PluginsTab.cs b/Radegast/GUI/Consoles/PluginsTab.cs index 45dbc62c5..375bb6088 100644 --- a/Radegast/GUI/Consoles/PluginsTab.cs +++ b/Radegast/GUI/Consoles/PluginsTab.cs @@ -1,12 +1,26 @@ -using System; +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + +using System; using System.Collections.Generic; -using System.ComponentModel; -using System.Drawing; -using System.Text; using System.Windows.Forms; -using System.Reflection; -using System.IO; -using System.Threading; using OpenMetaverse; namespace Radegast @@ -20,7 +34,7 @@ public PluginsTab(RadegastInstance instance) ListPlugins(); PluginsTab_SizeChanged(this, EventArgs.Empty); - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } void ListPlugins() @@ -30,9 +44,7 @@ void ListPlugins() foreach (PluginInfo plugin in plugins) { - ListViewItem item = new ListViewItem(); - item.Text = plugin.Attribures.Name; - item.Tag = plugin; + ListViewItem item = new ListViewItem {Text = plugin.Attribures.Name, Tag = plugin}; item.SubItems.Add(plugin.Attribures.Description); item.SubItems.Add(plugin.Attribures.Version); lvwPlugins.Items.Add(item); @@ -57,7 +69,21 @@ private void btnUnload_Click(object sender, EventArgs e) { foreach (ListViewItem item in lvwPlugins.SelectedItems) { - instance.PluginManager.UnloadPlugin((PluginInfo)item.Tag); + var plugin = item.Tag as PluginInfo; + if (plugin == null) + { + Logger.Log($"ERROR Attempting to unload a null plugin: {item}", Helpers.LogLevel.Warning); + continue; + } + + try + { + instance.PluginManager.UnloadPlugin(plugin); + } + catch (Exception ex) + { + instance.TabConsole.DisplayNotificationInChat($"ERROR unable to unload plugin: {plugin} because {ex}", ChatBufferTextStyle.Error); + } } ListPlugins(); } @@ -73,10 +99,18 @@ private void btnLoad_Click(object sender, EventArgs e) if (res == DialogResult.OK) { - for (int i = 0; i < dlg.FileNames.Length; i++) + foreach (var name in dlg.FileNames) { - instance.PluginManager.LoadPluginFile(dlg.FileNames[i], true); + try + { + instance.PluginManager.LoadPlugin(name); + } + catch (Exception ex) + { + instance.TabConsole.DisplayNotificationInChat($"ERROR unable to load plugin: {name} because {ex}", ChatBufferTextStyle.Error); + } } + ListPlugins(); } } @@ -86,9 +120,22 @@ private void btnReload_Click(object sender, EventArgs e) { foreach (ListViewItem item in lvwPlugins.SelectedItems) { - PluginInfo info = (PluginInfo)item.Tag; - instance.PluginManager.UnloadPlugin((PluginInfo)item.Tag); - instance.PluginManager.LoadPluginFile(info.FileName, true); + var plugin = item.Tag as PluginInfo; + if (plugin == null) + { + Logger.Log($"ERROR Attempting to reload a null plugin: {item}", Helpers.LogLevel.Warning); + continue; + } + + try + { + instance.PluginManager.UnloadPlugin(plugin); + instance.PluginManager.LoadPlugin(plugin.FileName); + } + catch (Exception ex) + { + instance.TabConsole.DisplayNotificationInChat($"ERROR unable to reload plugin: {item} because {ex}", ChatBufferTextStyle.Error); + } ListPlugins(); } } diff --git a/Radegast/GUI/Consoles/RegionInfo.cs b/Radegast/GUI/Consoles/RegionInfo.cs index 19d99dd6f..0ca5cb3f4 100644 --- a/Radegast/GUI/Consoles/RegionInfo.cs +++ b/Radegast/GUI/Consoles/RegionInfo.cs @@ -1,19 +1,32 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Drawing; -using System.Data; -using System.Linq; -using System.Text; +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + +using System; using System.Windows.Forms; -using System.Threading; using OpenMetaverse; namespace Radegast { public partial class RegionInfo : RadegastTabControl { - System.Windows.Forms.Timer refresh; + Timer refresh; UUID parcelGroupID = UUID.Zero; public RegionInfo() @@ -25,30 +38,30 @@ public RegionInfo(RadegastInstance instance) : base(instance) { InitializeComponent(); - Disposed += new EventHandler(RegionInfo_Disposed); + Disposed += RegionInfo_Disposed; - refresh = new System.Windows.Forms.Timer() + refresh = new Timer() { Enabled = false, Interval = 1000, }; - client.Groups.GroupNamesReply += new EventHandler(Groups_GroupNamesReply); - client.Parcels.ParcelProperties += new EventHandler(Parcels_ParcelProperties); - client.Parcels.ParcelDwellReply += new EventHandler(Parcels_ParcelDwellReply); - refresh.Tick += new EventHandler(refresh_Tick); + client.Groups.GroupNamesReply += Groups_GroupNamesReply; + client.Parcels.ParcelProperties += Parcels_ParcelProperties; + client.Parcels.ParcelDwellReply += Parcels_ParcelDwellReply; + refresh.Tick += refresh_Tick; refresh.Enabled = true; UpdateDisplay(); client.Parcels.RequestDwell(client.Network.CurrentSim, instance.State.Parcel.LocalID); - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } void RegionInfo_Disposed(object sender, EventArgs e) { - client.Groups.GroupNamesReply -= new EventHandler(Groups_GroupNamesReply); - client.Parcels.ParcelProperties -= new EventHandler(Parcels_ParcelProperties); - client.Parcels.ParcelDwellReply -= new EventHandler(Parcels_ParcelDwellReply); + client.Groups.GroupNamesReply -= Groups_GroupNamesReply; + client.Parcels.ParcelProperties -= Parcels_ParcelProperties; + client.Parcels.ParcelDwellReply -= Parcels_ParcelDwellReply; refresh.Enabled = false; refresh.Dispose(); refresh = null; @@ -136,7 +149,7 @@ void UpdateSimDisplay() lblSpareTime.Text = string.Format("{0:0.0} ms", Math.Max(0f, 1000f / 45f - total)); lblCPUClass.Text = client.Network.CurrentSim.CPUClass.ToString(); - lblDataCenter.Text = client.Network.CurrentSim.ColoLocation.ToString(); + lblDataCenter.Text = client.Network.CurrentSim.ColoLocation; lblVersion.Text = client.Network.CurrentSim.SimVersion; } @@ -145,14 +158,13 @@ void UpdateParcelDisplay() Parcel p = instance.State.Parcel; txtParcelTitle.Text = p.Name; txtParcelDescription.Text = p.Desc; - lblSimType.Text = client.Network.CurrentSim.ProductName.ToString(); + lblSimType.Text = client.Network.CurrentSim.ProductName; pnlParcelImage.Controls.Clear(); if (p.SnapshotID != UUID.Zero) { - SLImageHandler imgParcel = new SLImageHandler(); - imgParcel.Dock = DockStyle.Fill; + SLImageHandler imgParcel = new SLImageHandler {Dock = DockStyle.Fill}; pnlParcelImage.Controls.Add(imgParcel); imgParcel.Init(instance, p.SnapshotID, string.Empty); } diff --git a/Radegast/GUI/Consoles/SearchConsole.cs b/Radegast/GUI/Consoles/SearchConsole.cs index 4142c5b31..29f1a824c 100644 --- a/Radegast/GUI/Consoles/SearchConsole.cs +++ b/Radegast/GUI/Consoles/SearchConsole.cs @@ -1,38 +1,29 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections.Generic; using System.Windows.Forms; using OpenMetaverse; using System.Diagnostics; +using System.Globalization; namespace Radegast { @@ -40,7 +31,7 @@ public partial class SearchConsole : UserControl { #region Private members private RadegastInstance instance; - private GridClient client { get { return instance.Client; } } + private GridClient client => instance.Client; private FindPeopleConsole console; @@ -54,7 +45,7 @@ public partial class SearchConsole : UserControl public SearchConsole(RadegastInstance instance) { InitializeComponent(); - Disposed += new EventHandler(SearchConsole_Disposed); + Disposed += SearchConsole_Disposed; this.instance = instance; @@ -63,27 +54,26 @@ public SearchConsole(RadegastInstance instance) lvwEvents.ListViewItemSorter = new EventSorter(); // Callbacks - client.Directory.DirPeopleReply += new EventHandler(Directory_DirPeopleReply); - client.Directory.DirPlacesReply += new EventHandler(Directory_DirPlacesReply); - client.Directory.DirGroupsReply += new EventHandler(Directory_DirGroupsReply); + client.Directory.DirPeopleReply += Directory_DirPeopleReply; + client.Directory.DirPlacesReply += Directory_DirPlacesReply; + client.Directory.DirGroupsReply += Directory_DirGroupsReply; client.Directory.DirEventsReply += Directory_DirEventsReply; client.Directory.EventInfoReply += Directory_EventInfoReply; instance.Names.NameUpdated += Names_NameUpdated; - console = new FindPeopleConsole(instance, UUID.Random()); - console.Dock = DockStyle.Fill; - console.SelectedIndexChanged += new EventHandler(console_SelectedIndexChanged); + console = new FindPeopleConsole(instance, UUID.Random()) {Dock = DockStyle.Fill}; + console.SelectedIndexChanged += console_SelectedIndexChanged; pnlFindPeople.Controls.Add(console); lvwPlaces.ListViewItemSorter = new PlaceSorter(); lvwGroups.ListViewItemSorter = new GroupSorter(); - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } void SearchConsole_Disposed(object sender, EventArgs e) { - client.Directory.DirPeopleReply -= new EventHandler(Directory_DirPeopleReply); - client.Directory.DirPlacesReply -= new EventHandler(Directory_DirPlacesReply); - client.Directory.DirGroupsReply -= new EventHandler(Directory_DirGroupsReply); + client.Directory.DirPeopleReply -= Directory_DirPeopleReply; + client.Directory.DirPlacesReply -= Directory_DirPlacesReply; + client.Directory.DirGroupsReply -= Directory_DirGroupsReply; client.Directory.DirEventsReply -= Directory_DirEventsReply; client.Directory.EventInfoReply -= Directory_EventInfoReply; instance.Names.NameUpdated -= Names_NameUpdated; @@ -109,7 +99,7 @@ void Directory_DirPeopleReply(object sender, DirPeopleReplyEventArgs e) if (console.QueryID != e.QueryID) return; totalResults += e.MatchedPeople.Count; - lblResultCount.Text = totalResults.ToString() + " people found"; + lblResultCount.Text = totalResults + " people found"; txtPersonName.Enabled = true; btnFind.Enabled = true; @@ -219,11 +209,13 @@ void Directory_DirPlacesReply(object sender, DirPlacesReplyEventArgs e) { if (parcel.ID == UUID.Zero) continue; - ListViewItem item = new ListViewItem(); - item.Name = parcel.ID.ToString(); - item.Text = parcel.Name; - item.Tag = parcel; - item.SubItems.Add(new ListViewItem.ListViewSubItem(item, parcel.Dwell.ToString())); + ListViewItem item = new ListViewItem + { + Name = parcel.ID.ToString(), + Text = parcel.Name, + Tag = parcel + }; + item.SubItems.Add(new ListViewItem.ListViewSubItem(item, parcel.Dwell.ToString(CultureInfo.InvariantCulture))); lvwPlaces.Items.Add(item); } lvwPlaces.Sort(); @@ -238,7 +230,7 @@ void Directory_DirPlacesReply(object sender, DirPlacesReplyEventArgs e) placeMatches -= 1; lblNrPlaces.Visible = true; - lblNrPlaces.Text = string.Format("{0} places found", placeMatches > 100 ? "More than " + (placeStart + 100).ToString() : (placeStart + placeMatches).ToString()); + lblNrPlaces.Text = string.Format("{0} places found", placeMatches > 100 ? "More than " + (placeStart + 100) : (placeStart + placeMatches).ToString()); } @@ -321,10 +313,7 @@ public int Compare(object x, object y) switch (SortBy) { case SortByColumn.Name: - if (CurrentOrder == SortOrder.Ascending) - return string.Compare(item1.Text, item2.Text); - else - return string.Compare(item2.Text, item1.Text); + return CurrentOrder == SortOrder.Ascending ? String.CompareOrdinal(item1.Text, item2.Text) : String.CompareOrdinal(item2.Text, item1.Text); case SortByColumn.Traffic: if (CurrentOrder == SortOrder.Ascending) @@ -381,8 +370,8 @@ private void lvwPlaces_SelectedIndexChanged(object sender, EventArgs e) if (lvwPlaces.SelectedItems.Count == 1) { - Landmark l = new Landmark(instance, ((DirectoryManager.DirectoryParcel)lvwPlaces.SelectedItems[0].Tag).ID); - l.Dock = DockStyle.Fill; + Landmark l = new Landmark(instance, + ((DirectoryManager.DirectoryParcel) lvwPlaces.SelectedItems[0].Tag).ID) {Dock = DockStyle.Fill}; pnlPlaceDetail.Controls.Add(l); } } @@ -412,10 +401,10 @@ void Directory_DirGroupsReply(object sender, DirGroupsReplyEventArgs e) { if (group.GroupID == UUID.Zero) continue; - ListViewItem item = new ListViewItem(); - item.Name = group.GroupID.ToString(); - item.Text = group.GroupName; - item.Tag = group; + ListViewItem item = new ListViewItem + { + Name = @group.GroupID.ToString(), Text = @group.GroupName, Tag = @group + }; item.SubItems.Add(new ListViewItem.ListViewSubItem(item, group.Members.ToString())); lvwGroups.Items.Add(item); @@ -431,7 +420,7 @@ void Directory_DirGroupsReply(object sender, DirGroupsReplyEventArgs e) groupMatches -= 1; lblNrGroups.Visible = true; - lblNrGroups.Text = string.Format("{0} groups found", groupMatches > 100 ? "More than " + (groupStart + 100).ToString() : (groupStart + groupMatches).ToString()); + lblNrGroups.Text = string.Format("{0} groups found", groupMatches > 100 ? "More than " + (groupStart + 100) : (groupStart + groupMatches).ToString()); } private void btnSearchGroup_Click(object sender, EventArgs e) @@ -492,8 +481,10 @@ private void lvwGroups_SelectedIndexChanged(object sender, EventArgs e) try { DirectoryManager.GroupSearchData g = (DirectoryManager.GroupSearchData)lvwGroups.SelectedItems[0].Tag; - GroupDetails grpPanel = new GroupDetails(instance, new Group() { ID = g.GroupID, Name = g.GroupName }); - grpPanel.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + GroupDetails grpPanel = new GroupDetails(instance, new Group() {ID = g.GroupID, Name = g.GroupName}) + { + Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right + }; grpPanel.Region = new System.Drawing.Region( new System.Drawing.RectangleF( grpPanel.tpGeneral.Left, grpPanel.tpGeneral.Top, grpPanel.tpGeneral.Width, grpPanel.tpGeneral.Height)); @@ -552,10 +543,9 @@ public int Compare(object x, object y) switch (SortBy) { case SortByColumn.Name: - if (CurrentOrder == SortOrder.Ascending) - return string.Compare(item1.Text, item2.Text); - else - return string.Compare(item2.Text, item1.Text); + return CurrentOrder == SortOrder.Ascending + ? String.CompareOrdinal(item1.Text, item2.Text) + : String.CompareOrdinal(item2.Text, item1.Text); case SortByColumn.Members: if (CurrentOrder == SortOrder.Ascending) @@ -609,10 +599,7 @@ void Directory_DirEventsReply(object sender, DirEventsReplyEventArgs e) { if (evt.ID == 0) continue; - ListViewItem item = new ListViewItem(); - item.Name = "evt" + evt.ID.ToString(); - item.Text = evt.Name; - item.Tag = evt; + ListViewItem item = new ListViewItem {Name = "evt" + evt.ID, Text = evt.Name, Tag = evt}; item.SubItems.Add(new ListViewItem.ListViewSubItem(item, evt.Date)); lvwEvents.Items.Add(item); @@ -629,7 +616,8 @@ void Directory_DirEventsReply(object sender, DirEventsReplyEventArgs e) eventMatches -= 1; lblNrEvents.Visible = true; - lblNrEvents.Text = string.Format("{0} events found", eventMatches > eventsPerPage ? "More than " + (eventStart + eventsPerPage).ToString() : (eventStart + eventMatches).ToString()); + lblNrEvents.Text = + $"{(eventMatches > eventsPerPage ? "More than " + (eventStart + eventsPerPage) : (eventStart + eventMatches).ToString())} events found"; } @@ -713,8 +701,8 @@ public int Compare(object a, object b) DirectoryManager.EventsSearchData e2 = (DirectoryManager.EventsSearchData)((ListViewItem)b).Tag; if (e1.Time < e2.Time) return -1; - else if (e1.Time > e2.Time) return 1; - else return string.Compare(e1.Name, e2.Name); + if (e1.Time > e2.Time) return 1; + return String.CompareOrdinal(e1.Name, e2.Name); } catch { } return 0; @@ -748,7 +736,7 @@ void Directory_EventInfoReply(object sender, EventInfoReplyEventArgs e) txtEventName.Text = evt.Name; txtEventType.Text = evt.Category.ToString(); txtEventMaturity.Text = evt.Flags.ToString(); - txtEventDate.Text = OpenMetaverse.Utils.UnixTimeToDateTime(evt.DateUTC).ToString("r"); + txtEventDate.Text = Utils.UnixTimeToDateTime(evt.DateUTC).ToString("r"); txtEventDuration.Text = string.Format("{0}:{1:00}", evt.Duration / 60u, evt.Duration % 60u); txtEventOrganizer.Text = instance.Names.Get(evt.Creator, string.Empty); txtEventOrganizer.Tag = evt.Creator; @@ -785,7 +773,7 @@ private void btnTeleport_Click(object sender, EventArgs e) { var evt = (DirectoryManager.EventInfo)pnlEventDetail.Tag; float localX, localY; - ulong handle = OpenMetaverse.Helpers.GlobalPosToRegionHandle((float)evt.GlobalPos.X, (float)evt.GlobalPos.Y, out localX, out localY); + ulong handle = Helpers.GlobalPosToRegionHandle((float)evt.GlobalPos.X, (float)evt.GlobalPos.Y, out localX, out localY); client.Self.Teleport(handle, new Vector3(localX, localY, (float)evt.GlobalPos.Z)); } diff --git a/Radegast/GUI/Consoles/TabsConsole.Designer.cs b/Radegast/GUI/Consoles/TabsConsole.Designer.cs index 5f8e20e53..b7ef320f6 100644 --- a/Radegast/GUI/Consoles/TabsConsole.Designer.cs +++ b/Radegast/GUI/Consoles/TabsConsole.Designer.cs @@ -59,9 +59,9 @@ protected override void Dispose(bool disposing) if (disposing) { - lock (tabs) + lock (Tabs) { - System.Collections.Generic.List tabNames = new System.Collections.Generic.List(tabs.Keys); + System.Collections.Generic.List tabNames = new System.Collections.Generic.List(Tabs.Keys); for (int i = 0; i < tabNames.Count; i++) { if (tabNames[i] != "chat") diff --git a/Radegast/GUI/Consoles/TabsConsole.cs b/Radegast/GUI/Consoles/TabsConsole.cs index f3fc057c0..ed3cbbd15 100644 --- a/Radegast/GUI/Consoles/TabsConsole.cs +++ b/Radegast/GUI/Consoles/TabsConsole.cs @@ -1,39 +1,29 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Windows.Forms; -using Radegast.Netcom; +using Radegast; using OpenMetaverse; namespace Radegast @@ -105,38 +95,28 @@ public List NearbyAvatars public event TabCallback OnTabRemoved; private RadegastInstance instance; - private GridClient client { get { return instance.Client; } } - private RadegastNetcom netcom { get { return instance.Netcom; } } - private ChatTextManager mainChatManger; - public ChatTextManager MainChatManger { get { return mainChatManger; } } + private GridClient client => instance.Client; + private Radegast.Netcom netcom => instance.Netcom; + public ChatTextManager MainChatManger { get; private set; } - private Dictionary tabs = new Dictionary(); - public Dictionary Tabs { get { return tabs; } } + public Dictionary Tabs { get; } = new Dictionary(); private ChatConsole chatConsole; - private RadegastTab selectedTab; - /// /// Currently selected tab /// - public RadegastTab SelectedTab - { - get - { - return selectedTab; - } - } + public RadegastTab SelectedTab { get; private set; } private Form owner; public TabsConsole(RadegastInstance instance) { InitializeComponent(); - Disposed += new EventHandler(TabsConsole_Disposed); + Disposed += TabsConsole_Disposed; this.instance = instance; - this.instance.ClientChanged += new EventHandler(instance_ClientChanged); + this.instance.ClientChanged += instance_ClientChanged; AddNetcomEvents(); @@ -146,28 +126,28 @@ public TabsConsole(RadegastInstance instance) // Callbacks RegisterClientEvents(client); - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } private void RegisterClientEvents(GridClient client) { - client.Self.ScriptQuestion += new EventHandler(Self_ScriptQuestion); - client.Self.ScriptDialog += new EventHandler(Self_ScriptDialog); - client.Self.LoadURL += new EventHandler(Self_LoadURL); - client.Self.SetDisplayNameReply += new EventHandler(Self_SetDisplayNameReply); - client.Avatars.DisplayNameUpdate += new EventHandler(Avatars_DisplayNameUpdate); - client.Network.EventQueueRunning += new EventHandler(Network_EventQueueRunning); + client.Self.ScriptQuestion += Self_ScriptQuestion; + client.Self.ScriptDialog += Self_ScriptDialog; + client.Self.LoadURL += Self_LoadURL; + client.Self.SetDisplayNameReply += Self_SetDisplayNameReply; + client.Avatars.DisplayNameUpdate += Avatars_DisplayNameUpdate; + client.Network.EventQueueRunning += Network_EventQueueRunning; client.Network.RegisterCallback(OpenMetaverse.Packets.PacketType.ScriptTeleportRequest, ScriptTeleportRequestHandler); } private void UnregisterClientEvents(GridClient client) { - client.Self.ScriptQuestion -= new EventHandler(Self_ScriptQuestion); - client.Self.ScriptDialog -= new EventHandler(Self_ScriptDialog); - client.Self.LoadURL -= new EventHandler(Self_LoadURL); - client.Self.SetDisplayNameReply -= new EventHandler(Self_SetDisplayNameReply); - client.Avatars.DisplayNameUpdate -= new EventHandler(Avatars_DisplayNameUpdate); - client.Network.EventQueueRunning -= new EventHandler(Network_EventQueueRunning); + client.Self.ScriptQuestion -= Self_ScriptQuestion; + client.Self.ScriptDialog -= Self_ScriptDialog; + client.Self.LoadURL -= Self_LoadURL; + client.Self.SetDisplayNameReply -= Self_SetDisplayNameReply; + client.Avatars.DisplayNameUpdate -= Avatars_DisplayNameUpdate; + client.Network.EventQueueRunning -= Network_EventQueueRunning; client.Network.UnregisterCallback(OpenMetaverse.Packets.PacketType.ScriptTeleportRequest, ScriptTeleportRequestHandler); } @@ -185,22 +165,22 @@ void TabsConsole_Disposed(object sender, EventArgs e) private void AddNetcomEvents() { - netcom.ClientLoginStatus += new EventHandler(netcom_ClientLoginStatus); - netcom.ClientLoggedOut += new EventHandler(netcom_ClientLoggedOut); - netcom.ClientDisconnected += new EventHandler(netcom_ClientDisconnected); - netcom.ChatSent += new EventHandler(netcom_ChatSent); - netcom.AlertMessageReceived += new EventHandler(netcom_AlertMessageReceived); - netcom.InstantMessageReceived += new EventHandler(netcom_InstantMessageReceived); + netcom.ClientLoginStatus += netcom_ClientLoginStatus; + netcom.ClientLoggedOut += netcom_ClientLoggedOut; + netcom.ClientDisconnected += netcom_ClientDisconnected; + netcom.ChatSent += netcom_ChatSent; + netcom.AlertMessageReceived += netcom_AlertMessageReceived; + netcom.InstantMessageReceived += netcom_InstantMessageReceived; } private void RemoveNetcomEvents() { - netcom.ClientLoginStatus -= new EventHandler(netcom_ClientLoginStatus); - netcom.ClientLoggedOut -= new EventHandler(netcom_ClientLoggedOut); - netcom.ClientDisconnected -= new EventHandler(netcom_ClientDisconnected); - netcom.ChatSent -= new EventHandler(netcom_ChatSent); - netcom.AlertMessageReceived -= new EventHandler(netcom_AlertMessageReceived); - netcom.InstantMessageReceived -= new EventHandler(netcom_InstantMessageReceived); + netcom.ClientLoginStatus -= netcom_ClientLoginStatus; + netcom.ClientLoggedOut -= netcom_ClientLoggedOut; + netcom.ClientDisconnected -= netcom_ClientDisconnected; + netcom.ChatSent -= netcom_ChatSent; + netcom.AlertMessageReceived -= netcom_AlertMessageReceived; + netcom.InstantMessageReceived -= netcom_InstantMessageReceived; } void ScriptTeleportRequestHandler(object sender, PacketReceivedEventArgs e) @@ -235,7 +215,7 @@ void Network_EventQueueRunning(object sender, EventQueueRunningEventArgs e) if (TabExists("friends")) return; if (e.Simulator == client.Network.CurrentSim) { - client.Self.UpdateAgentLanguage("en", true); + client.Self.UpdateAgentLanguage("en", true); // FIXME: This should user set. InitializeOnlineTabs(); } } @@ -287,12 +267,12 @@ private void netcom_ClientLoginStatus(object sender, LoginProgressEventArgs e) } else if (e.Status == LoginStatus.Success) { - DisplayNotificationInChat("Logged in as " + netcom.LoginOptions.FullName + ".", ChatBufferTextStyle.StatusDarkBlue); + DisplayNotificationInChat($"Logged in as {netcom.LoginOptions.FullName}.", ChatBufferTextStyle.StatusDarkBlue); DisplayNotificationInChat("Login reply: " + e.Message, ChatBufferTextStyle.StatusDarkBlue); - if (tabs.ContainsKey("login")) + if (Tabs.ContainsKey("login")) { - if (selectedTab.Name == "login") + if (SelectedTab.Name == "login") SelectDefaultTab(); ForceCloseTab("login"); } @@ -316,34 +296,47 @@ private void netcom_ClientDisconnected(object sender, DisconnectedEventArgs e) DisposeOnlineTabs(); SelectDefaultTab(); - DisplayNotificationInChat("Disconnected: " + e.Message, ChatBufferTextStyle.Error); + DisplayNotificationInChat($"Disconnected: {e.Message}", ChatBufferTextStyle.Error); } void Avatars_DisplayNameUpdate(object sender, DisplayNameUpdateEventArgs e) { - DisplayNotificationInChat(string.Format("({0}) is now known as {1}", e.DisplayName.UserName, e.DisplayName.DisplayName)); + DisplayNotificationInChat($"({e.DisplayName.UserName}) is now known as {e.DisplayName.DisplayName}"); } void Self_SetDisplayNameReply(object sender, SetDisplayNameReplyEventArgs e) { if (e.Status == 200) { - DisplayNotificationInChat("You are now knows as " + e.DisplayName.DisplayName); + DisplayNotificationInChat($"You are now knows as {e.DisplayName.DisplayName}"); } else { - DisplayNotificationInChat("Failed to set a new display name: " + e.Reason, ChatBufferTextStyle.Error); + DisplayNotificationInChat($"Failed to set a new display name: {e.Reason}", ChatBufferTextStyle.Error); } } private void netcom_AlertMessageReceived(object sender, AlertMessageEventArgs e) { - tabs["chat"].Highlight(); + if (e.NotificationId == "AutopilotCanceled") { return; } + + // Pop up a notification for region restarts + if (e.NotificationId == "RegionRestartMinutes") { + int minutes = e.ExtraParams["MINUTES"].AsInteger(); + string name = e.ExtraParams["NAME"].AsString(); + instance.MainForm.AddNotification(new ntfRegionRestart(instance, name, minutes * 60)); + } else if (e.NotificationId == "RegionRestartSeconds") { + int seconds = e.ExtraParams["SECONDS"].AsInteger(); + string name = e.ExtraParams["NAME"].AsString(); + instance.MainForm.AddNotification(new ntfRegionRestart(instance, name, seconds)); + } + + Tabs["chat"].Highlight(); } private void netcom_ChatSent(object sender, ChatSentEventArgs e) { - tabs["chat"].Highlight(); + Tabs["chat"].Highlight(); } void Self_LoadURL(object sender, LoadUrlEventArgs e) @@ -371,7 +364,7 @@ private void netcom_InstantMessageReceived(object sender, InstantMessageEventArg } catch (Exception ex) { - Logger.Log("Failed executing automation action: " + ex.ToString(), Helpers.LogLevel.Warning); + Logger.Log("Failed executing automation action: " + ex, Helpers.LogLevel.Warning); } switch (e.IM.Dialog) @@ -423,7 +416,7 @@ private void netcom_InstantMessageReceived(object sender, InstantMessageEventArg case InstantMessageDialog.StartTyping: if (TabExists(e.IM.FromAgentName)) { - RadegastTab tab = tabs[e.IM.FromAgentName.ToLower()]; + RadegastTab tab = Tabs[e.IM.FromAgentName.ToLower()]; if (!tab.Highlighted) tab.PartialHighlight(); } @@ -432,7 +425,7 @@ private void netcom_InstantMessageReceived(object sender, InstantMessageEventArg case InstantMessageDialog.StopTyping: if (TabExists(e.IM.FromAgentName)) { - RadegastTab tab = tabs[e.IM.FromAgentName.ToLower()]; + RadegastTab tab = Tabs[e.IM.FromAgentName.ToLower()]; if (!tab.Highlighted) tab.Unhighlight(); } @@ -445,7 +438,7 @@ private void netcom_InstantMessageReceived(object sender, InstantMessageEventArg case InstantMessageDialog.RequestTeleport: if (instance.RLV.AutoAcceptTP(e.IM.FromAgentID)) { - DisplayNotificationInChat("Auto accepting teleprot from " + e.IM.FromAgentName); + DisplayNotificationInChat($"Automatically accepted a teleport request from {e.IM.FromAgentName}"); instance.Client.Self.TeleportLureRespond(e.IM.FromAgentID, e.IM.IMSessionID, true); } else @@ -474,11 +467,11 @@ private void netcom_InstantMessageReceived(object sender, InstantMessageEventArg break; case InstantMessageDialog.InventoryAccepted: - DisplayNotificationInChat(e.IM.FromAgentName + " accepted your inventory offer."); + DisplayNotificationInChat($"{e.IM.FromAgentName} accepted your inventory offer."); break; case InstantMessageDialog.InventoryDeclined: - DisplayNotificationInChat(e.IM.FromAgentName + " declined your inventory offer."); + DisplayNotificationInChat($"{e.IM.FromAgentName} declined your inventory offer."); break; case InstantMessageDialog.GroupNotice: @@ -525,7 +518,7 @@ private void netcom_InstantMessageReceived(object sender, InstantMessageEventArg public void SelectDefaultTab() { if (IsHandleCreated && TabExists("chat")) - tabs["chat"].Select(); + Tabs["chat"].Select(); } /// @@ -574,10 +567,10 @@ public void DisplayNotificationInChat(string msg, ChatBufferTextStyle style, boo try { - mainChatManger.ProcessBufferItem(line, true); + MainChatManger.ProcessBufferItem(line, true); if (highlightChatTab) { - tabs["chat"].Highlight(); + Tabs["chat"].Highlight(); } } catch (Exception) { } @@ -647,9 +640,9 @@ public bool ShowIMTab(UUID agentID, string label, bool makeActive) { instance.TabConsole.SelectTab((client.Self.AgentID ^ agentID).ToString()); } - else if (active != null) + else { - active.Focus(); + active?.Focus(); } return true; @@ -659,7 +652,7 @@ private void HandleIM(InstantMessageEventArgs e) { bool isNew = ShowIMTab(e.IM.FromAgentID, e.IM.FromAgentName, false); if (!TabExists(e.IM.IMSessionID.ToString())) return; // this should now exist. sanity check anyway - RadegastTab tab = tabs[e.IM.IMSessionID.ToString()]; + RadegastTab tab = Tabs[e.IM.IMSessionID.ToString()]; tab.Highlight(); if (isNew) @@ -672,7 +665,7 @@ private void HandleConferenceIM(InstantMessageEventArgs e) { if (TabExists(e.IM.IMSessionID.ToString())) { - RadegastTab tab = tabs[e.IM.IMSessionID.ToString()]; + RadegastTab tab = Tabs[e.IM.IMSessionID.ToString()]; tab.Highlight(); return; } @@ -682,13 +675,10 @@ private void HandleConferenceIM(InstantMessageEventArgs e) Control active = FindFocusedControl(instance.MainForm); ConferenceIMTabWindow imTab = AddConferenceIMTab(e.IM.IMSessionID, Utils.BytesToString(e.IM.BinaryBucket)); - tabs[e.IM.IMSessionID.ToString()].Highlight(); + Tabs[e.IM.IMSessionID.ToString()].Highlight(); imTab.TextManager.ProcessIM(e, true); - if (active != null) - { - active.Focus(); - } + active?.Focus(); } private void HandleGroupIM(InstantMessageEventArgs e) @@ -698,7 +688,7 @@ private void HandleGroupIM(InstantMessageEventArgs e) if (TabExists(e.IM.IMSessionID.ToString())) { - RadegastTab tab = tabs[e.IM.IMSessionID.ToString()]; + RadegastTab tab = Tabs[e.IM.IMSessionID.ToString()]; tab.Highlight(); return; } @@ -709,12 +699,9 @@ private void HandleGroupIM(InstantMessageEventArgs e) GroupIMTabWindow imTab = AddGroupIMTab(e.IM.IMSessionID, Utils.BytesToString(e.IM.BinaryBucket)); imTab.TextManager.ProcessIM(e, true); - tabs[e.IM.IMSessionID.ToString()].Highlight(); + Tabs[e.IM.IMSessionID.ToString()].Highlight(); - if (active != null) - { - active.Focus(); - } + active?.Focus(); } public void InitializeMainTab() @@ -738,7 +725,7 @@ public void InitializeMainTab() private void InitializeChatTab() { chatConsole = new ChatConsole(instance); - mainChatManger = chatConsole.ChatManager; + MainChatManger = chatConsole.ChatManager; RadegastTab tab = AddTab("chat", "Chat", chatConsole); tab.AllowClose = false; @@ -792,7 +779,7 @@ private void InitializeOnlineTabs() /// private void DisposeOnlineTabs() { - lock (tabs) + lock (Tabs) { ForceCloseTab("voice"); ForceCloseTab("map"); @@ -807,7 +794,7 @@ private void ForceCloseTab(string name) { if (!TabExists(name)) return; - RadegastTab tab = tabs[name]; + RadegastTab tab = Tabs[name]; if (tab.Merged) SplitTab(tab); tab.AllowClose = true; @@ -833,9 +820,9 @@ public void AddTab(RadegastTab tab) button.Image = null; button.AutoToolTip = false; button.Tag = tab.Name; - button.Click += new EventHandler(TabButtonClick); + button.Click += TabButtonClick; tab.Button = button; - tabs.Add(tab.Name, tab); + Tabs.Add(tab.Name, tab); if (OnTabAdded != null) { @@ -865,17 +852,17 @@ public RadegastTab AddTab(string name, string label, Control control) button.AutoToolTip = false; button.Tag = name.ToLower(); button.AllowDrop = true; - button.Click += new EventHandler(TabButtonClick); + button.Click += TabButtonClick; RadegastTab tab = new RadegastTab(instance, button, control, name.ToLower(), label); if (control is RadegastTabControl) ((RadegastTabControl)control).RadegastTab = tab; - tab.TabAttached += new EventHandler(tab_TabAttached); - tab.TabDetached += new EventHandler(tab_TabDetached); - tab.TabSelected += new EventHandler(tab_TabSelected); - tab.TabClosed += new EventHandler(tab_TabClosed); - tab.TabHidden += new EventHandler(tab_TabHidden); - tabs.Add(name.ToLower(), tab); + tab.TabAttached += tab_TabAttached; + tab.TabDetached += tab_TabDetached; + tab.TabSelected += tab_TabSelected; + tab.TabClosed += tab_TabClosed; + tab.TabHidden += tab_TabHidden; + Tabs.Add(name.ToLower(), tab); if (OnTabAdded != null) { @@ -920,11 +907,11 @@ private void tab_TabSelected(object sender, EventArgs e) { RadegastTab tab = (RadegastTab)sender; - if (selectedTab != null && - selectedTab != tab) - { selectedTab.Deselect(); } + if (SelectedTab != null && + SelectedTab != tab) + { SelectedTab.Deselect(); } - selectedTab = tab; + SelectedTab = tab; tbtnCloseTab.Enabled = !tab.Merged && (tab.AllowClose || tab.AllowHide); @@ -935,7 +922,7 @@ private void tab_TabSelected(object sender, EventArgs e) if (OnTabSelected != null) { - try { OnTabSelected(this, new TabEventArgs(selectedTab)); } + try { OnTabSelected(this, new TabEventArgs(SelectedTab)); } catch (Exception) { } } } @@ -944,7 +931,7 @@ void tab_TabHidden(object sender, EventArgs e) { RadegastTab tab = (RadegastTab)sender; - if (selectedTab != null && selectedTab == tab) + if (SelectedTab != null && SelectedTab == tab) { tab.Deselect(); SelectDefaultTab(); @@ -955,13 +942,13 @@ private void tab_TabClosed(object sender, EventArgs e) { RadegastTab tab = (RadegastTab)sender; - if (selectedTab != null && selectedTab == tab && tab.Name != "chat") + if (SelectedTab != null && SelectedTab == tab && tab.Name != "chat") { tab.Deselect(); SelectDefaultTab(); } - tabs.Remove(tab.Name); + Tabs.Remove(tab.Name); if (OnTabRemoved != null) { @@ -976,7 +963,7 @@ private void TabButtonClick(object sender, EventArgs e) { ToolStripButton button = (ToolStripButton)sender; - RadegastTab tab = tabs[button.Tag.ToString()]; + RadegastTab tab = Tabs[button.Tag.ToString()]; tab.Select(); } @@ -988,14 +975,14 @@ public void RemoveTabEntry(RadegastTab tab) } tab.Button.Dispose(); - tabs.Remove(tab.Name); + Tabs.Remove(tab.Name); } public void RemoveTab(string name) { - if (tabs.ContainsKey(name)) + if (Tabs.ContainsKey(name)) { - tabs.Remove(name); + Tabs.Remove(name); } } @@ -1003,18 +990,18 @@ public void RemoveTab(string name) public void SelectTab(string name) { if (TabExists(name.ToLower())) - tabs[name.ToLower()].Select(); + Tabs[name.ToLower()].Select(); } public bool TabExists(string name) { - return tabs.ContainsKey(name.ToLower()); + return Tabs.ContainsKey(name.ToLower()); } public RadegastTab GetTab(string name) { if (TabExists(name.ToLower())) - return tabs[name.ToLower()]; + return Tabs[name.ToLower()]; else return null; } @@ -1026,9 +1013,9 @@ public List GetOtherTabs() foreach (ToolStripItem item in tstTabs.Items) { if (item.Tag == null) continue; - if ((ToolStripItem)item == selectedTab.Button) continue; + if ((ToolStripItem)item == SelectedTab.Button) continue; - RadegastTab tab = tabs[item.Tag.ToString()]; + RadegastTab tab = Tabs[item.Tag.ToString()]; if (!tab.AllowMerge) continue; if (tab.Merged) continue; @@ -1056,7 +1043,7 @@ public void SelectNextTab() for (int i = 0; i < buttons.Count; i++) { - if (buttons[i] == selectedTab.Button) + if (buttons[i] == SelectedTab.Button) { current = i; break; @@ -1068,7 +1055,7 @@ public void SelectNextTab() if (current == buttons.Count) current = 0; - SelectTab(tabs[buttons[current].Tag.ToString()].Name); + SelectTab(Tabs[buttons[current].Tag.ToString()].Name); } /// @@ -1089,7 +1076,7 @@ public void SelectPreviousTab() for (int i = 0; i < buttons.Count; i++) { - if (buttons[i] == selectedTab.Button) + if (buttons[i] == SelectedTab.Button) { current = i; break; @@ -1101,7 +1088,7 @@ public void SelectPreviousTab() if (current == -1) current = buttons.Count - 1; - SelectTab(tabs[buttons[current].Tag.ToString()].Name); + SelectTab(Tabs[buttons[current].Tag.ToString()].Name); } @@ -1162,13 +1149,13 @@ public AnimTab AddAnimTab(Avatar avatar) private void tbtnTabOptions_Click(object sender, EventArgs e) { - tmnuMergeWith.Enabled = selectedTab.AllowMerge; - tmnuDetachTab.Enabled = selectedTab.AllowDetach; + tmnuMergeWith.Enabled = SelectedTab.AllowMerge; + tmnuDetachTab.Enabled = SelectedTab.AllowDetach; tmnuMergeWith.DropDown.Items.Clear(); - if (!selectedTab.AllowMerge) return; - if (!selectedTab.Merged) + if (!SelectedTab.AllowMerge) return; + if (!SelectedTab.Merged) { tmnuMergeWith.Text = "Merge With"; @@ -1181,36 +1168,36 @@ private void tbtnTabOptions_Click(object sender, EventArgs e) { ToolStripItem item = tmnuMergeWith.DropDown.Items.Add(tab.Label); item.Tag = tab.Name; - item.Click += new EventHandler(MergeItemClick); + item.Click += MergeItemClick; } } else { tmnuMergeWith.Text = "Split"; - tmnuMergeWith.Click += new EventHandler(SplitClick); + tmnuMergeWith.Click += SplitClick; } } private void MergeItemClick(object sender, EventArgs e) { ToolStripItem item = (ToolStripItem)sender; - RadegastTab tab = tabs[item.Tag.ToString()]; + RadegastTab tab = Tabs[item.Tag.ToString()]; - selectedTab.MergeWith(tab); + SelectedTab.MergeWith(tab); - SplitContainer container = (SplitContainer)selectedTab.Control; + SplitContainer container = (SplitContainer)SelectedTab.Control; toolStripContainer1.ContentPanel.Controls.Add(container); - selectedTab.Select(); + SelectedTab.Select(); RemoveTabEntry(tab); - tabs.Add(tab.Name, selectedTab); + Tabs.Add(tab.Name, SelectedTab); } private void SplitClick(object sender, EventArgs e) { - SplitTab(selectedTab); - selectedTab.Select(); + SplitTab(SelectedTab); + SelectedTab.Select(); } public void SplitTab(RadegastTab tab) @@ -1221,21 +1208,21 @@ public void SplitTab(RadegastTab tab) toolStripContainer1.ContentPanel.Controls.Add(tab.Control); toolStripContainer1.ContentPanel.Controls.Add(otherTab.Control); - tabs.Remove(otherTab.Name); + Tabs.Remove(otherTab.Name); AddTab(otherTab); } private void tmnuDetachTab_Click(object sender, EventArgs e) { - if (!selectedTab.AllowDetach) return; - RadegastTab tab = selectedTab; + if (!SelectedTab.AllowDetach) return; + RadegastTab tab = SelectedTab; SelectDefaultTab(); tab.Detach(instance); } private void tbtnCloseTab_Click(object sender, EventArgs e) { - RadegastTab tab = selectedTab; + RadegastTab tab = SelectedTab; if (tab.Merged) return; else if (tab.AllowClose) @@ -1246,14 +1233,14 @@ private void tbtnCloseTab_Click(object sender, EventArgs e) private void TabsConsole_Load(object sender, EventArgs e) { - owner = this.FindForm(); + owner = FindForm(); } private void ctxTabs_Opening(object sender, CancelEventArgs e) { e.Cancel = false; - Point pt = this.PointToClient(Cursor.Position); + Point pt = PointToClient(Cursor.Position); ToolStripItem stripItem = tstTabs.GetItemAt(pt); if (stripItem == null) @@ -1262,11 +1249,11 @@ private void ctxTabs_Opening(object sender, CancelEventArgs e) } else { - tabs[stripItem.Tag.ToString()].Select(); + Tabs[stripItem.Tag.ToString()].Select(); - ctxBtnClose.Enabled = !selectedTab.Merged && (selectedTab.AllowClose || selectedTab.AllowHide); - ctxBtnDetach.Enabled = selectedTab.AllowDetach; - ctxBtnMerge.Enabled = selectedTab.AllowMerge; + ctxBtnClose.Enabled = !SelectedTab.Merged && (SelectedTab.AllowClose || SelectedTab.AllowHide); + ctxBtnDetach.Enabled = SelectedTab.AllowDetach; + ctxBtnMerge.Enabled = SelectedTab.AllowMerge; ctxBtnMerge.DropDown.Items.Clear(); if (!ctxBtnClose.Enabled && !ctxBtnDetach.Enabled && !ctxBtnMerge.Enabled) @@ -1275,8 +1262,8 @@ private void ctxTabs_Opening(object sender, CancelEventArgs e) return; } - if (!selectedTab.AllowMerge) return; - if (!selectedTab.Merged) + if (!SelectedTab.AllowMerge) return; + if (!SelectedTab.Merged) { ctxBtnMerge.Text = "Merge With"; @@ -1289,13 +1276,13 @@ private void ctxTabs_Opening(object sender, CancelEventArgs e) { ToolStripItem item = ctxBtnMerge.DropDown.Items.Add(tab.Label); item.Tag = tab.Name; - item.Click += new EventHandler(MergeItemClick); + item.Click += MergeItemClick; } } else { ctxBtnMerge.Text = "Split"; - ctxBtnMerge.Click += new EventHandler(SplitClick); + ctxBtnMerge.Click += SplitClick; } } @@ -1314,12 +1301,10 @@ public class TabEventArgs : EventArgs public RadegastTab Tab; public TabEventArgs() - : base() { } public TabEventArgs(RadegastTab tab) - : base() { Tab = tab; } diff --git a/Radegast/GUI/Consoles/VoiceConsole.Designer.cs b/Radegast/GUI/Consoles/VoiceConsole.Designer.cs index 4f337fb5d..acaad05f0 100644 --- a/Radegast/GUI/Consoles/VoiceConsole.Designer.cs +++ b/Radegast/GUI/Consoles/VoiceConsole.Designer.cs @@ -94,6 +94,7 @@ private void InitializeComponent() this.ctxPoint = new System.Windows.Forms.ToolStripMenuItem(); this.ctxSource = new System.Windows.Forms.ToolStripMenuItem(); this.TalkStates = new System.Windows.Forms.ImageList(this.components); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout(); this.splitContainer1.SuspendLayout(); @@ -182,9 +183,9 @@ private void InitializeComponent() this.label3.AutoSize = true; this.label3.Location = new System.Drawing.Point(230, 10); this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(114, 13); + this.label3.Size = new System.Drawing.Size(120, 13); this.label3.TabIndex = 26; - this.label3.Text = "Voice conection status"; + this.label3.Text = "Voice connection status"; // // label1 // @@ -198,6 +199,7 @@ private void InitializeComponent() // // button1 // + this.button1.AccessibleName = "Push To Talk"; this.button1.BackColor = System.Drawing.SystemColors.AppWorkspace; this.button1.Font = new System.Drawing.Font("Arial", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.button1.Location = new System.Drawing.Point(81, 281); @@ -220,6 +222,7 @@ private void InitializeComponent() // // spkrMute // + this.spkrMute.AccessibleName = "Listen Mute"; this.spkrMute.AutoSize = true; this.spkrMute.Location = new System.Drawing.Point(92, 112); this.spkrMute.Name = "spkrMute"; @@ -230,6 +233,7 @@ private void InitializeComponent() // // micMute // + this.micMute.AccessibleName = "Talk Mute"; this.micMute.AutoSize = true; this.micMute.Checked = true; this.micMute.CheckState = System.Windows.Forms.CheckState.Checked; @@ -253,6 +257,7 @@ private void InitializeComponent() // // progressBar1 // + this.progressBar1.AccessibleName = "ConnectionStatus"; this.progressBar1.Location = new System.Drawing.Point(212, 26); this.progressBar1.Maximum = 8; this.progressBar1.Name = "progressBar1"; @@ -271,6 +276,7 @@ private void InitializeComponent() // // micLevel // + this.micLevel.AccessibleName = "Talk Level"; this.micLevel.BackColor = System.Drawing.SystemColors.Control; this.micLevel.LargeChange = 20; this.micLevel.Location = new System.Drawing.Point(14, 274); @@ -285,6 +291,7 @@ private void InitializeComponent() // // spkrLevel // + this.spkrLevel.AccessibleName = "Listen Level"; this.spkrLevel.Location = new System.Drawing.Point(405, 274); this.spkrLevel.Maximum = 100; this.spkrLevel.Minimum = -100; @@ -297,6 +304,7 @@ private void InitializeComponent() // // spkrDevice // + this.spkrDevice.AccessibleName = "Listen Device Selector"; this.spkrDevice.FormattingEnabled = true; this.spkrDevice.Location = new System.Drawing.Point(158, 112); this.spkrDevice.Name = "spkrDevice"; @@ -306,6 +314,7 @@ private void InitializeComponent() // // micDevice // + this.micDevice.AccessibleName = "Talk Device Selector"; this.micDevice.FormattingEnabled = true; this.micDevice.Location = new System.Drawing.Point(158, 67); this.micDevice.Name = "micDevice"; @@ -430,6 +439,7 @@ private void InitializeComponent() this.splitContainer1.Panel1.ResumeLayout(false); this.splitContainer1.Panel1.PerformLayout(); this.splitContainer1.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); this.splitContainer1.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit(); diff --git a/Radegast/GUI/Consoles/VoiceConsole.cs b/Radegast/GUI/Consoles/VoiceConsole.cs index 0d52e3680..e480e772e 100644 --- a/Radegast/GUI/Consoles/VoiceConsole.cs +++ b/Radegast/GUI/Consoles/VoiceConsole.cs @@ -1,44 +1,31 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id: ChatConsole.cs 371 2009-10-26 10:26:04Z latifer $ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2022, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections.Generic; -using System.Collections; -using System.ComponentModel; using System.Drawing; -using System.Text.RegularExpressions; using System.Windows.Forms; -using Radegast.Netcom; +using Radegast; using OpenMetaverse; using OpenMetaverse.StructuredData; -using OpenMetaverse.Voice; +using LibreMetaverse.Voice; namespace Radegast { @@ -53,8 +40,8 @@ private enum TalkState }; private RadegastInstance instance; - private RadegastNetcom netcom { get { return instance.Netcom; } } - private GridClient client { get { return instance.Client; } } + private Radegast.Netcom netcom => instance.Netcom; + private GridClient client => instance.Client; private TabsConsole tabConsole; private OSDMap config; public VoiceGateway gateway = null; @@ -64,20 +51,19 @@ private enum TalkState public VoiceConsole(RadegastInstance instance) { InitializeComponent(); - Disposed += new EventHandler(VoiceConsole_Disposed); + Disposed += VoiceConsole_Disposed; this.instance = instance; // Callbacks - netcom.ClientLoginStatus += new EventHandler(netcom_ClientLoginStatus); + netcom.ClientLoginStatus += netcom_ClientLoginStatus; - this.instance.MainForm.Load += new EventHandler(MainForm_Load); + this.instance.MainForm.Load += MainForm_Load; config = instance.GlobalSettings["voice"] as OSDMap; if (config == null) { - config = new OSDMap(); - config["enabled"] = new OSDBoolean(false); + config = new OSDMap {["enabled"] = new OSDBoolean(false)}; instance.GlobalSettings["voice"] = config; instance.GlobalSettings.Save(); } @@ -86,14 +72,14 @@ public VoiceConsole(RadegastInstance instance) if (chkVoiceEnable.Checked) Start(); - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } private void Start() { if (gateway == null) { - gateway = new VoiceGateway(this.instance.Client); + gateway = new VoiceGateway(instance.Client); } // Initialize progress bar @@ -125,19 +111,15 @@ void RadegastContextMenuStrip_OnContentMenuOpened(object sender, RadegastContext lock (e.Menu) { // Figure out what this menu applies to. - if (e.Menu.Selection is ListViewItem) + ListViewItem item = e.Menu.Selection as ListViewItem; + if (item?.Tag is VoiceParticipant tag) { - ListViewItem item = e.Menu.Selection as ListViewItem; - if (item.Tag is VoiceParticipant) - { - selected = item.Tag as VoiceParticipant; - ToolStripButton muteButton; - if (selected.IsMuted) - muteButton = new ToolStripButton("Unmute", null, new EventHandler(OnUnMuteClick)); - else - muteButton = new ToolStripButton("Mute", null, new EventHandler(OnMuteClick)); - e.Menu.Items.Add(muteButton); - } + selected = tag; + ToolStripButton muteButton; + muteButton = selected.IsMuted + ? new ToolStripButton("Unmute", null, OnUnMuteClick) + : new ToolStripButton("Mute", null, OnMuteClick); + e.Menu.Items.Add(muteButton); } } } @@ -154,35 +136,35 @@ void OnUnMuteClick(object sender, EventArgs e) private void RegisterClientEvents() { - instance.Names.NameUpdated += new EventHandler(Names_NameUpdated); + instance.Names.NameUpdated += Names_NameUpdated; // Voice hooks gateway.OnSessionCreate += - new EventHandler(gateway_OnSessionCreate); + gateway_OnSessionCreate; gateway.OnSessionRemove += - new EventHandler(gateway_OnSessionRemove); + gateway_OnSessionRemove; gateway.OnVoiceConnectionChange += - new VoiceGateway.VoiceConnectionChangeCallback(gateway_OnVoiceConnectionChange); + gateway_OnVoiceConnectionChange; gateway.OnAuxGetCaptureDevicesResponse += - new EventHandler(gateway_OnAuxGetCaptureDevicesResponse); + gateway_OnAuxGetCaptureDevicesResponse; gateway.OnAuxGetRenderDevicesResponse += - new EventHandler(gateway_OnAuxGetRenderDevicesResponse); + gateway_OnAuxGetRenderDevicesResponse; } private void UnregisterClientEvents() { - instance.Names.NameUpdated -= new EventHandler(Names_NameUpdated); + instance.Names.NameUpdated -= Names_NameUpdated; gateway.OnSessionCreate -= - new EventHandler(gateway_OnSessionCreate); + gateway_OnSessionCreate; gateway.OnSessionRemove -= - new EventHandler(gateway_OnSessionRemove); + gateway_OnSessionRemove; gateway.OnVoiceConnectionChange -= - new VoiceGateway.VoiceConnectionChangeCallback(gateway_OnVoiceConnectionChange); + gateway_OnVoiceConnectionChange; gateway.OnAuxGetCaptureDevicesResponse -= - new EventHandler(gateway_OnAuxGetCaptureDevicesResponse); + gateway_OnAuxGetCaptureDevicesResponse; gateway.OnAuxGetRenderDevicesResponse -= - new EventHandler(gateway_OnAuxGetRenderDevicesResponse); + gateway_OnAuxGetRenderDevicesResponse; } void Names_NameUpdated(object sender, UUIDNameReplyEventArgs e) @@ -260,9 +242,9 @@ void gateway_OnSessionCreate(object sender, EventArgs e) // There could theoretically be more than one session active // at a time, but the current implementation in SL seems to be limited to one. session = s; - session.OnParticipantAdded += new EventHandler(session_OnParticipantAdded); - session.OnParticipantRemoved += new EventHandler(session_OnParticipantRemoved); - session.OnParticipantUpdate += new EventHandler(session_OnParticipantUpdate); + session.OnParticipantAdded += session_OnParticipantAdded; + session.OnParticipantRemoved += session_OnParticipantRemoved; + session.OnParticipantUpdate += session_OnParticipantUpdate; participants.Clear(); // Default Mic off and Spkr on @@ -280,9 +262,9 @@ void gateway_OnSessionRemove(object sender, EventArgs e) VoiceSession s = sender as VoiceSession; if (s == null) return; - s.OnParticipantAdded -= new EventHandler(session_OnParticipantAdded); - s.OnParticipantRemoved -= new EventHandler(session_OnParticipantRemoved); - s.OnParticipantUpdate -= new EventHandler(session_OnParticipantUpdate); + s.OnParticipantAdded -= session_OnParticipantAdded; + s.OnParticipantRemoved -= session_OnParticipantRemoved; + s.OnParticipantUpdate -= session_OnParticipantUpdate; if (session != s) return; @@ -309,15 +291,16 @@ void session_OnParticipantAdded(object sender, EventArgs e) BeginInvoke(new MethodInvoker(delegate() { // Supply the name based on the UUID. + if (p == null) return; p.Name = instance.Names.Get(p.ID); if (participants.Items.ContainsKey(p.ID.ToString())) return; - ListViewItem item = new ListViewItem(p.Name); - item.Name = p.ID.ToString(); - item.Tag = p; - item.StateImageIndex = (int)TalkState.Idle; + ListViewItem item = new ListViewItem(p.Name) + { + Name = p.ID.ToString(), Tag = p, StateImageIndex = (int)TalkState.Idle + }; lock (participants) participants.Items.Add(item); @@ -327,7 +310,7 @@ void session_OnParticipantAdded(object sender, EventArgs e) void session_OnParticipantRemoved(object sender, EventArgs e) { VoiceParticipant p = sender as VoiceParticipant; - if (p.Name == null) return; + if (p?.Name == null) return; BeginInvoke(new MethodInvoker(delegate() { lock (participants) @@ -342,7 +325,7 @@ void session_OnParticipantRemoved(object sender, EventArgs e) void session_OnParticipantUpdate(object sender, EventArgs e) { VoiceParticipant p = sender as VoiceParticipant; - if (p.Name == null) return; + if (p?.Name == null) return; BeginInvoke(new MethodInvoker(delegate() { lock (participants) @@ -384,8 +367,7 @@ private void btnUnmuteAll_Click(object sender, EventArgs e) { foreach (ListViewItem i in participants.Items) { - VoiceParticipant p = i.Tag as VoiceParticipant; - if (p.ID != instance.Client.Self.AgentID) + if (i.Tag is VoiceParticipant p && p.ID != instance.Client.Self.AgentID) { p.IsMuted = false; i.StateImageIndex = (int)TalkState.Idle; @@ -402,8 +384,7 @@ private void btnMuteAll_Click(object sender, EventArgs e) { foreach (ListViewItem i in participants.Items) { - VoiceParticipant p = i.Tag as VoiceParticipant; - if (p.ID != instance.Client.Self.AgentID) + if (i.Tag is VoiceParticipant p && p.ID != instance.Client.Self.AgentID) { p.IsMuted = true; i.StateImageIndex = (int)TalkState.Muted; @@ -427,7 +408,7 @@ void VoiceConsole_Disposed(object sender, EventArgs e) { try { - netcom.ClientLoginStatus -= new EventHandler(netcom_ClientLoginStatus); + netcom.ClientLoginStatus -= netcom_ClientLoginStatus; if (gateway != null) { UnregisterClientEvents(); @@ -458,7 +439,7 @@ private void netcom_ClientLoginStatus(object sender, LoginProgressEventArgs e) #region Talk control void OnMouseUp(object sender, MouseEventArgs e) { - this.BeginInvoke(new MethodInvoker(delegate() + BeginInvoke(new MethodInvoker(delegate() { if (e.Button == MouseButtons.Left) { @@ -470,7 +451,7 @@ void OnMouseUp(object sender, MouseEventArgs e) void OnMouseDown(object sender, MouseEventArgs e) { - this.BeginInvoke(new MethodInvoker(delegate() + BeginInvoke(new MethodInvoker(delegate() { if (e.Button == MouseButtons.Left) @@ -542,7 +523,7 @@ private void spkrLevel_ValueChanged(object sender, EventArgs e) /// private void chkVoiceEnable_Click(object sender, EventArgs e) { - this.BeginInvoke(new MethodInvoker(delegate() + BeginInvoke(new MethodInvoker(delegate() { config["enabled"] = new OSDBoolean(chkVoiceEnable.Checked); instance.GlobalSettings.Save(); diff --git a/Radegast/GUI/Consoles/VoiceConsole.resx b/Radegast/GUI/Consoles/VoiceConsole.resx index e40125da4..8e26b2c36 100644 --- a/Radegast/GUI/Consoles/VoiceConsole.resx +++ b/Radegast/GUI/Consoles/VoiceConsole.resx @@ -112,60 +112,60 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + - iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAq5JREFUWEftV09I - FFEcfhplRnvQy9KphYVWbVddR2dnZ51xYbMuG1EUimhZZKQSKaWgdLKDHbKU0I10Ww+leDSog51sRcM/ - WLcIwjyVXYr8U6v79Vo7zPRyxmaHQII9PJj5veH7vve93zfzhlBKyU6OHSXfXHhKQMqB/9cBrqgVWvF1 - uUo063pRN+VAVtYBFHNtukRimWBYRNICSEY6Kk+OgnPfYEjycg4z94JgTERSAkhaBmqqRvE4QnG9+cWW - VXr4IqZmt9v/6oRhAWmZBHW1YxgKU4y//Ira6lFN8MJCUakbccGQAEIcuFDxGgOhZUzNLuHbD4qmximF - 6FjgtHKdm8sp17Ism3eAECtI2j7s2mNF06VJhLsp3ryliNEVRKOraLg4oYC7XSpRQYGXIQ0EAtuK0HVA - 8LRhaJCiuzOOkZEFrNFlbGxQTEcp5ueX0Nw4xwBzRfnKfYlXbUCOUx3RiqKugP57a4iBJoi/YAVxxOIU - M7PrmJumiITWEzE8wwhwudQUFLtzlDme58054Jda0XNrEY/CcdzsmMTD8CLC9+Po7aEY6P8Or1DFAIui - uupid54yZ7PZzAkgJBMd7fO4cu4TThyZwN3bq+jto3jylOJO72c4Dh1lgMvL1b0u9apxDAaDJgWkE+ze - awEhhWi5+g7NiRGKfETXg/foS/SGLFUrwJKsrl4ulRhC01vwe8MQYkN9wxjO1j3D4DBFZ9cG3O7jCpEr - X91zgVdT4Pf7zcfwz44l5CDaWz+gpmIBwwkRslypCS7wPqXucDj+nYBf5zfiwbXGV7h8fhyieGoLuE8o - Y2peL/tOSCqGup9Psh8t9c8TvWFlyJxOZ9Lkpg+lFstmcxJdeyWJbcTtjv2GvgVaANnZ2ZoCfD61B4z8 - b5gWYATcyDMpASkHUg78BObrkHKxikh0AAAAAElFTkSuQmCC + iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6 + JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAACtUlEQVRYR8WUP0wTURzHXzGKGBlgIU42 + IbGAFGgPyrWlR5OKLhij0UAIKBoxQmOEKCQQJxxwEIUYwAgVBoUwYqIDTggBgxB0MyYGmRQXjfzR0n59 + tsudT34ttTHP4ZO8+wzf7+/evXeMc/5fIaVMSCkTUsqElDIhpUxIKRNSJoJibwPlrdYS0seClDuRkXEA + xUp7zCJXuZrwEKSMB0tNQfXJCSi2G0JJXs5h4VlVExuClLFgplTU1Uzg8TDH9ZYX2wpKHXbBZWdn7zgE + KSlMaQwN9ZMYDXBMvfyG+toJMryoyKX7RHaBlH/CmAUXqt5gaGANcwur+P6To9k/p4cf853W17m5ir7W + NC35ARjLAjPtw649WWi+NItAD8fbdxxBvo7p6Q00XZzRw21Wo6iw0CmU+ny+uEOQMopa2o7REY6erjDG + x5exydcQCnHMT3MsLa2ixb8oBCv2Av25xGlsvaIYO0JByiiD9zYRBI8Uf8U6wgiGOV4tbGFxnmN4YCty + Dc8IwVarcQuKbTn62uFwJDeA19OG3lsreBQI42bnLB4GVhC4H0ZfL8fQ4A841Roh2OUy3rrYlqevzWZz + cgMwlobOjiVcOfcZJ47M4O7tDfT1czx5ynGn7wssh44KwRUVxrcucxrXsbKyMskBUhh2700HY0Vovfoe + LREGhj+h+8EH9EfOhuap1YM9mvH2WplHKEz6E/wOY2Y0Nk3ibMMzjIxxdHWHYLMd14OtBcY3Vx3GLfB6 + vXHLo5CSgrGD6Gj7iLqqZYxFhtC0ajJcdbh1b7FY/t0AURgrxTX/a1w+PwWX69S2cLdaLjinU/wnUJAy + HoztR2vj88jZyBLC8/Pz/7o8Cil3Ij09ejhZzAKPRzyI8SBlImRmZpIlbrdxBhKBlDIhpUxIKRNSyoSU + MiGlTEgpD85+AebrkHJVi6gaAAAAAElFTkSuQmCC - iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAq5JREFUWEftV09I - FFEcfhplRnvQy9KphYVWbVddR2dnZ51xYbMuG1EUimhZZKQSKaWgdLKDHbKU0I10Ww+leDSog51sRcM/ - WLcIwjyVXYr8U6v79Vo7zPRyxmaHQII9PJj5veH7vve93zfzhlBKyU6OHSXfXHhKQMqB/9cBrqgVWvF1 - uUo063pRN+VAVtYBFHNtukRimWBYRNICSEY6Kk+OgnPfYEjycg4z94JgTERSAkhaBmqqRvE4QnG9+cWW - VXr4IqZmt9v/6oRhAWmZBHW1YxgKU4y//Ira6lFN8MJCUakbccGQAEIcuFDxGgOhZUzNLuHbD4qmximF - 6FjgtHKdm8sp17Ism3eAECtI2j7s2mNF06VJhLsp3ryliNEVRKOraLg4oYC7XSpRQYGXIQ0EAtuK0HVA - 8LRhaJCiuzOOkZEFrNFlbGxQTEcp5ueX0Nw4xwBzRfnKfYlXbUCOUx3RiqKugP57a4iBJoi/YAVxxOIU - M7PrmJumiITWEzE8wwhwudQUFLtzlDme58054Jda0XNrEY/CcdzsmMTD8CLC9+Po7aEY6P8Or1DFAIui - uupid54yZ7PZzAkgJBMd7fO4cu4TThyZwN3bq+jto3jylOJO72c4Dh1lgMvL1b0u9apxDAaDJgWkE+ze - awEhhWi5+g7NiRGKfETXg/foS/SGLFUrwJKsrl4ulRhC01vwe8MQYkN9wxjO1j3D4DBFZ9cG3O7jCpEr - X91zgVdT4Pf7zcfwz44l5CDaWz+gpmIBwwkRslypCS7wPqXucDj+nYBf5zfiwbXGV7h8fhyieGoLuE8o - Y2peL/tOSCqGup9Psh8t9c8TvWFlyJxOZ9Lkpg+lFstmcxJdeyWJbcTtjv2GvgVaANnZ2ZoCfD61B4z8 - b5gWYATcyDMpASkHUg78BObrkHKxikh0AAAAAElFTkSuQmCC + iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6 + JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAACtUlEQVRYR8WUP0wTURzHXzGKGBlgIU42 + IbGAFGgPyrWlR5OKLhij0UAIKBoxQmOEKCQQJxxwEIUYwAgVBoUwYqIDTggBgxB0MyYGmRQXjfzR0n59 + tsudT34ttTHP4ZO8+wzf7+/evXeMc/5fIaVMSCkTUsqElDIhpUxIKRNSJoJibwPlrdYS0seClDuRkXEA + xUp7zCJXuZrwEKSMB0tNQfXJCSi2G0JJXs5h4VlVExuClLFgplTU1Uzg8TDH9ZYX2wpKHXbBZWdn7zgE + KSlMaQwN9ZMYDXBMvfyG+toJMryoyKX7RHaBlH/CmAUXqt5gaGANcwur+P6To9k/p4cf853W17m5ir7W + NC35ARjLAjPtw649WWi+NItAD8fbdxxBvo7p6Q00XZzRw21Wo6iw0CmU+ny+uEOQMopa2o7REY6erjDG + x5exydcQCnHMT3MsLa2ixb8oBCv2Av25xGlsvaIYO0JByiiD9zYRBI8Uf8U6wgiGOV4tbGFxnmN4YCty + Dc8IwVarcQuKbTn62uFwJDeA19OG3lsreBQI42bnLB4GVhC4H0ZfL8fQ4A841Roh2OUy3rrYlqevzWZz + cgMwlobOjiVcOfcZJ47M4O7tDfT1czx5ynGn7wssh44KwRUVxrcucxrXsbKyMskBUhh2700HY0Vovfoe + LREGhj+h+8EH9EfOhuap1YM9mvH2WplHKEz6E/wOY2Y0Nk3ibMMzjIxxdHWHYLMd14OtBcY3Vx3GLfB6 + vXHLo5CSgrGD6Gj7iLqqZYxFhtC0ajJcdbh1b7FY/t0AURgrxTX/a1w+PwWX69S2cLdaLjinU/wnUJAy + HoztR2vj88jZyBLC8/Pz/7o8Cil3Ij09ejhZzAKPRzyI8SBlImRmZpIlbrdxBhKBlDIhpUxIKRNSyoSU + MiGlTEgpD85+AebrkHJVi6gaAAAAAElFTkSuQmCC - + 122, 17 - + 243, 17 - AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w + AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAACk - CAAAAk1TRnQBSQFMAgEBAwEAARwBAAEcAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo + CAAAAk1TRnQBSQFMAgEBAwEAASQBAAEkAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5 AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA diff --git a/Radegast/GUI/Controls/AgentNameTextBox.cs b/Radegast/GUI/Controls/AgentNameTextBox.cs new file mode 100644 index 000000000..0056cf979 --- /dev/null +++ b/Radegast/GUI/Controls/AgentNameTextBox.cs @@ -0,0 +1,97 @@ +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + +using System; +using System.Windows.Forms; +using System.ComponentModel; +using OpenMetaverse; + +namespace Radegast +{ + public class AgentNameTextBox : TextBox + { + private UUID agentID; + private GridClient client => RadegastInstance.GlobalInstance.Client; + private RadegastInstance instance => RadegastInstance.GlobalInstance; + + [Browsable(false)] + public UUID AgentID + { + get => agentID; + + set + { + if (agentID == value) return; + + agentID = value; + + if (agentID == UUID.Zero) + { + SetName(string.Empty); + } + else + { + SetupHandlers(); + string name = instance.Names.Get(agentID); + SetName(name); + } + } + } + + public AgentNameTextBox() + { + SetStyle(ControlStyles.SupportsTransparentBackColor, true); + Disposed += CleanupHandlers; + } + + void SetupHandlers() + { + if (instance?.Names == null) return; + instance.Names.NameUpdated += Names_NameUpdated; + } + + void CleanupHandlers(object sender, EventArgs e) + { + if (instance?.Names != null) + { + instance.Names.NameUpdated -= Names_NameUpdated; + } + } + + void Names_NameUpdated(object sender, UUIDNameReplyEventArgs e) + { + if (e.Names.ContainsKey(agentID)) + { + SetName(e.Names[agentID]); + } + } + + void SetName(string name) + { + if (InvokeRequired) + { + BeginInvoke(new MethodInvoker(delegate() { SetName(name); })); + return; + } + + Text = name; + } + } +} diff --git a/Radegast/GUI/Controls/BufferedTreeView.cs b/Radegast/GUI/Controls/BufferedTreeView.cs new file mode 100644 index 000000000..a46749b60 --- /dev/null +++ b/Radegast/GUI/Controls/BufferedTreeView.cs @@ -0,0 +1,42 @@ +/* + * Radegast Metaverse Client + * Copyright(c) 2021, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + +using System; +using System.Windows.Forms; +using System.Runtime.InteropServices; + +namespace Radegast.WinForms +{ + public class BufferedTreeView : TreeView + { + protected override void OnHandleCreated(EventArgs e) + { + SendMessage(this.Handle, TVM_SETEXTENDEDSTYLE, (IntPtr)TVS_EX_DOUBLEBUFFER, (IntPtr)TVS_EX_DOUBLEBUFFER); + base.OnHandleCreated(e); + } + + // Pinvoke: + private const int TVM_SETEXTENDEDSTYLE = 0x1100 + 44; + private const int TVM_GETEXTENDEDSTYLE = 0x1100 + 45; + private const int TVS_EX_DOUBLEBUFFER = 0x0004; + + [DllImport("user32.dll")] + private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wp, IntPtr lp); + } +} \ No newline at end of file diff --git a/Radegast/GUI/Controls/ChatInputBox.cs b/Radegast/GUI/Controls/ChatInputBox.cs new file mode 100644 index 000000000..2dc280c7b --- /dev/null +++ b/Radegast/GUI/Controls/ChatInputBox.cs @@ -0,0 +1,56 @@ +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + +using System; +using System.Windows.Forms; + +namespace Radegast +{ + public class ChatInputBox : TextBox + { + public static readonly string NewlineMarker = new string('\u00b6', 1); + + protected override void WndProc(ref Message m) + { + switch (m.Msg) + { + case 0x302: //WM_PASTE + Paste(); + break; + + default: + base.WndProc(ref m); + break; + } + } + + public new void Paste() + { + Paste(Clipboard.GetText()); + } + + public new void Paste(string text) + { + base.Paste(text.Replace(Environment.NewLine, NewlineMarker)); + } + + + } +} diff --git a/Radegast/GUI/Controls/CircularList.cs b/Radegast/GUI/Controls/CircularList.cs new file mode 100644 index 000000000..bc70c0ebf --- /dev/null +++ b/Radegast/GUI/Controls/CircularList.cs @@ -0,0 +1,90 @@ +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + +using System.Collections.Generic; + +namespace Radegast +{ + /// + /// A list which acts like the List class, but with more of a java + /// influence. This allows you to set + /// a looping variable to true, and creates + /// a circular list. Also it utilizes the java iterator pattern of + /// Next and HasNext. + /// + /// Author: Wesley Tansey + /// + /// The type of item that + /// will be stored in the list + + public class CircularList : List + { + #region Member Variables + + private int index; + #endregion + + #region Properties + + /// + /// If true, the list will loop to the beginning when Next + /// is called after the last element has been accessed. + /// + public bool Loop { get; set; } = true; + + /// + /// The next element in the list. The user is responsible for + /// making sure that HasNext is true + /// before getting the next element. + /// + + public T Next + { + get + { + if (index >= Count) + { + if (!Loop) + { + return default(T); + } + index = 0; + } + return this[index++]; + } + } + + /// + /// Tells whether there is another element in the list + /// + public bool HasNext + { + get + { + if (Count == 0 || (!Loop && index >= Count)) + { + return false; + } + return true; + } + } + #endregion + } +} diff --git a/Radegast/Core/Types/DettachableControl.cs b/Radegast/GUI/Controls/DettachableControl.cs similarity index 51% rename from Radegast/Core/Types/DettachableControl.cs rename to Radegast/GUI/Controls/DettachableControl.cs index 3ea93c72e..046a8a476 100644 --- a/Radegast/Core/Types/DettachableControl.cs +++ b/Radegast/GUI/Controls/DettachableControl.cs @@ -1,33 +1,23 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System.Drawing; using System.Windows.Forms; @@ -53,9 +43,8 @@ public class DettachableControl : UserControl public bool DisposeOnDetachedClose = true; public DettachableControl() - : base() { - SizeChanged += new System.EventHandler(DettachableControl_SizeChanged); + SizeChanged += DettachableControl_SizeChanged; } void DettachableControl_SizeChanged(object sender, System.EventArgs e) @@ -68,10 +57,7 @@ void DettachableControl_SizeChanged(object sender, System.EventArgs e) public virtual bool Detached { - get - { - return detached; - } + get => detached; set { @@ -99,14 +85,16 @@ protected virtual void Detach() { detached = true; AttachedSize = Size; - - if (detachedForm != null) - { - detachedForm.Dispose(); - } - detachedForm = new RadegastForm(RadegastInstance.GlobalInstance) { SettingsKeyBase = GetType().ToString(), AutoSavePosition = true }; - detachedForm.Icon = Properties.Resources.radegast_icon; + detachedForm?.Dispose(); + + detachedForm = + new RadegastForm(RadegastInstance.GlobalInstance) + { + SettingsKeyBase = GetType().ToString(), + AutoSavePosition = true, + Icon = Properties.Resources.radegast_icon + }; OriginalParent = Parent; Parent = detachedForm; Dock = DockStyle.Fill; @@ -114,7 +102,7 @@ protected virtual void Detach() SetTitle(); detachedForm.ActiveControl = this; detachedForm.Show(); - detachedForm.FormClosing += new FormClosingEventHandler(detachedForm_FormClosing); + detachedForm.FormClosing += detachedForm_FormClosing; if (OriginalParent == null) { @@ -122,13 +110,10 @@ protected virtual void Detach() } else { - OriginalParent.ControlAdded += new ControlEventHandler(originalParent_ControlAdded); + OriginalParent.ControlAdded += originalParent_ControlAdded; } - if (OnDetached != null) - { - OnDetached(); - } + OnDetached?.Invoke(); } protected virtual void ControlIsNotRetachable() { } @@ -137,9 +122,9 @@ void originalParent_ControlAdded(object sender, ControlEventArgs e) { if (detachedForm != null) { - detachedForm.FormClosing -= new FormClosingEventHandler(detachedForm_FormClosing); + detachedForm.FormClosing -= detachedForm_FormClosing; } - OriginalParent.ControlAdded -= new ControlEventHandler(originalParent_ControlAdded); + OriginalParent.ControlAdded -= originalParent_ControlAdded; ControlIsNotRetachable(); } @@ -154,7 +139,7 @@ protected virtual void Retach() if (OriginalParent != null) { - OriginalParent.ControlAdded -= new ControlEventHandler(originalParent_ControlAdded); + OriginalParent.ControlAdded -= originalParent_ControlAdded; Size = AttachedSize; } @@ -171,10 +156,7 @@ protected virtual void Retach() Dispose(); } - if (OnRetached != null) - { - OnRetached(); - } + OnRetached?.Invoke(); } protected virtual void SetTitle() diff --git a/Radegast/Core/Types/ExtendedRichTextBox.cs b/Radegast/GUI/Controls/ExtendedRichTextBox.cs similarity index 93% rename from Radegast/Core/Types/ExtendedRichTextBox.cs rename to Radegast/GUI/Controls/ExtendedRichTextBox.cs index 92f25ab8d..8461de4b8 100644 --- a/Radegast/Core/Types/ExtendedRichTextBox.cs +++ b/Radegast/GUI/Controls/ExtendedRichTextBox.cs @@ -1,4 +1,24 @@ -#region Using directives +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + +#region Using directives using System; using System.Collections.Generic; @@ -174,43 +194,47 @@ public class ExtendedRichTextBox : RichTextBox public ExtendedRichTextBox() { - this.myToolTip = new ToolTip(); - this.ContextMenu = new ContextMenu(); + myToolTip = new ToolTip(); + ContextMenuStrip = new ContextMenuStrip(); // Initialize default text and background colors textColor = RtfColor.Black; highlightColor = RtfColor.White; // Initialize the dictionary mapping color codes to definitions - rtfColor = new Dictionary(); - rtfColor[RtfColor.Aqua] = RtfColorDef.Aqua; - rtfColor[RtfColor.Black] = RtfColorDef.Black; - rtfColor[RtfColor.Blue] = RtfColorDef.Blue; - rtfColor[RtfColor.Fuchsia] = RtfColorDef.Fuchsia; - rtfColor[RtfColor.Gray] = RtfColorDef.Gray; - rtfColor[RtfColor.Green] = RtfColorDef.Green; - rtfColor[RtfColor.Lime] = RtfColorDef.Lime; - rtfColor[RtfColor.Maroon] = RtfColorDef.Maroon; - rtfColor[RtfColor.Navy] = RtfColorDef.Navy; - rtfColor[RtfColor.Olive] = RtfColorDef.Olive; - rtfColor[RtfColor.Purple] = RtfColorDef.Purple; - rtfColor[RtfColor.Red] = RtfColorDef.Red; - rtfColor[RtfColor.Silver] = RtfColorDef.Silver; - rtfColor[RtfColor.Teal] = RtfColorDef.Teal; - rtfColor[RtfColor.White] = RtfColorDef.White; - rtfColor[RtfColor.Yellow] = RtfColorDef.Yellow; + rtfColor = new Dictionary + { + [RtfColor.Aqua] = RtfColorDef.Aqua, + [RtfColor.Black] = RtfColorDef.Black, + [RtfColor.Blue] = RtfColorDef.Blue, + [RtfColor.Fuchsia] = RtfColorDef.Fuchsia, + [RtfColor.Gray] = RtfColorDef.Gray, + [RtfColor.Green] = RtfColorDef.Green, + [RtfColor.Lime] = RtfColorDef.Lime, + [RtfColor.Maroon] = RtfColorDef.Maroon, + [RtfColor.Navy] = RtfColorDef.Navy, + [RtfColor.Olive] = RtfColorDef.Olive, + [RtfColor.Purple] = RtfColorDef.Purple, + [RtfColor.Red] = RtfColorDef.Red, + [RtfColor.Silver] = RtfColorDef.Silver, + [RtfColor.Teal] = RtfColorDef.Teal, + [RtfColor.White] = RtfColorDef.White, + [RtfColor.Yellow] = RtfColorDef.Yellow + }; // Initialize the dictionary mapping default Framework font families to // RTF font families - rtfFontFamily = new Dictionary(); - rtfFontFamily[FontFamily.GenericMonospace.Name] = RtfFontFamilyDef.Modern; - rtfFontFamily[FontFamily.GenericSansSerif.Name] = RtfFontFamilyDef.Swiss; - rtfFontFamily[FontFamily.GenericSerif.Name] = RtfFontFamilyDef.Roman; - rtfFontFamily[FF_UNKNOWN] = RtfFontFamilyDef.Unknown; + rtfFontFamily = new Dictionary + { + [FontFamily.GenericMonospace.Name] = RtfFontFamilyDef.Modern, + [FontFamily.GenericSansSerif.Name] = RtfFontFamilyDef.Swiss, + [FontFamily.GenericSerif.Name] = RtfFontFamilyDef.Roman, + [FF_UNKNOWN] = RtfFontFamilyDef.Unknown + }; // Get the horizontal and vertical resolutions at which the object is // being displayed - using (Graphics _graphics = this.CreateGraphics()) + using (Graphics _graphics = CreateGraphics()) { xDpi = _graphics.DpiX; yDpi = _graphics.DpiY; @@ -341,6 +365,7 @@ private static extern int SetWindowTheme( /// /// the window to send the message to /// the number of the sroll bar to look at + /// /// [DllImport("user32", CharSet = CharSet.Auto)] private static extern int GetScrollInfo(HandleRef hWnd, int nBar, ref SCROLLINFO info); @@ -653,10 +678,7 @@ public void EndUpdate() /// /// Returns if updates to the controls are under way with BeginUpdate /// - public bool Updating - { - get { return _Updating > 0; } - } + public bool Updating => _Updating > 0; #endregion #region ScrollBarDetails @@ -780,11 +802,11 @@ public void AppendRtf(string _rtf) { // Move caret to the end of the text - this.Select(this.TextLength, 0); + Select(TextLength, 0); // Since SelectedRtf is null, this will append the string to the // end of the existing RTF - this.SelectedRtf = _rtf; + SelectedRtf = _rtf; } /// @@ -798,7 +820,7 @@ public void AppendRtf(string _rtf) /// public void InsertRtf(string _rtf) { - this.SelectedRtf = _rtf; + SelectedRtf = _rtf; } /// @@ -807,7 +829,7 @@ public void InsertRtf(string _rtf) /// public void AppendTextAsRtf(string _text) { - AppendTextAsRtf(_text, this.Font); + AppendTextAsRtf(_text, Font); } /// @@ -827,7 +849,7 @@ public void AppendTextAsRtf(string _text, Font _font) /// /// /// - /// + /// public void AppendTextAsRtf(string _text, Font _font, RtfColor _textColor) { AppendTextAsRtf(_text, _font, _textColor, highlightColor); @@ -845,7 +867,7 @@ public void AppendTextAsRtf(string _text, Font _font, RtfColor _textColor) public void AppendTextAsRtf(string _text, Font _font, RtfColor _textColor, RtfColor _backColor) { // Move carret to the end of the text - this.Select(this.TextLength, 0); + Select(TextLength, 0); InsertTextAsRtf(_text, _font, _textColor, _backColor); } @@ -859,7 +881,7 @@ public void AppendTextAsRtf(string _text, Font _font, RtfColor _textColor, RtfCo /// public void InsertTextAsRtf(string _text) { - InsertTextAsRtf(_text, this.Font); + InsertTextAsRtf(_text, Font); } @@ -880,7 +902,7 @@ public void InsertTextAsRtf(string _text, Font _font) /// /// /// - /// + /// public void InsertTextAsRtf(string _text, Font _font, RtfColor _textColor) { InsertTextAsRtf(_text, _font, _textColor, highlightColor); @@ -902,8 +924,8 @@ public void InsertTextAsRtf(string _text, Font _font, RtfColor _textColor) /// /// /// - /// - /// + /// + /// public void InsertTextAsRtf(string _text, Font _font, RtfColor _textColor, RtfColor _backColor) { @@ -924,7 +946,7 @@ public void InsertTextAsRtf(string _text, Font _font, RtfColor _textColor, RtfCo // it to the RTF string. _rtf.Append(GetDocumentArea(_text, _font)); - this.SelectedRtf = _rtf.ToString(); + SelectedRtf = _rtf.ToString(); } /// @@ -1048,7 +1070,7 @@ public virtual void InsertImage(Image _image) // Create the font table using the RichTextBox's current font and append // it to the RTF string - _rtf.Append(GetFontTable(this.Font)); + _rtf.Append(GetFontTable(Font)); // Create the image control string and append it to the RTF string _rtf.Append(GetImagePrefix(_image)); @@ -1059,7 +1081,7 @@ public virtual void InsertImage(Image _image) // Close the RTF image control string _rtf.Append(RTF_IMAGE_POST); - this.SelectedRtf = _rtf.ToString(); + SelectedRtf = _rtf.ToString(); } /// @@ -1206,7 +1228,7 @@ private string GetRtfImage(Image _image) _stream = new MemoryStream(); // Get a graphics context from the RichTextBox - using (_graphics = this.CreateGraphics()) + using (_graphics = CreateGraphics()) { // Get the device context from the graphics context @@ -1246,21 +1268,18 @@ private string GetRtfImage(Image _image) EmfToWmfBitsFlags.EmfToWmfBitsFlagsDefault); // Append the bits to the RTF string - for (int i = 0; i < _buffer.Length; ++i) + foreach (var t in _buffer) { - _rtf.Append(String.Format("{0:X2}", _buffer[i])); + _rtf.Append(String.Format("{0:X2}", t)); } return _rtf.ToString(); } finally { - if (_graphics != null) - _graphics.Dispose(); - if (_metaFile != null) - _metaFile.Dispose(); - if (_stream != null) - _stream.Close(); + _graphics?.Dispose(); + _metaFile?.Dispose(); + _stream?.Close(); } } @@ -1489,12 +1508,6 @@ protected override void WndProc(ref Message m) /// public class ScrollBarInformation { - int nMin = 0; - int nMax = 0; - int nPage = 0; - int nPos = 0; - int nTrackPos = 0; - /// /// Sets up an empty scroll bar information class. /// @@ -1513,53 +1526,37 @@ public ScrollBarInformation() /// this is updated while the scroll bar is wiggling up and down. public ScrollBarInformation(int min, int max, int page, int pos, int trackpos) { - this.nMin = min; - this.nMax = max; - this.nPage = page; - this.nPos = pos; - this.nTrackPos = trackpos; + Minimum = min; + Maximum = max; + Page = page; + Position = pos; + TrackPosition = trackpos; } /// /// Specifies the minimum scrolling position. /// /// the minimum scrolling position - public int Minimum - { - get { return nMin; } - set { nMin = value; } - } + public int Minimum { get; set; } = 0; /// /// Specifies the maximum scrolling position. /// /// the maximum scrolling position - public int Maximum - { - get { return nMax; } - set { nMax = value; } - } + public int Maximum { get; set; } = 0; /// /// Specifies the page size. A scroll bar uses this value to determine the /// appropriate size of the proportional scroll box. /// /// - public int Page - { - get { return nPage; } - set { nPage = value; } - } + public int Page { get; set; } = 0; /// /// The position of the thumb inside the scroll bar. /// /// - public int Position - { - get { return nPos; } - set { nPos = value; } - } + public int Position { get; set; } = 0; /// /// Specifies the immediate position of a scroll box that the user is dragging. @@ -1568,11 +1565,7 @@ public int Position /// SetScrollInfo function ignores this member. /// /// the immediated position of the scroll box - public int TrackPosition - { - get { return nTrackPos; } - set { nTrackPos = value; } - } + public int TrackPosition { get; set; } = 0; } #endregion } \ No newline at end of file diff --git a/Radegast/Core/Types/LineNumberPanel.cs b/Radegast/GUI/Controls/LineNumberPanel.cs similarity index 54% rename from Radegast/Core/Types/LineNumberPanel.cs rename to Radegast/GUI/Controls/LineNumberPanel.cs index 482bf04b8..87ada0c4e 100644 --- a/Radegast/Core/Types/LineNumberPanel.cs +++ b/Radegast/GUI/Controls/LineNumberPanel.cs @@ -1,33 +1,23 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Drawing; using System.Windows.Forms; @@ -41,7 +31,7 @@ namespace Radegast [Browsable(true), Category("Containers"), Description("Used in conjuction with ritch text box to display lone numbers")] - public partial class LineNumberPanel : Control + public class LineNumberPanel : Control { private RRichTextBox rtb; private SolidBrush brush; @@ -68,14 +58,14 @@ public RRichTextBox RTB { if (rtb != null) { - rtb.VScroll -= new EventHandler(rtb_InvalidateNumbers); - rtb.TextChanged -= new EventHandler(rtb_InvalidateNumbers); - rtb.Resize -= new EventHandler(rtb_InvalidateNumbers); + rtb.VScroll -= rtb_InvalidateNumbers; + rtb.TextChanged -= rtb_InvalidateNumbers; + rtb.Resize -= rtb_InvalidateNumbers; } rtb = value; - rtb.VScroll += new EventHandler(rtb_InvalidateNumbers); - rtb.TextChanged += new EventHandler(rtb_InvalidateNumbers); - rtb.Resize += new EventHandler(rtb_InvalidateNumbers); + rtb.VScroll += rtb_InvalidateNumbers; + rtb.TextChanged += rtb_InvalidateNumbers; + rtb.Resize += rtb_InvalidateNumbers; } } @@ -85,7 +75,6 @@ void rtb_InvalidateNumbers(object sender, EventArgs e) } public LineNumberPanel() - : base() { SetStyle( ControlStyles.DoubleBuffer | @@ -118,18 +107,18 @@ protected override void OnPaint(PaintEventArgs e) } Point pos = new Point(0, (int)(g.VisibleClipBounds.Y + font_height / 3)); - int first_index, first_line, first_line_y; - first_index = rtb.GetCharIndexFromPosition(pos); - first_line = rtb.GetLineFromCharIndex(first_index); - first_line_y = 1 + rtb.GetPositionFromCharIndex(first_index).Y; + var first_index = rtb.GetCharIndexFromPosition(pos); + var first_line = rtb.GetLineFromCharIndex(first_index); + var first_line_y = 1 + rtb.GetPositionFromCharIndex(first_index).Y; int i = first_line; - int x = 0; Single y = 0; int total_lines = rtb.GetLineFromCharIndex(Int32.MaxValue) + 1; - StringFormat align = new StringFormat(StringFormatFlags.NoWrap); - align.Alignment = StringAlignment.Far; - align.LineAlignment = StringAlignment.Center; + StringFormat align = new StringFormat(StringFormatFlags.NoWrap) + { + Alignment = StringAlignment.Far, + LineAlignment = StringAlignment.Center + }; int maxWidth = 0; while (y < g.VisibleClipBounds.Y + g.VisibleClipBounds.Height) @@ -142,7 +131,7 @@ protected override void OnPaint(PaintEventArgs e) } y = first_line_y - 1 + font_height * (i - first_line - 1); - x = Width - (int)tSize.Width - 5; + var x = Width - (int)tSize.Width - 5; if (i <= total_lines) { diff --git a/Radegast/GUI/Controls/ListBoxCustomSort.cs b/Radegast/GUI/Controls/ListBoxCustomSort.cs new file mode 100644 index 000000000..782906dac --- /dev/null +++ b/Radegast/GUI/Controls/ListBoxCustomSort.cs @@ -0,0 +1,69 @@ +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + +using System; +using System.Windows.Forms; + +namespace Radegast +{ + public class ListBoxCustomSort : ListBox + { + public void PerformSort() + { + QuickSort(0, Items.Count - 1); + } + + private void QuickSort(int left, int right) + { + if (right > left) + { + int pivotIndex = left; + int pivotNewIndex = QuickSortPartition(left, right, pivotIndex); + + QuickSort(left, pivotNewIndex - 1); + QuickSort(pivotNewIndex + 1, right); + } + } + + private int QuickSortPartition(int left, int right, int pivot) + { + var pivotValue = (IComparable)Items[pivot]; + Swap(pivot, right); + + int storeIndex = left; + for (int i = left; i < right; ++i) + { + if (pivotValue.CompareTo(Items[i]) >= 0) + { + Swap(i, storeIndex); + ++storeIndex; + } + } + + Swap(storeIndex, right); + return storeIndex; + } + + private void Swap(int left, int right) + { + (Items[left], Items[right]) = (Items[right], Items[left]); + } + } +} diff --git a/Radegast/GUI/Controls/ListViewNoFlicker.cs b/Radegast/GUI/Controls/ListViewNoFlicker.cs new file mode 100644 index 000000000..274a47818 --- /dev/null +++ b/Radegast/GUI/Controls/ListViewNoFlicker.cs @@ -0,0 +1,47 @@ +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + +using System.Windows.Forms; + +namespace Radegast +{ + public class ListViewNoFlicker : ListView + { + public ListViewNoFlicker() + { + + //Activate double buffering + SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true); + + //Enable the OnNotifyMessage event so we get a chance to filter out + // Windows messages before they get to the form's WndProc + SetStyle(ControlStyles.EnableNotifyMessage, true); + } + + protected override void OnNotifyMessage(Message m) + { + //Filter out the WM_ERASEBKGND message + if (m.Msg != 0x14) + { + base.OnNotifyMessage(m); + } + } + } +} diff --git a/Radegast/Core/Types/MapControl.Designer.cs b/Radegast/GUI/Controls/MapControl.Designer.cs similarity index 100% rename from Radegast/Core/Types/MapControl.Designer.cs rename to Radegast/GUI/Controls/MapControl.Designer.cs diff --git a/Radegast/Core/Types/MapControl.cs b/Radegast/GUI/Controls/MapControl.cs similarity index 72% rename from Radegast/Core/Types/MapControl.cs rename to Radegast/GUI/Controls/MapControl.cs index c8ae3d972..a4cd8f96a 100644 --- a/Radegast/Core/Types/MapControl.cs +++ b/Radegast/GUI/Controls/MapControl.cs @@ -1,32 +1,42 @@ -using System; +/* + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2023, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + +using System; using System.Collections.Generic; -using System.ComponentModel; using System.Drawing; -using System.Data; using System.Security.Cryptography.X509Certificates; -using System.Text; using System.Windows.Forms; using System.Net; -using System.Text.RegularExpressions; using System.IO; -#if (COGBOT_LIBOMV || USE_STHREADS) -using ThreadPoolUtil; -using Thread = ThreadPoolUtil.Thread; -using ThreadPool = ThreadPoolUtil.ThreadPool; -using Monitor = ThreadPoolUtil.Monitor; -#endif using System.Threading; +using CoreJ2K; using OpenMetaverse; -using OpenMetaverse.Http; -using OpenMetaverse.Assets; +using SkiaSharp; +using SkiaSharp.Views.Desktop; namespace Radegast { public partial class MapControl : UserControl { RadegastInstance Instance; - GridClient Client { get { return Instance.Client; } } - ParallelDownloader downloader; + GridClient Client => Instance.Client; Color background; float zoom; Font textFont; @@ -41,25 +51,23 @@ public partial class MapControl : UserControl GridRegion targetRegion, nullRegion; bool centered = false; int PixRegS; - float maxZoom = 6f, minZoom = 0.5f; string targetParcelName = null; System.Threading.Timer repaint; bool needRepaint = false; + CancellationTokenSource mapTileCts = new CancellationTokenSource(); public bool UseExternalTiles = false; public event EventHandler MapTargetChanged; public event EventHandler ZoomChanged; - public float MaxZoom { get { return maxZoom; } } - public float MinZoom { get { return minZoom; } } + public float MaxZoom { get; } = 6f; + public float MinZoom { get; } = 0.5f; public MapControl(RadegastInstance instance) { Zoom = 1.0f; InitializeComponent(); - Disposed += new EventHandler(MapControl_Disposed); - this.Instance = instance; - - downloader = new ParallelDownloader(); + Disposed += MapControl_Disposed; + Instance = instance; background = Color.FromArgb(4, 4, 75); textFont = new Font(FontFamily.GenericSansSerif, 8.0f, FontStyle.Bold); @@ -70,10 +78,10 @@ public MapControl(RadegastInstance instance) repaint = new System.Threading.Timer(RepaintTick, null, 1000, 1000); - Instance.ClientChanged += new EventHandler(Instance_ClientChanged); + Instance.ClientChanged += Instance_ClientChanged; RegisterClientEvents(); - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } void MapControl_Disposed(object sender, EventArgs e) @@ -86,19 +94,14 @@ void MapControl_Disposed(object sender, EventArgs e) repaint = null; } - if (downloader != null) - { - downloader.Dispose(); - downloader = null; - } - if (regionTiles != null) { lock (regionTiles) { foreach (Image img in regionTiles.Values) - if (img != null) - img.Dispose(); + { + img?.Dispose(); + } regionTiles.Clear(); } regionTiles = null; @@ -107,18 +110,18 @@ void MapControl_Disposed(object sender, EventArgs e) void RegisterClientEvents() { - Client.Grid.GridItems += new EventHandler(Grid_GridItems); - Client.Grid.GridRegion += new EventHandler(Grid_GridRegion); - Client.Grid.GridLayer += new EventHandler(Grid_GridLayer); + Client.Grid.GridItems += Grid_GridItems; + Client.Grid.GridRegion += Grid_GridRegion; + Client.Grid.GridLayer += Grid_GridLayer; } void UnregisterClientEvents(GridClient Client) { if (Client == null) return; - Client.Grid.GridItems -= new EventHandler(Grid_GridItems); - Client.Grid.GridRegion -= new EventHandler(Grid_GridRegion); - Client.Grid.GridLayer -= new EventHandler(Grid_GridLayer); + Client.Grid.GridItems -= Grid_GridItems; + Client.Grid.GridRegion -= Grid_GridRegion; + Client.Grid.GridLayer -= Grid_GridLayer; } void RepaintTick(object sync) @@ -177,15 +180,15 @@ void Instance_ClientChanged(object sender, ClientChangedEventArgs e) public float Zoom { - get { return zoom; } + get => zoom; set { - if (value >= minZoom && value <= maxZoom) + if (value >= MinZoom && value <= MaxZoom) { zoom = value; pixelsPerMeter = 1f / zoom; PixRegS = (int)(regionSize / zoom); - Logger.DebugLog("Region tile size = " + PixRegS.ToString()); + Logger.DebugLog("Region tile size = " + PixRegS); Invalidate(); } } @@ -195,7 +198,7 @@ public void ClearTarget() { targetRegion = nullRegion; targetX = targetY = -5000000000d; - WorkPool.QueueUserWorkItem(sync => + ThreadPool.QueueUserWorkItem(sync => { Thread.Sleep(500); needRepaint = true; @@ -208,7 +211,7 @@ public void SafeInvalidate() if (InvokeRequired) { if (!Instance.MonoRuntime || IsHandleCreated) - BeginInvoke(new MethodInvoker(() => Invalidate())); + BeginInvoke(new MethodInvoker(Invalidate)); } else { @@ -237,10 +240,7 @@ public void CenterMap(uint regionX, uint regionY, uint localX, uint localY, bool { targetRegion = regions[handle]; GetTargetParcel(); - if (MapTargetChanged != null) - { - MapTargetChanged(this, new MapTargetChangedEventArgs(targetRegion, (int)localX, (int)localY)); - } + MapTargetChanged?.Invoke(this, new MapTargetChangedEventArgs(targetRegion, (int)localX, (int)localY)); } else { @@ -298,54 +298,48 @@ void DownloadRegionTile(ulong handle, UUID imageID) tileRequests.Add(handle); - Uri url = Client.Network.CurrentSim.Caps.CapabilityURI("GetTexture"); - + Uri url = Client.Network.CurrentSim.Caps.GetTextureCapURI(); if (url != null) { if (Client.Assets.Cache.HasAsset(imageID)) { - Image img; - OpenMetaverse.Imaging.ManagedImage mi; - if (OpenMetaverse.Imaging.OpenJPEG.DecodeToImage(Client.Assets.Cache.GetCachedAssetBytes(imageID), out mi, out img)) - { - regionTiles[handle] = img; - needRepaint = true; - } + regionTiles[handle] = J2kImage.FromBytes( + Client.Assets.Cache.GetCachedAssetBytes(imageID)).As().ToBitmap(); + needRepaint = true; + lock (tileRequests) + { if (tileRequests.Contains(handle)) + { tileRequests.Remove(handle); + } + } } else { - downloader.QueueDownlad( - new Uri(string.Format("{0}/?texture_id={1}", url.ToString(), imageID.ToString())), - 30 * 1000, - "image/x-j2c", - null, - (HttpWebRequest request, HttpWebResponse response, byte[] responseData, Exception error) => + Client.HttpCapsClient.GetRequestAsync(new Uri($"{url}/?texture_id={imageID}"), mapTileCts.Token, + (response, responseData, error) => { if (error == null && responseData != null) { - Image img; - OpenMetaverse.Imaging.ManagedImage mi; - if (OpenMetaverse.Imaging.OpenJPEG.DecodeToImage(responseData, out mi, out img)) - { - regionTiles[handle] = img; - needRepaint = true; - Client.Assets.Cache.SaveAssetToCache(imageID, responseData); - } + regionTiles[handle] = J2kImage.FromBytes(responseData).As().ToBitmap(); + needRepaint = true; + Client.Assets.Cache.SaveAssetToCache(imageID, responseData); } lock (tileRequests) + { if (tileRequests.Contains(handle)) + { tileRequests.Remove(handle); - + } + } }); } } else { - Client.Assets.RequestImage(imageID, (TextureRequestState state, AssetTexture assetTexture) => + Client.Assets.RequestImage(imageID, (state, assetTexture) => { switch (state) { @@ -355,15 +349,11 @@ void DownloadRegionTile(ulong handle, UUID imageID) return; case TextureRequestState.Finished: - if (assetTexture != null && assetTexture.AssetData != null) + if (assetTexture?.AssetData != null) { - Image img; - OpenMetaverse.Imaging.ManagedImage mi; - if (OpenMetaverse.Imaging.OpenJPEG.DecodeToImage(assetTexture.AssetData, out mi, out img)) - { - regionTiles[handle] = img; - needRepaint = true; - } + regionTiles[handle] = + J2kImage.FromBytes(assetTexture.AssetData).As().ToBitmap(); + needRepaint = true; } lock (tileRequests) if (tileRequests.Contains(handle)) @@ -407,14 +397,11 @@ Image GetRegionTileExternal(ulong handle) Utils.LongToUInts(handle, out regX, out regY); regX /= regionSize; regY /= regionSize; - int zoom = 1; - - downloader.QueueDownlad( - new Uri(string.Format("http://map.secondlife.com/map-{0}-{1}-{2}-objects.jpg", zoom, regX, regY)), - 20 * 1000, - null, - null, - (HttpWebRequest request, HttpWebResponse response, byte[] responseData, Exception error) => + int zoomlevel = 1; + + Client.HttpCapsClient.GetRequestAsync( + new Uri($"http://map.secondlife.com/map-{zoomlevel}-{regX}-{regY}-objects.jpg"), mapTileCts.Token, + (response, responseData, error) => { if (error == null && responseData != null) { @@ -464,11 +451,12 @@ void DrawRegion(Graphics g, int x, int y, ulong handle) if (tile != null) { int targetSize = 256; - for (targetSize = 128; targetSize > PixRegS; targetSize /= 2) ; + for (targetSize = 128; targetSize > PixRegS; targetSize /= 2) + { } targetSize *= 2; if (targetSize != 256) { - string id = string.Format("{0},{1}", handle, targetSize); + string id = $"{handle},{targetSize}"; if (smallerTiles.ContainsKey(id)) { tile = smallerTiles[id]; @@ -632,9 +620,8 @@ private void MapControl_Paint(object sender, PaintEventArgs e) { foreach (MapItem i in regionMapItems[handle]) { - if (i is MapAgentLocation) + if (i is MapAgentLocation loc) { - MapAgentLocation loc = (MapAgentLocation)i; if (loc.AvatarCount == 0) continue; int dotX = pixX + (int)((float)loc.LocalX * ratio); int dotY = pixY - (int)((float)loc.LocalY * ratio); @@ -708,8 +695,7 @@ protected override void OnMouseWheel(MouseEventArgs e) else Zoom -= 0.25f; - if (ZoomChanged != null) - ZoomChanged(this, EventArgs.Empty); + ZoomChanged?.Invoke(this, EventArgs.Empty); } bool dragging = false; @@ -727,7 +713,7 @@ private void MapControl_MouseDown(object sender, MouseEventArgs e) void GetTargetParcel() { - WorkPool.QueueUserWorkItem(sync => + ThreadPool.QueueUserWorkItem(sync => { UUID parcelID = Client.Parcels.RequestRemoteParcelID( new Vector3((float)(targetX % regionSize), (float)(targetY % regionSize), 20f), @@ -735,7 +721,7 @@ void GetTargetParcel() if (parcelID != UUID.Zero) { ManualResetEvent done = new ManualResetEvent(false); - EventHandler handler = (object sender, ParcelInfoReplyEventArgs e) => + EventHandler handler = (sender, e) => { if (e.Parcel.ID == parcelID) { @@ -771,10 +757,7 @@ private void MapControl_MouseUp(object sender, MouseEventArgs e) { targetRegion = regions[handle]; GetTargetParcel(); - if (MapTargetChanged != null) - { - MapTargetChanged(this, new MapTargetChangedEventArgs(targetRegion, (int)localX, (int)localY)); - } + MapTargetChanged?.Invoke(this, new MapTargetChangedEventArgs(targetRegion, (int)localX, (int)localY)); } else { @@ -818,141 +801,4 @@ public MapTargetChangedEventArgs(GridRegion region, int x, int y) LocalY = y; } } - - public class ParallelDownloader : IDisposable - { - Queue queue = new Queue(); - List activeDownloads = new List(); - - int m_ParallelDownloads = 15; - X509Certificate2 m_ClientCert; - - public int ParallelDownloads - { - get { return m_ParallelDownloads; } - set { m_ParallelDownloads = value; } - } - - public X509Certificate2 ClientCert - { - get { return m_ClientCert; } - set { m_ClientCert = value; } - } - - public ParallelDownloader() - { - } - - public virtual void Dispose() - { - lock (activeDownloads) - { - for (int i = 0; i < activeDownloads.Count; i++) - { - try - { - activeDownloads[i].Abort(); - } - catch { } - } - } - } - - protected virtual HttpWebRequest SetupRequest(Uri address, string acceptHeader) - { - HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(address); - request.Method = "GET"; - - if (!string.IsNullOrEmpty(acceptHeader)) - request.Accept = acceptHeader; - - // Add the client certificate to the request if one was given - if (m_ClientCert != null) - request.ClientCertificates.Add(m_ClientCert); - - // Leave idle connections to this endpoint open for up to 60 seconds - request.ServicePoint.MaxIdleTime = 0; - // Disable stupid Expect-100: Continue header - request.ServicePoint.Expect100Continue = false; - // Crank up the max number of connections per endpoint (default is 2!) - request.ServicePoint.ConnectionLimit = Math.Max(request.ServicePoint.ConnectionLimit, 128); - // Caps requests are never sent as trickles of data, so Nagle's - // coalescing algorithm won't help us - request.ServicePoint.UseNagleAlgorithm = false; - - return request; - } - - private void EnqueuePending() - { - lock (queue) - { - if (queue.Count > 0) - { - int nr = 0; - lock (activeDownloads) nr = activeDownloads.Count; - - for (int i = nr; i < ParallelDownloads && queue.Count > 0; i++) - { - QueuedItem item = queue.Dequeue(); - Logger.DebugLog("Requesting " + item.address.ToString()); - HttpWebRequest req = SetupRequest(item.address, item.contentType); - CapsBase.DownloadDataAsync( - req, - item.millisecondsTimeout, - item.downloadProgressCallback, - (HttpWebRequest request, HttpWebResponse response, byte[] responseData, Exception error) => - { - lock (activeDownloads) activeDownloads.Remove(request); - item.completedCallback(request, response, responseData, error); - EnqueuePending(); - } - ); - - lock (activeDownloads) activeDownloads.Add(req); - } - } - } - } - - public void QueueDownlad(Uri address, int millisecondsTimeout, - string contentType, - CapsBase.DownloadProgressEventHandler downloadProgressCallback, - CapsBase.RequestCompletedEventHandler completedCallback) - { - lock (queue) - { - queue.Enqueue(new QueuedItem( - address, - millisecondsTimeout, - contentType, - downloadProgressCallback, - completedCallback - )); - } - EnqueuePending(); - } - - public class QueuedItem - { - public Uri address; - public int millisecondsTimeout; - public CapsBase.DownloadProgressEventHandler downloadProgressCallback; - public CapsBase.RequestCompletedEventHandler completedCallback; - public string contentType; - - public QueuedItem(Uri address, int millisecondsTimeout, - string contentType, - CapsBase.DownloadProgressEventHandler downloadProgressCallback, - CapsBase.RequestCompletedEventHandler completedCallback) - { - this.address = address; - this.millisecondsTimeout = millisecondsTimeout; - this.downloadProgressCallback = downloadProgressCallback; - this.completedCallback = completedCallback; - this.contentType = contentType; - } - } - - } } diff --git a/Radegast/Core/Types/MapControl.resx b/Radegast/GUI/Controls/MapControl.resx similarity index 97% rename from Radegast/Core/Types/MapControl.resx rename to Radegast/GUI/Controls/MapControl.resx index ff31a6db5..19dc0dd8b 100644 --- a/Radegast/Core/Types/MapControl.resx +++ b/Radegast/GUI/Controls/MapControl.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/Radegast/GUI/Controls/MiniMap.cs b/Radegast/GUI/Controls/MiniMap.cs new file mode 100644 index 000000000..e04a88b50 --- /dev/null +++ b/Radegast/GUI/Controls/MiniMap.cs @@ -0,0 +1,216 @@ +/* + * Copyright (c) 2006-2016, openmetaverse.co + * Copyright (c) 2021, Sjofn LLC. + * All rights reserved. + * + * - Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Neither the name of the openmetaverse.co nor the names + * of its contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +using System.Collections.Generic; +using System.Drawing; +using System.Windows.Forms; +using CoreJ2K; +using OpenMetaverse.Assets; +using OpenMetaverse; +using SkiaSharp; +using SkiaSharp.Views.Desktop; + +namespace Radegast.WinForms +{ + /// + /// PictureBox GUI component for displaying a client's mini-map + /// + public class MiniMap : PictureBox + { + private static Brush BG_COLOR = Brushes.Navy; + + private UUID _MapImageID; + private GridClient _Client; + private Image _MapLayer; + + /// + /// Gets or sets the GridClient associated with this control + /// + public GridClient Client + { + get { return _Client; } + set { if (value != null) InitializeClient(value); } + } + + /// + /// PictureBox control for an unspecified client's mini-map + /// + public MiniMap() + { + this.BorderStyle = BorderStyle.FixedSingle; + this.SizeMode = PictureBoxSizeMode.Zoom; + } + + /// + /// PictureBox control for the specified client's mini-map + /// + public MiniMap(GridClient client) : this () + { + InitializeClient(client); + } + + /// Sets the map layer to the specified bitmap image + /// + public void SetMapLayer(Bitmap mapImage) + { + if (this.InvokeRequired) this.BeginInvoke((MethodInvoker)delegate { SetMapLayer(mapImage); }); + else + { + if (mapImage == null) + { + Bitmap bmp = new Bitmap(256, 256); + Graphics g = Graphics.FromImage(bmp); + g.Clear((System.Drawing.Color)(object)this.BackColor); // *HACK: + g.FillRectangle(BG_COLOR, 0f, 0f, 256f, 256f); + g.DrawImage(bmp, 0, 0); + + _MapLayer = bmp; + } + else _MapLayer = mapImage; + } + } + + private void InitializeClient(GridClient client) + { + _Client = client; + FetchMapLayer(); + _Client.Grid.CoarseLocationUpdate += Grid_CoarseLocationUpdate; + _Client.Network.SimChanged += Network_OnCurrentSimChanged; + } + + void Grid_CoarseLocationUpdate(object sender, CoarseLocationUpdateEventArgs e) + { + UpdateMiniMap(e.Simulator); + } + + private void UpdateMiniMap(Simulator sim) + { + if (!this.IsHandleCreated) { return; } + + if (this.InvokeRequired) + { + this.BeginInvoke((MethodInvoker)delegate { UpdateMiniMap(sim); }); + } + else + { + if (_MapLayer == null) + { + SetMapLayer(null); + } + Bitmap bmp = (Bitmap)_MapLayer.Clone(); + Graphics g = Graphics.FromImage(bmp); + + Vector3 myCoarsePos; + + if (!sim.AvatarPositions.TryGetValue(Client.Self.AgentID, out myCoarsePos)) { return; } + + int i = 0; + + _Client.Network.CurrentSim.AvatarPositions.ForEach( + delegate (KeyValuePair coarse) + { + int x = (int)coarse.Value.X; + int y = 255 - (int)coarse.Value.Y; + if (coarse.Key == Client.Self.AgentID) + { + g.FillEllipse(Brushes.Yellow, x - 5, y - 5, 10, 10); + g.DrawEllipse(Pens.Khaki, x - 5, y - 5, 10, 10); + } + else + { + Pen penColor; + Brush brushColor; + + if (Client.Network.CurrentSim.ObjectsAvatars.Find(av => av.ID == coarse.Key) != null) + { + brushColor = Brushes.PaleGreen; + penColor = Pens.Green; + } + else + { + brushColor = Brushes.LightGray; + penColor = Pens.Gray; + } + + if (myCoarsePos.Z - coarse.Value.Z > 1) + { + Point[] points = new Point[3] { new Point(x - 6, y - 6), new Point(x + 6, y - 6), new Point(x, y + 6) }; + g.FillPolygon(brushColor, points); + g.DrawPolygon(penColor, points); + } + + else if (myCoarsePos.Z - coarse.Value.Z < -1) + { + Point[] points = new Point[3] { new Point(x - 6, y + 6), new Point(x + 6, y + 6), new Point(x, y - 6) }; + g.FillPolygon(brushColor, points); + g.DrawPolygon(penColor, points); + } + + else + { + g.FillEllipse(brushColor, x - 5, y - 5, 10, 10); + g.DrawEllipse(penColor, x - 5, y - 5, 10, 10); + } + } + i++; + } + ); + + g.DrawImage(bmp, 0, 0); + Image = bmp; + } + } + + void Network_OnCurrentSimChanged(object sender, SimChangedEventArgs e) + { + FetchMapLayer(); + } + + private void FetchMapLayer() + { + if (!_Client.Network.Connected) { return; } + + GridRegion region; + if (Client.Grid.GetGridRegion(Client.Network.CurrentSim.Name, GridLayerType.Objects, out region)) + { + SetMapLayer(null); + + _MapImageID = region.MapImageID; + + Client.Assets.RequestImage(_MapImageID, ImageType.Baked, + delegate (TextureRequestState state, AssetTexture asset) + { + if (state == TextureRequestState.Finished) + { + _MapLayer = J2kImage.FromBytes(asset.AssetData).As().ToBitmap(); + } + }); + } + } + + } +} diff --git a/Radegast/Core/Types/RRichTextBox.cs b/Radegast/GUI/Controls/RRichTextBox.cs similarity index 86% rename from Radegast/Core/Types/RRichTextBox.cs rename to Radegast/GUI/Controls/RRichTextBox.cs index 6688c28a0..d55613c09 100644 --- a/Radegast/Core/Types/RRichTextBox.cs +++ b/Radegast/GUI/Controls/RRichTextBox.cs @@ -1,33 +1,23 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2022, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections.Generic; using System.Text; @@ -35,7 +25,7 @@ using System.Drawing; using System.Runtime.InteropServices; using System.ComponentModel; -using Tools; +using LibreMetaverse.LslTools; namespace Radegast { @@ -45,7 +35,7 @@ public class RRichTextBox : ExtendedRichTextBox /// /// Required designer variable. /// - private System.ComponentModel.IContainer components = null; + private IContainer components = null; private bool supressOnTextChanged = false; private bool syntaxHighLightEnabled = false; @@ -60,7 +50,7 @@ public class RRichTextBox : ExtendedRichTextBox [Browsable(true), Category("Behavior"), DefaultValue(false)] public bool SyntaxHighlightEnabled { - get { return syntaxHighLightEnabled; } + get => syntaxHighLightEnabled; set { @@ -81,7 +71,6 @@ public bool SyntaxHighlightEnabled #endregion public RRichTextBox() - : base() { InitializeComponent(); @@ -91,16 +80,16 @@ public RRichTextBox() monoRuntime = true; } - rtfHeader = this.Rtf.Substring(0, this.Rtf.IndexOf('{', 2)) + " "; + rtfHeader = Rtf.Substring(0, Rtf.IndexOf('{', 2)) + " "; - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } private void InitializeComponent() { - this.components = new System.ComponentModel.Container(); - this.ttKeyWords = new ToolTip(this.components); - this.ttTimer = new System.Threading.Timer(ttTimerElapsed, null, System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite); + components = new Container(); + ttKeyWords = new ToolTip(components); + ttTimer = new System.Threading.Timer(ttTimerElapsed, null, System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite); } /// @@ -194,11 +183,8 @@ private List UsedColors { if (usedColors == null) { - usedColors = new List(); - usedColors.Add(ForeColor); - usedColors.Add(CommentColor); - usedColors.Add(StringColor); - + usedColors = new List {ForeColor, CommentColor, StringColor}; + foreach (LSLKeyWord w in KeyWords.Values) { if (!usedColors.Contains(w.Color)) @@ -283,16 +269,13 @@ private string ReHighlight(string text) public override string Text { - get - { - return base.Text; - } + get => base.Text; set { if (syntaxHighLightEnabled && value != null) { BeginUpdate(); - base.Rtf = ReHighlight(value); + Rtf = ReHighlight(value); EndUpdate(); } else @@ -353,7 +336,7 @@ public CursorLocation(int Line, int Column) public override string ToString() { - return string.Format("Ln {0} Col {1}", Line + 1, Column + 1); + return $"Ln {Line + 1} Col {Column + 1}"; } } @@ -448,8 +431,8 @@ private void ttTimerElapsed(Object sender) // Yes we want empty statement here #pragma warning disable 642 - for (starPos = trackedPos; starPos >= 0 && validWordChar(trackedString[starPos]); starPos--) ; - for (endPos = trackedPos; endPos < trackedString.Length && validWordChar(trackedString[endPos]); endPos++) ; + for (starPos = trackedPos; starPos >= 0 && validWordChar(trackedString[starPos]); starPos--) { } + for (endPos = trackedPos; endPos < trackedString.Length && validWordChar(trackedString[endPos]); endPos++) { } string word = trackedString.Substring(starPos + 1, endPos - starPos - 1); if (!KeyWords.ContainsKey(word) || KeyWords[word].ToolTip == string.Empty) @@ -483,7 +466,7 @@ protected override void OnMouseMove(MouseEventArgs e) /// Text to be inserted public void InsertLink(string text) { - InsertLink(text, this.SelectionStart); + InsertLink(text, SelectionStart); } /// @@ -493,14 +476,14 @@ public void InsertLink(string text) /// Insert position public void InsertLink(string text, int position) { - if (position < 0 || position > this.Text.Length) - throw new ArgumentOutOfRangeException("position"); + if (position < 0 || position > Text.Length) + throw new ArgumentOutOfRangeException(nameof(position)); - this.SelectionStart = position; - this.SelectedText = text; - this.Select(position, text.Length); - this.SetSelectionLink(true); - this.Select(position + text.Length, 0); + SelectionStart = position; + SelectedText = text; + Select(position, text.Length); + SetSelectionLink(true); + Select(position + text.Length, 0); } /// @@ -514,7 +497,7 @@ public void InsertLink(string text, int position) /// Invisible hyperlink string to be inserted public void InsertLink(string text, string hyperlink) { - InsertLink(text, hyperlink, this.SelectionStart); + InsertLink(text, hyperlink, SelectionStart); } //public const char LinkSeparator = (char)0x1970; @@ -523,15 +506,15 @@ public void InsertLink(string text, string hyperlink) private string RtfUnicode(string s) { StringBuilder sb = new StringBuilder(); - for (int i = 0; i < s.Length; i++) + foreach (char c in s) { - if (s[i] > (char)255) + if (c > (char)255) { - sb.Append(string.Format("\\u{0}?", (short)s[i])); + sb.Append($"\\u{(short) c}?"); } else { - sb.Append(s[i]); + sb.Append(c); } } return sb.ToString(); @@ -548,10 +531,10 @@ private string RtfUnicode(string s) /// Insert position public void InsertLink(string text, string hyperlink, int position) { - if (position < 0 || position > this.Text.Length) - throw new ArgumentOutOfRangeException("position"); + if (position < 0 /* Commented out for now until we can find out why this is happening || position > Text.Length*/) + throw new ArgumentOutOfRangeException(nameof(position)); - this.SelectionStart = position; + SelectionStart = position; if (monoRuntime) { @@ -560,10 +543,10 @@ public void InsertLink(string text, string hyperlink, int position) } else { - this.SelectedRtf = rtfHeader + RtfUnicode(text) + @"\v " + LinkSeparator + hyperlink + @"\v0}"; - this.Select(position, text.Length + hyperlink.Length + 1); - this.SetSelectionLink(true); - this.Select(position + text.Length + hyperlink.Length + 1, 0); + SelectedRtf = rtfHeader + RtfUnicode(text) + @"\v " + LinkSeparator + hyperlink + @"\v0}"; + Select(position, text.Length + hyperlink.Length + 1); + SetSelectionLink(true); + Select(position + text.Length + hyperlink.Length + 1, 0); } } diff --git a/Radegast/Core/Types/RadegastContextMenu.cs b/Radegast/GUI/Controls/RadegastContextMenu.cs similarity index 74% rename from Radegast/Core/Types/RadegastContextMenu.cs rename to Radegast/GUI/Controls/RadegastContextMenu.cs index cd2cfdcb5..92fc50948 100644 --- a/Radegast/Core/Types/RadegastContextMenu.cs +++ b/Radegast/GUI/Controls/RadegastContextMenu.cs @@ -1,33 +1,22 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ using System; using System.Collections.Generic; @@ -40,10 +29,10 @@ namespace Radegast /// /// A Radegast based ContextMenuStrip /// the Opened/Closing/Selected/Clicked events may be subscribed to by plugins - /// This class is our Drop In replacement that add accessablity features to context menus + /// This class is our Drop In replacement that add accessibility features to context menus /// /// To use: - /// 1) In the 'Forms designer', intially drag in or use a ContextMenuStrip + /// 1) In the 'Forms designer', initially drag in or use a ContextMenuStrip /// 2) The replace the declared type and constructor with this class in the MyForm.Designer.cs /// 3) Pretend it is a typical ContextMenuStrip /// @@ -127,7 +116,7 @@ public class RadegastContextMenuStrip : ContextMenuStrip /// /// Fires whenever a context menu is "Opening" (not yet opened) anywhere from Radegast - /// Accesability should be more interested in OnContentMenuOpened + /// Accessibility should be more interested in OnContentMenuOpened /// This is for times context menus are busy deciding what to enable/disable /// public static event ContextMenuCallback OnContentMenuOpening; @@ -173,7 +162,6 @@ public class ContextMenuEventArgs : EventArgs public object Selection; public ContextMenuEventArgs(RadegastContextMenuStrip tab, ToolStripDropDownItem item, object target) - : base() { Menu = tab; MenuItem = item; @@ -201,11 +189,11 @@ public ContextMenuEventArgs(RadegastContextMenuStrip tab, ToolStripDropDownItem readonly object _selectionLock = new object(); /// - /// Childs we have added our hooks into + /// Children we have added our hooks into /// public readonly HashSet KnownItems = new HashSet(); - // for Control Chartacter we'd use when the Keys.Apps is not available + // for Control Character we'd use when the Keys.Apps is not available public const Keys ContexMenuKeyCode = Keys.Enter; /// @@ -222,7 +210,6 @@ public RadegastContextMenuStrip(IContainer components) /// Initializes a new instance of the System.Windows.Forms.ContextMenuStrip class. /// public RadegastContextMenuStrip() - : base() { RegisterEvents(); } @@ -245,13 +232,13 @@ private void RegisterEvents() private void Rad_OnItemRemoved(object sender, ToolStripItemEventArgs e) { - ToolStripDropDownItem Item = e.Item as ToolStripDropDownItem; - if (Item != null) - lock (KnownItems) - { - DeregisterItemEvents(Item); - WriteDebug("removed {0}", e.Item); - } + if (!(e.Item is ToolStripDropDownItem Item)) return; + + lock (KnownItems) + { + DeregisterItemEvents(Item); + WriteDebug("removed {0}", e.Item); + } } @@ -268,7 +255,7 @@ private void WriteDebug(string s, params object[] args) public override string ToString() { - return string.Format("RadMenu {0} MenuItem='{1}' selection='{2}'", Name, MenuItem, Selection); + return $"RadMenu {Name} MenuItem='{MenuItem}' selection='{Selection}'"; } @@ -299,16 +286,15 @@ private void Rad_Menu_KeyUp(object sender, KeyEventArgs e) private void Rad_Menu_Opened(object sender, EventArgs e) { WriteDebug("Menu_Opened: {0} {1}", sender, e); - if (OnContentMenuOpened != null) + if (OnContentMenuOpened == null) return; + + try { - try - { - OnContentMenuOpened(sender, new ContextMenuEventArgs(this, MenuItem, Selection)); - } - catch (Exception ex) - { - Logger.DebugLog("ERROR " + ex + " in " + this); - } + OnContentMenuOpened(sender, new ContextMenuEventArgs(this, MenuItem, Selection)); + } + catch (Exception ex) + { + Logger.DebugLog("ERROR " + ex + " in " + this); } } @@ -321,32 +307,22 @@ private void Rad_Menu_Opening(object sender, CancelEventArgs e) RenderMode = ToolStripRenderMode.System; } e.Cancel = false; - if (OnContentMenuOpening != null) - { - try - { - OnContentMenuOpening(sender, new ContextMenuEventArgs(this, MenuItem, Selection)); - } - catch (Exception ex) - { - - throw ex; - } - } + OnContentMenuOpening?.Invoke(sender, new ContextMenuEventArgs(this, MenuItem, Selection)); } private void Rad_Menu_Closing(object sender, ToolStripDropDownClosingEventArgs e) { WriteDebug("Menu_Closing: {0} {1}", sender, e.CloseReason); - if (OnContentMenuClosing != null) - try - { - OnContentMenuClosing(sender, new ContextMenuEventArgs(this, MenuItem, Selection)); - } - catch (Exception ex) - { - Logger.DebugLog("ERROR " + ex + " in " + this); - } + if (OnContentMenuClosing == null) return; + + try + { + OnContentMenuClosing(sender, new ContextMenuEventArgs(this, MenuItem, Selection)); + } + catch (Exception ex) + { + Logger.DebugLog("ERROR " + ex + " in " + this); + } } // This might be both the best Keyboard and Mouse event @@ -354,15 +330,15 @@ private void Rad_Menu_ItemClicked(object sender, ToolStripItemClickedEventArgs e { SetMenuItemSelected(e.ClickedItem); WriteDebug("Menu_ItemClicked: {0} {1}", sender, e.ClickedItem); - if (OnContentMenuItemClicked != null) - try - { - OnContentMenuItemClicked(sender, new ContextMenuEventArgs(this, MenuItem, Selection)); - } - catch (Exception ex) - { - Logger.DebugLog("ERROR " + ex + " in " + this); - } + if (OnContentMenuItemClicked == null) return; + try + { + OnContentMenuItemClicked(sender, new ContextMenuEventArgs(this, MenuItem, Selection)); + } + catch (Exception ex) + { + Logger.DebugLog("ERROR " + ex + " in " + this); + } } /// @@ -371,34 +347,32 @@ private void Rad_Menu_ItemClicked(object sender, ToolStripItemClickedEventArgs e /// private void SetMenuItemSelected(object sender) { - ToolStripDropDownItem stripDropDownItem = sender as ToolStripDropDownItem; - if (stripDropDownItem != null) + if (!(sender is ToolStripDropDownItem stripDropDownItem)) return; + + // dereference a chain of dropdown items + if (stripDropDownItem.HasDropDownItems) { - // dereference a chain of dropdown items - if (stripDropDownItem.HasDropDownItems) + foreach (var s in stripDropDownItem.DropDownItems) { - foreach (var s in stripDropDownItem.DropDownItems) + if (!(s is ToolStripDropDownItem sub)) continue; + + if (sub.Selected) { - ToolStripDropDownItem sub = s as ToolStripDropDownItem; - if (sub == null) continue; - if (sub.Selected) - { - SetMenuItemSelected(sub); - return; - } + SetMenuItemSelected(sub); + return; } } - // otherwise use it - lock (_selectionLock) + } + // otherwise use it + lock (_selectionLock) + { + if (MenuItem == stripDropDownItem) return; + MenuItem = stripDropDownItem; + if (string.IsNullOrEmpty(MenuItem.ToolTipText) || MenuItem.ToolTipText.StartsWith(" ")) { - if (MenuItem == stripDropDownItem) return; - MenuItem = stripDropDownItem; - if (string.IsNullOrEmpty(MenuItem.ToolTipText) || MenuItem.ToolTipText.StartsWith(" ")) - { - MenuItem.ToolTipText = " " + MenuItem.Text + " " + Selection; - } - OnItemSelected(MenuItem); + MenuItem.ToolTipText = " " + MenuItem.Text + " " + Selection; } + OnItemSelected(MenuItem); } } @@ -407,15 +381,15 @@ private void OnItemSelected(ToolStripDropDownItem item) lock (_selectionLock) { WriteDebug("OnMenuItemChanged {0}", this); - if (OnContentMenuItemSelected != null) - try - { - OnContentMenuItemSelected(this, new ContextMenuEventArgs(this, MenuItem, Selection)); - } - catch (Exception ex) - { - Logger.DebugLog("ERROR " + ex + " in " + this); - } + if (OnContentMenuItemSelected == null) return; + try + { + OnContentMenuItemSelected(this, new ContextMenuEventArgs(this, MenuItem, Selection)); + } + catch (Exception ex) + { + Logger.DebugLog("ERROR " + ex + " in " + this); + } } } @@ -484,7 +458,7 @@ private void DeregisterItemEvents(ToolStripDropDownItem item) // Not so vital events that may lead to discovering some accessiblity features item.GiveFeedback -= Rad_Item_GiveFeedback; - // Deregister childs + // Deregister children if (item.HasDropDownItems) { foreach (var collection in item.DropDownItems) @@ -531,17 +505,15 @@ private void Rad_Item_Enter(object sender, EventArgs e) private void Rad_Item_Leave(object sender, EventArgs e) { - ToolStripDropDownItem stripDropDownItem = sender as ToolStripDropDownItem; - if (stripDropDownItem != null) + if (!(sender is ToolStripDropDownItem stripDropDownItem)) return; + + lock (_selectionLock) { - lock (_selectionLock) + if (MenuItem == stripDropDownItem) { - if (MenuItem == stripDropDownItem) - { - WriteDebug("Item_Leave: {0} {1}", sender, e); - MenuItem = null; - OnItemSelected(MenuItem); - } + WriteDebug("Item_Leave: {0} {1}", sender, e); + MenuItem = null; + OnItemSelected(MenuItem); } } } @@ -555,7 +527,7 @@ private void Rad_Item_Clicked(object sender, ToolStripItemClickedEventArgs e) public IEnumerable Choices() { List lst = new List(); - foreach (ToolStripItem item in this.Items) + foreach (ToolStripItem item in Items) { lst.Add(item); } diff --git a/Radegast/Core/Types/RadegastForm.cs b/Radegast/GUI/Controls/RadegastForm.cs similarity index 67% rename from Radegast/Core/Types/RadegastForm.cs rename to Radegast/GUI/Controls/RadegastForm.cs index 8ff0c49bf..59c0e779d 100644 --- a/Radegast/Core/Types/RadegastForm.cs +++ b/Radegast/GUI/Controls/RadegastForm.cs @@ -1,43 +1,30 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id: DettachableControl.cs 211 2009-09-09 06:46:18Z latifer@gmail.com $ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; -using System.Threading; -using System.Collections.Generic; using System.Windows.Forms; -using System.Text; using System.ComponentModel; using System.Drawing; using OpenMetaverse; using OpenMetaverse.StructuredData; -using Radegast.Netcom; +using Radegast; namespace Radegast { @@ -54,10 +41,7 @@ public class RadegastForm : Form ] public bool AutoSavePosition { - get - { - return autoSavePosition; - } + get => autoSavePosition; set { @@ -85,41 +69,35 @@ public virtual string SettingsKeyBase return settingsKeyBase; } - set - { - settingsKeyBase = value; - } + set => settingsKeyBase = value; } private string settingsKeyBase = string.Empty; /// /// Instance of Radegast /// - protected RadegastInstance Instance { get { return instance; } } - private RadegastInstance instance = null; + protected RadegastInstance Instance { get; } = null; /// /// Instance of OpenMetaverse's GridClient /// - protected GridClient Client { get { return instance.Client; } } + protected GridClient Client => Instance.Client; /// /// Instance of RadegastNetcom /// - protected RadegastNetcom Netcom { get { return instance.Netcom; } } + protected Radegast.Netcom Netcom => Instance.Netcom; private System.Threading.Timer SettingsTimer; private const int SettingsTimerTimeout = 500; public RadegastForm() - : base() { } public RadegastForm(RadegastInstance instance) - : base() { - this.instance = instance; + Instance = instance; instance.OnRadegastFormCreated(this); } @@ -147,7 +125,7 @@ private void InitTimer() protected void SavePosition() { - if (instance == null) return; + if (Instance == null) return; Instance.GlobalSettings[GetSettingsKey("left")] = OSD.FromInteger(Left); Instance.GlobalSettings[GetSettingsKey("top")] = OSD.FromInteger(Top); @@ -157,7 +135,7 @@ protected void SavePosition() protected void ClearSavedPosition() { - if (instance == null) return; + if (Instance == null) return; Instance.GlobalSettings.Remove(GetSettingsKey("left")); Instance.GlobalSettings.Remove(GetSettingsKey("top")); @@ -167,7 +145,7 @@ protected void ClearSavedPosition() protected void RestoreSavedPosition() { - if (instance == null) return; + if (Instance == null) return; int left = Left, top = Top, width = Width, height = Height; @@ -227,12 +205,9 @@ protected override void OnResizeEnd(EventArgs e) private void TriggerSavePosition() { - if (SettingsTimer != null) - { - SettingsTimer.Change( - SettingsTimerTimeout, - System.Threading.Timeout.Infinite); - } + SettingsTimer?.Change( + SettingsTimerTimeout, + System.Threading.Timeout.Infinite); } private void SettingsTimer_Tick(object e) diff --git a/Radegast/GUI/Controls/RadegastTabControl.cs b/Radegast/GUI/Controls/RadegastTabControl.cs new file mode 100644 index 000000000..fd936c3d9 --- /dev/null +++ b/Radegast/GUI/Controls/RadegastTabControl.cs @@ -0,0 +1,40 @@ +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + +using System.Windows.Forms; +using OpenMetaverse; + +namespace Radegast +{ + public class RadegastTabControl : UserControl + { + public RadegastTab RadegastTab { get; set; } + + protected RadegastInstance instance; + protected GridClient client => instance.Client; + + public RadegastTabControl() { } + + public RadegastTabControl(RadegastInstance instance) + { + this.instance = instance; + } + } +} diff --git a/Radegast/Core/Types/StringTokenizer.cs b/Radegast/GUI/Controls/StringTokenizer.cs similarity index 71% rename from Radegast/Core/Types/StringTokenizer.cs rename to Radegast/GUI/Controls/StringTokenizer.cs index c9fd5f9ff..ec08c0d0d 100644 --- a/Radegast/Core/Types/StringTokenizer.cs +++ b/Radegast/GUI/Controls/StringTokenizer.cs @@ -1,33 +1,23 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + /********************************************************8 * Author: Andrew Deren * Date: July, 2004 @@ -39,6 +29,7 @@ **********************************************************/ using System; using System.IO; +using System.Linq; namespace Radegast { @@ -57,38 +48,21 @@ public enum TokenKind public class Token { - int line; - int column; - string value; - TokenKind kind; - public Token(TokenKind kind, string value, int line, int column) { - this.kind = kind; - this.value = value; - this.line = line; - this.column = column; + Kind = kind; + Value = value; + Line = line; + Column = column; } - public int Column - { - get { return this.column; } - } + public int Column { get; } - public TokenKind Kind - { - get { return this.kind; } - } + public TokenKind Kind { get; } - public int Line - { - get { return this.line; } - } + public int Line { get; } - public string Value - { - get { return this.value; } - } + public string Value { get; } } /// @@ -104,17 +78,14 @@ public class StringTokenizer string data; - bool ignoreWhiteSpace; - char[] symbolChars; - - int saveLine; + int saveLine; int saveCol; int savePos; public StringTokenizer(TextReader reader) { if (reader == null) - throw new ArgumentNullException("reader"); + throw new ArgumentNullException(nameof(reader)); data = reader.ReadToEnd(); @@ -123,10 +94,7 @@ public StringTokenizer(TextReader reader) public StringTokenizer(string data) { - if (data == null) - throw new ArgumentNullException("data"); - - this.data = data; + this.data = data ?? throw new ArgumentNullException(nameof(data)); Reset(); } @@ -134,26 +102,18 @@ public StringTokenizer(string data) /// /// gets or sets which characters are part of TokenKind.Symbol /// - public char[] SymbolChars - { - get { return this.symbolChars; } - set { this.symbolChars = value; } - } + public char[] SymbolChars { get; set; } - /// + /// /// if set to true, white space characters will be ignored, /// but EOL and whitespace inside of string will still be tokenized /// - public bool IgnoreWhiteSpace - { - get { return this.ignoreWhiteSpace; } - set { this.ignoreWhiteSpace = value; } - } + public bool IgnoreWhiteSpace { get; set; } - private void Reset() + private void Reset() { - this.ignoreWhiteSpace = false; - this.symbolChars = new char[]{'=', '+', '-', '/', ',', '.', '*', '~', '!', '@', '#', '$', '%', '^', '&', '(', ')', '{', '}', '[', ']', ':', ';', '<', '>', '?', '|', '\\'}; + IgnoreWhiteSpace = false; + SymbolChars = new char[]{'=', '+', '-', '/', ',', '.', '*', '~', '!', '@', '#', '$', '%', '^', '&', '(', ')', '{', '}', '[', ']', ':', ';', '<', '>', '?', '|', '\\'}; line = 1; column = 1; @@ -201,7 +161,7 @@ public Token Next() case ' ': case '\t': { - if (this.ignoreWhiteSpace) + if (IgnoreWhiteSpace) { Consume(); goto ReadToken; @@ -474,12 +434,8 @@ protected Token ReadString() /// checks whether c is a symbol character. /// protected bool IsSymbol(char c) - { - for (int i=0; i t == c); + } } } diff --git a/Radegast/GUI/Controls/ToolStripCheckBox.cs b/Radegast/GUI/Controls/ToolStripCheckBox.cs new file mode 100644 index 000000000..c4c63425f --- /dev/null +++ b/Radegast/GUI/Controls/ToolStripCheckBox.cs @@ -0,0 +1,112 @@ +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + +using System; +using System.Windows.Forms; +using System.Windows.Forms.Design; +using System.ComponentModel; + +namespace Radegast +{ + [ToolStripItemDesignerAvailability( + ToolStripItemDesignerAvailability.ToolStrip)] + public class ToolStripCheckBox + : ToolStripControlHost + { + public CheckBox CheckBoxControl => Control as CheckBox; + + /// + /// Is check box ticked + /// + [Category("Appearance")] + public bool Checked + { + get => CheckBoxControl.Checked; + set => CheckBoxControl.Checked = value; + } + + /// + /// Checked state + /// + [Category("Appearance")] + public CheckState CheckState + { + get => CheckBoxControl.CheckState; + set => CheckBoxControl.CheckState = value; + } + + /// + /// Label text + /// + [Category("Appearance")] + public override string Text + { + get => CheckBoxControl.Text; + set => CheckBoxControl.Text = value; + } + + /// + /// Occurs when check property is changed + /// + [Category("Misc")] + public event EventHandler CheckedChanged; + + /// + /// Occurs when check state of the control changes + /// + [Category("Misc")] + public event EventHandler CheckStateChanged; + + public ToolStripCheckBox() + : base(new CheckBox()) + { + CheckBoxControl.MouseHover += chk_MouseHover; + } + + void chk_MouseHover(object sender, EventArgs e) + { + OnMouseHover(e); + } + + protected override void OnSubscribeControlEvents(Control c) + { + base.OnSubscribeControlEvents(c); + ((CheckBox)c).CheckedChanged += ToolStripCheckBox_CheckedChanged; + ((CheckBox)c).CheckStateChanged += ToolStripCheckBox_CheckStateChanged; + } + + protected override void OnUnsubscribeControlEvents(Control c) + { + base.OnUnsubscribeControlEvents(c); + ((CheckBox)c).CheckedChanged -= ToolStripCheckBox_CheckedChanged; + ((CheckBox)c).CheckStateChanged -= ToolStripCheckBox_CheckStateChanged; + } + + void ToolStripCheckBox_CheckedChanged(object sender, EventArgs e) + { + CheckedChanged?.Invoke(this, e); + } + + void ToolStripCheckBox_CheckStateChanged(object sender, EventArgs e) + { + CheckStateChanged?.Invoke(this, e); + } + } +} \ No newline at end of file diff --git a/Radegast/GUI/Controls/TransparentButton.cs b/Radegast/GUI/Controls/TransparentButton.cs new file mode 100644 index 000000000..a855a4019 --- /dev/null +++ b/Radegast/GUI/Controls/TransparentButton.cs @@ -0,0 +1,48 @@ +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + +using System.Drawing; +using System.Windows.Forms; + +namespace Radegast +{ + class TransparentButton : Button + { + public TransparentButton() + { + SetStyle(ControlStyles.SupportsTransparentBackColor, true); + BackColor = Color.Transparent; + } + + protected override CreateParams CreateParams + { + get + { + CreateParams cp = base.CreateParams; + cp.ExStyle |= 0x20; + return cp; + } + } + + protected override void OnPaintBackground(PaintEventArgs pevent) + { + } + } +} diff --git a/Radegast/Core/Types/TransparentLabel.cs b/Radegast/GUI/Controls/TransparentLabel.cs similarity index 51% rename from Radegast/Core/Types/TransparentLabel.cs rename to Radegast/GUI/Controls/TransparentLabel.cs index 689072632..1400505a7 100644 --- a/Radegast/Core/Types/TransparentLabel.cs +++ b/Radegast/GUI/Controls/TransparentLabel.cs @@ -1,34 +1,23 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// -using System; +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System.Drawing; using System.Windows.Forms; @@ -37,7 +26,6 @@ namespace Radegast class TransparentLabel : Label { public TransparentLabel() - : base() { SetStyle(ControlStyles.SupportsTransparentBackColor, true); BackColor = Color.Transparent; diff --git a/Radegast/GUI/Dialogs/About.Designer.cs b/Radegast/GUI/Dialogs/About.Designer.cs index 0844c23c7..edf2e68f2 100644 --- a/Radegast/GUI/Dialogs/About.Designer.cs +++ b/Radegast/GUI/Dialogs/About.Designer.cs @@ -63,20 +63,23 @@ private void InitializeComponent() this.txtTitle = new System.Windows.Forms.Label(); this.txtLicense = new System.Windows.Forms.TextBox(); this.txtOtherLicenses = new System.Windows.Forms.TextBox(); - this.txtWrittenBy = new System.Windows.Forms.TextBox(); + this.contributorsTxt = new System.Windows.Forms.TextBox(); this.btnClose = new System.Windows.Forms.Button(); this.lblHomepage = new System.Windows.Forms.Label(); + this.authorTxt = new System.Windows.Forms.TextBox(); + this.contributorsTxt2 = new System.Windows.Forms.TextBox(); + this.txtVersionInfo = new System.Windows.Forms.TextBox(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); this.SuspendLayout(); // // pictureBox1 // - this.pictureBox1.BackgroundImage = global::Radegast.Properties.Resources.radegast_large; + this.pictureBox1.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("pictureBox1.BackgroundImage"))); this.pictureBox1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; this.pictureBox1.InitialImage = null; this.pictureBox1.Location = new System.Drawing.Point(12, 12); this.pictureBox1.Name = "pictureBox1"; - this.pictureBox1.Size = new System.Drawing.Size(143, 108); + this.pictureBox1.Size = new System.Drawing.Size(110, 110); this.pictureBox1.TabIndex = 0; this.pictureBox1.TabStop = false; // @@ -84,22 +87,22 @@ private void InitializeComponent() // this.txtTitle.AutoSize = true; this.txtTitle.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.txtTitle.Location = new System.Drawing.Point(161, 9); + this.txtTitle.Location = new System.Drawing.Point(125, 7); this.txtTitle.Name = "txtTitle"; - this.txtTitle.Size = new System.Drawing.Size(137, 17); + this.txtTitle.Size = new System.Drawing.Size(101, 17); this.txtTitle.TabIndex = 1; - this.txtTitle.Text = "Radegast 2.0.000"; + this.txtTitle.Text = "Radegast-ng"; // // txtLicense // this.txtLicense.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.txtLicense.Location = new System.Drawing.Point(12, 125); + this.txtLicense.Location = new System.Drawing.Point(12, 176); this.txtLicense.MaximumSize = new System.Drawing.Size(315, 113); this.txtLicense.Multiline = true; this.txtLicense.Name = "txtLicense"; this.txtLicense.ReadOnly = true; this.txtLicense.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - this.txtLicense.Size = new System.Drawing.Size(315, 113); + this.txtLicense.Size = new System.Drawing.Size(315, 89); this.txtLicense.TabIndex = 2; this.txtLicense.TabStop = false; this.txtLicense.Text = resources.GetString("txtLicense.Text"); @@ -107,35 +110,35 @@ private void InitializeComponent() // txtOtherLicenses // this.txtOtherLicenses.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.txtOtherLicenses.Location = new System.Drawing.Point(12, 244); + this.txtOtherLicenses.Location = new System.Drawing.Point(12, 271); this.txtOtherLicenses.MaximumSize = new System.Drawing.Size(315, 92); this.txtOtherLicenses.Multiline = true; this.txtOtherLicenses.Name = "txtOtherLicenses"; this.txtOtherLicenses.ReadOnly = true; this.txtOtherLicenses.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - this.txtOtherLicenses.Size = new System.Drawing.Size(315, 92); + this.txtOtherLicenses.Size = new System.Drawing.Size(315, 88); this.txtOtherLicenses.TabIndex = 3; this.txtOtherLicenses.TabStop = false; this.txtOtherLicenses.Text = resources.GetString("txtOtherLicenses.Text"); // - // txtWrittenBy + // contributorsTxt // - this.txtWrittenBy.BorderStyle = System.Windows.Forms.BorderStyle.None; - this.txtWrittenBy.Location = new System.Drawing.Point(165, 27); - this.txtWrittenBy.Multiline = true; - this.txtWrittenBy.Name = "txtWrittenBy"; - this.txtWrittenBy.ReadOnly = true; - this.txtWrittenBy.Size = new System.Drawing.Size(162, 102); - this.txtWrittenBy.TabIndex = 1; - this.txtWrittenBy.TabStop = false; - this.txtWrittenBy.Text = "Written by Latif Khalifa\r\nwith contributions from\r\n- Douglas R. Miles\r\n- Mojito S" + - "orbet\r\n- Robin Cornelius\r\n- Revolution Smythe\r\n- Signpost Marv"; + this.contributorsTxt.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.contributorsTxt.Location = new System.Drawing.Point(128, 73); + this.contributorsTxt.Multiline = true; + this.contributorsTxt.Name = "contributorsTxt"; + this.contributorsTxt.ReadOnly = true; + this.contributorsTxt.Size = new System.Drawing.Size(108, 97); + this.contributorsTxt.TabIndex = 1; + this.contributorsTxt.TabStop = false; + this.contributorsTxt.Text = "with contributions from:\r\n- Cinder Roxley\r\n- Douglas R. Miles\r\n- Mojito Sorbet\r\n-" + + " Robin Cornelius\r\n- Revolution Smythe\r\n- Signpost Marv"; // // btnClose // this.btnClose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.btnClose.DialogResult = System.Windows.Forms.DialogResult.OK; - this.btnClose.Location = new System.Drawing.Point(251, 342); + this.btnClose.Location = new System.Drawing.Point(252, 365); this.btnClose.Name = "btnClose"; this.btnClose.Size = new System.Drawing.Size(75, 23); this.btnClose.TabIndex = 0; @@ -147,13 +150,49 @@ private void InitializeComponent() this.lblHomepage.AutoSize = true; this.lblHomepage.Cursor = System.Windows.Forms.Cursors.Hand; this.lblHomepage.ForeColor = System.Drawing.Color.Blue; - this.lblHomepage.Location = new System.Drawing.Point(12, 342); + this.lblHomepage.Location = new System.Drawing.Point(9, 365); this.lblHomepage.Name = "lblHomepage"; - this.lblHomepage.Size = new System.Drawing.Size(93, 13); + this.lblHomepage.Size = new System.Drawing.Size(64, 13); this.lblHomepage.TabIndex = 4; - this.lblHomepage.Text = "www.radegast.org"; + this.lblHomepage.Text = "radegast.life"; this.lblHomepage.Click += new System.EventHandler(this.lblHomepage_Click); // + // authorTxt + // + this.authorTxt.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.authorTxt.Location = new System.Drawing.Point(12, 128); + this.authorTxt.Multiline = true; + this.authorTxt.Name = "authorTxt"; + this.authorTxt.ReadOnly = true; + this.authorTxt.Size = new System.Drawing.Size(110, 16); + this.authorTxt.TabIndex = 5; + this.authorTxt.TabStop = false; + this.authorTxt.Text = "Written by Latif Khalifa"; + // + // contributorsTxt2 + // + this.contributorsTxt2.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.contributorsTxt2.Location = new System.Drawing.Point(242, 73); + this.contributorsTxt2.Multiline = true; + this.contributorsTxt2.Name = "contributorsTxt2"; + this.contributorsTxt2.ReadOnly = true; + this.contributorsTxt2.Size = new System.Drawing.Size(85, 97); + this.contributorsTxt2.TabIndex = 6; + this.contributorsTxt2.TabStop = false; + this.contributorsTxt2.Text = "\r\n- nooperation\r\n- nopjmp\r\n- Madpeterz"; + // + // txtVersionInfo + // + this.txtVersionInfo.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.txtVersionInfo.Location = new System.Drawing.Point(128, 27); + this.txtVersionInfo.Multiline = true; + this.txtVersionInfo.Name = "txtVersionInfo"; + this.txtVersionInfo.ReadOnly = true; + this.txtVersionInfo.Size = new System.Drawing.Size(194, 40); + this.txtVersionInfo.TabIndex = 7; + this.txtVersionInfo.TabStop = false; + this.txtVersionInfo.Text = "Windows 10 x64\r\n.NET 4.8.0"; + // // frmAbout // this.AcceptButton = this.btnClose; @@ -161,18 +200,22 @@ private void InitializeComponent() this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.btnClose; - this.ClientSize = new System.Drawing.Size(339, 375); + this.ClientSize = new System.Drawing.Size(334, 391); + this.Controls.Add(this.txtVersionInfo); + this.Controls.Add(this.contributorsTxt2); + this.Controls.Add(this.authorTxt); this.Controls.Add(this.txtTitle); this.Controls.Add(this.txtLicense); this.Controls.Add(this.lblHomepage); this.Controls.Add(this.btnClose); this.Controls.Add(this.txtOtherLicenses); - this.Controls.Add(this.txtWrittenBy); + this.Controls.Add(this.contributorsTxt); this.Controls.Add(this.pictureBox1); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.MaximizeBox = false; + this.MaximumSize = new System.Drawing.Size(350, 430); this.MinimizeBox = false; - this.MinimumSize = new System.Drawing.Size(351, 409); + this.MinimumSize = new System.Drawing.Size(350, 430); this.Name = "frmAbout"; this.ShowInTaskbar = false; this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; @@ -189,9 +232,11 @@ private void InitializeComponent() public System.Windows.Forms.Label txtTitle; public System.Windows.Forms.TextBox txtLicense; public System.Windows.Forms.TextBox txtOtherLicenses; - public System.Windows.Forms.TextBox txtWrittenBy; + public System.Windows.Forms.TextBox contributorsTxt; public System.Windows.Forms.Button btnClose; private System.Windows.Forms.Label lblHomepage; - + public System.Windows.Forms.TextBox authorTxt; + public System.Windows.Forms.TextBox contributorsTxt2; + public System.Windows.Forms.TextBox txtVersionInfo; } -} \ No newline at end of file +} diff --git a/Radegast/GUI/Dialogs/About.cs b/Radegast/GUI/Dialogs/About.cs index f1df0d069..81560476e 100644 --- a/Radegast/GUI/Dialogs/About.cs +++ b/Radegast/GUI/Dialogs/About.cs @@ -1,34 +1,25 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id: MainForm.cs 223 2009-09-12 04:33:49Z latifer@gmail.com $ -// -using System.Windows.Forms; +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + +using System.Reflection; +using System.Runtime.InteropServices; namespace Radegast { @@ -38,15 +29,16 @@ public frmAbout(RadegastInstance instance) : base(instance) { InitializeComponent(); - txtTitle.Text = Properties.Resources.RadegastTitle + " " + RadegastBuild.VersionString; + txtTitle.Text = $"{Properties.Resources.RadegastTitle} {Assembly.GetExecutingAssembly().GetName().Version}"; + txtVersionInfo.Text = $"{RuntimeInformation.OSDescription} {RuntimeInformation.OSArchitecture} {RuntimeInformation.ProcessArchitecture}\n" + + $"{RuntimeInformation.FrameworkDescription}"; - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } private void lblHomepage_Click(object sender, System.EventArgs e) { - Instance.MainForm.ProcessLink("http://www.radegast.org/"); + Instance.MainForm.ProcessLink("https://radegast.life/"); } - } } diff --git a/Radegast/GUI/Dialogs/About.resx b/Radegast/GUI/Dialogs/About.resx index 69ad79c98..8915d34c3 100644 --- a/Radegast/GUI/Dialogs/About.resx +++ b/Radegast/GUI/Dialogs/About.resx @@ -112,14 +112,295 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAABGdBTUEAANjr9RwUqgAAACBjSFJNAACH + DwAAjA0AAPmTAACE5QAAe4IAAOt1AAA/tAAAIlh1a16cAAAEDGlDQ1BJQ0MgUHJvZmlsZQAASMeNVV1o + HFUUPrtzZyMkzlNsNIV0qD8NJQ2bVjShtLp/3d02bpZJNtoi6GT27s6Yycw4M7v9oU9FUHwx6psUxL+3 + gCAo9Q/bPrQvlQol2tQgKD60+INQ6Ium65k7M5lpurHeZe58853vnnvuuWfvBei5KluWnhQBFgzXlopZ + 8bnDR8SeFUjCQ9ALg9ArK46VqVYnAZunhbvare8h4b2v7Opu/8/WW6eOApC4D7FZd5QFxMcA+NOKZbsY + Xz/y40ddy8NeDP02Boj4RQ83fex6eM7HrzHNjJRDfBqxoKhyHfES4pG5GN+MYT8G1vqL1KC2poheLqq2 + 2dB0Ggv3Hub/2Rb0VjjfNnz6nPnpQ/gexrW/UpfzHh5FvKTIhWnEjyC+1tZmKwG+bblZCfFjAMntrfla + BvFOxKWGfaDm+0naaqsU4ndOqDPPIt6C+LwxV5kKxl5VnBzmDLYjvq3SspffIQBO1NzyjD+W22+b0pQ/ + L9eo03zByyPi1+fNQ5Lvk/vMaU8XQp8n1Fwl4C+9JB+sIh5E/AvVi5I/F/eP5VaDGMiQoVcm/blInjps + vYx31ZmSPy/RXdxQfyxZbGgHyoH+E9UuSQG+ZumsRjE2Pmm3pJqv50dlu1D0ffJVatQC/3wbZhMyUDBh + DnsFDFgDESQoQhbfFthoaYAGOjIUrRQZil+hZhcb58A88hq0mc3BvsqU/sjIX5P5uM60CuSGPoIWsir8 + jqwa0+Xwq4VccxM/fiw3Aj8mGSBpsgefvWSS7CPjZAJE8hR5muwneWQnyN71sdXYirx4bqz7eRlnpEw3 + i7pzaHdBxv5nVJi4pq5ZWRxsDUeWU/YLmnL5jb9iudJYbqJsxTM6da+c87/y1/ll7Ff41UjB/8iv4m/l + jrWYd2WZhtnZsObuqgzadMYt4KMxixOLO+bj4smvHoz8LJMzz1/pu3iyYSwORqyXBfpq5VYFTo1EbPqH + 9B/p5fR76Q/Tv3Fvc59yX3Ofc19wl0DkznLnuG+4C9zH3Jexvdq8htb3nkUexu1ZuuUaq1LICluFh4W8 + sE14VJiM/AkDwphQEnagZev6vsXni2dPg8PYh/npPpevi1VA4n6sAG2Tf1UNVRocZUqH1ZsBxzdogpFk + iIyR8obqHvdqPlSkCql8KgNiamdqIjWWOujhcNbUDrRNYF+4ozqVTVZKXXrMu08gZ1rHba2puuLudPpJ + MYNXGxXLhjI6Isq6LjKTI9rUoXab1kfBuzf9I/2mxO7DxJbLEec+A7DvTzz7vou4Iy2AJQdg4PGIG8az + 8oF3Ac48obTsdnBHJBLfAjiNPbv9r74snl8/dTo38RzreQtg7c1O5+/3O521D9D/KsBZ/V+gn3xVg3tu + lQAAO+NJREFUeF7tfQV4Vde2dXGnUKylpRQtTiBoAhQneHAI7u4eNBBCsLiRhAhxD3F3IQkJcSGCheDS + QguVe8c/5rk5fdy++z/7Lve1fWd+3/jWPvvss2XNsaattZOPVKISlahEJSpRiUpUohKVqEQlKlGJSlSi + EpWoRCUqUYlKVKISlahEJSpRiUpUohKVqEQlKlGJSlSiEpWoRCUqUYlKVKISlahEJSr510id2lYlfxZx + 9Ylv4eOT5OvunvjUxSMFUbF5oWkZlYa1X6vkzypmVp7bvbySEJtQibjUuwiLKsfduz/A2CoRviElqH7w + FoHBmT97+8d/VfsTlfxZxNsnBcZmMQgML0FR0TO4emTB99oN3L79AqbW4XC4mgoPj2Rk3KhG1o0HSEi4 + BQ/P+OG1P1fJH1mcXMJx1SsFF4wj4O6bjZycauw94Q4X9wQqOg+WVtdgczkYu/db8hgfODpEIzXtNp4+ + +xnePukICclsUXsqlfwRxd0nDkEc7TEJ5fAJyEBwUDrO6Ns71H6tEGtrP9ODRy1w7qILTpyywxmDq4hP + LoGbTzZikysRG5v3vPZQlfzRZO9hS5hbByIxpQg2DmEwvOCE2q/+ndjb+XU/b+yOY8fM4OgejXi6gvzc + B3hQ8xrJaVWIjM0OrT1UJX8UmT1rByxsrsHHKxbuHtEwMfb8/xJAKTHRWZ+amnjCytIbNjZeiIzKJyqQ + nHkbRcUPER+Xt672UJX8nqWstHy4t3c0HF1CERSUBAsLX+jqWf2nBFCKm1uY9vlzNliz9hisbYIQE1uE + vPz7uF/9hlbhe3h7x6nig9+bpCVlv8q9WYDnz16hpvohXr76Fs8ePcWLl69RXfOcQWAJbtysQHRi3huf + sJQjtT/7D8XU1OWc3ikzmFp5w9k1hpnCfTx79j0KS54wc7hVXXuYSv63JSY0fk9hQRlKCpnj36lG9f2H + uJlbgIcPn6Oi8i4q79Qgv6AcBSV3EBOfDb/g67BxiUFA9I1Ntaf4D8XU4mqEvY0/XN2i4OWXiMKiByRT + FVPLGkTHZByrPUwl/1sSG5uCqJA4VJTfxUMqv6ysksopQ0XFPRQUV6Kw4DbSMgoQFHEdgVFZCCWsnCLg + GZ6P85Z+j2tP8778w1KwhbXbj54eUXQr6UhNyeN5bvIaL5gtZCMyIuMfuQU5z2/P9V8pMyt/pzz2/c// + Gf5viZ9PSJecrEJkpmfjQfUjPCSqqu7iXtUDlJMAhUVVuJ5VgJT0IqTfLIOnfzxML/tB94wzdhy1wraj + ttA9+58HiEoJCUkcccnEAbqHz8PWzg9RJNPVq9Hw9ExESEhaUe1hH0JEuXVrUa8Wsv1b5f/fIkFKQsa9 + lLjrKMwrp+Lv4O69Gty+fR+3bt3Bnbs1qLr7CMHRKSgsrETy9SKkpJXA3j0CZlcicPikI3Yes8EhQ3fo + rNH9L5NAxNjIKfL48bPw9AtDaEQ6klMKce/uK173OSorv91Ze9g/W0ThDd6DkgTv430y/PklMS4dBdmF + KCmpxNMnL3C7/DbNchXdwG0Ul91h+nYHyam5SLmeRyJkwTsgDhZXQ2Fg6gtTmzAcOe+Jnbo2WLbFAOcu + XcWDO89X1p76vySh4ddhZ+eGq87+iIxMQXFxNZRSe8hHEeFxZ4uLyitePXuLH38E7t97hEre1/vy7vt3 + ePfuXe0n4JdfajcoZWX3kJ1dBBcXTw2erhHRpLZtSCiJUL+2VZLgzy8BfmERSfEZHP3FHHmVuH3nHh4/ + fYXbVdW4w8CvmEHfzfwyxCbmIDjmBuJSihAYnAb34HScMveBvnkgjp5zxcLVRzBn6R6Mn7kaHgz0CvOq + kJdb8Y+I8A9HV0RI6phLF6xw/rw1Ll/2QEL0DVRVPlUoT3RqbOEEH1qK6yn5iIhMQt6NW3B38kdYYDgq + K+4gLzuPSq7CvXv38OjRHTx89JCEvoXMzDzcuFFAQt9hNvM945gbsbxcc+JjQmIOIYKQQKAkhJDgTyn/ + rvOTEzJwM6cQOVn5ePL4GTvvGSP/J3j86CXKblXgRm4JIqLTEB2XCU9fRv30165+cXD0S8WhM644et4N + esb+WLlFH4s3HsfAYdOhf9IciSTM40evUVxwl66j6rdE+Hf3sXbLzv479h1/c+mSA3ZvPw4LUwe4uYeQ + iI/w3Yt3+O7lT/DndU+cOIfp0xcg9FoSLCwdYGdzFefOGcLZ2Q0JCYmMJyLh5x2I8IhYREcnIzAwBCkp + DFpDo1HEZ8ktLKjh5doR7YlWRLNaNK1thRD1qiru/7es2O9dlB3+dx3v7R1sKMovKbiFrOs5ePTwKX3v + XcYB91DElDArpwhx8Vlw8Y7AtTB2ZnAqgiMz4UWTbWwfBj0jBoLGPtinZ48Dpx2xfsdpDNecjpMn9WFq + aofbFTUoLeGIrHnJCD8TL569WV976V/F0T/y/jF9Y0ydMQ+jxozDuIlaGD5mNI4dvoiTVHZoSBKyb5Tg + u+c/4Gea/qLCGgxQG4qdWw9h7uzF2Lf9IPZs3Ynde3Zh34F90DtpiCNHTmDf7r08x2mSwwQ2Ng7w8PAh + CUJoDfLErXxJdCKEBJ8QQgRl29LR0a33m7c/4e7dZygtvf0L9/2h5R8qX+RGag7S0/MUFqCU/v9WuZjQ + GtytrEbmzULcyC5GQlounNwj4eAZARffWMTE34SLfwqMncJxyiQABxgEbth9Aau2nsIUmn/1QaOwdOkq + 7NtzBOFhsUhJzkB2RiHiaEVuVz3G86dvUH3n8Up9S/fSrXv08c1UbcyetwSz5szHUM1xGK6hiV69+uOr + Ll0xecpMXLF1g6W1M+JjUlGQX4FfSIK//hVwsvVH56++xNe9v8bEcVq85kpoac3C1MkzoMPtxfN1sH79 + JmzdsgMGZy9CV/c49M9cQHBwpBCgN9Gd+IIQErQlOhCfyXZx0d2sXAbEWblFyKBlLCurRg1jo4LSqkH8 + /g8j7yv9/ehWIVERSXMLb95CVHgCCnOLUVJcyly/TGH+7997TOUXoISEqKysQURCJpy8o+Ervj8wEeds + /HHBKpSRvxtW7ziH9bsMsG73aQwdqY0F2jqwtnL5SUdnLfbuPcr0zgtmpo64cN4CXu7ByMwoUfj1yqIa + HD1thm59B2DQoOEYPGwU+g9WR/9Bw9C33yB8/kVntG3XAZ90aI9lq3fCyzMI4aFxyEgtxEsGgj/9BDx6 + 8g79evRCi+bNMHKwBoYN10D//oMxdtxETJ06DVO0JkN7Dgk2ZyEOH9aFvp4hU01/IcBAoh/RvU6dOkKC + z4kuRDdpE+i+0jgwQqJjUVBcjAc1j/Dm+ze4dfcBigvvIDEpbwGP+93Lb5Uvgc2vBKgqe/Bzalo2YsIT + OUrTaAXyGQcUoZxKLy6uREFRBTL5+VblA0TGZ8PE2htunjEkQCpN/mU4+2TgwpVorNl6Fku36GH1xpMY + p7UIC2boYLHOjhczZsw55O8bigMHTuLsWRMYGZlTCfrM/Q3w8sVrvPn2J1xPy8ftymeYMX8p2n3aCR2/ + 6ISuPfuha9euJMFAdO3WE60/+QStW3+Cdh0+xbnT1vALiMDd24/w7i3NQK2Ymjn9lY/0tmWr5j937Pgp + BgwcgEnjJ0JrkhZmz56HOXOWYMmSVTh9+jzc3QOFAKMIWbQiROhBiOK/JgYQfX28wxg85sLV0x32tlfh + 6+2P0mJax7vVimvfqnyI0NgMbNi4S/r1dynvK1+Z3vx6s2lJNz7NZRRdQN9aUlhKk3+fVqAENRz9t5j6 + PXr0FNev55P9Vagor4EnR30g/b5/aAbTPUvsPnEZO4/aMQbwxKbdl7Bg6T7orD+MZcu2YIzGFPToMYgd + vlHq/OsmjJ1w1tTEFg627rCycsS6tdvh7SWWoABB1xiY0axXskOzMssxbMxE1G3YEG3at6d574beffqj + /WcdUb9BfVHa98SjLz/v/JOvZxT8A6KQnHITjx68rKUBSJY2d3hMBnGjtk0loghPwpw4TMhs5FxiQt26 + dYeyFUsgih9CjCQ03f2ocGYU1lZXcPDgScYRxjhvbAoTCwdERiXjLrOj6OQbCOZ2fvEDubffnfxW+cr8 + ViEpiVl5VbfuoKy4gulTIe5UVuLuvQe4c/sBHlQ/QX5hORKv5yIpPRtJ9N+XnQIRl5qPIKaBOw+ZwNAy + GGdtI3DknBe2HTbF7EVbMF5rCcaMnobpM5ZCa7oOFurshPbC7S8aN2lyMrf6BYYN+4bpnSec7F0YyV+A + Df26q4cfAvyjER+XhfjoVGSTdJ6e0TTjff/C23xSr17dmvr16z+qV6+e4Cn3PZP9xNMt6/YixD8G19Pz + FXGFUm5k3RVrkE0kEfGErEPwJxyJc8QBnms5W60GDRqIFRhMiPK/IabuOXAs0sr6Cjy8/VBUXI6kpDTY + 2NrjtN5FmFvYws7eE86eARwQCeyvGrrNewiLTIW3f/Tvyi0ola+sdgkBfjX/N3NKmKeXIDM5EzeZI99h + 5P+MaV95aTnyaBFybhbRLeQhgxYiLbMU9m6RsHEIgb6JJwws/GFiG40Tl7yxca8Rdp60x6wlm6GpoYVR + wydi5crtmDl/E8aMX4xZC7fglKkfdu05hM8+74gGjZui/eedcOmMHeMCOxzefwq2JMI5AwsGaMa0DCEk + QBDSUwsYrCXjs3affsfbfUA/LanbA+Ih8ai2fcAR/K27SxAimSl89+pHvHr2PfAX4PV3wIYNO+/zmKvE + FcKOMCHO8Fy72a4gJhNiAdSJkSTFVLZLiQ2NGjY0PXPGBLt3H4Gt7RUUFDIYTkmGPl3I1p26OHHKCBeM + ruCqWxCev36Nh0+eIzY2i+4xRu7xf12Uo1+UrixwyLZCEmMzXOLCk5j23cS9qhrcv1OtqP49ePAYuTeL + cT0zjwQohW9gLFPAm4rS71XPWNg4h8HILhhWLjE4YxOMY2fdsemAKdZsO4spczdgiPpoDB82BjO112Pe + ku1Ytv4Ytu0xIkkuYv764xg2egI+adsezT5uiY/q1EGj5i1w7NglHD9+kTiL44fP4pKRDa3DeZiZ2SM5 + OQfTtLR/5C3fJqqICir8lrS1nwXyXeX06Qt+iaZ1SrteipoHr/DmNVlAkYyhSZNmovyjxEEqfwcVvZrn + kdE6ia1UBYcRmtw/k+0qQtyELHW3Jzy/mTD+L7v26sLB3h0//PAGOdn5OHDkDMws7eDiEYoYWq4EZlOZ + OWUIZIp86Oh/fc3EhxLl6H+/siX7FHKPqVhF0W363lLcKqjEo+qHePXqDR4+fsHOe4ag4FhF0SctI585 + cylcvKPgcy0V6bmVSLpZDVOnWJw2DcDeU47Yw2BQc/J8jNSYiUnjJmPoiMlYsGAzlq05iC27L2L19jNY + tfkc1u66hP0nr2L9AX20/7QDPqpfD23atJGOErwbN24Sjh47z1xeF0cOnoHrVX84OETId6VEAd1ANpWV + xu0kKkpa8fG5RCFRTJQQNQcOnGOQF8FI/QFevPwbCUTc3MLu8XtR+jxiOqFFjCU0eF6xAqOJadwWy7Cf + EGvhwesGsRU3kjZScwJOGVxC5Z07ePLkGQyML8PI3JH36Q8bx0CcPuuIZ0+/w83iahiYeuPsJSsh1r9c + ZPQr/b4oX0kAhdyuerKviIqMi0tCeEg4PL08ERwSjOT4JKSlpqGgoBhFJTINfA+RMVmIicuF9dVgpHBk + XS+8h7isezBxiMZ5m1Cs5shfvcsQE6cuxuSJczF5xmJMmLIAG7bpYc7i7Viy+gi27jfG5gNGOGxwFWct + grFd1w4HDV0xbNw01K+jUP7bOnU+esv2B+I7dfWRf9m+7QQMDBSjSMx+NkdtIn11UMOGDd0bNWokJt2D + CCDC+DmBbbocRwghcidMmPXuyhVPODoGIT6+ENXV34IZHEkOTJs2T5/HyKgXvy+Bn1otAST4G89rCUE2 + sT3J/Tbc9iPiiOtEDlE6f/5KWFk74ceffoYHMwora3/oG17BcT07GBq5IpCDpbTiMSxsfOHqEzOLv/mX + ihBAlC9+X5TfuBYKkdm+2JgY+Pt7cXTfQE5OBkpKqPSiIpQUFKCy6hbTwGLcrWJwyDggPrMQQRFZcHGP + hZljOMzdYmHvn4GLl0OxcuNprN1zDtMXbMCEb+Zh/eZjWLhqO9ZuOYVVhM664zh1wZtKt8LmfWY4fN4L + h8+5wtI9Dh5hxTCyCUer1m1/5m29IcTXvyQk0Kv5+OOWsr4gj4qQur0X28tsJYDTowU4w9aUsON+d7bB + RDQhQV8GFZfJtuzQIUn5omHncA0Rkbl4Uhsovv4Br/n9CEJI0IfoRhL2Z6vBc4/lOcVSbOR5TrC15j4f + tjGEZBRCsrymTZu82rXLgKT6EUUFFcxufLDrgAn2HreA+WV/pDJwvl/zDD5BiYV+YTGt+Zt/ifzW9zfm + qJH6ttS2P9q9Z3fforwilJUVwvqyBXR0dP6Wb/ftAw0NTaxevRyWZmbIy8tTdNSbN6/x6uVTZgM5cPeK + pdJuwto5Ad4xt+AbX4EtB42wnZi1YA2+GTcLS5fuhc7y/Vi95SRWbz3LzGAvR7sLdhyxZiDoj92nLiss + gWtwHiydouAXVYyTFz1h4RYDtYHq4utl+bgEd5LKiWmXkScj0JZKEZ98kNhKbObnvVSMLEk7QzNtQQvh + xH1iFSKJZELcRJqG5oTvjIxcYHn5GtLTqvg8Pyue7ce3YB94WvIYqez1JDoTQoZhPM84nnsez7uBn3UJ + I8KNkGxCzi0EEyJUzJ63DZXlj1BT8xTbDxtBz9AedleD4M+0OSA0GVV3nuD0OUfJOP4l8j4B6jdu3Fgs + gHKio05UVKj5/epqWJqaKnyvFFc+++wztG3bFt26dcfnn3+u2G7V6mNMnjyZ6U8yfvrxJzx9+gS3mB3E + 0Pyv2noRh8+6Yetha2w+Yo7l645i8dJtmKO9Glt3n8LyDcc5EkyxdP0JLFi8F5sPmmElXYUxrYe993U4 + BubCxisZdn4p8A7LgQUDy9isW7B3iYV/6A3M19kkRBACJBKSu9tQIQZsD7PdwlG5mtvSoTJRs4bYxH37 + 2CqtgrgISfnEIoh7SCFurtt6hNlFMl3ZHeSXPUFh6VO8pEt4SyLw+75EV0IqgVIUUufA+YbnncZtyQq2 + 89qnmzVrdrlJkya+/BzbqFFDqTHcJHKmzVmG58w+Xr5+C//gBLj4huMa3cDBU9a4bB8Mr4BUrNqpJ+f+ + 4KIkgID3XEcI0JIQE9S0sLAg7C9/+RFbt21TEKBz587o06cPBgwYAHV1dQwfPhxqamrMwftj8KBB6NG9 + OxW7AEFhkUhiQBgQFo1LjhH06WZYu/0CVu80xIp1utCevwLz52/F8tUHsXzjIX53Fmu2X8RJMy9sP3IZ + 2ssPYRfbQ+fdYcaRv3jFYZi7RiMx9x68Q1JwxTNGUWZ29ktEdGo+4q+XwMrO969qA4eJyZWATNYcirJF + 8TrEfGI2n08wl1hKZclolWNPc/RKwceFuEYIEYRMif0Gqz+LSShGbEI54hKrUFj0GOVVrxjwVjJ7KBI3 + InMDSiJIcUjcxARiHq+xljjIc4s1cGEbzmsm00pIMHpz/GRtvHn7iyIFNXMIh5dvLKws/WBk68dsphgn + zjl/yFVOCnlf+XV5s/XIVvH9QoCOxBfB/v7WYv5iY+MVBOj42Rfo3bs3RowcCY0xYzB2zATMmDlDUUOf + OHESNLhfU1MDg4cOpgJPMfr3xwVbd+w9fRWzdXZjxeaTWLd2HyZqLcCylQewdscJLFyxH7pnxOzT7+ua + Yu1eI+zTu0L/747dupZMG014nD5cgmkBrmUgNPoGouKzEZOeDwe3YLj7RcMrJJ7BEy1DchYePXsNYxtn + IYKicENMIiYSEsFLK7m8RO/afGYhhwRwyjTuMoNEsSIhhBBBXEra5t16cHZLZGaQiuDwfFwLyUVp6RsU + lb3AtBlzxvEYIYFACCEuYhQVLjWCxYS4IAkkr/A6gdwv5MoicrSmLFS4l8LSap4zE24+8TCm6zln7Irs + m+UwuOj2QQPCvxv9RD2ysyHdgMxySZ1bgpzpijukaI4fj1Yft0LnLztjsPpQ9OzdB0NGakBjFHN5zdGY + PnsOtKbPgpr6MFqHYejy1ZdYumEX9pw0wq6Tppi/4gDmr9wJbe21mD5tBZatO4LZy/bzmGPYc8JREfgt + 32KA9XuMcICE0TfzI4mscNLIC5v2XKIrSIRPSAbC47MUWYaPfxJTKT9amUS2XghLTIdvUAz8wpMQkZiL + /FtPkZpVVjlQbYhE6ZqERPJSxZNUS7ZFcUIQbWIZn30blXOU7QW2ks97ETLKJZiL/axD+2oDs1CY2Mgb + TGVw801HYsYjxj/PkZBeKnUG6TMhgbS9CLEG42qJtpbbQjJLnlsCRCGWuIRMvXOOiv59+OgtnH0SYCkW + c99FlBZUw9wlQYj4wURJAEkB69KHyXZTEqAdO6EHb1QeYMZFU/NMucHq6qdo99nnqN+4ETp+2QX9Bw1B + P7URGDB0JAaPGI0BwzTQd+BQ9O4/BENHjsXX/dXQucfXmL1iE7TmLles/Zs6dxPmzVuPeatIhlWHsHTt + IazbfZ6RsB02cvSv3GSILfsvYw1dhp5ZEDbuN4KBRSB2H7eClUsEYplaWjkF4aShDRzdQ6iESPhJDSLx + BrJyCxAemQYnjyBci0hDek4l4lOLkZZ9F9klNX85fdZYgjOp4KkRMqEjKZ2QYQwxhc8vkfwaKmsntyWa + N6HypBQsChMiRBBJixZtg7t/NomXj9Lyb+HoloLE1IdITLkH3aMGUhRSWgJpB/Aco3lOiQ3ku/3EeX6W + AFHmGyQdvZuUUaEggZNHKKwdo6CrZ48L1j6wsAsWy/vB5FcC8Cbr8aYUBKDi29MVfM19Mvu1iNh/xcnj + x0eMhm/de46hGuPQokUrdPqqG7p06YmB6iPwVffeJIMGuvbsjx691bk9FL36DWJw2I4EGQXthauwZN1B + 7Duoj8MHj+HM6XM4feoCThw7i9CQKDg6+NK3R8LJxQeBYbGIjElCJpVtbO4EZ/rGAycdoG/ugdiUIphd + CYCJpQeVnIro6OvwC4mDvbM/wmKScdk1AMa2HlROCtOpBFwhSew9InAtLgfhqQWIyrkNa7dgUahE7zJK + ZTZPWiGCoq5PCBFk8kfKv8cJ8eHycqtvgwb1w9hGt/+0/e39J67g7KUw5FW8RtVDjuAXQNrNV8gpfCQ1 + CiGAkgS92JcybzCR7Xz2s7gECUDd6tevJ5bgxijNmXj0+Hs8ePwdAoKzYEAXsOWgCUwue0Bt1FyxVEoR + nf3T5H0LoCj70v81adq0aWtaAbl5MZsLiUOE97yl6985X0uGkXMQFtG0d/yyG5q2+Bhde/RB91790bOf + mmLU9+g9AD36DlR836p9e4wYNQFaU+dh987DcHJ0g5G5PdbSKqxbtxXLlq+BibUjTp88ByMzO47oABTe + uofSivvILbmH+KTrzMF/wo3CMo7kQgZgD6jcdFg7BVC51+DhH4OAiHj4BkbBNziSn2kNknMREc84IS4L + wSSCpFZO1+Lh6Me0NDIDIUkFSC2vQXJ2RbHGqAky+sVkCyS1E7cnBR4J5GYTEtGLwqQsrMgYqETJGMKJ + +DlLNsPcLonBaC4zkye0UE9w1b8QgdG3cMncRY4XAsgfwJDVREI6cT3icrYTUjmUqqFYgULf8Dz8xIzT + LyADjl6RWLDhBC1CIPT1ra35vVI+GAEkCKxL06/MAjqTBEMICULkZqWoktymQ8dXe05bYccJM6zbcwbT + 565A74Hq+PSLTujY6St07toDPXr1Rqs2HdHh007ox++makmQOFNMmRRspLwqkx8yO/e8Tp2PXrFVBJi/ + Rbt2HaA5YRzTxi2ovP8EVY9f4tnrN3j04hU/P0BUchrcOcq9A2KRkJbDYDCCcUE8ElLy4BOajqDIdCSl + F8DFPwGuTLXMXCPgHXUdPhEZ8I3OQkrebcTm3mVskfr6gP6FHbymrOyRlT6yykcUp8b+GE2LKOZbgkVZ + cn6a/SQKUeb4EihW7DtkB2OrJHgHlcLcPh1naBlOGFxjbPBQnkUyBFk88ikhRBPSLSORjjRs2EBSUCkb + Z2xloPn8258RR4JetPSHzsYTWLvxOMLC0qR+oJR/KgFE5IQKAghoARrwAVvw5qQTJNcdww6QUSCvYUl0 + LAWN2wPVNX7W2bAXS9ftwrK1O6mkXRg/aTpG0D0MGzEW34wZh7FjJ2DSuPHQmqKFHt26vOPvZK5fijZP + eM7H9erVfcHrfMvPaPlxazRp3gJ16jZAi5Yt8FH9+mjerCXatGmnJISssftZZ+OWvzz+7m/rtmVpx6sf + XuOHd78gIjkTDu7htCDxcPGKRmxiHsKiM+DPWMAjJAnuhLN/NCwYMzjTGviSCKFJNxCZVojI60UIiC3A + NRLnWlSmE6+jrIPICmBZAyj9IHV/SSElmDtAXCIkPhBrIIWk+Bmzlv5Vzzgcuw8644JFAhYsN8CtB8Ct + GuCqZ6IQRayAQGKP6TyXkE6shLiVNPXho5GcVow71c+ZRmfC0j4Q+w4YYdmq/fL8H0yUVkDAe1LEAWIF + 2rRs2bITYwG52QktWrSQCQ89fu9KpcXQd0kaU9GxY6c3fQcMxtKVEtnPwuLFSzFp4kRMnjQRMyZNhVq/ + /vi4ZUsp10qhRmbhlK3CEvBcT1q1bkOlt0KHDp+iVWuiTXt83rkrPmeg2b1bdzRq2ERJACn4KOr/tBzf + nzW9/N4K/r9J1YPHyC6sYoAYAXPGCuZuYbhg7wO/qAxagRQEJdEtJNxEaEIGvMJT4RqYBAv3IDj6RsPO + JwKetBrBcQXwCk3KHzdxmihL+kcqpLJNi1BP0siFvO+t7AspMVuz9axbt44oUbKFsjWb9LCNJPCLugO3 + wFLYeGTDJ+w+knIeY8WqzZIW9uBvJN4QMp0lpFCU0LZN6+fptEhSfvbwS8SKdcfQdcBoDNScja97D/5g + peG/I0BtJtCwQYMGsvZd0kHxX2q84fFsJR6QwMiQrkHSJN/mzZtLZCw+LJ/HPKAFecRo8ltRLPeJkmUq + toSmVIoa+Ywv8qTldYp4TBl/U9W6dZufe/bsjUFDhuCTdpJltGBQ2QftO3ZmqtkPffoPUJCCv5PVPTIH + IG5DSsByjceffvnld8GJmf+ODA9fvkF4Ug6sJQhkXOBMAriGJuGMpSdsvMNh7xsFByrdxT8Odm7BuHjZ + HZe9wuha8hHH7CGHMcj1m1XfGl26IuQXkbkSKf9KQDeDWMkBItbgIiGWQ4pIEtnHDNOY+KOxcxpT2Ai6 + sa1MYx2RVQYERD+T55DAcwT7QCyrlKbFkkRREfcyc6rx5PFr7GRKvIJEmjFvA/YcOo9e/UdIkemDiZIE + dchoaetRkdRxYzGBHXijX1JZfahESQsn8fM8KnIlP4tP1CMkmHGmP/OnQsUcSqFDMQ1LJPA4GRnSMUIW + aZXHyGyZ1O/vte30Na3IGo763kwlR6Bv/6EKVzJq/CTMnLOIgeUg6biXJKYoXiZ9xJXIzJ9AtgWPuvbq + 9eZ62e1/m9OlyDs/5TXP6fPLFVbAwMYNbuEpsHAJxDUGixFJN+EXkQ5LtyD4cn94bDqDuXxExGUjMa0A + YbQKUQmFcPEJFdIrJ83El0uWJDUGCRJPElZ8fk92oTJlzF+8dC9mztPF/mNXYetehL2Hzokr6E8LpsU+ + FQLsIcQN+Ldo8XHNFa9UFJVXw8TCGyZWnhigMRm79xtwcIyTa30w+ZUAvCnZrtOsWbP6fJgGVLb4QrEE + n/E7sQaS0gyqJYNU1mSeXCyDrN2X+vppfneRRLLgcWb8LJAHFBjzOzOSS6ptHoSYTam7F3To3Avrt+3E + 4kWrMHLsNPQZMgZT5izF+KmLsGbDTkzSXiYppSzbEvdRTiKU8Rpl3K6UfY0aNhRrI2SQlT9iGZ6MGjfj + bU5J9b+tAqU8/OEtsopuMy3MZmyQDDuPEEXE7eATifM2Hswg8uAWEANrV39csrgKZ48wBIQkwtU7CvEJ + eYih+/C/Fn999ChNWSIufSMppFhHHfaZKPMC+82BCvbmdiDhqzFmyutDZ72weqO+kFiOkQrlMh4n2MjU + 8jQ/uwwdOuS1k3ci8oruQs/QDrrHLGgBNmHNtsPoM2CkuIwPKr+SQPHpb7UBxQQRIQ/anBahNeOCdtwv + Ee1XvPmeRD9+HsxWUqeJJMwctku4byUVLD5uYy3WUvlrqTSpvyuiaUIyC6l0pXXt0Q86K3Yq1s+Nnb6A + D30AU+evxbTFm7Hn6Hlc8QrApPlrpAPLCXE5Yj0EWbxWPltZ3CFkUGYZSjIInk6Zrv02qaBKQYYfiaLq + FzTJ9+HPQNErOBHeoQkMEmMRFJUKK2c/2LuEKqqMlnQLDrQUZ02uwpGtg6M/PH3CkEI3ERKS8HLl6s1b + eH5xl5I+SnlZ6gdScDIm5PmcCce2bVvLyJdlZvr169WTrGqF9JX0E7fFejgtWb0F5fde4Rqt0MJVh7Bp + xxmMn74EU2evRt8BIyR9/KCiGPm1UAr1WkdRI6AyG/Jmm1CJUihqzrYVP0tg0oGfZY28BEmSR/flb2Sx + hNywZBAyTSqWQhg8hsGktFKLF5JIadSmceNGklOXte0+DHfvV2P+oq3oMWImth0zwi49a+gaWsHaPRjX + olNxzsxDSCDpl/hbgWzH8n7SeT5ZCFJIlNFCCBkk4JQ1fpJ9CCGEGI+nzV/y1j/+Ju5/BxQ//BHJOXfg + GsAsISAB7tcS4ewZgvA4MfsZCgtgYesJMyt3RbnZ0TEA1lZuCAiIQAzTSX//SISHpMHUzEZiAHELMg8g + 2cIG9pnUDmRWUgpJprQKQgopLK3jvYrrkDhiSe2+K1d9k1FR/gznLVyxZvMx9Bk0AZNn6GDjln34ZvxM + OfcHl78jARmqJIO4BkVsQAgZlIWjhux4IUVzBkMSL7Tlg0seLRNJX3Jbblry6R60Ht14XHeepidbGS0j + eJ55/CyjRapsMZ+06wFja0/oGVhAfcw8zFq3H3tOXoaNcwB8I68jkKM14UYedp8xFhLI6LrCTnXm+RSr + fXgucSmyGETcSiaJJ/mzBJ8SiFbRpN1lK4QQIggpHk+ZufydhWsywjMewPxqIrYet8P6vRcURIuKvw5L + W3d4B0bBjoqXxZz2JIGdnR9caQ18mVKaGzsgkBmErEV0tveGg53rzWYtWopipbIoy8g38P52kZCyLkGw + mfclmcB09u9U3rMQ4GiDBnVzUnPvIe56Hoxtg3HKwAmz5m7C4JFTMXrsTMyYsfCDBoHvy9+RQIQ3+es2 + Fa38TghRlw9DPStSx/o8TtIlWUwib9FKMeljHi/vzbXmd4qWx7ehr+zADhFiyMSMdIaYQI82rdu8mr5w + O4Jj4jBi/CJor94D/YsOuGjni0AGa6FJGUzxKlHx4BV2GjgKCWS1j+TjskjDlh0to1AKNEr/G8HrxbGj + ZWZQpmDFVZTWWocq3rcQQlyGtI9GTZjzdqeuNQ4bemPp5nNYvdMEGw9cwkE9c/gxLfP2C0NEWBpHfxS8 + XMNgamqPC5cs4XzFH1bmTgi/loS0pGzEk6ihgTESr0i2MIvXFyXr8P6kncN7msJtqTRK2VkKTEc2bjyI + +Mw7OH7+KvROX8HBY8bYf8gQ47XmQmvKfPTo0UuHv5N+/VUXH1L+WxepJYiCFHwwJTkkk6jPh1csMefN + S9uQ+2SlkfhMKTT14Pff8Lv1HMkSJIb2Uh8Hf/rjMyY22LT7KA6ftoCemRNi0nIRxlQuMaME8bm3kP/o + W7iEKV7YlBRMv26dOpJPKwkhplbm98VKOPH+vAgFIXh9WSCayZuUdLSY2+V0QcqVwrcb1K8n7cMhmmNJ + Bnus3XkRE6dvwqz5O7Fuqy4MzloplpPHxl2Hv3cMHB28cIUuwtMtAC6O3ji07wysLdxRWlAl9yYp4xhm + TKJsCRQV7pDEEzconyWAXtXp8/ZxXsHF8OZ5dxy+gDVbj2Kq9nIs0VmLUaMnY/iICXIusQBiXRUl+9+1 + 1FoEJT6i+Ve0tSLbMuUsJJBgchBJMKNJ48aST1NZdUo799bEy29fYzo7YNXWgzA0toET83UTjxjm7/Fw + D0/Fs9fv8DMz/4IHb9CkSVOpxkkGIib2EM+lS8sj+bX4VrEu50kAE96XBGGyHlCWgUmaJqloBvfLKh1J + R2U1sQSZCgsh202bNqrpP3jED1Nmr8PiZXswSnMO1NQnYPrsZbAwvYyIcLom31hahhRctnLGwb16OLDn + NAz1FSuoZD5FYiEJkAfxOgNIgKEcJPJZ1ijIXMM2Y1sf5Jc9xgVTF+zSvYBZCzdg1pxlGDFyLAYPHoEF + SzfIudT5DJ/x9zKQfjfyW0vxqyWohbLErNyvFHEdjTka5dXq7iTDKJrlFewgGcGBXw8chgPHz8H7WjDG + aC3ErOVbsfekMc5ZuyEiNgs3CipwLbMUKfm38eT1X3HnLWDoGCKdJBmGpKMbef7NJJZkHxKlS8lVCHaU + 15CgTFJTW3aoGyHrByV2iOe2ZBc5/F0BW4kbbtEyCSEk3cyvX7/BXbVBmj9M0pqFcWNnQL3vSHTv2gfr + V2/F+VOX4MQYICwoFhmpxdiyYpPcj8QBMhUsbT/ek4ziQXxe2SfrEObqHj2FqntvEBCaAnf3SGjNWI0N + mw9g3YbtGDVmAvr0HoxpU+dJBVSI1JHk+XWx7v+2vK9QpYIFSuWLqRICKPF3BOCDCJNbsJUJmIHsdPGH + kh6K2Y7u3mcYjp8xx84D+ujJEbds8yHoGVnismsIrvjFwu1aMsKyq2AfloycO88QVPQM2SWvMXi4hqRb + EleIb13ETme2UWcZt+XFjg3ENl5LrMURZiQyJStFLFnKLUu2ZJo4jMe8v2y8gMdLICkQt5FTt17d9ObN + mlWp9VP7XkN9FIb1HYQh/dTQ/auu2LBsAxxsfTFkkLoEmtN4TikdS6wjJfV+fF4hg7iE6brHLiC/+CHc + veJgZxsACxsvbN59QjHitbWXYcyYKVCjBeCxkjaK2+j0eyLA+/I+AZRQEkGgJIBAIexkPoviYdp8/PHH + XWkBpLAkChOzLWY6tVOf4fALjobhBVNo0Scu3rgHa/cZwMDEGWZXwxEUn4uAhAJ4xRXByD8N/um3Uf4C + MHWLRaOGDSU2EBMrkOlXWRMokPRTFomKpZAKnhRmJB09RUVLumZDYkgg6Us3Im5CZupSOWJlEkwCSUk1 + Za2/kEPxIunHLVtU9uz29Q+jho3CwB69oT5wID5r/5mkqIv4XFp8Jk3+Rky/pMcyxT7L8KwNbB0iYHTJ + BVv2nYLBeRsYmthizYZ90PhGC8No/ocM/wYTJitmUeV+JZWWwfK7cgH/kbxPBoEQ4VcCsFMUVoJuQCJb + CQh7cZ9Mk65lQHeBrfjpArVRU2Dr5AI9fSMMHzcX2nQHx9h5u/TNcNLSCx5h6dA19cbhyyE465WCkpof + cP8JUPjkF2SWPUX3PmpSvlWsASRkaltSz/m8llQvl7FdReWs576tSstAiGWQIFJeD3OnEsVNKJeGKcrc + /F1mnbp1FITg7ySOEKsR3K5t28IJo8eK0k4RK3leKYyJFZARPFxDc7i/ua0fUq4XwcMvDrZXAnH4hCn2 + HTqDrTsOQ2f5FoyfNAMamt+ge8++oPUSCyUFNRkgHXk+maj7Q8r7ZFCKbMsDSYrYiQ8n8+9T2bnit+XB + pchT1KxtRxw9awoLa2doMCVas/EAlmzQxfK953HG2hNrTtnijL0v/BLzUVxeg5LKGlTL3wcCFIgueEwX + sl8CPfG7EnkLESRHF4sgBRlxGUIG6ejNxC7eyyFCqpWSVVgQV/jZhRA3EcRW5jSUS8hl3kPW/oeTLJJx + yPHHSQpZmSzXmNKmdasju/aeQG5+DQLCkxAamQpDc0ecOG3K59kHnSUbMGfecmhojIX6yNHo1n0AunTu + JOnpGZ5T5gyG8P7EAvz6xtYfUX5LAPEDDekCJDVsQ3RhpykXoeykdZD1/TJxlNdz0HCMnbEQR86bY8GK + bRg7dw20SYJdJy0wbe0R7DW0h7FHBJyuJcI3IRspxfcRll6KsppXUv39VVwTi/FFly6SJkqxRl7sFCLI + EjCxCBI3KN8f2EhLJL53LyEVPSGDrBo24f1JzCAlXiGD0joIpP7gQIsg5xdLsumrLt2iFi9cCxNrd1hd + cUJ82g2cPmeKtVv3Y/02XaxYtwOrVm6H9vzlGDJiPH3+SPTvr46hNP/8vVivQySAuDEJID8hCf4UBHif + BFJJasRRI66gPR9QUicJlMR0in+2JSKpjLxPv+iC/uyYNfSZu49ehPaiTdDZcAhbDurjmLE9Thg5wNDe + D1Z+UQiKy4WFdxzCb5Sj4uFzvPsRePP2Z8ic8WNux1W8gGv4DcxZvkZ8uxBOriexglgEgayFlMKNTAVL + fV8sg2QTQgipXgohJM6QjEIIIbBo3LCx95edOtcMVlfH6vWrcODwSRw5cwYmFpexec8BeHsH4+jJS9i5 + 9yjN/inMX7wGAxlIqg3RRP/BwzCakf80LW1RfhBjECGSxCri/6VfWrKv6jdr1kw5afeHlN8SQKRey5Yt + FVkBoSgQESM40mR07qaVkEqfuIObLVo2/64/A6QpcxdjwdotjAnWYT5H0ZrtuthPc7p8rz7W616EtWcQ + YtIK4BaeTkWnIpQ+1zOlAEn5d1Hz8hfcffmDYlLofSm4/QoJxXdxNTQR209eeHfC2PLdrHmLy3v3HRQ3 + fLhG0pARwxO/7NktcZr24u+nas//ccDgQe/GjBuPSTOm45vxkzB3+Xxs2L4FM+fNwdgJVOTsaVims5Tx + iz5mzZ0HbZ010Dc0wikDQ2zduR8TJs5Cj14D8WWXPvj8i6/wZefuGDBwsChfXIszLcmRRo0aSuVQKopS + M5FBogioaR3/sAQQ+YckoMKbkNl/RwJCsYCS+yVCl8BQViKVDxw2FsM1pmLC7KVYt2U/1m0/hG379LBh + rx5On7fDlau+uHDFA+dtPRASmY6g6OswdI3CuauRSM2vQEZhFV7/8AvuP3+NR8+/VxDgHc2DWIhH371D + ZuVD3H7yBo9f/YyKJ68Qe6MImQW34REaD8+QJFxxDsYxBqarN++FiY0DTfk2LF1Bt7R8KcZNnAjtOfMw + fdpkTNOeik3b1jKoG4Uli5dh1sLFGD9VCx2//Ap9+w1G5669MaC/Gr7q0h1qauqifLFIUtgS67KaVkBG + v8y6tqUrkHhJCPCHl39IAELWIChKxVR4B26L2ZPUSYK39RwJEp1LiigLTeT9/qeaE+dj1vwVOHL4DNbv + PIKp3J6qsxkL1+zERXN7nDd1hpXzNWw+fBEX7D1whjl6ZPJNeEWlIjW3BHEZuQhMz0VyURWupeTAOyYD + MZmFyC+9h6iMHGSU3EVwYiaKKu4hPbtU8bqbZ3ACLBx8ceCcFYxMHWFDt7Njvx5sL3vg9KmLUFPXwOx5 + czFq7EQ0bdoaU6fMweJFazB2zExoz9bBhPEz0FtWUH/dH/0HqCkW0bZr1+41n1kCVZkZtaTV28bnn0rI + +wsy+iVQFgJI9vSnFUVqSChIwE6Q2resqB3EzpHiiQRpskTdpt7fZv6yGBtU1GtQ7+Wo6Ys4suZi2ESa + 42nzMHLCLGgvXY+5yzZiw65D2HHsNLYzdth/xgTnzZ1h5x6Cq37hsPMJh71fJOw8w5GcUYzwjJu0DncQ + EJOO0IRchCfdQFjiTdj7hMKNx/hz9Dv5XIOekSlOX7Bk/HEc5y1scc7UGkdOXaJpPwrNMWNw8qw+lugs + p0kfxOBOA127dUWfvlR6rz74rFMn9OjZD50798TQoUNl1N8muXPr168XxWeWQthePu9MmnmZWpZpdpl2 + F+VL2vyHNv3/qbAj6tLsiTWQ1cnN+bktfaF0gqzMHcUOkLhgGyFlYynYSKFGCjPyatbzr9WGYeiICfTJ + szFccxwWkwQTps/HlBnzMW7mXCxZux3rdh+B/kVLWFm70IybU5mXsd/gEi67XoOBlSNsPf1xnimnpaMX + DM3sccrUFjt1DWFgbgNjCztYOblTwSaKAG/9rgPQNTSEvpElpi9cgTETpmIR202b9mLixAkYNHQQlf41 + +vUfiK979sdX3brjC/r7QeqKJW6yRqGCzyf3H87nlUBSgkxtEkD8fhc+fxs+s8ywNmzevPmfevT/VoQE + jdgpYg0+YSdIEUTiAnEJMp0q5d199IvG7CRZDyAlYIkPZGXQvQHDR2D4xGkkwxjF20rDx4zDyLGTMXTU + ZAxhO2bSLEybp4OlKzdh+oLlWLZhOxau3oo1VNzW/SewetteLN2yi4TZqkjZ9h87C3NbB+geP4uDx85g + 4bKV2Lh9B7OIVVi9jsetWIdZc5Yw2FuMoSPHYIimBjrRz6sNGoSBaoPRpo28Tt8VfQf0E8VLmfg2n6eQ + 95/C+/fntkT8UgqXjEReX+vCfW35XVO29Xnc/ynlK4RKFhI0ZCc0JiQ4bM9A8Qt2iOTE8geaZP5gFY/b + R6Jc4H55yUKWmMn8v9TtZVavesDQERg8Zjr6DlRDl2590KOPGgYM4T5NTQzWGIt+6iMx8pvx6D9kKAky + HqOFOKO+wehJ0zFz/iLM0F6I2QuWYCGVvVhnNRbStM9dsoQuZyoWLF0BzfETMXDYMAX6DBhCJQ+i8rug + S9ce6Nm7t8LM8/5kJbMsRpF7kplHmWsQN3aFFkBSSilCyQyhLJb5ks/Whr9pQfxpAr//kVC5iriAim9A + NKN7+ISjQSpiXZs2bTqQHaRJ6yBEkLd75a95SWfacNub38XwWImqJWCU6d2ar7r3/KvamPEYPHI0AzCa + 5979GIT1wlfdv0bv3n0htYYeX/cjQYYr3nhWVx+B3kzN+jOvl2XrU6ZPw7hJkzBo8FCadTVM1JqmeEn2 + 865dqez+6DdkGIbQ+rRs+bG8vyAmXlYeVZGcYpno5+unECG8T1kKbsh73E4CSKYjU8SyXFxWU7WSjIjP + V5/H/d9V/m9EFqk2bNasmYwIyYfbsOM6sgMlU5CZNpkulREkBZyN7DypoEkq5chAURaDSG6dRaMis3oS + L9xjNPW4Z69+fx06ehJH/yhiuOJlFBm53UkKef29V69+GDF2PN3HRKhrjMJYrdlQHzkJasO/gdoQDfQf + PAQtPm4lyhZFK017BZUsawvExIt/l8kkmViSF0DEz+vxGCksSZlY3jiSdZSy4lqCXrF01H9jWTyjUv5v + RALEOuxUyRRkJrGFmEqJD7ivK7f7suOGsXPlbVrxpcv53VZ+J6+1/fqGLwkh5WWp3+ew44vq1q1TRjIo + 31YSVHO/KFQBHi+mW7F0rE4dxXFixgVlvJZC0YT8cSpR9nVeTwLTSN6L/DEI+asjUsiSPxAhMctKHifz + EULYfvwsgZ68M9iKhG7B3zTgOckfheVTyT8SdpB0joII7DwhglgEWVzSnhZCRpKYUnmbSYMEkJnA2ezc + pfwsk0ySRsryMSnhOnG/1PND+F0cz5VICDFkmleWnCtb8dcy2ZPI40W5ApkMCuPxQVSajGx33pYTFScv + jsoEkswGyoSS/I2i5TxuNlsp6sikjrxTIJlNB+6T+n4zXl+eQ55LNer/G6IgAiEWoRGV34wKkoJJe3as + xAkyudSL++QPQoiPHcvtmdy3iJA/1iCEkD/YoFi+zd9cJGRtogWVYiWQbRJN8XILvzOWY7hfJoVkRMtb + UbKWYD8VL75cViTJ+xDihmbwWCGfvNEjf1quNz9LTUPuS0x9K96DvG8hLk0meKQSqhr1/0Op26JFC2UH + NmC+LKmj1BBaUXntGQ/IW01dqCSxDAP4WbEwg8cp/0SMrONXrA+gEmXyR/64lETl0gpkQcZKnm8ZlatY + aUSI/xYyTaNbmsLvlO8+DOO2TGtLpiLvSYjSP+UxMtEl5BRr1YTbMvchb2PLiFcp/p8lVLh0puJFFipH + 5hYUZCBasdPlvQVZWNmJkJhBCNGXhBALoXiZhSTSJAkkMJPFKUrIGj4ZyZJ6iiWROGMIlTyI1xvIVv7w + g9Tru/L3ksJ1FIUTMsWtUDr3y30I5L7EYqmU/iGFSlR2sHS21BJkxImfbUaFSaQt7zsK5FW3jvxe/g6A + xA8yYgXdeQ7JMLqTTPJCiyhX9n8lSmbbkR5HFml24Gcx6W1oUdryOHlBRt6ckhdmxLzLdcXEy30o4xeV + /ItFViELFG6CqM9RrySEjMqW/CykEOXJK28yaj9h+wldiwSXyn8M1YpkkGPk2Ob8Xnx4ExKhMUd1I1oD + OadidFMkNpHUVUJ6ldJ/ZyIKEcifxRNFybZylDagkkWRko4pWvlMBSu2a49RWhX5nULRhOKcKmX/gUWs + gyiwVrF/BxHZL8LPKlGJSlSiEpWoRCUqUYlKVKISlahEJSpRiUpUohKVqEQlKlGJSlSiEpWoRCUqUYlK + VKISlahEJSpRiUpUohKVqEQlKlGJSlSiEpWoRCX/ZPnoo/8HSmFU3rDMtHcAAAAASUVORK5CYII= + + - Radegast Metaverse Client -Copyright © 2009-2014, Radegast Development Team + Radegast-ng Metaverse Client +Copyright © 2009-2016, Radegast Development Team +Copyright © 2017-2022, Sjofn LLC All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -131,53 +412,51 @@ Redistribution and use in source and binary forms, with or without modification, THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - Based on SLeek (BSD License) + Based on SLeek Copyright © 2006-2008, Paul Clement (a.k.a. Delta) All rights reserved. -Uses PrimMesher (BSD License) -© 2010 Dahlia Trimble +PrimMesher +Copyright © 2010 Dahlia Trimble http://forge.opensimulator.org/gf/project/primmesher/ -Uses AIMLBot (LGPL License) -The AIMLBot library (Program#) is a .NET implementation of the AIML standard. -© 2006 Nicholas H.Tollervey (http://ntoll.org) +AIMLBot +Copyright © 2006 Nicholas H.Tollervey http://aimlbot.sourceforge.net/ -Uses FMOD Library (FMOD Non Commercial License) -FMOD Ex SoundSystem Copyright © 2005-2009 Firelight Technologies Pty, Ltd. -Redistributions in binary form must follow the following rules: -* The FMOD library cannot be used for resale or other commercial distribution -* This license cannot be used for products which do not make profit but are still commercially released -* This license cannot be used for commercial services, where the executable containing fmod is not sold, but the data is -(If you want to redistribute Radegast commercially, remove fmodex.dll, fmodex*.so and fmodex*.dylib) - -Uses Ogg Vorbis codec (BSD License) +Ogg Vorbis codec Copyright © 2002, Xiph.org Foundation -Uses log4net (Apache 2.0 License) +log4net Copyright © Apache Software Foundation -Uses LSL parser from OpenSimulator project (BSD License) +LSL parser from OpenSimulator project Copyright © Contributors, http://opensimulator.org/ -Uses OpenTK library (MIT License) -Copyright © 2006 - 2009 The Open Toolkit library. +OpenTK library +Copyright © 2006 - 2020 The Open Toolkit library. http://www.opentk.com/ -Uses artwork files are licenced under the -Creative Commons Share and Share Alike 3.0 -Copyright © 2002-2009 Linden Research Inc. - -Command Line Library (MIT License) +Command Line Library Copyright © 2005 - 2010 Giacomo Stelluti Scala http://commandline.codeplex.com/ -Uses code snippets from CSAT Library (MIT License) +FMOD Studio +Copyright © 1994-2016 Firelight Technologies Pty, Ltd. + +OpenJpegDotNet +Copyright © 2021 Takuya Takuchi + +zlib.net +Copyright © 2011 ComponentAce + +Uses code snippets from CSAT Library Copyright © 2011 mjt -http://code.google.com/p/csat/ + +Uses artwork files are licenced under the +Creative Commons Share and Share Alike 3.0 +Copyright © 2002-2009 Linden Research Inc. - AAABAAEAEBAAAAAAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAQAQAAAAAAAAAAAAAAAAAAAAA diff --git a/Radegast/GUI/Dialogs/BanGroupMember.cs b/Radegast/GUI/Dialogs/BanGroupMember.cs index 9f65b66ee..6b4cdcf1c 100644 --- a/Radegast/GUI/Dialogs/BanGroupMember.cs +++ b/Radegast/GUI/Dialogs/BanGroupMember.cs @@ -1,40 +1,25 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; using System.Windows.Forms; using OpenMetaverse; @@ -44,7 +29,7 @@ public partial class BanGroupMember : RadegastForm { AvatarPicker picker; RadegastInstance instance; - Netcom.RadegastNetcom netcom; + Radegast.Netcom netcom; GroupDetails parent; Group group; @@ -53,22 +38,22 @@ public BanGroupMember(RadegastInstance instance, Group group, GroupDetails paren :base(instance) { InitializeComponent(); - Disposed += new EventHandler(GroupInvite_Disposed); + Disposed += GroupInvite_Disposed; AutoSavePosition = true; this.instance = instance; this.group = group; - this.netcom = instance.Netcom; + netcom = instance.Netcom; this.parent = parent; picker = new AvatarPicker(instance) { Dock = DockStyle.Fill }; Controls.Add(picker); - picker.SelectionChaged += new EventHandler(picker_SelectionChaged); + picker.SelectionChaged += picker_SelectionChaged; picker.BringToFront(); - netcom.ClientDisconnected += new EventHandler(Netcom_ClientDisconnected); + netcom.ClientDisconnected += Netcom_ClientDisconnected; - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } void picker_SelectionChaged(object sender, EventArgs e) @@ -78,23 +63,19 @@ void picker_SelectionChaged(object sender, EventArgs e) void GroupInvite_Disposed(object sender, EventArgs e) { - netcom.ClientDisconnected -= new EventHandler(Netcom_ClientDisconnected); + netcom.ClientDisconnected -= Netcom_ClientDisconnected; netcom = null; instance = null; picker.Dispose(); Logger.DebugLog("Group picker disposed"); } - void Netcom_ClientDisconnected(object sender, OpenMetaverse.DisconnectedEventArgs e) + void Netcom_ClientDisconnected(object sender, DisconnectedEventArgs e) { - ((Radegast.Netcom.RadegastNetcom)sender).ClientDisconnected -= new EventHandler(Netcom_ClientDisconnected); + ((Radegast.Netcom)sender).ClientDisconnected -= Netcom_ClientDisconnected; if (!instance.MonoRuntime || IsHandleCreated) - BeginInvoke(new MethodInvoker(() => - { - Close(); - } - )); + BeginInvoke(new MethodInvoker(Close)); } diff --git a/Radegast/GUI/Dialogs/DetachedTab.cs b/Radegast/GUI/Dialogs/DetachedTab.cs index 8eb8a96ed..2958b9779 100644 --- a/Radegast/GUI/Dialogs/DetachedTab.cs +++ b/Radegast/GUI/Dialogs/DetachedTab.cs @@ -1,33 +1,23 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Drawing; using System.Windows.Forms; @@ -42,8 +32,6 @@ public partial class frmDetachedTab : RadegastForm private RadegastTab tab; //For reattachment - private ToolStrip strip; - private Panel container; int mainTop; int mainLeft; @@ -53,7 +41,7 @@ public frmDetachedTab(RadegastInstance instance, RadegastTab tab) :base(instance) { InitializeComponent(); - Disposed += new EventHandler(frmDetachedTab_Disposed); + Disposed += frmDetachedTab_Disposed; this.instance = instance; this.tab = tab; @@ -61,17 +49,17 @@ public frmDetachedTab(RadegastInstance instance, RadegastTab tab) Controls.Add(tab.Control); tab.Control.Visible = true; tab.Control.BringToFront(); - tab.Control.TextChanged += new EventHandler(Control_TextChanged); + tab.Control.TextChanged += Control_TextChanged; SettingsKeyBase = "tab_window_" + tab.Control.GetType().Name; AutoSavePosition = true; - instance.MainForm.Move += new EventHandler(MainForm_ResizeEnd); + instance.MainForm.Move += MainForm_ResizeEnd; SaveMainFormPos(); if (tab.Floater) { Owner = instance.MainForm; } - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } void Control_TextChanged(object sender, EventArgs e) @@ -81,7 +69,7 @@ void Control_TextChanged(object sender, EventArgs e) void frmDetachedTab_Disposed(object sender, EventArgs e) { - instance.MainForm.Move -= new EventHandler(MainForm_ResizeEnd); + instance.MainForm.Move -= MainForm_ResizeEnd; } void SaveMainFormPos() @@ -103,27 +91,19 @@ void MainForm_ResizeEnd(object sender, EventArgs e) private void frmDetachedTab_FormClosing(object sender, FormClosingEventArgs e) { - tab.Control.TextChanged -= new EventHandler(Control_TextChanged); + tab.Control.TextChanged -= Control_TextChanged; if (tab.Detached) { if (tab.CloseOnDetachedClose) tab.Close(); else - tab.AttachTo(strip, container); + tab.AttachTo(ReattachStrip, ReattachContainer); } } - public ToolStrip ReattachStrip - { - get { return strip; } - set { strip = value; } - } + public ToolStrip ReattachStrip { get; set; } - public Panel ReattachContainer - { - get { return container; } - set { container = value; } - } + public Panel ReattachContainer { get; set; } private void UpdatePos() { @@ -143,7 +123,7 @@ private void UpdatePos() DockedToMain = false; if (!ShowInTaskbar) ShowInTaskbar = true; - this.Text = tab.Label + " - " + Properties.Resources.ProgramName; + Text = tab.Label + " - " + Properties.Resources.ProgramName; } } diff --git a/Radegast/GUI/Dialogs/DisplayNameChange.cs b/Radegast/GUI/Dialogs/DisplayNameChange.cs index c680b2382..8a3c48862 100644 --- a/Radegast/GUI/Dialogs/DisplayNameChange.cs +++ b/Radegast/GUI/Dialogs/DisplayNameChange.cs @@ -1,45 +1,28 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2022, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ using System; using System.Collections.Generic; +using System.Threading; using System.Windows.Forms; using OpenMetaverse; -#if (COGBOT_LIBOMV || USE_STHREADS) -using ThreadPoolUtil; -using Thread = ThreadPoolUtil.Thread; -using ThreadPool = ThreadPoolUtil.ThreadPool; -using Monitor = ThreadPoolUtil.Monitor; -#endif -using System.Threading; namespace Radegast @@ -50,36 +33,31 @@ public DisplayNameChange() { InitializeComponent(); - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } public DisplayNameChange(RadegastInstance inst) : base(inst) { InitializeComponent(); - Disposed += new EventHandler(DisplayNameChange_Disposed); + Disposed += DisplayNameChange_Disposed; AutoSavePosition = true; - Client.Self.SetDisplayNameReply += new EventHandler(Self_SetDisplayNameReply); + Client.Self.SetDisplayNameReply += Self_SetDisplayNameReply; - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } void DisplayNameChange_Disposed(object sender, EventArgs e) { - Client.Self.SetDisplayNameReply += new EventHandler(Self_SetDisplayNameReply); + Client.Self.SetDisplayNameReply += Self_SetDisplayNameReply; } void Self_SetDisplayNameReply(object sender, SetDisplayNameReplyEventArgs e) { - if (e.Status == 200) - { - UpdateStatus("Name successfully changed to: " + e.DisplayName.DisplayName); - } - else - { - UpdateStatus("Update failed: " + e.Reason); - } + UpdateStatus(e.Status == 200 + ? $"Name successfully changed to: {e.DisplayName.DisplayName}" + : $"Update failed: {e.Reason}"); } private void UpdateStatus(string msg) @@ -100,15 +78,14 @@ private void UpdateStatus(string msg) private void StartDisplayNameChage(string name) { - WorkPool.QueueUserWorkItem(sync => + ThreadPool.QueueUserWorkItem(sync => { - Client.Avatars.GetDisplayNames(new List() { Client.Self.AgentID }, - (bool success, AgentDisplayName[] names, UUID[] badIDs) => + Client.Avatars.GetDisplayNames(new List() { Client.Self.AgentID }, + (success, names, badIDs) => { if (!success || names.Length < 1) { - UpdateStatus("Failed to get curret name"); - return; + UpdateStatus("Failed to get current name"); } else { diff --git a/Radegast/GUI/Dialogs/GroupInfo.cs b/Radegast/GUI/Dialogs/GroupInfo.cs index cb21855ed..e4701b992 100644 --- a/Radegast/GUI/Dialogs/GroupInfo.cs +++ b/Radegast/GUI/Dialogs/GroupInfo.cs @@ -1,33 +1,23 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System.Drawing; using System.Windows.Forms; using OpenMetaverse; @@ -45,21 +35,20 @@ public frmGroupInfo(RadegastInstance instance, Group group) : base(instance) { InitializeComponent(); - Disposed += new System.EventHandler(frmGroupInfo_Disposed); + Disposed += frmGroupInfo_Disposed; AutoSavePosition = true; this.instance = instance; - this.Group = group; + Group = group; - GroupDetails = new GroupDetails(instance, group); - GroupDetails.Dock = DockStyle.Fill; + GroupDetails = new GroupDetails(instance, group) {Dock = DockStyle.Fill}; ClientSize = new Size(GroupDetails.Width, GroupDetails.Height); MinimumSize = Size; Controls.Add(GroupDetails); Text = group.Name + " - Group information"; - instance.Netcom.ClientDisconnected += new System.EventHandler(Netcom_ClientDisconnected); + instance.Netcom.ClientDisconnected += Netcom_ClientDisconnected; - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } void frmGroupInfo_Disposed(object sender, System.EventArgs e) @@ -68,7 +57,7 @@ void frmGroupInfo_Disposed(object sender, System.EventArgs e) void Netcom_ClientDisconnected(object sender, DisconnectedEventArgs e) { - ((Radegast.Netcom.RadegastNetcom)sender).ClientDisconnected -= new System.EventHandler(Netcom_ClientDisconnected); + ((Radegast.Netcom)sender).ClientDisconnected -= Netcom_ClientDisconnected; if (InvokeRequired) { diff --git a/Radegast/GUI/Dialogs/GroupInvite.cs b/Radegast/GUI/Dialogs/GroupInvite.cs index 23ea408dd..54f1ba3ee 100644 --- a/Radegast/GUI/Dialogs/GroupInvite.cs +++ b/Radegast/GUI/Dialogs/GroupInvite.cs @@ -1,40 +1,25 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; using System.Windows.Forms; using OpenMetaverse; @@ -44,7 +29,7 @@ public partial class GroupInvite : RadegastForm { AvatarPicker picker; RadegastInstance instance; - Netcom.RadegastNetcom netcom; + Radegast.Netcom netcom; Group group; Dictionary roles; @@ -53,20 +38,20 @@ public GroupInvite(RadegastInstance instance, Group group, Dictionary(Netcom_ClientDisconnected); + netcom.ClientDisconnected += Netcom_ClientDisconnected; cmbRoles.Items.Add(roles[UUID.Zero]); cmbRoles.SelectedIndex = 0; @@ -75,7 +60,7 @@ public GroupInvite(RadegastInstance instance, Group group, Dictionary(Netcom_ClientDisconnected); + netcom.ClientDisconnected -= Netcom_ClientDisconnected; netcom = null; instance = null; picker.Dispose(); Logger.DebugLog("Group picker disposed"); } - void Netcom_ClientDisconnected(object sender, OpenMetaverse.DisconnectedEventArgs e) + void Netcom_ClientDisconnected(object sender, DisconnectedEventArgs e) { - ((Radegast.Netcom.RadegastNetcom)sender).ClientDisconnected -= new EventHandler(Netcom_ClientDisconnected); + ((Radegast.Netcom)sender).ClientDisconnected -= Netcom_ClientDisconnected; if (!instance.MonoRuntime || IsHandleCreated) - BeginInvoke(new MethodInvoker(() => - { - Close(); - } - )); + BeginInvoke(new MethodInvoker(Close)); } @@ -112,8 +93,7 @@ private void GroupInvite_Load(object sender, EventArgs e) private void btnIvite_Click(object sender, EventArgs e) { - List roleID = new List(); - roleID.Add(((GroupRole)cmbRoles.SelectedItem).ID); + List roleID = new List {((GroupRole) cmbRoles.SelectedItem).ID}; foreach (UUID key in picker.SelectedAvatars.Keys) { diff --git a/Radegast/GUI/Dialogs/HoverHeight.Designer.cs b/Radegast/GUI/Dialogs/HoverHeight.Designer.cs new file mode 100644 index 000000000..dbc85cbd8 --- /dev/null +++ b/Radegast/GUI/Dialogs/HoverHeight.Designer.cs @@ -0,0 +1,98 @@ +namespace Radegast +{ + partial class frmHoverHeight + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.tbHoverHeight = new System.Windows.Forms.TrackBar(); + this.label1 = new System.Windows.Forms.Label(); + this.txtHoverHeight = new System.Windows.Forms.TextBox(); + ((System.ComponentModel.ISupportInitialize)(this.tbHoverHeight)).BeginInit(); + this.SuspendLayout(); + // + // tbHoverHeight + // + this.tbHoverHeight.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.tbHoverHeight.Location = new System.Drawing.Point(56, 9); + this.tbHoverHeight.Maximum = 200; + this.tbHoverHeight.Minimum = -200; + this.tbHoverHeight.Name = "tbHoverHeight"; + this.tbHoverHeight.Size = new System.Drawing.Size(290, 45); + this.tbHoverHeight.TabIndex = 0; + this.tbHoverHeight.TickStyle = System.Windows.Forms.TickStyle.None; + this.tbHoverHeight.Scroll += new System.EventHandler(this.tbHoverHeight_Scroll); + this.tbHoverHeight.MouseCaptureChanged += new System.EventHandler(this.tbHoverHeight_MouseCaptureChanged); + this.tbHoverHeight.MouseDown += new System.Windows.Forms.MouseEventHandler(this.tbHoverHeight_MouseDown); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(12, 13); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(38, 13); + this.label1.TabIndex = 1; + this.label1.Text = "Height"; + // + // txtHoverHeight + // + this.txtHoverHeight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.txtHoverHeight.Location = new System.Drawing.Point(353, 9); + this.txtHoverHeight.Name = "txtHoverHeight"; + this.txtHoverHeight.Size = new System.Drawing.Size(68, 21); + this.txtHoverHeight.TabIndex = 2; + this.txtHoverHeight.Tag = ""; + // + // frmHoverHeight + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(433, 43); + this.Controls.Add(this.txtHoverHeight); + this.Controls.Add(this.label1); + this.Controls.Add(this.tbHoverHeight); + this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "frmHoverHeight"; + this.ShowIcon = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Hover Height"; + ((System.ComponentModel.ISupportInitialize)(this.tbHoverHeight)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TrackBar tbHoverHeight; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.TextBox txtHoverHeight; + } +} \ No newline at end of file diff --git a/Radegast/GUI/Dialogs/HoverHeight.cs b/Radegast/GUI/Dialogs/HoverHeight.cs new file mode 100644 index 000000000..4e75a87b0 --- /dev/null +++ b/Radegast/GUI/Dialogs/HoverHeight.cs @@ -0,0 +1,215 @@ +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + +using System; +using System.ComponentModel; +using System.Runtime.CompilerServices; +using System.Windows.Forms; + +namespace Radegast +{ + public partial class frmHoverHeight : Form, INotifyPropertyChanged + { + private const int HoverHeightPrecision = 100; + + private bool IsMouseDown { get; set; } + private bool IsScrolling { get; set; } + private bool IsMono { get; } + + private double _realHoverHeight; + + /// + /// Gets or sets the real hover height + /// + public double RealHoverHeight + { + get => _realHoverHeight; + set + { + if (Math.Abs(RealHoverHeight - value) > double.Epsilon) + { + _realHoverHeight = value; + OnPropertyChanged(); + + if (!IsScrolling) + { + OnHoverHeightChanged(_realHoverHeight); + } + else + { + OnHoverHeightPreview(_realHoverHeight); + } + } + } + } + + /// + /// Gets or sets the hover height for use in the TrackBar control. + /// + public int FakeHoverHeight + { + get => (int)(RealHoverHeight * HoverHeightPrecision); + set + { + if (FakeHoverHeight != value) + { + RealHoverHeight = value / (double) HoverHeightPrecision; + OnPropertyChanged(); + } + } + } + + /// Minimum hover height + public double MinHoverHeight => -2.0; + + /// Maximum hover height + public double MaxHoverHeight => 2.0; + + /// + /// Constructs a new hover height dialog. + /// + /// Initial hover height + /// Determines if mono hacks should be applied + public frmHoverHeight(double initialHoverHeight, bool isMono) + { + IsMono = isMono; + + InitializeComponent(); + + tbHoverHeight.Maximum = (int)(MaxHoverHeight * HoverHeightPrecision); + tbHoverHeight.Minimum = (int)(MinHoverHeight * HoverHeightPrecision); + tbHoverHeight.DataBindings.Add(new Binding("Value", this, nameof(FakeHoverHeight), true, DataSourceUpdateMode.OnPropertyChanged)); + + var textBinding = new Binding("Text", this, nameof(RealHoverHeight), true, DataSourceUpdateMode.OnPropertyChanged); + textBinding.Parse += textBinding_Parse; + txtHoverHeight.DataBindings.Add(textBinding); + + RealHoverHeight = initialHoverHeight; + } + + private void textBinding_Parse(object sender, ConvertEventArgs e) + { + var sourceBinding = sender as Binding; + var sourceControl = sourceBinding.Control as TextBox; + + var attemptedHoverHeight = 0.0; + if (double.TryParse(sourceControl.Text, out attemptedHoverHeight)) + { + sourceControl.ForeColor = DefaultForeColor; + if (attemptedHoverHeight < MinHoverHeight) + { + e.Value = MinHoverHeight; + sourceControl.Text = e.Value.ToString(); + } + else if(attemptedHoverHeight > MaxHoverHeight) + { + e.Value = MaxHoverHeight; + sourceControl.Text = e.Value.ToString(); + } + } + else + { + sourceControl.ForeColor = System.Drawing.Color.Red; + } + } + + private void tbHoverHeight_MouseCaptureChanged(object sender, EventArgs e) + { + IsMouseDown = false; + + if (IsScrolling) + { + IsScrolling = false; + OnHoverHeightChanged(RealHoverHeight); + } + } + + private void tbHoverHeight_MouseDown(object sender, MouseEventArgs e) + { + IsMouseDown = true; + } + + private void tbHoverHeight_Scroll(object sender, EventArgs e) + { + if (IsMouseDown) + { + IsScrolling = true; + } + } + + /// Raised whenever the hover height changes. + public event EventHandler HoverHeightChanged; + + /// + /// Raises the HoverHeightChanged event + /// + /// New hover height + private void OnHoverHeightChanged(double newHoverHeight) + { + HoverHeightChanged?.Invoke(this, new HoverHeightChangedEventArgs(newHoverHeight)); + } + + /// + /// Raised whenever the hover height preview changes. This event is raised rapidly and + /// should only be used to preview the hover height locally. + /// + public event EventHandler HoverHeightPreview; + + /// + /// Raises the HoverHeightPreview event + /// + /// New hover height + private void OnHoverHeightPreview(double newHoverHeight) + { + HoverHeightPreview?.Invoke(this, new HoverHeightChangedEventArgs(newHoverHeight)); + } + + /// Raised whenever a property changes + public event PropertyChangedEventHandler PropertyChanged; + private void OnPropertyChanged([CallerMemberName] string propertyName = null) + { + if (IsMono) + { + // TODO: PropertyChanged is always null on mono, we must manually update our controls + switch (propertyName) + { + case nameof(FakeHoverHeight): + tbHoverHeight.Value = FakeHoverHeight; + break; + case nameof(RealHoverHeight): + txtHoverHeight.Text = RealHoverHeight.ToString("F3"); + break; + } + } + + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + } + + public class HoverHeightChangedEventArgs : EventArgs + { + public double HoverHeight { get; set; } + + public HoverHeightChangedEventArgs(double newHoverHeight) + { + HoverHeight = newHoverHeight; + } + } +} diff --git a/plugins/IdealistRadegastPlugin/Renderer/IdealistViewControl.resx b/Radegast/GUI/Dialogs/HoverHeight.resx similarity index 95% rename from plugins/IdealistRadegastPlugin/Renderer/IdealistViewControl.resx rename to Radegast/GUI/Dialogs/HoverHeight.resx index ff31a6db5..1af7de150 100644 --- a/plugins/IdealistRadegastPlugin/Renderer/IdealistViewControl.resx +++ b/Radegast/GUI/Dialogs/HoverHeight.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/Radegast/GUI/Dialogs/KeyboardShortcuts.cs b/Radegast/GUI/Dialogs/KeyboardShortcuts.cs index d0c32a305..cdbaba0f6 100644 --- a/Radegast/GUI/Dialogs/KeyboardShortcuts.cs +++ b/Radegast/GUI/Dialogs/KeyboardShortcuts.cs @@ -1,33 +1,23 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id: TabsConsole.cs 361 2009-10-24 15:04:57Z latifer $ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Windows.Forms; @@ -42,7 +32,7 @@ public frmKeyboardShortcuts(RadegastInstance instance) InitializeComponent(); this.instance = instance; - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } private void btnClose_Click(object sender, EventArgs e) diff --git a/Radegast/GUI/Dialogs/MainForm.Designer.cs b/Radegast/GUI/Dialogs/MainForm.Designer.cs index 77857c2bd..7e2dc865c 100644 --- a/Radegast/GUI/Dialogs/MainForm.Designer.cs +++ b/Radegast/GUI/Dialogs/MainForm.Designer.cs @@ -92,6 +92,7 @@ private void InitializeComponent() this.tmnuControlAlwaysRun = new System.Windows.Forms.ToolStripMenuItem(); this.groundSitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.standToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.setHoverHeightToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.stopAllAnimationsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.changeMyDisplayNameToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.muteListToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -114,6 +115,7 @@ private void InitializeComponent() this.setAppearanceToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.rebakeTexturesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.myAttachmentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.miniMapToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.tbnPlugins = new System.Windows.Forms.ToolStripDropDownButton(); this.btnPluginsTab = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); @@ -130,12 +132,11 @@ private void InitializeComponent() this.tbtnHelp = new System.Windows.Forms.ToolStripDropDownButton(); this.keyboardShortcutsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.reportBugsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.checkForUpdatesToolStripItem = new System.Windows.Forms.ToolStripMenuItem(); this.accessibilityGuideToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.checkForUpdatesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.debugConsoleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItem6 = new System.Windows.Forms.ToolStripSeparator(); this.aboutRadegastToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); + this.debugConsoleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.statusStrip1 = new System.Windows.Forms.StatusStrip(); this.tlblLoginName = new System.Windows.Forms.ToolStripStatusLabel(); this.tlblMoneyBalance = new System.Windows.Forms.ToolStripStatusLabel(); @@ -157,6 +158,8 @@ private void InitializeComponent() this.ctxTreyRestore = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); this.ctxTreyExit = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator(); + this.toolStripSeparator5 = new System.Windows.Forms.ToolStripSeparator(); this.toolStrip1.SuspendLayout(); this.statusStrip1.SuspendLayout(); this.toolStripContainer1.TopToolStripPanel.SuspendLayout(); @@ -318,6 +321,7 @@ private void InitializeComponent() this.tmnuControlAlwaysRun, this.groundSitToolStripMenuItem, this.standToolStripMenuItem, + this.setHoverHeightToolStripMenuItem, this.stopAllAnimationsToolStripMenuItem, this.changeMyDisplayNameToolStripMenuItem, this.muteListToolStripMenuItem, @@ -341,7 +345,7 @@ private void InitializeComponent() // this.tmnuControlFly.CheckOnClick = true; this.tmnuControlFly.Name = "tmnuControlFly"; - this.tmnuControlFly.Size = new System.Drawing.Size(223, 22); + this.tmnuControlFly.Size = new System.Drawing.Size(221, 22); this.tmnuControlFly.Text = "Fly"; this.tmnuControlFly.Click += new System.EventHandler(this.tmnuControlFly_Click); // @@ -349,61 +353,68 @@ private void InitializeComponent() // this.tmnuControlAlwaysRun.CheckOnClick = true; this.tmnuControlAlwaysRun.Name = "tmnuControlAlwaysRun"; - this.tmnuControlAlwaysRun.Size = new System.Drawing.Size(223, 22); + this.tmnuControlAlwaysRun.Size = new System.Drawing.Size(221, 22); this.tmnuControlAlwaysRun.Text = "Always Run"; this.tmnuControlAlwaysRun.Click += new System.EventHandler(this.tmnuControlAlwaysRun_Click); // // groundSitToolStripMenuItem // this.groundSitToolStripMenuItem.Name = "groundSitToolStripMenuItem"; - this.groundSitToolStripMenuItem.Size = new System.Drawing.Size(223, 22); + this.groundSitToolStripMenuItem.Size = new System.Drawing.Size(221, 22); this.groundSitToolStripMenuItem.Text = "Sit On Ground"; this.groundSitToolStripMenuItem.Click += new System.EventHandler(this.groundSitToolStripMenuItem_Click); // // standToolStripMenuItem // this.standToolStripMenuItem.Name = "standToolStripMenuItem"; - this.standToolStripMenuItem.Size = new System.Drawing.Size(223, 22); + this.standToolStripMenuItem.Size = new System.Drawing.Size(221, 22); this.standToolStripMenuItem.Text = "Stand"; this.standToolStripMenuItem.Click += new System.EventHandler(this.standToolStripMenuItem_Click); // + // setHoverHeightToolStripMenuItem + // + this.setHoverHeightToolStripMenuItem.Name = "setHoverHeightToolStripMenuItem"; + this.setHoverHeightToolStripMenuItem.Size = new System.Drawing.Size(221, 22); + this.setHoverHeightToolStripMenuItem.Text = "Set Hover Height"; + this.setHoverHeightToolStripMenuItem.Click += new System.EventHandler(this.setHoverHeightToolStripMenuItem_Click); + // // stopAllAnimationsToolStripMenuItem // this.stopAllAnimationsToolStripMenuItem.Name = "stopAllAnimationsToolStripMenuItem"; - this.stopAllAnimationsToolStripMenuItem.Size = new System.Drawing.Size(223, 22); + this.stopAllAnimationsToolStripMenuItem.Size = new System.Drawing.Size(221, 22); this.stopAllAnimationsToolStripMenuItem.Text = "Stop All Animations"; this.stopAllAnimationsToolStripMenuItem.Click += new System.EventHandler(this.stopAllAnimationsToolStripMenuItem_Click); // // changeMyDisplayNameToolStripMenuItem // this.changeMyDisplayNameToolStripMenuItem.Name = "changeMyDisplayNameToolStripMenuItem"; - this.changeMyDisplayNameToolStripMenuItem.Size = new System.Drawing.Size(223, 22); + this.changeMyDisplayNameToolStripMenuItem.Size = new System.Drawing.Size(221, 22); this.changeMyDisplayNameToolStripMenuItem.Text = "Change My Display Name"; this.changeMyDisplayNameToolStripMenuItem.Click += new System.EventHandler(this.changeMyDisplayNameToolStripMenuItem_Click); // // muteListToolStripMenuItem // this.muteListToolStripMenuItem.Name = "muteListToolStripMenuItem"; - this.muteListToolStripMenuItem.Size = new System.Drawing.Size(223, 22); + this.muteListToolStripMenuItem.Size = new System.Drawing.Size(221, 22); this.muteListToolStripMenuItem.Text = "Mute List"; this.muteListToolStripMenuItem.Click += new System.EventHandler(this.muteListToolStripMenuItem_Click); // // toolStripMenuItem4 // this.toolStripMenuItem4.Name = "toolStripMenuItem4"; - this.toolStripMenuItem4.Size = new System.Drawing.Size(220, 6); + this.toolStripMenuItem4.Size = new System.Drawing.Size(218, 6); // // tmnuCreateLandmark // this.tmnuCreateLandmark.Name = "tmnuCreateLandmark"; - this.tmnuCreateLandmark.Size = new System.Drawing.Size(223, 22); + this.tmnuCreateLandmark.Size = new System.Drawing.Size(221, 22); this.tmnuCreateLandmark.Text = "Create Landmark Here"; this.tmnuCreateLandmark.Click += new System.EventHandler(this.tmnuCreateLandmark_Click); // // tmnuSetHome // this.tmnuSetHome.Name = "tmnuSetHome"; - this.tmnuSetHome.Size = new System.Drawing.Size(223, 22); + this.tmnuSetHome.Size = new System.Drawing.Size(221, 22); this.tmnuSetHome.Text = "Set Home To Here"; this.tmnuSetHome.Click += new System.EventHandler(this.tmnuSetHome_Click); // @@ -411,7 +422,7 @@ private void InitializeComponent() // this.tmnuTeleportHome.Name = "tmnuTeleportHome"; this.tmnuTeleportHome.ShortcutKeyDisplayString = "Ctrl-Shift-H"; - this.tmnuTeleportHome.Size = new System.Drawing.Size(223, 22); + this.tmnuTeleportHome.Size = new System.Drawing.Size(221, 22); this.tmnuTeleportHome.Text = "Teleport Home"; this.tmnuTeleportHome.Click += new System.EventHandler(this.tmnuTeleportHome_Click); // @@ -419,7 +430,7 @@ private void InitializeComponent() // this.regionParcelToolStripMenuItem.Name = "regionParcelToolStripMenuItem"; this.regionParcelToolStripMenuItem.ShortcutKeyDisplayString = "Ctrl-Shift-1"; - this.regionParcelToolStripMenuItem.Size = new System.Drawing.Size(223, 22); + this.regionParcelToolStripMenuItem.Size = new System.Drawing.Size(221, 22); this.regionParcelToolStripMenuItem.Text = "Region/Parcel"; this.regionParcelToolStripMenuItem.Click += new System.EventHandler(this.regionParcelToolStripMenuItem_Click); // @@ -430,7 +441,7 @@ private void InitializeComponent() this.matureToolStripMenuItem, this.adultToolStripMenuItem}); this.setAccessLevelToolStripMenuItem.Name = "setAccessLevelToolStripMenuItem"; - this.setAccessLevelToolStripMenuItem.Size = new System.Drawing.Size(223, 22); + this.setAccessLevelToolStripMenuItem.Size = new System.Drawing.Size(221, 22); this.setAccessLevelToolStripMenuItem.Text = "Set Access Level"; this.setAccessLevelToolStripMenuItem.ToolTipText = "To which maturity level sims will you be able to teleport"; // @@ -458,13 +469,13 @@ private void InitializeComponent() // toolStripMenuItem5 // this.toolStripMenuItem5.Name = "toolStripMenuItem5"; - this.toolStripMenuItem5.Size = new System.Drawing.Size(220, 6); + this.toolStripMenuItem5.Size = new System.Drawing.Size(218, 6); // // tmnuStatusAway // this.tmnuStatusAway.CheckOnClick = true; this.tmnuStatusAway.Name = "tmnuStatusAway"; - this.tmnuStatusAway.Size = new System.Drawing.Size(223, 22); + this.tmnuStatusAway.Size = new System.Drawing.Size(221, 22); this.tmnuStatusAway.Text = "Away"; this.tmnuStatusAway.Click += new System.EventHandler(this.tmnuStatusAway_Click); // @@ -472,7 +483,7 @@ private void InitializeComponent() // this.tmnuStatusBusy.CheckOnClick = true; this.tmnuStatusBusy.Name = "tmnuStatusBusy"; - this.tmnuStatusBusy.Size = new System.Drawing.Size(223, 22); + this.tmnuStatusBusy.Size = new System.Drawing.Size(221, 22); this.tmnuStatusBusy.Text = "Busy"; this.tmnuStatusBusy.Click += new System.EventHandler(this.tmnuStatusBusy_Click); // @@ -485,12 +496,13 @@ private void InitializeComponent() this.reloadInventoryToolStripMenuItem, this.setAppearanceToolStripMenuItem, this.rebakeTexturesToolStripMenuItem, - this.myAttachmentsToolStripMenuItem}); + this.myAttachmentsToolStripMenuItem, + this.miniMapToolStripMenuItem}); this.tbnTools.Enabled = false; this.tbnTools.Image = ((System.Drawing.Image)(resources.GetObject("tbnTools.Image"))); this.tbnTools.ImageTransparentColor = System.Drawing.Color.Magenta; this.tbnTools.Name = "tbnTools"; - this.tbnTools.Size = new System.Drawing.Size(49, 22); + this.tbnTools.Size = new System.Drawing.Size(47, 22); this.tbnTools.Text = "&Tools"; // // autopilotToolStripMenuItem @@ -536,6 +548,13 @@ private void InitializeComponent() this.myAttachmentsToolStripMenuItem.Text = "My Attachments"; this.myAttachmentsToolStripMenuItem.Click += new System.EventHandler(this.myAttachmentsToolStripMenuItem_Click); // + // miniMapToolStripMenuItem + // + this.miniMapToolStripMenuItem.Name = "miniMapToolStripMenuItem"; + this.miniMapToolStripMenuItem.Size = new System.Drawing.Size(163, 22); + this.miniMapToolStripMenuItem.Text = "Mini Map"; + this.miniMapToolStripMenuItem.Click += new System.EventHandler(this.openMiniMapToolStripMenuItem_Click); + // // tbnPlugins // this.tbnPlugins.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; @@ -658,7 +677,7 @@ private void InitializeComponent() this.tbtnVoice.Image = ((System.Drawing.Image)(resources.GetObject("tbtnVoice.Image"))); this.tbtnVoice.ImageTransparentColor = System.Drawing.Color.Magenta; this.tbtnVoice.Name = "tbtnVoice"; - this.tbtnVoice.Size = new System.Drawing.Size(40, 22); + this.tbtnVoice.Size = new System.Drawing.Size(39, 22); this.tbtnVoice.Text = "Voice"; this.tbtnVoice.Click += new System.EventHandler(this.tbtnVoice_Click); // @@ -680,9 +699,9 @@ private void InitializeComponent() this.keyboardShortcutsToolStripMenuItem, this.reportBugsToolStripMenuItem, this.accessibilityGuideToolStripMenuItem, - this.checkForUpdatesToolStripMenuItem, - this.debugConsoleToolStripMenuItem, - this.toolStripMenuItem6, + this.toolStripSeparator5, + this.checkForUpdatesToolStripItem, + this.toolStripSeparator4, this.aboutRadegastToolStripMenuItem}); this.tbtnHelp.Image = ((System.Drawing.Image)(resources.GetObject("tbtnHelp.Image"))); this.tbtnHelp.ImageTransparentColor = System.Drawing.Color.Magenta; @@ -693,48 +712,36 @@ private void InitializeComponent() // keyboardShortcutsToolStripMenuItem // this.keyboardShortcutsToolStripMenuItem.Name = "keyboardShortcutsToolStripMenuItem"; - this.keyboardShortcutsToolStripMenuItem.Size = new System.Drawing.Size(223, 22); - this.keyboardShortcutsToolStripMenuItem.Text = "Keyboard Shortcuts"; + this.keyboardShortcutsToolStripMenuItem.Size = new System.Drawing.Size(203, 22); + this.keyboardShortcutsToolStripMenuItem.Text = "Keyboard Shortcuts..."; this.keyboardShortcutsToolStripMenuItem.Click += new System.EventHandler(this.keyboardShortcutsToolStripMenuItem_Click); // // reportBugsToolStripMenuItem // this.reportBugsToolStripMenuItem.Name = "reportBugsToolStripMenuItem"; - this.reportBugsToolStripMenuItem.Size = new System.Drawing.Size(223, 22); + this.reportBugsToolStripMenuItem.Size = new System.Drawing.Size(203, 22); this.reportBugsToolStripMenuItem.Text = "Bugs/Feature Requests..."; this.reportBugsToolStripMenuItem.Click += new System.EventHandler(this.reportBugsToolStripMenuItem_Click); // + // checkForUpdatesToolStripItem + // + this.checkForUpdatesToolStripItem.Name = "checkForUpdatesToolStripItem"; + this.checkForUpdatesToolStripItem.Size = new System.Drawing.Size(203, 22); + this.checkForUpdatesToolStripItem.Text = "Check For Updates..."; + this.checkForUpdatesToolStripItem.ToolTipText = "Checks Radegast server for an updated version of Radegast"; + this.checkForUpdatesToolStripItem.Click += new System.EventHandler(this.ctxCheckForUpdates_Click); + // // accessibilityGuideToolStripMenuItem // this.accessibilityGuideToolStripMenuItem.Name = "accessibilityGuideToolStripMenuItem"; - this.accessibilityGuideToolStripMenuItem.Size = new System.Drawing.Size(223, 22); - this.accessibilityGuideToolStripMenuItem.Text = "Accessibility Guide"; + this.accessibilityGuideToolStripMenuItem.Size = new System.Drawing.Size(203, 22); + this.accessibilityGuideToolStripMenuItem.Text = "Accessibility Guide..."; this.accessibilityGuideToolStripMenuItem.Click += new System.EventHandler(this.accessibilityGuideToolStripMenuItem_Click); // - // checkForUpdatesToolStripMenuItem - // - this.checkForUpdatesToolStripMenuItem.Name = "checkForUpdatesToolStripMenuItem"; - this.checkForUpdatesToolStripMenuItem.Size = new System.Drawing.Size(223, 22); - this.checkForUpdatesToolStripMenuItem.Text = "Check for Updates..."; - this.checkForUpdatesToolStripMenuItem.Click += new System.EventHandler(this.checkForUpdatesToolStripMenuItem_Click); - // - // debugConsoleToolStripMenuItem - // - this.debugConsoleToolStripMenuItem.Name = "debugConsoleToolStripMenuItem"; - this.debugConsoleToolStripMenuItem.ShortcutKeyDisplayString = "Alt-Ctrl-D"; - this.debugConsoleToolStripMenuItem.Size = new System.Drawing.Size(223, 22); - this.debugConsoleToolStripMenuItem.Text = "Debug Console..."; - this.debugConsoleToolStripMenuItem.Click += new System.EventHandler(this.debugConsoleToolStripMenuItem_Click); - // - // toolStripMenuItem6 - // - this.toolStripMenuItem6.Name = "toolStripMenuItem6"; - this.toolStripMenuItem6.Size = new System.Drawing.Size(220, 6); - // // aboutRadegastToolStripMenuItem // this.aboutRadegastToolStripMenuItem.Name = "aboutRadegastToolStripMenuItem"; - this.aboutRadegastToolStripMenuItem.Size = new System.Drawing.Size(223, 22); + this.aboutRadegastToolStripMenuItem.Size = new System.Drawing.Size(203, 22); this.aboutRadegastToolStripMenuItem.Text = "About Radegast..."; this.aboutRadegastToolStripMenuItem.Click += new System.EventHandler(this.aboutRadegastToolStripMenuItem_Click); // @@ -743,6 +750,14 @@ private void InitializeComponent() this.toolStripSeparator2.Name = "toolStripSeparator2"; this.toolStripSeparator2.Size = new System.Drawing.Size(6, 25); // + // debugConsoleToolStripMenuItem + // + this.debugConsoleToolStripMenuItem.Name = "debugConsoleToolStripMenuItem"; + this.debugConsoleToolStripMenuItem.ShortcutKeyDisplayString = "Alt-Ctrl-D"; + this.debugConsoleToolStripMenuItem.Size = new System.Drawing.Size(223, 22); + this.debugConsoleToolStripMenuItem.Text = "Debug Console..."; + this.debugConsoleToolStripMenuItem.Click += new System.EventHandler(this.debugConsoleToolStripMenuItem_Click); + // // statusStrip1 // this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -904,7 +919,7 @@ private void InitializeComponent() // this.trayIcon.ContextMenuStrip = this.ctxTrayIcon; this.trayIcon.Icon = ((System.Drawing.Icon)(resources.GetObject("trayIcon.Icon"))); - this.trayIcon.Text = "Radegast"; + this.trayIcon.Text = "Radegast-ng"; this.trayIcon.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.treyIcon_MouseDoubleClick); // // ctxTrayIcon @@ -916,23 +931,23 @@ private void InitializeComponent() this.toolStripSeparator3, this.ctxTreyExit}); this.ctxTrayIcon.Name = "ctxTreyIcon"; - this.ctxTrayIcon.Size = new System.Drawing.Size(123, 82); + this.ctxTrayIcon.Size = new System.Drawing.Size(142, 82); // // ctxTrayMenuLabel // this.ctxTrayMenuLabel.Name = "ctxTrayMenuLabel"; - this.ctxTrayMenuLabel.Size = new System.Drawing.Size(122, 22); - this.ctxTrayMenuLabel.Text = "Radegast"; + this.ctxTrayMenuLabel.Size = new System.Drawing.Size(141, 22); + this.ctxTrayMenuLabel.Text = "Radegast-ng"; // // toolStripMenuItem1 // this.toolStripMenuItem1.Name = "toolStripMenuItem1"; - this.toolStripMenuItem1.Size = new System.Drawing.Size(119, 6); + this.toolStripMenuItem1.Size = new System.Drawing.Size(138, 6); // // ctxTreyRestore // this.ctxTreyRestore.Name = "ctxTreyRestore"; - this.ctxTreyRestore.Size = new System.Drawing.Size(122, 22); + this.ctxTreyRestore.Size = new System.Drawing.Size(141, 22); this.ctxTreyRestore.Text = "Restore"; this.ctxTreyRestore.ToolTipText = "Restore Window"; this.ctxTreyRestore.Click += new System.EventHandler(this.ctxTreyRestore_Click); @@ -940,16 +955,26 @@ private void InitializeComponent() // toolStripSeparator3 // this.toolStripSeparator3.Name = "toolStripSeparator3"; - this.toolStripSeparator3.Size = new System.Drawing.Size(119, 6); + this.toolStripSeparator3.Size = new System.Drawing.Size(138, 6); // // ctxTreyExit // this.ctxTreyExit.Name = "ctxTreyExit"; - this.ctxTreyExit.Size = new System.Drawing.Size(122, 22); + this.ctxTreyExit.Size = new System.Drawing.Size(141, 22); this.ctxTreyExit.Text = "Exit"; - this.ctxTreyExit.ToolTipText = "Loggs of and closes application"; + this.ctxTreyExit.ToolTipText = "Logs off and closes application"; this.ctxTreyExit.Click += new System.EventHandler(this.ctxTreyExit_Click); // + // toolStripSeparator4 + // + this.toolStripSeparator4.Name = "toolStripSeparator4"; + this.toolStripSeparator4.Size = new System.Drawing.Size(200, 6); + // + // toolStripSeparator5 + // + this.toolStripSeparator5.Name = "toolStripSeparator5"; + this.toolStripSeparator5.Size = new System.Drawing.Size(200, 6); + // // frmMain // this.AutoSavePosition = true; @@ -959,12 +984,12 @@ private void InitializeComponent() this.Controls.Add(this.pnlDialog); this.Controls.Add(this.toolStripContainer1); this.Controls.Add(this.statusStrip1); - this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.KeyPreview = true; this.MinimumSize = new System.Drawing.Size(754, 541); this.Name = "frmMain"; - this.Text = "Radegast"; + this.Text = "Radegast-ng"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.frmMain_FormClosing); this.Load += new System.EventHandler(this.frmMain_Load); this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.frmMain_KeyDown); @@ -1044,7 +1069,6 @@ private void InitializeComponent() public System.Windows.Forms.ToolStripDropDownButton tbtnHelp; public System.Windows.Forms.ToolStripMenuItem reportBugsToolStripMenuItem; public System.Windows.Forms.ToolStripMenuItem aboutRadegastToolStripMenuItem; - public System.Windows.Forms.ToolStripSeparator toolStripMenuItem6; public System.Windows.Forms.ToolStripMenuItem checkForUpdatesToolStripMenuItem; public System.Windows.Forms.ToolStripButton tbtnFriends; public System.Windows.Forms.ToolStripButton tbtnInventory; @@ -1062,6 +1086,7 @@ private void InitializeComponent() public System.Windows.Forms.ToolStripMenuItem uploadImageToolStripMenuItem; public System.Windows.Forms.ToolStripMenuItem muteListToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem myAttachmentsToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem miniMapToolStripMenuItem; public System.Windows.Forms.ToolStripButton tsb3D; public System.Windows.Forms.ToolStripMenuItem loginToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem accessibilityGuideToolStripMenuItem; @@ -1070,6 +1095,10 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripMenuItem matureToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem adultToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem uploadmeshToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem setHoverHeightToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem checkForUpdatesToolStripItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator5; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator4; } } diff --git a/Radegast/GUI/Dialogs/MainForm.cs b/Radegast/GUI/Dialogs/MainForm.cs index 44f3a73bb..564c958ad 100644 --- a/Radegast/GUI/Dialogs/MainForm.cs +++ b/Radegast/GUI/Dialogs/MainForm.cs @@ -1,55 +1,39 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2021, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections.Generic; using System.Drawing; +using System.Globalization; using System.Text; using System.Text.RegularExpressions; using System.Timers; -#if (COGBOT_LIBOMV || USE_STHREADS) -using ThreadPoolUtil; -using Thread = ThreadPoolUtil.Thread; -using ThreadPool = ThreadPoolUtil.ThreadPool; -using Monitor = ThreadPoolUtil.Monitor; -#endif using System.Threading; using System.Windows.Forms; using System.Resources; using System.IO; using System.Web; -using Radegast.Netcom; +using Radegast; using OpenMetaverse; -using OpenMetaverse.StructuredData; -using OpenMetaverse.Assets; +using NetSparkleUpdater.SignatureVerifiers; namespace Radegast { @@ -62,78 +46,45 @@ public partial class frmMain : RadegastForm public delegate void ProfileHandlerDelegate(string agentName, UUID agentID); public ProfileHandlerDelegate ShowAgentProfile; - public TabsConsole TabConsole - { - get { return tabsConsole; } - } + public TabsConsole TabConsole { get; private set; } - public MapConsole WorldMap - { - get - { - if (MapTab != null) - { - return (MapConsole)MapTab.Control; - } - return null; - } - } + public MapConsole WorldMap => (MapConsole) MapTab?.Control; - public RadegastTab MapTab - { - get - { - if (tabsConsole.TabExists("map")) - { - return tabsConsole.Tabs["map"]; - } - else - { - return null; - } - } - } + public RadegastTab MapTab => + TabConsole.TabExists("map") + ? TabConsole.Tabs["map"] : null; - public MediaConsole MediaConsole { get { return mediaConsole; } } + public MediaConsole MediaConsole { get; private set; } /// /// Drop down that contains the tools menu /// - public ToolStripDropDownButton ToolsMenu - { - get { return tbnTools; } - } + public ToolStripDropDownButton ToolsMenu => tbnTools; /// /// Dropdown that contains the heelp menu /// - public ToolStripDropDownButton HelpMenu - { - get { return tbtnHelp; } - } + public ToolStripDropDownButton HelpMenu => tbtnHelp; /// /// Drop down that contants the plugins menu. Make sure to set it Visible if /// you add items to this menu, it's hidden by default /// - public ToolStripDropDownButton PluginsMenu - { - get { return tbnPlugins; } - } + public ToolStripDropDownButton PluginsMenu => tbnPlugins; #endregion #region Private members private RadegastInstance instance; - private GridClient client { get { return instance.Client; } } - private RadegastNetcom netcom { get { return instance.Netcom; } } - private TabsConsole tabsConsole; + private GridClient client => instance.Client; + private Radegast.Netcom netcom => instance.Netcom; private System.Timers.Timer statusTimer; private AutoPilot ap; private bool AutoPilotActive = false; private TransparentButton btnDialogNextControl; - private MediaConsole mediaConsole; private SlUriParser uriParser; + private NetSparkleUpdater.SparkleUpdater SparkleUpdater; + #endregion #region Constructor and disposal @@ -141,10 +92,10 @@ public frmMain(RadegastInstance instance) : base(instance) { InitializeComponent(); - Disposed += new EventHandler(frmMain_Disposed); + Disposed += frmMain_Disposed; this.instance = instance; - this.instance.ClientChanged += new EventHandler(instance_ClientChanged); + this.instance.ClientChanged += instance_ClientChanged; netcom.NetcomSync = this; ShowAgentProfile = ShowAgentProfileInternal; @@ -167,7 +118,7 @@ public frmMain(RadegastInstance instance) btnDialogNextControl.UseVisualStyleBackColor = false; btnDialogNextControl.Top = btnDialogNextControl.Parent.ClientSize.Height - btnDialogNextControl.Size.Height; btnDialogNextControl.Left = btnDialogNextControl.Parent.ClientSize.Width - btnDialogNextControl.Size.Width; - btnDialogNextControl.Click += new EventHandler(btnDialogNextControl_Click); + btnDialogNextControl.Click += btnDialogNextControl_Click; if (instance.MonoRuntime) { @@ -175,30 +126,40 @@ public frmMain(RadegastInstance instance) } // Callbacks - netcom.ClientLoginStatus += new EventHandler(netcom_ClientLoginStatus); - netcom.ClientLoggedOut += new EventHandler(netcom_ClientLoggedOut); - netcom.ClientDisconnected += new EventHandler(netcom_ClientDisconnected); - instance.Names.NameUpdated += new EventHandler(Names_NameUpdated); + netcom.ClientLoginStatus += netcom_ClientLoginStatus; + netcom.ClientLoggedOut += netcom_ClientLoggedOut; + netcom.ClientDisconnected += netcom_ClientDisconnected; + instance.Names.NameUpdated += Names_NameUpdated; + client.Network.SimChanged += Network_SimChanged; + RegisterClientEvents(client); InitializeStatusTimer(); RefreshWindowTitle(); - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); + + InitUpdater(); + } + + private void Network_SimChanged(object sender, SimChangedEventArgs e) + { + SetHoverHeightFromSettings(); + client.Network.CurrentSim.Caps.CapabilitiesReceived += Caps_CapabilitiesReceived; } private void RegisterClientEvents(GridClient client) { - client.Parcels.ParcelProperties += new EventHandler(Parcels_ParcelProperties); - client.Self.MoneyBalanceReply += new EventHandler(Self_MoneyBalanceReply); - client.Self.MoneyBalance += new EventHandler(Self_MoneyBalance); + client.Parcels.ParcelProperties += Parcels_ParcelProperties; + client.Self.MoneyBalanceReply += Self_MoneyBalanceReply; + client.Self.MoneyBalance += Self_MoneyBalance; } private void UnregisterClientEvents(GridClient client) { - client.Parcels.ParcelProperties -= new EventHandler(Parcels_ParcelProperties); - client.Self.MoneyBalanceReply -= new EventHandler(Self_MoneyBalanceReply); - client.Self.MoneyBalance -= new EventHandler(Self_MoneyBalance); + client.Parcels.ParcelProperties -= Parcels_ParcelProperties; + client.Self.MoneyBalanceReply -= Self_MoneyBalanceReply; + client.Self.MoneyBalance -= Self_MoneyBalance; } void instance_ClientChanged(object sender, ClientChangedEventArgs e) @@ -212,9 +173,9 @@ void frmMain_Disposed(object sender, EventArgs e) if (netcom != null) { netcom.NetcomSync = null; - netcom.ClientLoginStatus -= new EventHandler(netcom_ClientLoginStatus); - netcom.ClientLoggedOut -= new EventHandler(netcom_ClientLoggedOut); - netcom.ClientDisconnected -= new EventHandler(netcom_ClientDisconnected); + netcom.ClientLoginStatus -= netcom_ClientLoginStatus; + netcom.ClientLoggedOut -= netcom_ClientLoggedOut; + netcom.ClientDisconnected -= netcom_ClientDisconnected; } if (client != null) @@ -222,12 +183,12 @@ void frmMain_Disposed(object sender, EventArgs e) UnregisterClientEvents(client); } - if (instance != null && instance.Names != null) + if (instance?.Names != null) { - instance.Names.NameUpdated -= new EventHandler(Names_NameUpdated); + instance.Names.NameUpdated -= Names_NameUpdated; } - this.instance.CleanUp(); + if (instance != null) instance.CleanUp(); } #endregion @@ -245,17 +206,10 @@ void Self_MoneyBalance(object sender, BalanceEventArgs e) } else { - if (delta > 50) - { - if (oldBalance > e.Balance) - { - instance.MediaManager.PlayUISound(UISounds.MoneyIn); - } - else - { - instance.MediaManager.PlayUISound(UISounds.MoneyOut); - } - } + if (delta <= 50) return; + + instance.MediaManager.PlayUISound(oldBalance > e.Balance + ? UISounds.MoneyIn : UISounds.MoneyOut); } } @@ -278,13 +232,12 @@ void Names_NameUpdated(object sender, UUIDNameReplyEventArgs e) void Self_MoneyBalanceReply(object sender, MoneyBalanceReplyEventArgs e) { - if (!String.IsNullOrEmpty(e.Description)) - { - if (instance.GlobalSettings["transaction_notification_dialog"].AsBoolean()) - AddNotification(new ntfGeneric(instance, e.Description)); - if (instance.GlobalSettings["transaction_notification_chat"].AsBoolean()) - TabConsole.DisplayNotificationInChat(e.Description); - } + if (String.IsNullOrEmpty(e.Description)) return; + + if (instance.GlobalSettings["transaction_notification_dialog"].AsBoolean()) + AddNotification(new ntfGeneric(instance, e.Description)); + if (instance.GlobalSettings["transaction_notification_chat"].AsBoolean()) + TabConsole.DisplayNotificationInChat(e.Description); } public void InitializeControls() @@ -292,11 +245,10 @@ public void InitializeControls() InitializeTabsConsole(); uriParser = new SlUriParser(); - if (instance.MediaManager.SoundSystemAvailable) - { - mediaConsole = new MediaConsole(instance); - tbtnMedia.Visible = true; - } + if (!instance.MediaManager.SoundSystemAvailable) return; + + MediaConsole = new MediaConsole(instance); + tbtnMedia.Visible = true; } public bool InAutoReconnect { get; set; } @@ -322,12 +274,11 @@ public void BeginAutoReconnect() { // Sleep for 3 seconds on a separate thread while things unwind on // disconnect, since ShowDialog() blocks GUI thread - (new Thread(new ThreadStart(() => - { - System.Threading.Thread.Sleep(3000); - DisplayAutoReconnectForm(); - } - )) + (new Thread(() => + { + Thread.Sleep(3000); + DisplayAutoReconnectForm(); + }) { Name = "Reconnect Delay Thread", IsBackground = true @@ -339,13 +290,12 @@ private void netcom_ClientLoginStatus(object sender, LoginProgressEventArgs e) { if (e.Status == LoginStatus.Failed) { - if (InAutoReconnect) - { - if (instance.GlobalSettings["auto_reconnect"].AsBoolean() && e.FailReason != "tos") - BeginAutoReconnect(); - else - InAutoReconnect = false; - } + if (!InAutoReconnect) return; + + if (instance.GlobalSettings["auto_reconnect"].AsBoolean() && e.FailReason != "tos") + BeginAutoReconnect(); + else + InAutoReconnect = false; } else if (e.Status == LoginStatus.Success) { @@ -358,6 +308,12 @@ private void netcom_ClientLoginStatus(object sender, LoginProgressEventArgs e) statusTimer.Start(); RefreshWindowTitle(); + + if (instance.GlobalSettings.ContainsKey("AvatarHoverOffsetZ")) + { + var hoverHeight = instance.GlobalSettings["AvatarHoverOffsetZ"]; + Client.Self.SetHoverHeight(hoverHeight); + } } } @@ -371,8 +327,7 @@ private void netcom_ClientLoggedOut(object sender, EventArgs e) loginToolStripMenuItem.Enabled = true; InAutoReconnect = false; - if (statusTimer != null) - statusTimer.Stop(); + statusTimer?.Stop(); RefreshStatusBar(); RefreshWindowTitle(); @@ -395,7 +350,8 @@ private void frmMain_FormClosing(object sender, FormClosingEventArgs e) { if (instance.GlobalSettings["confirm_exit"].AsBoolean()) { - if (MessageBox.Show("Are you sure you want to exit Radegast?", "Confirm Exit", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != System.Windows.Forms.DialogResult.Yes) + if (MessageBox.Show("Are you sure you want to exit Radegast?", "Confirm Exit", + MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) { e.Cancel = true; return; @@ -409,32 +365,32 @@ private void frmMain_FormClosing(object sender, FormClosingEventArgs e) statusTimer = null; } - if (mediaConsole != null) + if (MediaConsole != null) { - if (tabsConsole.TabExists("media")) + if (TabConsole.TabExists("media")) { - tabsConsole.Tabs["media"].AllowClose = true; - tabsConsole.Tabs["media"].Close(); + TabConsole.Tabs["media"].AllowClose = true; + TabConsole.Tabs["media"].Close(); } else { - mediaConsole.Dispose(); + MediaConsole.Dispose(); } - mediaConsole = null; + MediaConsole = null; } - if (netcom.IsLoggedIn) + if (!netcom.IsLoggedIn) return; + + Thread saveInvToDisk = new Thread(delegate() { - Thread saveInvToDisk = new Thread(new ThreadStart( - delegate() - { - client.Inventory.Store.SaveToDisk(instance.InventoryCacheFileName); - })); - saveInvToDisk.Name = "Save inventory to disk"; - saveInvToDisk.Start(); + client.Inventory.Store.SaveToDisk(instance.InventoryCacheFileName); + }) + { + Name = "Save inventory to disk" + }; + saveInvToDisk.Start(); - netcom.Logout(); - } + netcom.Logout(); } #endregion @@ -454,35 +410,12 @@ void Parcels_ParcelProperties(object sender, ParcelPropertiesEventArgs e) tlblParcel.Text = parcel.Name; tlblParcel.ToolTipText = parcel.Desc; - if ((parcel.Flags & ParcelFlags.AllowFly) != ParcelFlags.AllowFly) - icoNoFly.Visible = true; - else - icoNoFly.Visible = false; - - if ((parcel.Flags & ParcelFlags.CreateObjects) != ParcelFlags.CreateObjects) - icoNoBuild.Visible = true; - else - icoNoBuild.Visible = false; - - if ((parcel.Flags & ParcelFlags.AllowOtherScripts) != ParcelFlags.AllowOtherScripts) - icoNoScript.Visible = true; - else - icoNoScript.Visible = false; - - if ((parcel.Flags & ParcelFlags.RestrictPushObject) == ParcelFlags.RestrictPushObject) - icoNoPush.Visible = true; - else - icoNoPush.Visible = false; - - if ((parcel.Flags & ParcelFlags.AllowDamage) == ParcelFlags.AllowDamage) - icoHealth.Visible = true; - else - icoHealth.Visible = false; - - if ((parcel.Flags & ParcelFlags.AllowVoiceChat) != ParcelFlags.AllowVoiceChat) - icoNoVoice.Visible = true; - else - icoNoVoice.Visible = false; + icoNoFly.Visible = (parcel.Flags & ParcelFlags.AllowFly) != ParcelFlags.AllowFly; + icoNoBuild.Visible = (parcel.Flags & ParcelFlags.CreateObjects) != ParcelFlags.CreateObjects; + icoNoScript.Visible = (parcel.Flags & ParcelFlags.AllowOtherScripts) != ParcelFlags.AllowOtherScripts; + icoNoPush.Visible = (parcel.Flags & ParcelFlags.RestrictPushObject) == ParcelFlags.RestrictPushObject; + icoHealth.Visible = (parcel.Flags & ParcelFlags.AllowDamage) == ParcelFlags.AllowDamage; + icoNoVoice.Visible = (parcel.Flags & ParcelFlags.AllowVoiceChat) != ParcelFlags.AllowVoiceChat; } private void RefreshStatusBar() @@ -491,20 +424,20 @@ private void RefreshStatusBar() { tlblLoginName.Text = instance.Names.Get(client.Self.AgentID, client.Self.Name); tlblMoneyBalance.Text = client.Self.Balance.ToString(); - icoHealth.Text = client.Self.Health.ToString() + "%"; + icoHealth.Text = client.Self.Health.ToString(CultureInfo.CurrentCulture) + @"%"; var cs = client.Network.CurrentSim; tlblRegionInfo.Text = (cs == null ? "No region" : cs.Name) + - " (" + Math.Floor(client.Self.SimPosition.X).ToString() + ", " + - Math.Floor(client.Self.SimPosition.Y).ToString() + ", " + - Math.Floor(client.Self.SimPosition.Z).ToString() + ")"; + @" (" + Math.Floor(client.Self.SimPosition.X).ToString(CultureInfo.CurrentCulture) + @", " + + Math.Floor(client.Self.SimPosition.Y).ToString(CultureInfo.CurrentCulture) + @", " + + Math.Floor(client.Self.SimPosition.Z).ToString(CultureInfo.CurrentCulture) + @")"; } else { tlblLoginName.Text = "Offline"; - tlblMoneyBalance.Text = "0"; - icoHealth.Text = "0%"; + tlblMoneyBalance.Text = @"0"; + icoHealth.Text = @"0%"; tlblRegionInfo.Text = "No Region"; tlblParcel.Text = "No Parcel"; @@ -548,7 +481,7 @@ private void RefreshWindowTitle() sb.Append("Logged Out"); } - this.Text = sb.ToString(); + Text = sb.ToString(); // When minimized to tray, update tray tool tip also if (WindowState == FormWindowState.Minimized && instance.GlobalSettings["minimize_to_tray"]) @@ -562,9 +495,8 @@ private void RefreshWindowTitle() private void InitializeStatusTimer() { - statusTimer = new System.Timers.Timer(250); - statusTimer.SynchronizingObject = this; - statusTimer.Elapsed += new ElapsedEventHandler(statusTimer_Elapsed); + statusTimer = new System.Timers.Timer(250) {SynchronizingObject = this}; + statusTimer.Elapsed += statusTimer_Elapsed; } private void statusTimer_Elapsed(object sender, ElapsedEventArgs e) @@ -582,9 +514,8 @@ private void statusTimer_Elapsed(object sender, ElapsedEventArgs e) #region Initialization, configuration, and key shortcuts private void InitializeTabsConsole() { - tabsConsole = new TabsConsole(instance); - tabsConsole.Dock = DockStyle.Fill; - toolStripContainer1.ContentPanel.Controls.Add(tabsConsole); + TabConsole = new TabsConsole(instance) {Dock = DockStyle.Fill}; + toolStripContainer1.ContentPanel.Controls.Add(TabConsole); } private void frmMain_KeyDown(object sender, KeyEventArgs e) @@ -609,7 +540,7 @@ private void frmMain_KeyDown(object sender, KeyEventArgs e) if (e.Modifiers == Keys.Control && e.KeyCode == Keys.W) { e.Handled = e.SuppressKeyPress = true; - RadegastTab tab = tabsConsole.SelectedTab; + RadegastTab tab = TabConsole.SelectedTab; if (tab.AllowClose) { @@ -646,7 +577,7 @@ private void frmMain_KeyDown(object sender, KeyEventArgs e) { case Keys.D1: e.Handled = e.SuppressKeyPress = true; - tabsConsole.Tabs["chat"].Select(); + TabConsole.Tabs["chat"].Select(); return; case Keys.D2: @@ -713,7 +644,6 @@ private void frmMain_KeyDown(object sender, KeyEventArgs e) TabConsole.SelectNextTab(); } e.Handled = e.SuppressKeyPress = true; - return; } } @@ -721,29 +651,26 @@ private void frmMain_KeyDown(object sender, KeyEventArgs e) private void frmMain_Load(object sender, EventArgs e) { - if (firstLoad) - { - firstLoad = false; - tabsConsole.SelectTab("login"); - ResourceManager rm = Properties.Resources.ResourceManager; - ResourceSet set = rm.GetResourceSet(System.Globalization.CultureInfo.CurrentCulture, true, true); - System.Collections.IDictionaryEnumerator de = set.GetEnumerator(); - while (de.MoveNext() == true) - { - if (de.Entry.Value is Image) - { - Bitmap bitMap = de.Entry.Value as Bitmap; - ResourceImages.Images.Add(bitMap); - ImageNames.Add(de.Entry.Key.ToString()); - } - } - StartUpdateCheck(false); + if (!firstLoad) return; - if (!instance.GlobalSettings["theme_compatibility_mode"] && instance.PlainColors) + firstLoad = false; + TabConsole.SelectTab("login"); + ResourceManager rm = Properties.Resources.ResourceManager; + ResourceSet set = rm.GetResourceSet(CultureInfo.CurrentCulture, true, true); + System.Collections.IDictionaryEnumerator de = set.GetEnumerator(); + while (de.MoveNext()) + { + if (de.Entry.Value is Image) { - pnlDialog.BackColor = System.Drawing.Color.FromArgb(120, 220, 255); + Bitmap bitMap = de.Entry.Value as Bitmap; + ResourceImages.Images.Add(bitMap); + ImageNames.Add(de.Entry.Key.ToString()); } + } + if (!instance.GlobalSettings["theme_compatibility_mode"] && instance.PlainColors) + { + pnlDialog.BackColor = Color.FromArgb(120, 220, 255); } } #endregion @@ -766,7 +693,7 @@ void ShowAgentProfileInternal(string name, UUID agentID) { profile = new frmProfile(instance, name, agentID); - profile.Disposed += (object sender, EventArgs e) => + profile.Disposed += (sender, e) => { lock (shownProfiles) { @@ -824,7 +751,7 @@ public void ShowGroupProfile(OpenMetaverse.Group group) { profile = new frmGroupInfo(instance, group); - profile.Disposed += (object sender, EventArgs e) => + profile.Disposed += (sender, e) => { lock (shownGroupProfiles) { @@ -902,18 +829,15 @@ public bool ProcessLink(string link, bool onlyMap) #region Notifications CircularList notifications = new CircularList(); - public Color NotificationBackground - { - get { return pnlDialog.BackColor; } - } + public Color NotificationBackground => pnlDialog.BackColor; void ResizeNotificationByControl(Control active) { - int Width = active.Size.Width + 6; - int Height = notifications.Count > 1 ? active.Size.Height + 3 + btnDialogNextControl.Size.Height : active.Size.Height + 3; - pnlDialog.Size = new Size(Width, Height); + int width = active.Size.Width + 6; + int height = notifications.Count > 1 ? active.Size.Height + 3 + btnDialogNextControl.Size.Height : active.Size.Height + 3; + pnlDialog.Size = new Size(width, height); pnlDialog.Top = 0; - pnlDialog.Left = pnlDialog.Parent.ClientSize.Width - Width; + pnlDialog.Left = pnlDialog.Parent.ClientSize.Width - width; btnDialogNextControl.Top = btnDialogNextControl.Parent.ClientSize.Height - btnDialogNextControl.Size.Height; btnDialogNextControl.Left = btnDialogNextControl.Parent.ClientSize.Width - btnDialogNextControl.Size.Width; @@ -944,6 +868,8 @@ public void AddNotification(Control control) existing.Visible = false; } + instance.MediaManager.PlayUISound(UISounds.WindowOpen); + notifications.Add(control); control.Visible = true; control.Anchor = AnchorStyles.Top | AnchorStyles.Left; @@ -954,10 +880,7 @@ public void AddNotification(Control control) btnDialogNextControl.Visible = notifications.Count > 1; - if (active != null) - { - active.Focus(); - } + active?.Focus(); } public void RemoveNotification(Control control) @@ -1112,7 +1035,7 @@ private void deleteFolder(DirectoryInfo dir) private void cleanCacheToolStripMenuItem_Click(object sender, EventArgs e) { - WorkPool.QueueUserWorkItem(sync => + ThreadPool.QueueUserWorkItem(sync => { filesDeleted = 0; try { deleteFolder(new DirectoryInfo(client.Settings.ASSET_CACHE_DIR)); } @@ -1129,14 +1052,13 @@ private void rebakeTexturesToolStripMenuItem_Click(object sender, EventArgs e) public void MapToCurrentLocation() { - if (MapTab != null && client.Network.Connected) - { - MapTab.Select(); - WorldMap.DisplayLocation(client.Network.CurrentSim.Name, - (int)client.Self.SimPosition.X, - (int)client.Self.SimPosition.Y, - (int)client.Self.SimPosition.Z); - } + if (MapTab == null || !client.Network.Connected) return; + + MapTab.Select(); + WorldMap.DisplayLocation(client.Network.CurrentSim.Name, + (int)client.Self.SimPosition.X, + (int)client.Self.SimPosition.Y, + (int)client.Self.SimPosition.Z); } private void standToolStripMenuItem_Click(object sender, EventArgs e) @@ -1170,8 +1092,7 @@ private void tlblRegionInfo_Click(object sender, EventArgs e) private void scriptEditorToolStripMenuItem_Click(object sender, EventArgs e) { - ScriptEditor se = new ScriptEditor(instance); - se.Dock = DockStyle.Fill; + ScriptEditor se = new ScriptEditor(instance) {Dock = DockStyle.Fill}; se.ShowDetached(); } @@ -1186,8 +1107,7 @@ private void tmnuCreateLandmark_Click(object sender, EventArgs e) client.Network.CurrentSim.Name, (int)client.Self.SimPosition.X, (int)client.Self.SimPosition.Y, - (int)client.Self.SimPosition.Z - ); + (int)client.Self.SimPosition.Z); string name = tlblParcel.Text; int maxLen = 63 - location.Length; @@ -1205,15 +1125,16 @@ private void tmnuCreateLandmark_Click(object sender, EventArgs e) UUID.Random(), InventoryType.Landmark, PermissionMask.All, - (bool success, InventoryItem item) => + (success, item) => { if (success) { BeginInvoke(new MethodInvoker(() => { - Landmark ln = new Landmark(instance, (InventoryLandmark)item); - ln.Dock = DockStyle.Fill; - ln.Detached = true; + Landmark ln = new Landmark(instance, (InventoryLandmark) item) + { + Dock = DockStyle.Fill, Detached = true + }; })); } } @@ -1223,17 +1144,17 @@ private void tmnuCreateLandmark_Click(object sender, EventArgs e) private void timerWorldClock_Tick(object sender, EventArgs e) { - lblTime.Text = instance.GetWorldTime().ToString("h:mm tt", System.Globalization.CultureInfo.InvariantCulture); + lblTime.Text = instance.GetWorldTime().ToString("h:mm tt", CultureInfo.InvariantCulture); } private void reportBugsToolStripMenuItem_Click(object sender, EventArgs e) { - ProcessLink("https://metaverse.atlassian.net/browse/RAD"); + ProcessLink("https://radegast.life/bugs/issue-entry/"); } private void accessibilityGuideToolStripMenuItem_Click(object sender, EventArgs e) { - ProcessLink("http://radegast.org/wiki/Accessibility_Guide"); + ProcessLink("https://radegast.life/documentation/help/"); } private void aboutRadegastToolStripMenuItem_Click(object sender, EventArgs e) @@ -1241,75 +1162,11 @@ private void aboutRadegastToolStripMenuItem_Click(object sender, EventArgs e) (new frmAbout(instance)).ShowDialog(); } - #region Update Checking - private UpdateChecker updateChecker = null; - private bool ManualUpdateCheck = false; - - public void StartUpdateCheck(bool userInitiated) - { - ManualUpdateCheck = userInitiated; - - if (updateChecker != null) - { - if (ManualUpdateCheck) - tabsConsole.DisplayNotificationInChat("Update check already in progress."); - return; - } - - if (ManualUpdateCheck) - tabsConsole.DisplayNotificationInChat("Checking for updates...", ChatBufferTextStyle.StatusBlue); - updateChecker = new UpdateChecker(); - updateChecker.OnUpdateInfoReceived += new UpdateChecker.UpdateInfoCallback(OnUpdateInfoReceived); - updateChecker.StartCheck(); - } - - private void checkForUpdatesToolStripMenuItem_Click(object sender, EventArgs e) - { - tabsConsole.SelectTab("chat"); - StartUpdateCheck(true); - } - - void OnUpdateInfoReceived(object sender, UpdateCheckerArgs e) - { - if (InvokeRequired) - { - BeginInvoke(new MethodInvoker(() => OnUpdateInfoReceived(sender, e))); - return; - } - - if (!e.Success) - { - if (ManualUpdateCheck) - tabsConsole.DisplayNotificationInChat("Error: Failed connecting to the update site.", ChatBufferTextStyle.StatusBlue); - } - else - { - if (!ManualUpdateCheck && e.Info.DisplayMOTD) - { - tabsConsole.DisplayNotificationInChat(e.Info.MOTD, ChatBufferTextStyle.StatusBlue); - } - - if (e.Info.UpdateAvailable) - { - tabsConsole.DisplayNotificationInChat("New version available at " + e.Info.DownloadSite, ChatBufferTextStyle.Alert); - } - else - { - if (ManualUpdateCheck) - tabsConsole.DisplayNotificationInChat("Your version is up to date.", ChatBufferTextStyle.StatusBlue); - } - } - - updateChecker.Dispose(); - updateChecker = null; - } - #endregion - private void ToggleHidden(string tabName) { - if (!tabsConsole.TabExists(tabName)) return; + if (!TabConsole.TabExists(tabName)) return; - RadegastTab tab = tabsConsole.Tabs[tabName]; + RadegastTab tab = TabConsole.Tabs[tabName]; if (tab.Hidden) { @@ -1355,13 +1212,13 @@ private void tbtnVoice_Click(object sender, EventArgs e) private void tbtnMedia_Click(object sender, EventArgs e) { - if (tabsConsole.TabExists("media")) + if (TabConsole.TabExists("media")) { ToggleHidden("media"); } else { - RadegastTab tab = tabsConsole.AddTab("media", "Media", mediaConsole); + RadegastTab tab = TabConsole.AddTab("media", "Media", MediaConsole); tab.AllowClose = false; tab.AllowHide = true; tab.Select(); @@ -1370,13 +1227,13 @@ private void tbtnMedia_Click(object sender, EventArgs e) private void debugConsoleToolStripMenuItem_Click(object sender, EventArgs e) { - if (tabsConsole.TabExists("debug")) + if (TabConsole.TabExists("debug")) { ToggleHidden("debug"); } else { - RadegastTab tab = tabsConsole.AddTab("debug", "Debug", new DebugConsole(instance)); + RadegastTab tab = TabConsole.AddTab("debug", "Debug", new DebugConsole(instance)); tab.AllowClose = false; tab.AllowHide = true; tab.Select(); @@ -1385,9 +1242,9 @@ private void debugConsoleToolStripMenuItem_Click(object sender, EventArgs e) private void tbnObjects_Click(object sender, EventArgs e) { - if (tabsConsole.TabExists("objects")) + if (TabConsole.TabExists("objects")) { - RadegastTab tab = tabsConsole.Tabs["objects"]; + RadegastTab tab = TabConsole.Tabs["objects"]; if (!tab.Selected) { tab.Select(); @@ -1400,7 +1257,7 @@ private void tbnObjects_Click(object sender, EventArgs e) } else { - RadegastTab tab = tabsConsole.AddTab("objects", "Objects", new ObjectsConsole(instance)); + RadegastTab tab = TabConsole.AddTab("objects", "Objects", new ObjectsConsole(instance)); tab.AllowClose = true; tab.AllowDetach = true; tab.Visible = true; @@ -1444,12 +1301,9 @@ private void keyboardShortcutsToolStripMenuItem_Click(object sender, EventArgs e { keyboardShortcutsForm = new frmKeyboardShortcuts(instance); - keyboardShortcutsForm.Disposed += (object senderx, EventArgs ex) => + keyboardShortcutsForm.Disposed += (senderx, ex) => { - if (components != null) - { - components.Remove(keyboardShortcutsForm); - } + components?.Remove(keyboardShortcutsForm); keyboardShortcutsForm = null; }; @@ -1457,10 +1311,7 @@ private void keyboardShortcutsToolStripMenuItem_Click(object sender, EventArgs e keyboardShortcutsForm.Top = Top + 100; keyboardShortcutsForm.Left = Left + 100; - if (components != null) - { - components.Add(keyboardShortcutsForm); - } + components?.Add(keyboardShortcutsForm); } } @@ -1471,11 +1322,10 @@ private void testToolStripMenuItem_Click(object sender, EventArgs e) private void reloadInventoryToolStripMenuItem_Click(object sender, EventArgs e) { - if (tabsConsole.TabExists("inventory")) - { - ((InventoryConsole)tabsConsole.Tabs["inventory"].Control).ReloadInventory(); - tabsConsole.Tabs["inventory"].Select(); - } + if (!TabConsole.TabExists("inventory")) return; + + ((InventoryConsole)TabConsole.Tabs["inventory"].Control).ReloadInventory(); + TabConsole.Tabs["inventory"].Select(); } private void btnLoadScript_Click(object sender, EventArgs e) @@ -1489,17 +1339,17 @@ private void btnLoadScript_Click(object sender, EventArgs e) private void frmMain_Resize(object sender, EventArgs e) { - if (WindowState == FormWindowState.Minimized && instance.GlobalSettings["minimize_to_tray"].AsBoolean()) + if (WindowState != FormWindowState.Minimized || + !instance.GlobalSettings["minimize_to_tray"].AsBoolean()) return; + + if (TabConsole.TabExists("scene_window") && !TabConsole.Tabs["scene_window"].Detached) { - if (TabConsole.TabExists("scene_window") && !TabConsole.Tabs["scene_window"].Detached) - { - TabConsole.Tabs["scene_window"].Close(); - } - ShowInTaskbar = false; - trayIcon.Visible = true; - trayIcon.BalloonTipText = "Radegast is runnig in the background"; - trayIcon.ShowBalloonTip(2000); + TabConsole.Tabs["scene_window"].Close(); } + ShowInTaskbar = false; + trayIcon.Visible = true; + trayIcon.BalloonTipText = "Radegast is running in the background"; + trayIcon.ShowBalloonTip(2000); } private void treyIcon_MouseDoubleClick(object sender, MouseEventArgs e) @@ -1532,15 +1382,15 @@ private void stopAllAnimationsToolStripMenuItem_Click(object sender, EventArgs e public void DisplayRegionParcelConsole() { - if (tabsConsole.TabExists("current region info")) + if (TabConsole.TabExists("current region info")) { - tabsConsole.Tabs["current region info"].Select(); - (tabsConsole.Tabs["current region info"].Control as RegionInfo).UpdateDisplay(); + TabConsole.Tabs["current region info"].Select(); + (TabConsole.Tabs["current region info"].Control as RegionInfo)?.UpdateDisplay(); } else { - tabsConsole.AddTab("current region info", "Region info", new RegionInfo(instance)); - tabsConsole.Tabs["current region info"].Select(); + TabConsole.AddTab("current region info", "Region info", new RegionInfo(instance)); + TabConsole.Tabs["current region info"].Select(); } } @@ -1553,11 +1403,11 @@ public void DisplayExportConsole(uint localID) return; } - if (tabsConsole.TabExists("export console")) + if (TabConsole.TabExists("export console")) { - tabsConsole.Tabs["export console"].Close(); + TabConsole.Tabs["export console"].Close(); } - RadegastTab tab = tabsConsole.AddTab("export console", "Export Object", new ExportConsole(client, localID)); + RadegastTab tab = TabConsole.AddTab("export console", "Export Object", new ExportConsole(client, localID)); tab.Select(); } @@ -1569,7 +1419,7 @@ public void DisplayImportConsole() } else { - RadegastTab tab = tabsConsole.AddTab("import console", "Import Object", new ImportConsole(client)); + RadegastTab tab = TabConsole.AddTab("import console", "Import Object", new ImportConsole(client)); tab.AllowClose = false; tab.AllowHide = true; tab.Select(); @@ -1585,11 +1435,11 @@ public void DisplayColladaConsole(Primitive prim) return; } - if (tabsConsole.TabExists("collada console")) + if (TabConsole.TabExists("collada console")) { - tabsConsole.Tabs["collada console"].Close(); + TabConsole.Tabs["collada console"].Close(); } - RadegastTab tab = tabsConsole.AddTab("collada console", "Export Collada", new ExportCollada(instance, prim)); + RadegastTab tab = TabConsole.AddTab("collada console", "Export Collada", new ExportCollada(instance, prim)); tab.Select(); } @@ -1608,7 +1458,7 @@ private void changeMyDisplayNameToolStripMenuItem_Click(object sender, EventArgs { if (!client.Avatars.DisplayNamesAvailable()) { - tabsConsole.DisplayNotificationInChat("This grid does not support display names.", ChatBufferTextStyle.Error); + TabConsole.DisplayNotificationInChat("This grid does not support display names.", ChatBufferTextStyle.Error); return; } @@ -1618,38 +1468,38 @@ private void changeMyDisplayNameToolStripMenuItem_Click(object sender, EventArgs private void muteListToolStripMenuItem_Click(object sender, EventArgs e) { - if (!tabsConsole.TabExists("mute list console")) + if (!TabConsole.TabExists("mute list console")) { - tabsConsole.AddTab("mute list console", "Mute list", new MuteList(instance)); + TabConsole.AddTab("mute list console", "Mute list", new MuteList(instance)); } - tabsConsole.Tabs["mute list console"].Select(); + TabConsole.Tabs["mute list console"].Select(); } private void uploadImageToolStripMenuItem_Click(object sender, EventArgs e) { - if (!tabsConsole.TabExists("image upload console")) + if (!TabConsole.TabExists("image upload console")) { - tabsConsole.AddTab("image upload console", "Upload image", new ImageUploadConsole(instance)); + TabConsole.AddTab("image upload console", "Upload image", new ImageUploadConsole(instance)); } - tabsConsole.Tabs["image upload console"].Select(); + TabConsole.Tabs["image upload console"].Select(); } #endregion private void myAttachmentsToolStripMenuItem_Click(object sender, EventArgs e) { - Avatar av = client.Network.CurrentSim.ObjectsAvatars.Find((Avatar a) => { return a.ID == client.Self.AgentID; }); + Avatar av = client.Network.CurrentSim.ObjectsAvatars.Find(a => a.ID == client.Self.AgentID); if (av == null) { - tabsConsole.DisplayNotificationInChat("Unable to find my avatar!", ChatBufferTextStyle.Error); + TabConsole.DisplayNotificationInChat("Unable to find my avatar!", ChatBufferTextStyle.Error); return; } - if (!instance.TabConsole.TabExists("AT: " + av.ID.ToString())) + if (!instance.TabConsole.TabExists("AT: " + av.ID)) { - instance.TabConsole.AddTab("AT: " + av.ID.ToString(), "My Attachments", new AttachmentTab(instance, av)); + instance.TabConsole.AddTab("AT: " + av.ID, "My Attachments", new AttachmentTab(instance, av)); } - instance.TabConsole.SelectTab("AT: " + av.ID.ToString()); + instance.TabConsole.SelectTab("AT: " + av.ID); } @@ -1661,8 +1511,7 @@ private void tsb3D_Click(object sender, EventArgs e) } else { - var control = new Rendering.SceneWindow(instance); - control.Dock = DockStyle.Fill; + var control = new Rendering.SceneWindow(instance) {Dock = DockStyle.Fill}; instance.TabConsole.AddTab("scene_window", "Scene Viewer", control); instance.TabConsole.Tabs["scene_window"].Floater = false; instance.TabConsole.Tabs["scene_window"].CloseOnDetachedClose = true; @@ -1694,11 +1543,11 @@ private void setMaturityLevel(string level) { if (res.Success) { - tabsConsole.DisplayNotificationInChat("Successfully changed maturity access level to " + res.NewLevel); + TabConsole.DisplayNotificationInChat("Successfully changed maturity access level to " + res.NewLevel); } else { - tabsConsole.DisplayNotificationInChat("Failed to change maturity access level.", ChatBufferTextStyle.Error); + TabConsole.DisplayNotificationInChat("Failed to change maturity access level.", ChatBufferTextStyle.Error); } }); } @@ -1720,12 +1569,75 @@ private void adultToolStripMenuItem_Click(object sender, EventArgs e) private void uploadmeshToolStripMenuItem_Click(object sender, EventArgs e) { - if (!tabsConsole.TabExists("mesh upload console")) + if (!TabConsole.TabExists("mesh upload console")) + { + TabConsole.AddTab("mesh upload console", "Upload mesh", new MeshUploadConsole(instance)); + } + TabConsole.Tabs["mesh upload console"].Select(); + } + + private void setHoverHeightToolStripMenuItem_Click(object sender, EventArgs e) + { + var hoverHeight = 0.0; + if (instance.GlobalSettings.ContainsKey("AvatarHoverOffsetZ")) + { + hoverHeight = instance.GlobalSettings["AvatarHoverOffsetZ"]; + } + + var hoverHeightControl = new frmHoverHeight(hoverHeight, Instance.MonoRuntime); + hoverHeightControl.HoverHeightChanged += HoverHeightControl_HoverHeightChanged; + hoverHeightControl.Show(); + } + + private void HoverHeightControl_HoverHeightChanged(object sender, HoverHeightChangedEventArgs e) + { + instance.GlobalSettings["AvatarHoverOffsetZ"] = e.HoverHeight; + Client.Self.SetHoverHeight(e.HoverHeight); + } + + private void Caps_CapabilitiesReceived(object sender, CapabilitiesReceivedEventArgs e) + { + e.Simulator.Caps.CapabilitiesReceived -= Caps_CapabilitiesReceived; + + if (e.Simulator == client.Network.CurrentSim) { - tabsConsole.AddTab("mesh upload console", "Upload mesh", new MeshUploadConsole(instance)); + SetHoverHeightFromSettings(); } - tabsConsole.Tabs["mesh upload console"].Select(); } + private void SetHoverHeightFromSettings() + { + if (!instance.GlobalSettings.ContainsKey("AvatarHoverOffsetZ")) return; + + var hoverHeight = instance.GlobalSettings["AvatarHoverOffsetZ"]; + Client.Self.SetHoverHeight(hoverHeight); + } + + private void openMiniMapToolStripMenuItem_Click(object sender, EventArgs e) + { + var miniMapControl = new GUI.Dialogs.MiniMapForm(client); + miniMapControl.Show(); + } + + private void InitUpdater() + { + var appcastUrl = "https://update.radegast.life/appcast.xml"; + var manifestModuleName = System.Reflection.Assembly.GetEntryAssembly()?.ManifestModule.FullyQualifiedName; + var icon = Icon.ExtractAssociatedIcon(manifestModuleName); + SparkleUpdater = new NetSparkleUpdater.SparkleUpdater(appcastUrl, + new Ed25519Checker(NetSparkleUpdater.Enums.SecurityMode.Strict, "YR4STztpPyLnlPwhOVwaL2F7ToCmyXZ53cTt/encBu8=")) + { + UIFactory = new NetSparkleUpdater.UI.WinForms.UIFactory(icon), + RelaunchAfterUpdate = true, + UseNotificationToast = true, + SecurityProtocolType = System.Net.SecurityProtocolType.Tls12 + }; + SparkleUpdater.StartLoop(true); + } + + private void ctxCheckForUpdates_Click(object sender, EventArgs e) + { + SparkleUpdater.CheckForUpdatesAtUserRequest(); + } } } \ No newline at end of file diff --git a/Radegast/GUI/Dialogs/MainForm.resx b/Radegast/GUI/Dialogs/MainForm.resx index bb28e5353..b34e2b3e4 100644 --- a/Radegast/GUI/Dialogs/MainForm.resx +++ b/Radegast/GUI/Dialogs/MainForm.resx @@ -1,64 +1,4 @@ - - @@ -117,10 +57,10 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + 17, 17 - + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 @@ -316,16 +256,16 @@ TgDQASA1MVpwzwAAAABJRU5ErkJggg== - + 116, 17 - + 232, 17 - + 375, 17 - + 471, 17 diff --git a/Radegast/GUI/Dialogs/MfaPrompt.Designer.cs b/Radegast/GUI/Dialogs/MfaPrompt.Designer.cs new file mode 100644 index 000000000..d1360991b --- /dev/null +++ b/Radegast/GUI/Dialogs/MfaPrompt.Designer.cs @@ -0,0 +1,91 @@ + +namespace Radegast.GUI +{ + partial class MfaPrompt + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.tokenBox = new System.Windows.Forms.TextBox(); + this.btnSubmit = new System.Windows.Forms.Button(); + this.label1 = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // tokenBox + // + this.tokenBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.tokenBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 36F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.tokenBox.Location = new System.Drawing.Point(14, 42); + this.tokenBox.Name = "tokenBox"; + this.tokenBox.Size = new System.Drawing.Size(277, 62); + this.tokenBox.TabIndex = 0; + this.tokenBox.AcceptsReturn = true; + // + // btnSubmit + // + this.btnSubmit.AccessibleName = "Submit"; + this.btnSubmit.Dock = System.Windows.Forms.DockStyle.Bottom; + this.btnSubmit.Location = new System.Drawing.Point(0, 110); + this.btnSubmit.Name = "btnSubmit"; + this.btnSubmit.Size = new System.Drawing.Size(300, 30); + this.btnSubmit.TabIndex = 1; + this.btnSubmit.Text = "Submit"; + this.btnSubmit.UseVisualStyleBackColor = true; + this.btnSubmit.Click += new System.EventHandler(this.btnSubmit_Click); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(12, 13); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(279, 26); + this.label1.TabIndex = 2; + this.label1.Text = "The login service has requested MFA authentication. \r\nPlease enter the MFA token " + + "from your authentication app."; + // + // MfaPrompt + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(300, 140); + this.Controls.Add(this.label1); + this.Controls.Add(this.btnSubmit); + this.Controls.Add(this.tokenBox); + this.Name = "MfaPrompt"; + this.Text = "Multi-Factor Authentication Requested"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TextBox tokenBox; + private System.Windows.Forms.Button btnSubmit; + private System.Windows.Forms.Label label1; + } +} \ No newline at end of file diff --git a/Radegast/GUI/Dialogs/MfaPrompt.cs b/Radegast/GUI/Dialogs/MfaPrompt.cs new file mode 100644 index 000000000..e6c38773c --- /dev/null +++ b/Radegast/GUI/Dialogs/MfaPrompt.cs @@ -0,0 +1,46 @@ +/** + * Radegast Metaverse Client + * Copyright(c) 2022, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + +using System.Windows.Forms; + +namespace Radegast.GUI +{ + public partial class MfaPrompt : Form + { + private readonly RadegastInstance Instance; + private Netcom Netcom => Instance.Netcom; + + public MfaPrompt(RadegastInstance instance) + { + Instance = instance; + InitializeComponent(); + + AcceptButton = btnSubmit; + GuiHelpers.ApplyGuiFixes(this); + } + + private void btnSubmit_Click(object sender, System.EventArgs e) + { + Netcom.LoginOptions.MfaToken = tokenBox.Text; + Netcom.Login(); + DialogResult = DialogResult.OK; + Close(); + } + } +} diff --git a/plugins/IdealistRadegastPlugin/Properties/Resources.resx b/Radegast/GUI/Dialogs/MfaPrompt.resx similarity index 93% rename from plugins/IdealistRadegastPlugin/Properties/Resources.resx rename to Radegast/GUI/Dialogs/MfaPrompt.resx index 4d26a2af7..61bc649ba 100644 --- a/plugins/IdealistRadegastPlugin/Properties/Resources.resx +++ b/Radegast/GUI/Dialogs/MfaPrompt.resx @@ -1,121 +1,123 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + \ No newline at end of file diff --git a/Radegast/GUI/Dialogs/MiniMapForm.Designer.cs b/Radegast/GUI/Dialogs/MiniMapForm.Designer.cs new file mode 100644 index 000000000..8e232613d --- /dev/null +++ b/Radegast/GUI/Dialogs/MiniMapForm.Designer.cs @@ -0,0 +1,89 @@ +/** + * Radegast Metaverse Client + * Copyright(c) 2016-2021, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + +namespace Radegast.GUI.Dialogs +{ + partial class MiniMapForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.miniMap1 = new Radegast.WinForms.MiniMap(); + ((System.ComponentModel.ISupportInitialize)(this.miniMap1)).BeginInit(); + this.SuspendLayout(); + // + // miniMap1 + // + this.miniMap1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.miniMap1.Client = null; + this.miniMap1.Location = new System.Drawing.Point(0, 0); + this.miniMap1.Name = "miniMap1"; + this.miniMap1.Size = new System.Drawing.Size(200, 200); + this.miniMap1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; + this.miniMap1.TabIndex = 0; + this.miniMap1.TabStop = false; + this.miniMap1.UseWaitCursor = true; + // + // MiniMapForm + // + this.AccessibleDescription = "MiniMap"; + this.AccessibleName = "MiniMap"; + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(199, 199); + this.Controls.Add(this.miniMap1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.MaximizeBox = false; + this.Name = "MiniMapForm"; + this.ShowIcon = false; + this.Text = "Mini Map"; + this.UseWaitCursor = true; + ((System.ComponentModel.ISupportInitialize)(this.miniMap1)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private Radegast.WinForms.MiniMap miniMap1; + } +} \ No newline at end of file diff --git a/Radegast/GUI/Dialogs/MiniMapForm.cs b/Radegast/GUI/Dialogs/MiniMapForm.cs new file mode 100644 index 000000000..3849ec0c1 --- /dev/null +++ b/Radegast/GUI/Dialogs/MiniMapForm.cs @@ -0,0 +1,37 @@ +/** + * Radegast Metaverse Client + * Copyright(c) 2016-2021, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + +using OpenMetaverse; +using System.Windows.Forms; + +namespace Radegast.GUI.Dialogs +{ + public partial class MiniMapForm : Form + { + /// + /// Constructs minimap dialog for specified Client + /// + /// + public MiniMapForm(GridClient client) + { + InitializeComponent(); + this.miniMap1.Client = client; + } + } +} diff --git a/plugins/IdealistRadegastPlugin/Renderer/ParentWindowForm.resx b/Radegast/GUI/Dialogs/MiniMapForm.resx similarity index 95% rename from plugins/IdealistRadegastPlugin/Renderer/ParentWindowForm.resx rename to Radegast/GUI/Dialogs/MiniMapForm.resx index ff31a6db5..1af7de150 100644 --- a/plugins/IdealistRadegastPlugin/Renderer/ParentWindowForm.resx +++ b/Radegast/GUI/Dialogs/MiniMapForm.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/Radegast/GUI/Dialogs/MuteResident.cs b/Radegast/GUI/Dialogs/MuteResident.cs index eb5c3db7b..638202e0f 100644 --- a/Radegast/GUI/Dialogs/MuteResident.cs +++ b/Radegast/GUI/Dialogs/MuteResident.cs @@ -1,40 +1,24 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; using System.Windows.Forms; using OpenMetaverse; @@ -44,26 +28,26 @@ public partial class MuteResidentForm : RadegastForm { AvatarPicker picker; RadegastInstance instance; - Netcom.RadegastNetcom netcom; + Radegast.Netcom netcom; public MuteResidentForm(RadegastInstance instance) :base(instance) { InitializeComponent(); - Disposed += new EventHandler(MuteResidentForm_Disposed); + Disposed += MuteResidentForm_Disposed; AutoSavePosition = true; this.instance = instance; - this.netcom = instance.Netcom; + netcom = instance.Netcom; picker = new AvatarPicker(instance) { Dock = DockStyle.Fill }; Controls.Add(picker); - picker.SelectionChaged += new EventHandler(picker_SelectionChaged); + picker.SelectionChaged += picker_SelectionChaged; picker.BringToFront(); - netcom.ClientDisconnected += new EventHandler(Netcom_ClientDisconnected); + netcom.ClientDisconnected += Netcom_ClientDisconnected; - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } void picker_SelectionChaged(object sender, EventArgs e) @@ -73,23 +57,19 @@ void picker_SelectionChaged(object sender, EventArgs e) void MuteResidentForm_Disposed(object sender, EventArgs e) { - netcom.ClientDisconnected -= new EventHandler(Netcom_ClientDisconnected); + netcom.ClientDisconnected -= Netcom_ClientDisconnected; netcom = null; instance = null; picker.Dispose(); Logger.DebugLog("Group picker disposed"); } - void Netcom_ClientDisconnected(object sender, OpenMetaverse.DisconnectedEventArgs e) + void Netcom_ClientDisconnected(object sender, DisconnectedEventArgs e) { - ((Radegast.Netcom.RadegastNetcom)sender).ClientDisconnected -= new EventHandler(Netcom_ClientDisconnected); + ((Radegast.Netcom)sender).ClientDisconnected -= Netcom_ClientDisconnected; if (!instance.MonoRuntime || IsHandleCreated) - BeginInvoke(new MethodInvoker(() => - { - Close(); - } - )); + BeginInvoke(new MethodInvoker(Close)); } diff --git a/Radegast/GUI/Dialogs/Pay.cs b/Radegast/GUI/Dialogs/Pay.cs index 30f904e7c..1ca2f3bbe 100644 --- a/Radegast/GUI/Dialogs/Pay.cs +++ b/Radegast/GUI/Dialogs/Pay.cs @@ -1,35 +1,24 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; -using System.Collections.Generic; using System.Windows.Forms; using OpenMetaverse; @@ -38,19 +27,19 @@ namespace Radegast public partial class frmPay : RadegastForm { private RadegastInstance instance; - private GridClient client { get { return instance.Client; } } + private GridClient client => instance.Client; private UUID target; private string name; private UUID owner; private bool isObject; private Button[] buttons; - private int[] defaultAmounts = new int[4] { 1, 5, 10, 20 }; + private int[] defaultAmounts = new int[] { 1, 5, 10, 20 }; public static int LastPayed = -1; public frmPay(RadegastInstance instance, UUID target, string name, bool isObject) { InitializeComponent(); - Disposed += new EventHandler(frmPay_Disposed); + Disposed += frmPay_Disposed; this.instance = instance; this.target = target; @@ -58,18 +47,18 @@ public frmPay(RadegastInstance instance, UUID target, string name, bool isObject this.isObject = isObject; // Buttons - buttons = new Button[4] { btnFastPay1, btnFastPay2, btnFastPay3, btnFastPay4 }; + buttons = new Button[] { btnFastPay1, btnFastPay2, btnFastPay3, btnFastPay4 }; for (int i = 0; i < buttons.Length; i++) { - buttons[i].Click += new EventHandler(frmPay_Click); + buttons[i].Click += frmPay_Click; buttons[i].Text = string.Format("L${0}", defaultAmounts[i]); buttons[i].Tag = defaultAmounts[i]; } // Callbacks - client.Objects.PayPriceReply += new EventHandler(Objects_PayPriceReply); - client.Objects.ObjectPropertiesFamily += new EventHandler(Objects_ObjectPropertiesFamily); - instance.Names.NameUpdated += new EventHandler(Avatars_UUIDNameReply); + client.Objects.PayPriceReply += Objects_PayPriceReply; + client.Objects.ObjectPropertiesFamily += Objects_ObjectPropertiesFamily; + instance.Names.NameUpdated += Avatars_UUIDNameReply; if (isObject) { @@ -89,14 +78,14 @@ public frmPay(RadegastInstance instance, UUID target, string name, bool isObject txtAmount.Text = LastPayed.ToString(); } - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } void frmPay_Disposed(object sender, EventArgs e) { - client.Objects.PayPriceReply -= new EventHandler(Objects_PayPriceReply); - client.Objects.ObjectPropertiesFamily -= new EventHandler(Objects_ObjectPropertiesFamily); - instance.Names.NameUpdated -= new EventHandler(Avatars_UUIDNameReply); + client.Objects.PayPriceReply -= Objects_PayPriceReply; + client.Objects.ObjectPropertiesFamily -= Objects_ObjectPropertiesFamily; + instance.Names.NameUpdated -= Avatars_UUIDNameReply; } void frmPay_Click(object sender, EventArgs e) @@ -118,22 +107,18 @@ void UpdateResident() { if (InvokeRequired) { - BeginInvoke(new MethodInvoker(delegate() - { - UpdateResident(); - } - )); + BeginInvoke(new MethodInvoker(UpdateResident)); return; } - lblResident.Text = string.Format("Pay resident: {0}", instance.Names.Get(owner)); + lblResident.Text = $"Pay resident: {instance.Names.Get(owner)}"; } void Avatars_UUIDNameReply(object sender, UUIDNameReplyEventArgs e) { if (e.Names.ContainsKey(owner)) { - instance.Names.NameUpdated -= new EventHandler(Avatars_UUIDNameReply); + instance.Names.NameUpdated -= Avatars_UUIDNameReply; UpdateResident(); } } diff --git a/Radegast/GUI/Dialogs/Profile.Designer.cs b/Radegast/GUI/Dialogs/Profile.Designer.cs index c2959c772..f4d937f2f 100644 --- a/Radegast/GUI/Dialogs/Profile.Designer.cs +++ b/Radegast/GUI/Dialogs/Profile.Designer.cs @@ -77,18 +77,38 @@ private void InitializeComponent() this.btnPay = new System.Windows.Forms.Button(); this.rtbAccountInfo = new System.Windows.Forms.RichTextBox(); this.rtbAbout = new System.Windows.Forms.RichTextBox(); - this.label5 = new System.Windows.Forms.Label(); - this.label4 = new System.Windows.Forms.Label(); - this.label3 = new System.Windows.Forms.Label(); + this.labelPartner = new System.Windows.Forms.Label(); + this.labelInfo = new System.Windows.Forms.Label(); this.txtBornOn = new System.Windows.Forms.TextBox(); - this.label2 = new System.Windows.Forms.Label(); - this.label1 = new System.Windows.Forms.Label(); + this.labelBornOn = new System.Windows.Forms.Label(); + this.labelName = new System.Windows.Forms.Label(); this.tpgWeb = new System.Windows.Forms.TabPage(); this.pnlWeb = new System.Windows.Forms.Panel(); this.btnWebOpen = new System.Windows.Forms.Button(); this.btnWebView = new System.Windows.Forms.Button(); this.txtWebURL = new System.Windows.Forms.TextBox(); - this.label6 = new System.Windows.Forms.Label(); + this.labelUrl = new System.Windows.Forms.Label(); + this.tabInterests = new System.Windows.Forms.TabPage(); + this.txtLanguages = new System.Windows.Forms.TextBox(); + this.txtSkills = new System.Windows.Forms.TextBox(); + this.txtWantTo = new System.Windows.Forms.TextBox(); + this.checkBoxEventPlanning = new System.Windows.Forms.CheckBox(); + this.checkBoxCustomCharacters = new System.Windows.Forms.CheckBox(); + this.checkBoxArchitecture = new System.Windows.Forms.CheckBox(); + this.checkBoxScripting = new System.Windows.Forms.CheckBox(); + this.checkBoxModeling = new System.Windows.Forms.CheckBox(); + this.checkBoxTextures = new System.Windows.Forms.CheckBox(); + this.checkBoxHire = new System.Windows.Forms.CheckBox(); + this.checkBoxBuy = new System.Windows.Forms.CheckBox(); + this.checkBoxBeHired = new System.Windows.Forms.CheckBox(); + this.checkBoxExplore = new System.Windows.Forms.CheckBox(); + this.checkBoxSell = new System.Windows.Forms.CheckBox(); + this.checkBoxGroup = new System.Windows.Forms.CheckBox(); + this.checkBoxMeet = new System.Windows.Forms.CheckBox(); + this.checkBoxBuild = new System.Windows.Forms.CheckBox(); + this.labelLanguages = new System.Windows.Forms.Label(); + this.labelSkills = new System.Windows.Forms.Label(); + this.labelWantTo = new System.Windows.Forms.Label(); this.tbpPicks = new System.Windows.Forms.TabPage(); this.pickDetailPanel = new System.Windows.Forms.Panel(); this.pickDetail = new System.Windows.Forms.RichTextBox(); @@ -103,21 +123,24 @@ private void InitializeComponent() this.btnNewPick = new System.Windows.Forms.Button(); this.tpgFirstLife = new System.Windows.Forms.TabPage(); this.txtUUID = new System.Windows.Forms.TextBox(); - this.label9 = new System.Windows.Forms.Label(); + this.labelKey = new System.Windows.Forms.Label(); this.rlPicPanel = new System.Windows.Forms.Panel(); this.rtbAboutFL = new System.Windows.Forms.RichTextBox(); - this.label8 = new System.Windows.Forms.Label(); - this.label7 = new System.Windows.Forms.Label(); + this.tabNotes = new System.Windows.Forms.TabPage(); + this.rtbNotes = new System.Windows.Forms.RichTextBox(); + this.labelNotes = new System.Windows.Forms.Label(); this.btnClose = new System.Windows.Forms.Button(); this.textBox1 = new System.Windows.Forms.TextBox(); this.tabProfile.SuspendLayout(); this.tpgProfile.SuspendLayout(); this.tpgWeb.SuspendLayout(); + this.tabInterests.SuspendLayout(); this.tbpPicks.SuspendLayout(); this.pickDetailPanel.SuspendLayout(); this.picksLowerPanel.SuspendLayout(); this.pickListPanel.SuspendLayout(); this.tpgFirstLife.SuspendLayout(); + this.tabNotes.SuspendLayout(); this.SuspendLayout(); // // tabProfile @@ -127,8 +150,10 @@ private void InitializeComponent() | System.Windows.Forms.AnchorStyles.Right))); this.tabProfile.Controls.Add(this.tpgProfile); this.tabProfile.Controls.Add(this.tpgWeb); + this.tabProfile.Controls.Add(this.tabInterests); this.tabProfile.Controls.Add(this.tbpPicks); this.tabProfile.Controls.Add(this.tpgFirstLife); + this.tabProfile.Controls.Add(this.tabNotes); this.tabProfile.Location = new System.Drawing.Point(12, 12); this.tabProfile.Name = "tabProfile"; this.tabProfile.SelectedIndex = 0; @@ -152,12 +177,11 @@ private void InitializeComponent() this.tpgProfile.Controls.Add(this.btnPay); this.tpgProfile.Controls.Add(this.rtbAccountInfo); this.tpgProfile.Controls.Add(this.rtbAbout); - this.tpgProfile.Controls.Add(this.label5); - this.tpgProfile.Controls.Add(this.label4); - this.tpgProfile.Controls.Add(this.label3); + this.tpgProfile.Controls.Add(this.labelPartner); + this.tpgProfile.Controls.Add(this.labelInfo); this.tpgProfile.Controls.Add(this.txtBornOn); - this.tpgProfile.Controls.Add(this.label2); - this.tpgProfile.Controls.Add(this.label1); + this.tpgProfile.Controls.Add(this.labelBornOn); + this.tpgProfile.Controls.Add(this.labelName); this.tpgProfile.Location = new System.Drawing.Point(4, 22); this.tpgProfile.Name = "tpgProfile"; this.tpgProfile.Padding = new System.Windows.Forms.Padding(3); @@ -187,7 +211,7 @@ private void InitializeComponent() this.btnGive.Name = "btnGive"; this.btnGive.Size = new System.Drawing.Size(107, 23); this.btnGive.TabIndex = 24; - this.btnGive.Text = "&Give Inventory"; + this.btnGive.Text = "Give Inventory"; this.btnGive.UseVisualStyleBackColor = true; this.btnGive.Click += new System.EventHandler(this.btnGive_Click); // @@ -229,6 +253,7 @@ private void InitializeComponent() // txtFullName // this.txtFullName.AccessibleName = "Name"; + this.txtFullName.AgentID = ((OpenMetaverse.UUID)(resources.GetObject("txtFullName.AgentID"))); this.txtFullName.Location = new System.Drawing.Point(50, 6); this.txtFullName.Name = "txtFullName"; this.txtFullName.ReadOnly = true; @@ -238,6 +263,7 @@ private void InitializeComponent() // anPartner // this.anPartner.AccessibleName = "Partner"; + this.anPartner.AgentID = ((OpenMetaverse.UUID)(resources.GetObject("anPartner.AgentID"))); this.anPartner.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.anPartner.Location = new System.Drawing.Point(306, 34); this.anPartner.Name = "anPartner"; @@ -344,35 +370,25 @@ private void InitializeComponent() this.rtbAbout.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(this.rtbAbout_LinkClicked); this.rtbAbout.Leave += new System.EventHandler(this.rtbAbout_Leave); // - // label5 + // labelPartner // - this.label5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(252, 36); - this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(47, 13); - this.label5.TabIndex = 9; - this.label5.Text = "Partner:"; + this.labelPartner.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.labelPartner.AutoSize = true; + this.labelPartner.Location = new System.Drawing.Point(252, 36); + this.labelPartner.Name = "labelPartner"; + this.labelPartner.Size = new System.Drawing.Size(47, 13); + this.labelPartner.TabIndex = 9; + this.labelPartner.Text = "Partner:"; // - // label4 + // labelInfo // - this.label4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(6, 280); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(40, 13); - this.label4.TabIndex = 8; - this.label4.Text = "About:"; - // - // label3 - // - this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(251, 63); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(31, 13); - this.label3.TabIndex = 7; - this.label3.Text = "Info:"; + this.labelInfo.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.labelInfo.AutoSize = true; + this.labelInfo.Location = new System.Drawing.Point(251, 63); + this.labelInfo.Name = "labelInfo"; + this.labelInfo.Size = new System.Drawing.Size(31, 13); + this.labelInfo.TabIndex = 7; + this.labelInfo.Text = "Info:"; // // txtBornOn // @@ -384,24 +400,24 @@ private void InitializeComponent() this.txtBornOn.Size = new System.Drawing.Size(148, 21); this.txtBornOn.TabIndex = 2; // - // label2 + // labelBornOn // - this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(252, 9); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(48, 13); - this.label2.TabIndex = 3; - this.label2.Text = "Born on:"; + this.labelBornOn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.labelBornOn.AutoSize = true; + this.labelBornOn.Location = new System.Drawing.Point(252, 9); + this.labelBornOn.Name = "labelBornOn"; + this.labelBornOn.Size = new System.Drawing.Size(48, 13); + this.labelBornOn.TabIndex = 3; + this.labelBornOn.Text = "Born on:"; // - // label1 + // labelName // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(6, 9); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(38, 13); - this.label1.TabIndex = 1; - this.label1.Text = "Name:"; + this.labelName.AutoSize = true; + this.labelName.Location = new System.Drawing.Point(6, 9); + this.labelName.Name = "labelName"; + this.labelName.Size = new System.Drawing.Size(38, 13); + this.labelName.TabIndex = 1; + this.labelName.Text = "Name:"; // // tpgWeb // @@ -409,7 +425,7 @@ private void InitializeComponent() this.tpgWeb.Controls.Add(this.btnWebOpen); this.tpgWeb.Controls.Add(this.btnWebView); this.tpgWeb.Controls.Add(this.txtWebURL); - this.tpgWeb.Controls.Add(this.label6); + this.tpgWeb.Controls.Add(this.labelUrl); this.tpgWeb.Location = new System.Drawing.Point(4, 22); this.tpgWeb.Name = "tpgWeb"; this.tpgWeb.Padding = new System.Windows.Forms.Padding(3); @@ -464,14 +480,266 @@ private void InitializeComponent() this.txtWebURL.TabIndex = 1; this.txtWebURL.Leave += new System.EventHandler(this.txtWebURL_Leave); // - // label6 - // - this.label6.AutoSize = true; - this.label6.Location = new System.Drawing.Point(6, 9); - this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(30, 13); - this.label6.TabIndex = 0; - this.label6.Text = "URL:"; + // labelUrl + // + this.labelUrl.AutoSize = true; + this.labelUrl.Location = new System.Drawing.Point(6, 9); + this.labelUrl.Name = "labelUrl"; + this.labelUrl.Size = new System.Drawing.Size(30, 13); + this.labelUrl.TabIndex = 0; + this.labelUrl.Text = "URL:"; + // + // tabInterests + // + this.tabInterests.Controls.Add(this.txtLanguages); + this.tabInterests.Controls.Add(this.txtSkills); + this.tabInterests.Controls.Add(this.txtWantTo); + this.tabInterests.Controls.Add(this.checkBoxEventPlanning); + this.tabInterests.Controls.Add(this.checkBoxCustomCharacters); + this.tabInterests.Controls.Add(this.checkBoxArchitecture); + this.tabInterests.Controls.Add(this.checkBoxScripting); + this.tabInterests.Controls.Add(this.checkBoxModeling); + this.tabInterests.Controls.Add(this.checkBoxTextures); + this.tabInterests.Controls.Add(this.checkBoxHire); + this.tabInterests.Controls.Add(this.checkBoxBuy); + this.tabInterests.Controls.Add(this.checkBoxBeHired); + this.tabInterests.Controls.Add(this.checkBoxExplore); + this.tabInterests.Controls.Add(this.checkBoxSell); + this.tabInterests.Controls.Add(this.checkBoxGroup); + this.tabInterests.Controls.Add(this.checkBoxMeet); + this.tabInterests.Controls.Add(this.checkBoxBuild); + this.tabInterests.Controls.Add(this.labelLanguages); + this.tabInterests.Controls.Add(this.labelSkills); + this.tabInterests.Controls.Add(this.labelWantTo); + this.tabInterests.Location = new System.Drawing.Point(4, 22); + this.tabInterests.Name = "tabInterests"; + this.tabInterests.Padding = new System.Windows.Forms.Padding(3); + this.tabInterests.Size = new System.Drawing.Size(460, 476); + this.tabInterests.TabIndex = 5; + this.tabInterests.Text = "Interests"; + this.tabInterests.UseVisualStyleBackColor = true; + // + // txtLanguages + // + this.txtLanguages.Location = new System.Drawing.Point(77, 271); + this.txtLanguages.Name = "txtLanguages"; + this.txtLanguages.ReadOnly = true; + this.txtLanguages.Size = new System.Drawing.Size(285, 21); + this.txtLanguages.TabIndex = 19; + this.txtLanguages.Leave += new System.EventHandler(this.interestsUpdated); + // + // txtSkills + // + this.txtSkills.Location = new System.Drawing.Point(77, 233); + this.txtSkills.Name = "txtSkills"; + this.txtSkills.ReadOnly = true; + this.txtSkills.Size = new System.Drawing.Size(285, 21); + this.txtSkills.TabIndex = 18; + this.txtSkills.Leave += new System.EventHandler(this.interestsUpdated); + // + // txtWantTo + // + this.txtWantTo.Location = new System.Drawing.Point(77, 118); + this.txtWantTo.Name = "txtWantTo"; + this.txtWantTo.ReadOnly = true; + this.txtWantTo.Size = new System.Drawing.Size(285, 21); + this.txtWantTo.TabIndex = 17; + this.txtWantTo.Leave += new System.EventHandler(this.interestsUpdated); + // + // checkBoxEventPlanning + // + this.checkBoxEventPlanning.AutoSize = true; + this.checkBoxEventPlanning.Enabled = false; + this.checkBoxEventPlanning.Location = new System.Drawing.Point(239, 187); + this.checkBoxEventPlanning.Name = "checkBoxEventPlanning"; + this.checkBoxEventPlanning.Size = new System.Drawing.Size(97, 17); + this.checkBoxEventPlanning.TabIndex = 16; + this.checkBoxEventPlanning.Text = "Event Planning"; + this.checkBoxEventPlanning.UseVisualStyleBackColor = true; + this.checkBoxEventPlanning.CheckedChanged += new System.EventHandler(this.interestsUpdated); + // + // checkBoxCustomCharacters + // + this.checkBoxCustomCharacters.AutoSize = true; + this.checkBoxCustomCharacters.Enabled = false; + this.checkBoxCustomCharacters.Location = new System.Drawing.Point(239, 210); + this.checkBoxCustomCharacters.Name = "checkBoxCustomCharacters"; + this.checkBoxCustomCharacters.Size = new System.Drawing.Size(118, 17); + this.checkBoxCustomCharacters.TabIndex = 15; + this.checkBoxCustomCharacters.Text = "Custom Characters"; + this.checkBoxCustomCharacters.UseVisualStyleBackColor = true; + this.checkBoxCustomCharacters.CheckedChanged += new System.EventHandler(this.interestsUpdated); + // + // checkBoxArchitecture + // + this.checkBoxArchitecture.AutoSize = true; + this.checkBoxArchitecture.Enabled = false; + this.checkBoxArchitecture.Location = new System.Drawing.Point(239, 164); + this.checkBoxArchitecture.Name = "checkBoxArchitecture"; + this.checkBoxArchitecture.Size = new System.Drawing.Size(85, 17); + this.checkBoxArchitecture.TabIndex = 14; + this.checkBoxArchitecture.Text = "Architecture"; + this.checkBoxArchitecture.UseVisualStyleBackColor = true; + this.checkBoxArchitecture.CheckedChanged += new System.EventHandler(this.interestsUpdated); + // + // checkBoxScripting + // + this.checkBoxScripting.AutoSize = true; + this.checkBoxScripting.Enabled = false; + this.checkBoxScripting.Location = new System.Drawing.Point(77, 210); + this.checkBoxScripting.Name = "checkBoxScripting"; + this.checkBoxScripting.Size = new System.Drawing.Size(67, 17); + this.checkBoxScripting.TabIndex = 13; + this.checkBoxScripting.Text = "Scripting"; + this.checkBoxScripting.UseVisualStyleBackColor = true; + this.checkBoxScripting.CheckedChanged += new System.EventHandler(this.interestsUpdated); + // + // checkBoxModeling + // + this.checkBoxModeling.AutoSize = true; + this.checkBoxModeling.Enabled = false; + this.checkBoxModeling.Location = new System.Drawing.Point(77, 187); + this.checkBoxModeling.Name = "checkBoxModeling"; + this.checkBoxModeling.Size = new System.Drawing.Size(68, 17); + this.checkBoxModeling.TabIndex = 12; + this.checkBoxModeling.Text = "Modeling"; + this.checkBoxModeling.UseVisualStyleBackColor = true; + this.checkBoxModeling.CheckedChanged += new System.EventHandler(this.interestsUpdated); + // + // checkBoxTextures + // + this.checkBoxTextures.AutoSize = true; + this.checkBoxTextures.Enabled = false; + this.checkBoxTextures.Location = new System.Drawing.Point(77, 164); + this.checkBoxTextures.Name = "checkBoxTextures"; + this.checkBoxTextures.Size = new System.Drawing.Size(69, 17); + this.checkBoxTextures.TabIndex = 11; + this.checkBoxTextures.Text = "Textures"; + this.checkBoxTextures.UseVisualStyleBackColor = true; + this.checkBoxTextures.CheckedChanged += new System.EventHandler(this.interestsUpdated); + // + // checkBoxHire + // + this.checkBoxHire.AutoSize = true; + this.checkBoxHire.Enabled = false; + this.checkBoxHire.Location = new System.Drawing.Point(239, 95); + this.checkBoxHire.Name = "checkBoxHire"; + this.checkBoxHire.Size = new System.Drawing.Size(45, 17); + this.checkBoxHire.TabIndex = 10; + this.checkBoxHire.Text = "Hire"; + this.checkBoxHire.UseVisualStyleBackColor = true; + this.checkBoxHire.CheckedChanged += new System.EventHandler(this.interestsUpdated); + // + // checkBoxBuy + // + this.checkBoxBuy.AutoSize = true; + this.checkBoxBuy.Enabled = false; + this.checkBoxBuy.Location = new System.Drawing.Point(239, 49); + this.checkBoxBuy.Name = "checkBoxBuy"; + this.checkBoxBuy.Size = new System.Drawing.Size(44, 17); + this.checkBoxBuy.TabIndex = 9; + this.checkBoxBuy.Text = "Buy"; + this.checkBoxBuy.UseVisualStyleBackColor = true; + this.checkBoxBuy.CheckedChanged += new System.EventHandler(this.interestsUpdated); + // + // checkBoxBeHired + // + this.checkBoxBeHired.AutoSize = true; + this.checkBoxBeHired.Enabled = false; + this.checkBoxBeHired.Location = new System.Drawing.Point(239, 72); + this.checkBoxBeHired.Name = "checkBoxBeHired"; + this.checkBoxBeHired.Size = new System.Drawing.Size(66, 17); + this.checkBoxBeHired.TabIndex = 8; + this.checkBoxBeHired.Text = "Be Hired"; + this.checkBoxBeHired.UseVisualStyleBackColor = true; + this.checkBoxBeHired.CheckedChanged += new System.EventHandler(this.interestsUpdated); + // + // checkBoxExplore + // + this.checkBoxExplore.AutoSize = true; + this.checkBoxExplore.Enabled = false; + this.checkBoxExplore.Location = new System.Drawing.Point(77, 95); + this.checkBoxExplore.Name = "checkBoxExplore"; + this.checkBoxExplore.Size = new System.Drawing.Size(62, 17); + this.checkBoxExplore.TabIndex = 7; + this.checkBoxExplore.Text = "Explore"; + this.checkBoxExplore.UseVisualStyleBackColor = true; + this.checkBoxExplore.CheckedChanged += new System.EventHandler(this.interestsUpdated); + // + // checkBoxSell + // + this.checkBoxSell.AutoSize = true; + this.checkBoxSell.Enabled = false; + this.checkBoxSell.Location = new System.Drawing.Point(239, 26); + this.checkBoxSell.Name = "checkBoxSell"; + this.checkBoxSell.Size = new System.Drawing.Size(42, 17); + this.checkBoxSell.TabIndex = 6; + this.checkBoxSell.Text = "Sell"; + this.checkBoxSell.UseVisualStyleBackColor = true; + this.checkBoxSell.CheckedChanged += new System.EventHandler(this.interestsUpdated); + // + // checkBoxGroup + // + this.checkBoxGroup.AutoSize = true; + this.checkBoxGroup.Enabled = false; + this.checkBoxGroup.Location = new System.Drawing.Point(77, 72); + this.checkBoxGroup.Name = "checkBoxGroup"; + this.checkBoxGroup.Size = new System.Drawing.Size(55, 17); + this.checkBoxGroup.TabIndex = 5; + this.checkBoxGroup.Text = "Group"; + this.checkBoxGroup.UseVisualStyleBackColor = true; + this.checkBoxGroup.CheckedChanged += new System.EventHandler(this.interestsUpdated); + // + // checkBoxMeet + // + this.checkBoxMeet.AutoSize = true; + this.checkBoxMeet.Enabled = false; + this.checkBoxMeet.Location = new System.Drawing.Point(77, 49); + this.checkBoxMeet.Name = "checkBoxMeet"; + this.checkBoxMeet.Size = new System.Drawing.Size(50, 17); + this.checkBoxMeet.TabIndex = 4; + this.checkBoxMeet.Text = "Meet"; + this.checkBoxMeet.UseVisualStyleBackColor = true; + this.checkBoxMeet.CheckedChanged += new System.EventHandler(this.interestsUpdated); + // + // checkBoxBuild + // + this.checkBoxBuild.AutoSize = true; + this.checkBoxBuild.Enabled = false; + this.checkBoxBuild.Location = new System.Drawing.Point(77, 26); + this.checkBoxBuild.Name = "checkBoxBuild"; + this.checkBoxBuild.Size = new System.Drawing.Size(48, 17); + this.checkBoxBuild.TabIndex = 3; + this.checkBoxBuild.Text = "Build"; + this.checkBoxBuild.UseVisualStyleBackColor = true; + this.checkBoxBuild.CheckedChanged += new System.EventHandler(this.interestsUpdated); + // + // labelLanguages + // + this.labelLanguages.AutoSize = true; + this.labelLanguages.Location = new System.Drawing.Point(8, 271); + this.labelLanguages.Name = "labelLanguages"; + this.labelLanguages.Size = new System.Drawing.Size(63, 13); + this.labelLanguages.TabIndex = 2; + this.labelLanguages.Text = "Languages:"; + // + // labelSkills + // + this.labelSkills.AutoSize = true; + this.labelSkills.Location = new System.Drawing.Point(37, 164); + this.labelSkills.Name = "labelSkills"; + this.labelSkills.Size = new System.Drawing.Size(33, 13); + this.labelSkills.TabIndex = 1; + this.labelSkills.Text = "Skills:"; + // + // labelWantTo + // + this.labelWantTo.AutoSize = true; + this.labelWantTo.Location = new System.Drawing.Point(15, 26); + this.labelWantTo.Name = "labelWantTo"; + this.labelWantTo.Size = new System.Drawing.Size(55, 13); + this.labelWantTo.TabIndex = 0; + this.labelWantTo.Text = "I want to:"; // // tbpPicks // @@ -609,11 +877,9 @@ private void InitializeComponent() // tpgFirstLife // this.tpgFirstLife.Controls.Add(this.txtUUID); - this.tpgFirstLife.Controls.Add(this.label9); + this.tpgFirstLife.Controls.Add(this.labelKey); this.tpgFirstLife.Controls.Add(this.rlPicPanel); this.tpgFirstLife.Controls.Add(this.rtbAboutFL); - this.tpgFirstLife.Controls.Add(this.label8); - this.tpgFirstLife.Controls.Add(this.label7); this.tpgFirstLife.Location = new System.Drawing.Point(4, 22); this.tpgFirstLife.Name = "tpgFirstLife"; this.tpgFirstLife.Padding = new System.Windows.Forms.Padding(3); @@ -631,15 +897,15 @@ private void InitializeComponent() this.txtUUID.Size = new System.Drawing.Size(259, 21); this.txtUUID.TabIndex = 17; // - // label9 + // labelKey // - this.label9.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.label9.AutoSize = true; - this.label9.Location = new System.Drawing.Point(8, 433); - this.label9.Name = "label9"; - this.label9.Size = new System.Drawing.Size(29, 13); - this.label9.TabIndex = 16; - this.label9.Text = "Key:"; + this.labelKey.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.labelKey.AutoSize = true; + this.labelKey.Location = new System.Drawing.Point(8, 433); + this.labelKey.Name = "labelKey"; + this.labelKey.Size = new System.Drawing.Size(29, 13); + this.labelKey.TabIndex = 16; + this.labelKey.Text = "Key:"; // // rlPicPanel // @@ -662,24 +928,39 @@ private void InitializeComponent() this.rtbAboutFL.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(this.rtbAboutFL_LinkClicked); this.rtbAboutFL.Leave += new System.EventHandler(this.rtbAboutFL_Leave); // - // label8 + // tabNotes // - this.label8.AutoSize = true; - this.label8.Location = new System.Drawing.Point(6, 6); - this.label8.Name = "label8"; - this.label8.Size = new System.Drawing.Size(80, 13); - this.label8.TabIndex = 6; - this.label8.Text = "My first life pic:"; + this.tabNotes.Controls.Add(this.rtbNotes); + this.tabNotes.Controls.Add(this.labelNotes); + this.tabNotes.Location = new System.Drawing.Point(4, 22); + this.tabNotes.Name = "tabNotes"; + this.tabNotes.Padding = new System.Windows.Forms.Padding(3); + this.tabNotes.Size = new System.Drawing.Size(460, 476); + this.tabNotes.TabIndex = 4; + this.tabNotes.Text = "Notes"; + this.tabNotes.UseVisualStyleBackColor = true; // - // label7 + // rtbNotes // - this.label7.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.label7.AutoSize = true; - this.label7.Location = new System.Drawing.Point(6, 185); - this.label7.Name = "label7"; - this.label7.Size = new System.Drawing.Size(96, 13); - this.label7.TabIndex = 5; - this.label7.Text = "About my first life:"; + this.rtbNotes.AccessibleName = "Private Notes on Avatar"; + this.rtbNotes.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.rtbNotes.Location = new System.Drawing.Point(6, 19); + this.rtbNotes.Name = "rtbNotes"; + this.rtbNotes.ReadOnly = false; + this.rtbNotes.Size = new System.Drawing.Size(448, 277); + this.rtbNotes.TabIndex = 1; + this.rtbNotes.Text = ""; + this.rtbNotes.Leave += new System.EventHandler(this.rtbNotes_Leave); + // + // labelNotes + // + this.labelNotes.AutoSize = true; + this.labelNotes.Location = new System.Drawing.Point(6, 3); + this.labelNotes.Name = "labelNotes"; + this.labelNotes.Size = new System.Drawing.Size(146, 13); + this.labelNotes.TabIndex = 0; + this.labelNotes.Text = "Private notes on this Avatar:"; // // btnClose // @@ -726,6 +1007,8 @@ private void InitializeComponent() this.tpgProfile.PerformLayout(); this.tpgWeb.ResumeLayout(false); this.tpgWeb.PerformLayout(); + this.tabInterests.ResumeLayout(false); + this.tabInterests.PerformLayout(); this.tbpPicks.ResumeLayout(false); this.pickDetailPanel.ResumeLayout(false); this.pickDetailPanel.PerformLayout(); @@ -733,6 +1016,8 @@ private void InitializeComponent() this.pickListPanel.ResumeLayout(false); this.tpgFirstLife.ResumeLayout(false); this.tpgFirstLife.PerformLayout(); + this.tabNotes.ResumeLayout(false); + this.tabNotes.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); @@ -744,20 +1029,17 @@ private void InitializeComponent() public System.Windows.Forms.TabPage tpgProfile; public System.Windows.Forms.TabPage tpgWeb; public System.Windows.Forms.TabPage tpgFirstLife; - public System.Windows.Forms.Label label1; - public System.Windows.Forms.Label label2; - public System.Windows.Forms.Label label4; - public System.Windows.Forms.Label label3; + public System.Windows.Forms.Label labelName; + public System.Windows.Forms.Label labelBornOn; + public System.Windows.Forms.Label labelInfo; public System.Windows.Forms.TextBox txtBornOn; - public System.Windows.Forms.Label label5; + public System.Windows.Forms.Label labelPartner; public System.Windows.Forms.Button btnClose; public System.Windows.Forms.Panel pnlWeb; public System.Windows.Forms.Button btnWebOpen; public System.Windows.Forms.Button btnWebView; public System.Windows.Forms.TextBox txtWebURL; - public System.Windows.Forms.Label label6; - public System.Windows.Forms.Label label8; - public System.Windows.Forms.Label label7; + public System.Windows.Forms.Label labelUrl; public System.Windows.Forms.RichTextBox rtbAbout; public System.Windows.Forms.RichTextBox rtbAboutFL; public System.Windows.Forms.RichTextBox rtbAccountInfo; @@ -781,7 +1063,7 @@ private void InitializeComponent() public AgentNameTextBox anPartner; public AgentNameTextBox txtFullName; public System.Windows.Forms.TextBox txtUUID; - public System.Windows.Forms.Label label9; + public System.Windows.Forms.Label labelKey; public ListViewNoFlicker lvwGroups; private System.Windows.Forms.ColumnHeader clGroupName; private System.Windows.Forms.ColumnHeader clGroupTitle; @@ -791,6 +1073,29 @@ private void InitializeComponent() public System.Windows.Forms.Button btnUnmute; public System.Windows.Forms.Button btnMute; private System.Windows.Forms.Button btnRequestTeleport; - + private System.Windows.Forms.TabPage tabNotes; + private System.Windows.Forms.TabPage tabInterests; + private System.Windows.Forms.TextBox txtLanguages; + private System.Windows.Forms.TextBox txtSkills; + private System.Windows.Forms.TextBox txtWantTo; + private System.Windows.Forms.CheckBox checkBoxEventPlanning; + private System.Windows.Forms.CheckBox checkBoxCustomCharacters; + private System.Windows.Forms.CheckBox checkBoxArchitecture; + private System.Windows.Forms.CheckBox checkBoxScripting; + private System.Windows.Forms.CheckBox checkBoxModeling; + private System.Windows.Forms.CheckBox checkBoxTextures; + private System.Windows.Forms.CheckBox checkBoxHire; + private System.Windows.Forms.CheckBox checkBoxBuy; + private System.Windows.Forms.CheckBox checkBoxBeHired; + private System.Windows.Forms.CheckBox checkBoxExplore; + private System.Windows.Forms.CheckBox checkBoxSell; + private System.Windows.Forms.CheckBox checkBoxGroup; + private System.Windows.Forms.CheckBox checkBoxMeet; + private System.Windows.Forms.CheckBox checkBoxBuild; + private System.Windows.Forms.Label labelLanguages; + private System.Windows.Forms.Label labelSkills; + private System.Windows.Forms.Label labelWantTo; + public System.Windows.Forms.RichTextBox rtbNotes; + private System.Windows.Forms.Label labelNotes; } } \ No newline at end of file diff --git a/Radegast/GUI/Dialogs/Profile.cs b/Radegast/GUI/Dialogs/Profile.cs index d7f02be38..d926d5487 100644 --- a/Radegast/GUI/Dialogs/Profile.cs +++ b/Radegast/GUI/Dialogs/Profile.cs @@ -1,45 +1,29 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2021, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections.Generic; +using System.Threading; using System.Windows.Forms; -using Radegast.Netcom; +using Radegast; using OpenMetaverse; -#if (COGBOT_LIBOMV || USE_STHREADS) -using ThreadPoolUtil; -using Thread = ThreadPoolUtil.Thread; -using ThreadPool = ThreadPoolUtil.ThreadPool; -using Monitor = ThreadPoolUtil.Monitor; -#endif -using System.Threading; namespace Radegast @@ -47,13 +31,13 @@ namespace Radegast public partial class frmProfile : RadegastForm { private RadegastInstance instance; - private RadegastNetcom netcom; - private GridClient client; - private string fullName; + private Radegast.Netcom netcom; + private readonly GridClient client; + private readonly string fullName; - private UUID agentID; - public UUID AgentID { get { return agentID; } } + public UUID AgentID { get; } private Avatar.AvatarProperties Profile; + private Avatar.Interests Interests; bool myProfile = false; UUID newPickID = UUID.Zero; @@ -70,7 +54,7 @@ public frmProfile(RadegastInstance instance, string fullName, UUID agentID) : base(instance) { InitializeComponent(); - Disposed += new EventHandler(frmProfile_Disposed); + Disposed += frmProfile_Disposed; AutoSavePosition = true; @@ -78,9 +62,9 @@ public frmProfile(RadegastInstance instance, string fullName, UUID agentID) netcom = this.instance.Netcom; client = this.instance.Client; this.fullName = fullName; - this.agentID = agentID; + AgentID = agentID; - this.Text = fullName + " (profile) - " + Properties.Resources.ProgramName; + Text = fullName + " (profile) - " + Properties.Resources.ProgramName; txtUUID.Text = agentID.ToString(); if (client.Friends.FriendList.ContainsKey(agentID)) @@ -104,32 +88,57 @@ public frmProfile(RadegastInstance instance, string fullName, UUID agentID) btnRequestTeleport.Visible = false; btnDeletePick.Visible = true; btnNewPick.Visible = true; + + txtWantTo.ReadOnly = false; + txtSkills.ReadOnly = false; + txtLanguages.ReadOnly = false; + + checkBoxBuild.Enabled = true; + checkBoxExplore.Enabled = true; + checkBoxMeet.Enabled = true; + checkBoxGroup.Enabled = true; + checkBoxBuy.Enabled = true; + checkBoxSell.Enabled = true; + checkBoxBeHired.Enabled = true; + checkBoxHire.Enabled = true; + checkBoxTextures.Enabled = true; + checkBoxArchitecture.Enabled = true; + checkBoxEventPlanning.Enabled = true; + checkBoxModeling.Enabled = true; + checkBoxScripting.Enabled = true; + checkBoxCustomCharacters.Enabled = true; } // Callbacks - client.Avatars.AvatarPropertiesReply += new EventHandler(Avatars_AvatarPropertiesReply); - client.Avatars.AvatarPicksReply += new EventHandler(Avatars_AvatarPicksReply); - client.Avatars.PickInfoReply += new EventHandler(Avatars_PickInfoReply); - client.Parcels.ParcelInfoReply += new EventHandler(Parcels_ParcelInfoReply); - client.Avatars.AvatarGroupsReply += new EventHandler(Avatars_AvatarGroupsReply); - client.Self.MuteListUpdated += new EventHandler(Self_MuteListUpdated); - netcom.ClientDisconnected += new EventHandler(netcom_ClientDisconnected); - instance.InventoryClipboardUpdated += new EventHandler(instance_InventoryClipboardUpdated); + client.Avatars.AvatarPropertiesReply += Avatars_AvatarPropertiesReply; + client.Avatars.AvatarPicksReply += Avatars_AvatarPicksReply; + //client.Avatars.AvatarClassifiedReply += new EventHandler(Avatars_AvatarClassifiedsReply); + client.Avatars.PickInfoReply += Avatars_PickInfoReply; + client.Parcels.ParcelInfoReply += Parcels_ParcelInfoReply; + client.Avatars.AvatarGroupsReply += Avatars_AvatarGroupsReply; + client.Avatars.AvatarInterestsReply += Avatars_AvatarInterestsReply; + client.Avatars.AvatarNotesReply += Avatars_AvatarNotesReply; + client.Self.MuteListUpdated += Self_MuteListUpdated; + netcom.ClientDisconnected += netcom_ClientDisconnected; + instance.InventoryClipboardUpdated += instance_InventoryClipboardUpdated; InitializeProfile(); - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } void frmProfile_Disposed(object sender, EventArgs e) { - client.Avatars.AvatarPropertiesReply -= new EventHandler(Avatars_AvatarPropertiesReply); - client.Avatars.AvatarPicksReply -= new EventHandler(Avatars_AvatarPicksReply); - client.Avatars.PickInfoReply -= new EventHandler(Avatars_PickInfoReply); - client.Parcels.ParcelInfoReply -= new EventHandler(Parcels_ParcelInfoReply); - client.Avatars.AvatarGroupsReply -= new EventHandler(Avatars_AvatarGroupsReply); - client.Self.MuteListUpdated -= new EventHandler(Self_MuteListUpdated); - netcom.ClientDisconnected -= new EventHandler(netcom_ClientDisconnected); - instance.InventoryClipboardUpdated -= new EventHandler(instance_InventoryClipboardUpdated); + client.Avatars.AvatarPropertiesReply -= Avatars_AvatarPropertiesReply; + client.Avatars.AvatarPicksReply -= Avatars_AvatarPicksReply; + //client.Avatars.AvatarClassifiedReply -= new EventHandler(Avatars_AvatarClassifiedsReply); + client.Avatars.PickInfoReply -= Avatars_PickInfoReply; + client.Parcels.ParcelInfoReply -= Parcels_ParcelInfoReply; + client.Avatars.AvatarGroupsReply -= Avatars_AvatarGroupsReply; + client.Avatars.AvatarInterestsReply -= Avatars_AvatarInterestsReply; + client.Avatars.AvatarNotesReply -= Avatars_AvatarNotesReply; + client.Self.MuteListUpdated -= Self_MuteListUpdated; + netcom.ClientDisconnected -= netcom_ClientDisconnected; + instance.InventoryClipboardUpdated -= instance_InventoryClipboardUpdated; } void Self_MuteListUpdated(object sender, EventArgs e) @@ -148,7 +157,7 @@ void Self_MuteListUpdated(object sender, EventArgs e) void UpdateMuteButton() { - bool isMuted = client.Self.MuteList.Find(me => (me.Type == MuteType.Resident && me.ID == agentID)) != null; + bool isMuted = client.Self.MuteList.Find(me => (me.Type == MuteType.Resident && me.ID == AgentID)) != null; if (isMuted) { @@ -169,7 +178,7 @@ void instance_InventoryClipboardUpdated(object sender, EventArgs e) void Avatars_AvatarGroupsReply(object sender, AvatarGroupsReplyEventArgs e) { - if (e.AvatarID != agentID) return; + if (e.AvatarID != AgentID) return; if (InvokeRequired) { @@ -183,10 +192,7 @@ void Avatars_AvatarGroupsReply(object sender, AvatarGroupsReplyEventArgs e) { if (!lvwGroups.Items.ContainsKey(g.GroupID.ToString())) { - ListViewItem item = new ListViewItem(); - item.Name = g.GroupID.ToString(); - item.Text = g.GroupName; - item.Tag = g; + ListViewItem item = new ListViewItem {Name = g.GroupID.ToString(), Text = g.GroupName, Tag = g}; item.SubItems.Add(new ListViewItem.ListViewSubItem(item, g.GroupTitle)); lvwGroups.Items.Add(item); @@ -197,9 +203,56 @@ void Avatars_AvatarGroupsReply(object sender, AvatarGroupsReplyEventArgs e) } + void Avatars_AvatarInterestsReply(object sender, AvatarInterestsReplyEventArgs e) + { + if (e.AvatarID != AgentID) return; + + if (InvokeRequired) + { + BeginInvoke(new MethodInvoker(() => Avatars_AvatarInterestsReply(sender, e))); + return; + } + + Interests = e.Interests; + + // want to's + checkBoxBuild.Checked = (Interests.WantToMask & (1 << 0)) != 0; + checkBoxExplore.Checked = (Interests.WantToMask & (1 << 1)) != 0; + checkBoxMeet.Checked = (Interests.WantToMask & (1 << 2)) != 0; + checkBoxGroup.Checked = (Interests.WantToMask & (1 << 3)) != 0; + checkBoxBuy.Checked = (Interests.WantToMask & (1 << 4)) != 0; + checkBoxSell.Checked = (Interests.WantToMask & (1 << 5)) != 0; + checkBoxBeHired.Checked = (Interests.WantToMask & (1 << 6)) != 0; + checkBoxHire.Checked = (Interests.WantToMask & (1 << 7)) != 0; + txtWantTo.Text = Interests.WantToText; + + // skills + checkBoxTextures.Checked = (Interests.WantToMask & (1 << 0)) != 0; + checkBoxArchitecture.Checked = (Interests.WantToMask & (1 << 1)) != 0; + checkBoxEventPlanning.Checked = (Interests.WantToMask & (1 << 2)) != 0; + checkBoxModeling.Checked = (Interests.WantToMask & (1 << 3)) != 0; + checkBoxScripting.Checked = (Interests.WantToMask & (1 << 4)) != 0; + checkBoxCustomCharacters.Checked = (Interests.WantToMask & (1 << 5)) != 0; + txtSkills.Text = Interests.SkillsText; + + txtLanguages.Text = Interests.LanguagesText; + } + + void Avatars_AvatarNotesReply(object sender, AvatarNotesReplyEventArgs e) + { + if (e.AvatarID != AgentID) return; + + if (InvokeRequired) + { + BeginInvoke(new MethodInvoker(() => Avatars_AvatarNotesReply(sender, e))); + return; + } + rtbNotes.Text = e.Notes; + } + void Avatars_AvatarPicksReply(object sender, AvatarPicksReplyEventArgs e) { - if (e.AvatarID != agentID) return; + if (e.AvatarID != AgentID) return; if (InvokeRequired) { @@ -230,17 +283,19 @@ private void DisplayListOfPicks(Dictionary picks) foreach (KeyValuePair PickInfo in picks) { - Button b = new Button(); - b.AutoSize = false; - b.Tag = PickInfo.Key; - b.Name = PickInfo.Key.ToString(); - b.Text = PickInfo.Value; - b.Width = 135; - b.Height = 25; - b.Left = 2; + Button b = new Button + { + AutoSize = false, + Tag = PickInfo.Key, + Name = PickInfo.Key.ToString(), + Text = PickInfo.Value, + Width = 135, + Height = 25, + Left = 2 + }; b.Top = i++ * b.Height + 5; b.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; - b.Click += new EventHandler(PickButtonClick); + b.Click += PickButtonClick; pickListPanel.Controls.Add(b); if (firstButton == null) @@ -252,10 +307,7 @@ private void DisplayListOfPicks(Dictionary picks) newPickID = UUID.Zero; - if (firstButton != null) - { - firstButton.PerformClick(); - } + firstButton?.PerformClick(); } void PickButtonClick(object sender, EventArgs e) @@ -270,7 +322,7 @@ void PickButtonClick(object sender, EventArgs e) } else { - client.Avatars.RequestPickInfo(agentID, requestedPick); + client.Avatars.RequestPickInfo(AgentID, requestedPick); } } @@ -296,14 +348,15 @@ void Avatars_PickInfoReply(object sender, PickInfoReplyEventArgs e) pickPicturePanel.Controls[0].Dispose(); pickPicturePanel.Controls.Clear(); - if (agentID == client.Self.AgentID || e.Pick.SnapshotID != UUID.Zero) + if (AgentID == client.Self.AgentID || e.Pick.SnapshotID != UUID.Zero) { - SLImageHandler img = new SLImageHandler(instance, e.Pick.SnapshotID, string.Empty); - img.Dock = DockStyle.Fill; - img.SizeMode = PictureBoxSizeMode.StretchImage; + SLImageHandler img = new SLImageHandler(instance, e.Pick.SnapshotID, string.Empty) + { + Dock = DockStyle.Fill, SizeMode = PictureBoxSizeMode.StretchImage + }; pickPicturePanel.Controls.Add(img); - if (agentID == client.Self.AgentID) + if (AgentID == client.Self.AgentID) { img.AllowUpdateImage = true; ProfilePick p = e.Pick; @@ -375,7 +428,7 @@ void netcom_ClientDisconnected(object sender, DisconnectedEventArgs e) void Avatars_AvatarPropertiesReply(object sender, AvatarPropertiesReplyEventArgs e) { - if (e.AvatarID != agentID) return; + if (e.AvatarID != AgentID) return; if (InvokeRequired) { @@ -387,11 +440,11 @@ void Avatars_AvatarPropertiesReply(object sender, AvatarPropertiesReplyEventArgs FLImageID = e.Properties.FirstLifeImage; SLImageID = e.Properties.ProfileImage; - if (agentID == client.Self.AgentID || SLImageID != UUID.Zero) + if (AgentID == client.Self.AgentID || SLImageID != UUID.Zero) { SLImageHandler pic = new SLImageHandler(instance, SLImageID, ""); - if (agentID == client.Self.AgentID) + if (AgentID == client.Self.AgentID) { pic.AllowUpdateImage = true; pic.ImageUpdated += (usender, ue) => @@ -412,12 +465,11 @@ void Avatars_AvatarPropertiesReply(object sender, AvatarPropertiesReplyEventArgs slPicPanel.Hide(); } - if (agentID == client.Self.AgentID || FLImageID != UUID.Zero) + if (AgentID == client.Self.AgentID || FLImageID != UUID.Zero) { - SLImageHandler pic = new SLImageHandler(instance, FLImageID, ""); - pic.Dock = DockStyle.Fill; + SLImageHandler pic = new SLImageHandler(instance, FLImageID, "") {Dock = DockStyle.Fill}; - if (agentID == client.Self.AgentID) + if (AgentID == client.Self.AgentID) { pic.AllowUpdateImage = true; pic.ImageUpdated += (usender, ue) => @@ -436,7 +488,7 @@ void Avatars_AvatarPropertiesReply(object sender, AvatarPropertiesReplyEventArgs rlPicPanel.Hide(); } - this.BeginInvoke( + BeginInvoke( new OnSetProfileProperties(SetProfileProperties), new object[] { e.Properties }); } @@ -448,9 +500,16 @@ private void SetProfileProperties(Avatar.AvatarProperties properties) txtBornOn.Text = properties.BornOn; anPartner.AgentID = properties.Partner; - if (fullName.EndsWith("Linden")) rtbAccountInfo.AppendText("Linden Lab Employee\n"); - if (properties.Identified) rtbAccountInfo.AppendText("Identified\n"); - if (properties.Transacted) rtbAccountInfo.AppendText("Transacted\n"); + if (fullName.EndsWith("Linden")) + { + rtbAccountInfo.AppendText("Linden Lab Employee\n"); + } + else if (!string.IsNullOrEmpty(properties.CharterMember)) + { + rtbAccountInfo.AppendText($"{properties.CharterMember}\n"); + } + if (properties.Identified) { rtbAccountInfo.AppendText("Identified\n"); } + if (properties.Transacted) { rtbAccountInfo.AppendText("Transacted\n"); } rtbAbout.AppendText(properties.AboutText); @@ -463,13 +522,14 @@ private void SetProfileProperties(Avatar.AvatarProperties properties) private void InitializeProfile() { txtFullName.Text = fullName; - txtFullName.AgentID = agentID; - btnOfferTeleport.Enabled = btnPay.Enabled = (agentID != client.Self.AgentID); + txtFullName.AgentID = AgentID; + btnOfferTeleport.Enabled = btnPay.Enabled = (AgentID != client.Self.AgentID); - client.Avatars.RequestAvatarProperties(agentID); + client.Avatars.RequestAvatarProperties(AgentID); + client.Avatars.RequestAvatarNotes(AgentID); UpdateMuteButton(); - if (agentID == client.Self.AgentID) + if (AgentID == client.Self.AgentID) { btnGive.Visible = btnIM.Visible = @@ -489,9 +549,7 @@ private void btnClose_Click(object sender, EventArgs e) private void btnWebView_Click(object sender, EventArgs e) { - WebBrowser web = new WebBrowser(); - web.Dock = DockStyle.Fill; - web.Url = new Uri(txtWebURL.Text); + WebBrowser web = new WebBrowser {Dock = DockStyle.Fill, Url = new Uri(txtWebURL.Text)}; pnlWeb.Controls.Add(web); } @@ -513,12 +571,12 @@ private void rtbAboutFL_LinkClicked(object sender, LinkClickedEventArgs e) private void btnOfferTeleport_Click(object sender, EventArgs e) { - instance.MainForm.AddNotification(new ntfSendLureOffer(instance, agentID)); + instance.MainForm.AddNotification(new ntfSendLureOffer(instance, AgentID)); } private void btnPay_Click(object sender, EventArgs e) { - (new frmPay(instance, agentID, fullName, false)).ShowDialog(); + (new frmPay(instance, AgentID, fullName, false)).ShowDialog(); } private void textBox1_DragEnter(object sender, DragEventArgs e) @@ -539,35 +597,33 @@ private void textBox1_DragDrop(object sender, DragEventArgs e) TreeNode node = e.Data.GetData(typeof(TreeNode)) as TreeNode; if (node == null) return; - if (node.Tag is InventoryItem) + if (node.Tag is InventoryItem item) { - InventoryItem item = node.Tag as InventoryItem; - client.Inventory.GiveItem(item.UUID, item.Name, item.AssetType, agentID, true); + client.Inventory.GiveItem(item.UUID, item.Name, item.AssetType, AgentID, true); instance.TabConsole.DisplayNotificationInChat("Offered item " + item.Name + " to " + fullName + "."); } - else if (node.Tag is InventoryFolder) + else if (node.Tag is InventoryFolder folder) { - InventoryFolder folder = node.Tag as InventoryFolder; - client.Inventory.GiveFolder(folder.UUID, folder.Name, AssetType.Folder, agentID, true); + client.Inventory.GiveFolder(folder.UUID, folder.Name, AgentID, true); instance.TabConsole.DisplayNotificationInChat("Offered folder " + folder.Name + " to " + fullName + "."); } } private void btnFriend_Click(object sender, EventArgs e) { - client.Friends.OfferFriendship(agentID); + client.Friends.OfferFriendship(AgentID); } private void btnIM_Click(object sender, EventArgs e) { - instance.TabConsole.ShowIMTab(agentID, fullName, true); + instance.TabConsole.ShowIMTab(AgentID, fullName, true); } private void tabProfile_SelectedIndexChanged(object sender, EventArgs e) { if (tabProfile.SelectedTab.Name == "tbpPicks" && !gotPicks) { - client.Avatars.RequestAvatarPicks(agentID); + client.Avatars.RequestAvatarPicks(AgentID); } } @@ -613,13 +669,13 @@ private void btnGive_Click(object sender, EventArgs e) if (inv is InventoryItem) { InventoryItem item = inv as InventoryItem; - client.Inventory.GiveItem(item.UUID, item.Name, item.AssetType, agentID, true); + client.Inventory.GiveItem(item.UUID, item.Name, item.AssetType, AgentID, true); instance.TabConsole.DisplayNotificationInChat("Offered item " + item.Name + " to " + fullName + "."); } else if (inv is InventoryFolder) { InventoryFolder folder = inv as InventoryFolder; - client.Inventory.GiveFolder(folder.UUID, folder.Name, AssetType.Folder, agentID, true); + client.Inventory.GiveFolder(folder.UUID, folder.Name, AgentID, true); instance.TabConsole.DisplayNotificationInChat("Offered folder " + folder.Name + " to " + fullName + "."); } @@ -669,12 +725,12 @@ private void btnDeletePick_Click(object sender, EventArgs e) if (!myProfile) return; client.Self.PickDelete(currentPick.PickID); ClearPicks(); - client.Avatars.RequestAvatarPicks(agentID); + client.Avatars.RequestAvatarPicks(AgentID); } private void btnNewPick_Click(object sender, EventArgs e) { - WorkPool.QueueUserWorkItem(sync => + ThreadPool.QueueUserWorkItem(sync => { UUID parcelID = client.Parcels.RequestRemoteParcelID(client.Self.SimPosition, client.Network.CurrentSim.Handle, client.Network.CurrentSim.ID); newPickID = UUID.Random(); @@ -689,19 +745,58 @@ private void btnNewPick_Click(object sender, EventArgs e) Instance.State.Parcel.Desc ); - Invoke(new MethodInvoker(() => ClearPicks())); - client.Avatars.RequestAvatarPicks(agentID); + Invoke(new MethodInvoker(ClearPicks)); + client.Avatars.RequestAvatarPicks(AgentID); }); } + private void interestsUpdated(object sender, EventArgs e) + { + if (AgentID != client.Self.AgentID) + { + return; + } + + uint wantto = ((checkBoxBuild.Checked ? 1u << 0 : 0u) + | (checkBoxExplore.Checked ? 1u << 1 : 0u) + | (checkBoxMeet.Checked ? 1u << 2 : 0u) + | (checkBoxGroup.Checked ? 1u << 3 : 0u) + | (checkBoxBuy.Checked ? 1u << 4 : 0u) + | (checkBoxSell.Checked ? 1u << 5 : 0u) + | (checkBoxBeHired.Checked ? 1u << 6 : 0u) + | (checkBoxHire.Checked ? 1u << 7 : 0u)); + + uint skills = ((checkBoxTextures.Checked ? 1u << 0 : 0u) + | (checkBoxArchitecture.Checked ? 1u << 1 : 0u) + | (checkBoxEventPlanning.Checked ? 1u << 2 : 0u) + | (checkBoxModeling.Checked ? 1u << 3 : 0u) + | (checkBoxScripting.Checked ? 1u << 4 : 0u) + | (checkBoxCustomCharacters.Checked ? 1u << 5 : 0u)); + + var interests = new Avatar.Interests + { + SkillsMask = skills, + WantToMask = wantto, + LanguagesText = txtLanguages.Text, + SkillsText = txtSkills.Text, + WantToText = txtWantTo.Text + }; + client.Self.UpdateInterests(interests); + } + + private void rtbNotes_Leave(object sender, EventArgs e) + { + client.Self.UpdateProfileNotes(AgentID, rtbNotes.Text); + } + private void btnMute_Click(object sender, EventArgs e) { - client.Self.UpdateMuteListEntry(MuteType.Resident, agentID, instance.Names.GetLegacyName(agentID)); + client.Self.UpdateMuteListEntry(MuteType.Resident, AgentID, instance.Names.GetLegacyName(AgentID)); } private void btnUnmute_Click(object sender, EventArgs e) { - MuteEntry me = client.Self.MuteList.Find(mle => mle.Type == MuteType.Resident && mle.ID == agentID); + MuteEntry me = client.Self.MuteList.Find(mle => mle.Type == MuteType.Resident && mle.ID == AgentID); if (me != null) { @@ -709,13 +804,13 @@ private void btnUnmute_Click(object sender, EventArgs e) } else { - client.Self.RemoveMuteListEntry(agentID, instance.Names.GetLegacyName(agentID)); + client.Self.RemoveMuteListEntry(AgentID, instance.Names.GetLegacyName(AgentID)); } } private void btnRequestTeleport_Click(object sender, EventArgs e) { - instance.MainForm.AddNotification(new ntfSendLureRequest(instance, agentID)); + instance.MainForm.AddNotification(new ntfSendLureRequest(instance, AgentID)); } } } \ No newline at end of file diff --git a/Radegast/GUI/Dialogs/Profile.resx b/Radegast/GUI/Dialogs/Profile.resx index 8d714a77b..f49cbac16 100644 --- a/Radegast/GUI/Dialogs/Profile.resx +++ b/Radegast/GUI/Dialogs/Profile.resx @@ -112,15 +112,33 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + AAEAAAD/////AQAAAAAAAAAMAgAAAE1MaWJyZU1ldGF2ZXJzZS5UeXBlcywgVmVyc2lvbj0xLjguNy4y + MzYsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49bnVsbAUBAAAAEk9wZW5NZXRhdmVyc2Uu + VVVJRAEAAAAVPEd1aWQ+a19fQmFja2luZ0ZpZWxkAwtTeXN0ZW0uR3VpZAIAAAAE/f///wtTeXN0ZW0u + R3VpZAsAAAACX2ECX2ICX2MCX2QCX2UCX2YCX2cCX2gCX2kCX2oCX2sAAAAAAAAAAAAAAAgHBwICAgIC + AgICAAAAAAAAAAAAAAAAAAAAAAs= + + + + + AAEAAAD/////AQAAAAAAAAAMAgAAAE1MaWJyZU1ldGF2ZXJzZS5UeXBlcywgVmVyc2lvbj0xLjguNy4y + MzYsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49bnVsbAUBAAAAEk9wZW5NZXRhdmVyc2Uu + VVVJRAEAAAAVPEd1aWQ+a19fQmFja2luZ0ZpZWxkAwtTeXN0ZW0uR3VpZAIAAAAE/f///wtTeXN0ZW0u + R3VpZAsAAAACX2ECX2ICX2MCX2QCX2UCX2YCX2cCX2gCX2kCX2oCX2sAAAAAAAAAAAAAAAgHBwICAgIC + AgICAAAAAAAAAAAAAAAAAAAAAAs= + + + True - + AAABAAEAEBAAAAAAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAQAQAAAAAAAAAAAAAAAAAAAAA diff --git a/Radegast/GUI/Dialogs/Reconnect.cs b/Radegast/GUI/Dialogs/Reconnect.cs index d9ebe37cd..9d3483e9b 100644 --- a/Radegast/GUI/Dialogs/Reconnect.cs +++ b/Radegast/GUI/Dialogs/Reconnect.cs @@ -1,35 +1,24 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id: TabsConsole.cs 361 2009-10-24 15:04:57Z latifer $ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; -using System.Windows.Forms; using OpenMetaverse.StructuredData; namespace Radegast @@ -41,7 +30,7 @@ public partial class frmReconnect : RadegastForm public int ReconnectTime { - get { return reconnectTime; } + get => reconnectTime; set { reconnectTime = value; @@ -52,12 +41,12 @@ public int ReconnectTime public frmReconnect(RadegastInstance instance, int time) { InitializeComponent(); - Disposed += new EventHandler(frmReconnect_Disposed); + Disposed += frmReconnect_Disposed; this.instance = instance; ReconnectTime = time; lblAutoReconnect.Text = string.Format("Auto reconnect in {0} seconds.", reconnectTime); - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } void frmReconnect_Disposed(object sender, EventArgs e) diff --git a/Radegast/GUI/Dialogs/Settings.Designer.cs b/Radegast/GUI/Dialogs/Settings.Designer.cs index 9cb8a4fc6..8a4f06d76 100644 --- a/Radegast/GUI/Dialogs/Settings.Designer.cs +++ b/Radegast/GUI/Dialogs/Settings.Designer.cs @@ -74,12 +74,11 @@ private void InitializeComponent() this.cbResolveURIs = new System.Windows.Forms.CheckBox(); this.cbShowScriptErrors = new System.Windows.Forms.CheckBox(); this.label4 = new System.Windows.Forms.Label(); - this.cbDisableHTTPInventory = new System.Windows.Forms.CheckBox(); this.cbHideLoginGraphics = new System.Windows.Forms.CheckBox(); this.cbDisableLookAt = new System.Windows.Forms.CheckBox(); this.cbTrasactDialog = new System.Windows.Forms.CheckBox(); this.cbRadegastLogToFile = new System.Windows.Forms.CheckBox(); - this.cbTrasactChat = new System.Windows.Forms.CheckBox(); + this.cbTransactChat = new System.Windows.Forms.CheckBox(); this.cbFriendsNotifications = new System.Windows.Forms.CheckBox(); this.txtReconnectTime = new System.Windows.Forms.TextBox(); this.cbAutoReconnect = new System.Windows.Forms.CheckBox(); @@ -87,9 +86,10 @@ private void InitializeComponent() this.cbRLV = new System.Windows.Forms.CheckBox(); this.cbRLVDebug = new System.Windows.Forms.CheckBox(); this.cbMinToTrey = new System.Windows.Forms.CheckBox(); - this.cbRadegastClientTag = new System.Windows.Forms.CheckBox(); this.cbSyntaxHighlight = new System.Windows.Forms.CheckBox(); this.Chat = new System.Windows.Forms.GroupBox(); + this.txtChatLogDir = new System.Windows.Forms.TextBox(); + this.lblChatLog = new System.Windows.Forms.Label(); this.cbNameLinks = new System.Windows.Forms.CheckBox(); this.cbDisableChatIMLog = new System.Windows.Forms.CheckBox(); this.cbChatTimestamps = new System.Windows.Forms.CheckBox(); @@ -116,9 +116,8 @@ private void InitializeComponent() this.gbLSLHelper = new System.Windows.Forms.GroupBox(); this.llLSLHelperInstructios = new System.Windows.Forms.LinkLabel(); this.cbLSLHelperEnabled = new System.Windows.Forms.CheckBox(); - this.lblLSLUUID = new System.Windows.Forms.Label(); this.tbLSLAllowedOwner = new System.Windows.Forms.TextBox(); - this.label3 = new System.Windows.Forms.Label(); + this.lblLSLUUID = new System.Windows.Forms.Label(); this.pseudoHome = new System.Windows.Forms.GroupBox(); this.pseudoHomeSet = new System.Windows.Forms.Button(); this.pseudoHomeTolerance = new System.Windows.Forms.NumericUpDown(); @@ -153,6 +152,7 @@ private void InitializeComponent() this.cbxFontSize = new System.Windows.Forms.ComboBox(); this.cbxFont = new System.Windows.Forms.ComboBox(); this.fontDialog1 = new System.Windows.Forms.FontDialog(); + this.btnChatLogDir = new System.Windows.Forms.Button(); this.tcGraphics.SuspendLayout(); this.tbpGeneral.SuspendLayout(); this.cbHighLight.SuspendLayout(); @@ -207,7 +207,7 @@ private void InitializeComponent() this.cbHighLight.Controls.Add(this.cbHighlightChat); this.cbHighLight.Controls.Add(this.cbFriendsHighlight); this.cbHighLight.Controls.Add(this.cbTaskBarHighLight); - this.cbHighLight.Location = new System.Drawing.Point(8, 180); + this.cbHighLight.Location = new System.Drawing.Point(8, 167); this.cbHighLight.Name = "cbHighLight"; this.cbHighLight.Size = new System.Drawing.Size(256, 136); this.cbHighLight.TabIndex = 1; @@ -273,12 +273,11 @@ private void InitializeComponent() this.cbMisc.Controls.Add(this.cbResolveURIs); this.cbMisc.Controls.Add(this.cbShowScriptErrors); this.cbMisc.Controls.Add(this.label4); - this.cbMisc.Controls.Add(this.cbDisableHTTPInventory); this.cbMisc.Controls.Add(this.cbHideLoginGraphics); this.cbMisc.Controls.Add(this.cbDisableLookAt); this.cbMisc.Controls.Add(this.cbTrasactDialog); this.cbMisc.Controls.Add(this.cbRadegastLogToFile); - this.cbMisc.Controls.Add(this.cbTrasactChat); + this.cbMisc.Controls.Add(this.cbTransactChat); this.cbMisc.Controls.Add(this.cbFriendsNotifications); this.cbMisc.Controls.Add(this.txtReconnectTime); this.cbMisc.Controls.Add(this.cbAutoReconnect); @@ -286,37 +285,38 @@ private void InitializeComponent() this.cbMisc.Controls.Add(this.cbRLV); this.cbMisc.Controls.Add(this.cbRLVDebug); this.cbMisc.Controls.Add(this.cbMinToTrey); - this.cbMisc.Controls.Add(this.cbRadegastClientTag); this.cbMisc.Controls.Add(this.cbSyntaxHighlight); this.cbMisc.Location = new System.Drawing.Point(270, 6); this.cbMisc.Name = "cbMisc"; - this.cbMisc.Size = new System.Drawing.Size(236, 413); + this.cbMisc.Size = new System.Drawing.Size(244, 403); this.cbMisc.TabIndex = 2; this.cbMisc.TabStop = false; // // cbThemeCompatibilityMode // this.cbThemeCompatibilityMode.AutoSize = true; - this.cbThemeCompatibilityMode.Location = new System.Drawing.Point(6, 380); + this.cbThemeCompatibilityMode.Location = new System.Drawing.Point(6, 300); this.cbThemeCompatibilityMode.Name = "cbThemeCompatibilityMode"; this.cbThemeCompatibilityMode.Size = new System.Drawing.Size(150, 17); this.cbThemeCompatibilityMode.TabIndex = 22; this.cbThemeCompatibilityMode.Text = "Theme Compatibility Mode"; this.cbThemeCompatibilityMode.UseVisualStyleBackColor = true; + this.cbThemeCompatibilityMode.CheckedChanged += new System.EventHandler(this.cbThemeCompatibilityMode_CheckedChanged); // // cbConfirmExit // this.cbConfirmExit.AutoSize = true; - this.cbConfirmExit.Location = new System.Drawing.Point(6, 357); + this.cbConfirmExit.Location = new System.Drawing.Point(6, 282); this.cbConfirmExit.Name = "cbConfirmExit"; this.cbConfirmExit.Size = new System.Drawing.Size(81, 17); this.cbConfirmExit.TabIndex = 21; this.cbConfirmExit.Text = "Confirm Exit"; this.cbConfirmExit.UseVisualStyleBackColor = true; + this.cbConfirmExit.CheckedChanged += new System.EventHandler(this.cbConfirmExit_CheckedChanged); // // txtResolveURITime // - this.txtResolveURITime.Location = new System.Drawing.Point(157, 338); + this.txtResolveURITime.Location = new System.Drawing.Point(156, 263); this.txtResolveURITime.Name = "txtResolveURITime"; this.txtResolveURITime.Size = new System.Drawing.Size(53, 20); this.txtResolveURITime.TabIndex = 20; @@ -326,7 +326,7 @@ private void InitializeComponent() // cbResolveURIs // this.cbResolveURIs.AutoSize = true; - this.cbResolveURIs.Location = new System.Drawing.Point(6, 322); + this.cbResolveURIs.Location = new System.Drawing.Point(6, 247); this.cbResolveURIs.Name = "cbResolveURIs"; this.cbResolveURIs.Size = new System.Drawing.Size(92, 17); this.cbResolveURIs.TabIndex = 18; @@ -337,32 +337,22 @@ private void InitializeComponent() // cbShowScriptErrors // this.cbShowScriptErrors.AutoSize = true; - this.cbShowScriptErrors.Location = new System.Drawing.Point(6, 280); + this.cbShowScriptErrors.Location = new System.Drawing.Point(6, 211); this.cbShowScriptErrors.Name = "cbShowScriptErrors"; - this.cbShowScriptErrors.Size = new System.Drawing.Size(110, 17); + this.cbShowScriptErrors.Size = new System.Drawing.Size(113, 17); this.cbShowScriptErrors.TabIndex = 17; - this.cbShowScriptErrors.Text = "Show Script Erros"; + this.cbShowScriptErrors.Text = "Show Script Errors"; this.cbShowScriptErrors.UseVisualStyleBackColor = true; // // label4 // this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(23, 341); + this.label4.Location = new System.Drawing.Point(22, 266); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(109, 13); this.label4.TabIndex = 19; this.label4.Text = "Resolve Timeout (ms)"; // - // cbDisableHTTPInventory - // - this.cbDisableHTTPInventory.AutoSize = true; - this.cbDisableHTTPInventory.Location = new System.Drawing.Point(6, 257); - this.cbDisableHTTPInventory.Name = "cbDisableHTTPInventory"; - this.cbDisableHTTPInventory.Size = new System.Drawing.Size(140, 17); - this.cbDisableHTTPInventory.TabIndex = 16; - this.cbDisableHTTPInventory.Text = "Disable HTTP Inventory"; - this.cbDisableHTTPInventory.UseVisualStyleBackColor = true; - // // cbHideLoginGraphics // this.cbHideLoginGraphics.AutoSize = true; @@ -377,7 +367,7 @@ private void InitializeComponent() // cbDisableLookAt // this.cbDisableLookAt.AutoSize = true; - this.cbDisableLookAt.Location = new System.Drawing.Point(6, 234); + this.cbDisableLookAt.Location = new System.Drawing.Point(6, 193); this.cbDisableLookAt.Name = "cbDisableLookAt"; this.cbDisableLookAt.Size = new System.Drawing.Size(140, 17); this.cbDisableLookAt.TabIndex = 15; @@ -387,7 +377,7 @@ private void InitializeComponent() // cbTrasactDialog // this.cbTrasactDialog.AutoSize = true; - this.cbTrasactDialog.Location = new System.Drawing.Point(6, 111); + this.cbTrasactDialog.Location = new System.Drawing.Point(6, 103); this.cbTrasactDialog.Name = "cbTrasactDialog"; this.cbTrasactDialog.Size = new System.Drawing.Size(176, 17); this.cbTrasactDialog.TabIndex = 9; @@ -398,7 +388,7 @@ private void InitializeComponent() // cbRadegastLogToFile // this.cbRadegastLogToFile.AutoSize = true; - this.cbRadegastLogToFile.Location = new System.Drawing.Point(6, 211); + this.cbRadegastLogToFile.Location = new System.Drawing.Point(6, 175); this.cbRadegastLogToFile.Name = "cbRadegastLogToFile"; this.cbRadegastLogToFile.Size = new System.Drawing.Size(72, 17); this.cbRadegastLogToFile.TabIndex = 14; @@ -406,21 +396,21 @@ private void InitializeComponent() this.cbRadegastLogToFile.UseVisualStyleBackColor = true; this.cbRadegastLogToFile.CheckedChanged += new System.EventHandler(this.cbRadegastLogToFile_CheckedChanged); // - // cbTrasactChat + // cbTransactChat // - this.cbTrasactChat.AutoSize = true; - this.cbTrasactChat.Location = new System.Drawing.Point(6, 131); - this.cbTrasactChat.Name = "cbTrasactChat"; - this.cbTrasactChat.Size = new System.Drawing.Size(170, 17); - this.cbTrasactChat.TabIndex = 10; - this.cbTrasactChat.Text = "Display L$ transactions in chat"; - this.cbTrasactChat.UseVisualStyleBackColor = true; - this.cbTrasactChat.CheckedChanged += new System.EventHandler(this.cbTrasactChat_CheckedChanged); + this.cbTransactChat.AutoSize = true; + this.cbTransactChat.Location = new System.Drawing.Point(6, 121); + this.cbTransactChat.Name = "cbTransactChat"; + this.cbTransactChat.Size = new System.Drawing.Size(170, 17); + this.cbTransactChat.TabIndex = 10; + this.cbTransactChat.Text = "Display L$ transactions in chat"; + this.cbTransactChat.UseVisualStyleBackColor = true; + this.cbTransactChat.CheckedChanged += new System.EventHandler(this.cbTrasactChat_CheckedChanged); // // cbFriendsNotifications // this.cbFriendsNotifications.AutoSize = true; - this.cbFriendsNotifications.Location = new System.Drawing.Point(6, 151); + this.cbFriendsNotifications.Location = new System.Drawing.Point(6, 139); this.cbFriendsNotifications.Name = "cbFriendsNotifications"; this.cbFriendsNotifications.Size = new System.Drawing.Size(184, 17); this.cbFriendsNotifications.TabIndex = 11; @@ -430,7 +420,7 @@ private void InitializeComponent() // // txtReconnectTime // - this.txtReconnectTime.Location = new System.Drawing.Point(157, 88); + this.txtReconnectTime.Location = new System.Drawing.Point(156, 82); this.txtReconnectTime.Name = "txtReconnectTime"; this.txtReconnectTime.Size = new System.Drawing.Size(53, 20); this.txtReconnectTime.TabIndex = 8; @@ -440,7 +430,7 @@ private void InitializeComponent() // cbAutoReconnect // this.cbAutoReconnect.AutoSize = true; - this.cbAutoReconnect.Location = new System.Drawing.Point(6, 71); + this.cbAutoReconnect.Location = new System.Drawing.Point(6, 65); this.cbAutoReconnect.Name = "cbAutoReconnect"; this.cbAutoReconnect.Size = new System.Drawing.Size(169, 17); this.cbAutoReconnect.TabIndex = 6; @@ -451,7 +441,7 @@ private void InitializeComponent() // label2 // this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(23, 91); + this.label2.Location = new System.Drawing.Point(22, 85); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(128, 13); this.label2.TabIndex = 7; @@ -460,7 +450,7 @@ private void InitializeComponent() // cbRLV // this.cbRLV.AutoSize = true; - this.cbRLV.Location = new System.Drawing.Point(6, 171); + this.cbRLV.Location = new System.Drawing.Point(6, 157); this.cbRLV.Name = "cbRLV"; this.cbRLV.Size = new System.Drawing.Size(85, 17); this.cbRLV.TabIndex = 12; @@ -471,7 +461,7 @@ private void InitializeComponent() // cbRLVDebug // this.cbRLVDebug.AutoSize = true; - this.cbRLVDebug.Location = new System.Drawing.Point(6, 300); + this.cbRLVDebug.Location = new System.Drawing.Point(6, 229); this.cbRLVDebug.Name = "cbRLVDebug"; this.cbRLVDebug.Size = new System.Drawing.Size(136, 17); this.cbRLVDebug.TabIndex = 12; @@ -482,7 +472,7 @@ private void InitializeComponent() // cbMinToTrey // this.cbMinToTrey.AutoSize = true; - this.cbMinToTrey.Location = new System.Drawing.Point(6, 31); + this.cbMinToTrey.Location = new System.Drawing.Point(6, 29); this.cbMinToTrey.Name = "cbMinToTrey"; this.cbMinToTrey.Size = new System.Drawing.Size(133, 17); this.cbMinToTrey.TabIndex = 4; @@ -490,20 +480,10 @@ private void InitializeComponent() this.cbMinToTrey.UseVisualStyleBackColor = true; this.cbMinToTrey.CheckedChanged += new System.EventHandler(this.cbTrasactChat_CheckedChanged); // - // cbRadegastClientTag - // - this.cbRadegastClientTag.AutoSize = true; - this.cbRadegastClientTag.Location = new System.Drawing.Point(6, 191); - this.cbRadegastClientTag.Name = "cbRadegastClientTag"; - this.cbRadegastClientTag.Size = new System.Drawing.Size(146, 17); - this.cbRadegastClientTag.TabIndex = 13; - this.cbRadegastClientTag.Text = "Send Radegast client tag"; - this.cbRadegastClientTag.UseVisualStyleBackColor = true; - // // cbSyntaxHighlight // this.cbSyntaxHighlight.AutoSize = true; - this.cbSyntaxHighlight.Location = new System.Drawing.Point(6, 51); + this.cbSyntaxHighlight.Location = new System.Drawing.Point(6, 47); this.cbSyntaxHighlight.Name = "cbSyntaxHighlight"; this.cbSyntaxHighlight.Size = new System.Drawing.Size(134, 17); this.cbSyntaxHighlight.TabIndex = 5; @@ -512,6 +492,9 @@ private void InitializeComponent() // // Chat // + this.Chat.Controls.Add(this.btnChatLogDir); + this.Chat.Controls.Add(this.txtChatLogDir); + this.Chat.Controls.Add(this.lblChatLog); this.Chat.Controls.Add(this.cbNameLinks); this.Chat.Controls.Add(this.cbDisableChatIMLog); this.Chat.Controls.Add(this.cbChatTimestamps); @@ -520,15 +503,34 @@ private void InitializeComponent() this.Chat.Controls.Add(this.cbNoTyping); this.Chat.Location = new System.Drawing.Point(8, 5); this.Chat.Name = "Chat"; - this.Chat.Size = new System.Drawing.Size(256, 169); + this.Chat.Size = new System.Drawing.Size(256, 156); this.Chat.TabIndex = 0; this.Chat.TabStop = false; this.Chat.Text = "Chat"; // + // txtChatLogDir + // + this.txtChatLogDir.AccessibleDescription = "Directory storing chat logs"; + this.txtChatLogDir.AccessibleName = "Chat Log Location"; + this.txtChatLogDir.Enabled = false; + this.txtChatLogDir.Location = new System.Drawing.Point(99, 127); + this.txtChatLogDir.Name = "txtChatLogDir"; + this.txtChatLogDir.Size = new System.Drawing.Size(91, 20); + this.txtChatLogDir.TabIndex = 11; + // + // lblChatLog + // + this.lblChatLog.AutoSize = true; + this.lblChatLog.Location = new System.Drawing.Point(6, 131); + this.lblChatLog.Name = "lblChatLog"; + this.lblChatLog.Size = new System.Drawing.Size(94, 13); + this.lblChatLog.TabIndex = 10; + this.lblChatLog.Text = "Chat Log Location"; + // // cbNameLinks // this.cbNameLinks.AutoSize = true; - this.cbNameLinks.Location = new System.Drawing.Point(8, 127); + this.cbNameLinks.Location = new System.Drawing.Point(8, 110); this.cbNameLinks.Name = "cbNameLinks"; this.cbNameLinks.Size = new System.Drawing.Size(110, 17); this.cbNameLinks.TabIndex = 9; @@ -538,7 +540,7 @@ private void InitializeComponent() // cbDisableChatIMLog // this.cbDisableChatIMLog.AutoSize = true; - this.cbDisableChatIMLog.Location = new System.Drawing.Point(8, 104); + this.cbDisableChatIMLog.Location = new System.Drawing.Point(8, 91); this.cbDisableChatIMLog.Name = "cbDisableChatIMLog"; this.cbDisableChatIMLog.Size = new System.Drawing.Size(138, 17); this.cbDisableChatIMLog.TabIndex = 8; @@ -548,7 +550,7 @@ private void InitializeComponent() // cbChatTimestamps // this.cbChatTimestamps.AutoSize = true; - this.cbChatTimestamps.Location = new System.Drawing.Point(8, 12); + this.cbChatTimestamps.Location = new System.Drawing.Point(8, 16); this.cbChatTimestamps.Name = "cbChatTimestamps"; this.cbChatTimestamps.Size = new System.Drawing.Size(143, 17); this.cbChatTimestamps.TabIndex = 0; @@ -568,7 +570,7 @@ private void InitializeComponent() // cbMUEmotes // this.cbMUEmotes.AutoSize = true; - this.cbMUEmotes.Location = new System.Drawing.Point(8, 58); + this.cbMUEmotes.Location = new System.Drawing.Point(8, 53); this.cbMUEmotes.Name = "cbMUEmotes"; this.cbMUEmotes.Size = new System.Drawing.Size(108, 17); this.cbMUEmotes.TabIndex = 5; @@ -579,7 +581,7 @@ private void InitializeComponent() // cbNoTyping // this.cbNoTyping.AutoSize = true; - this.cbNoTyping.Location = new System.Drawing.Point(8, 81); + this.cbNoTyping.Location = new System.Drawing.Point(8, 72); this.cbNoTyping.Name = "cbNoTyping"; this.cbNoTyping.Size = new System.Drawing.Size(150, 17); this.cbNoTyping.TabIndex = 6; @@ -593,7 +595,7 @@ private void InitializeComponent() this.gbDisplayNames.Controls.Add(this.rbDNDandUsernme); this.gbDisplayNames.Controls.Add(this.rbDNSmart); this.gbDisplayNames.Controls.Add(this.rbDNOff); - this.gbDisplayNames.Location = new System.Drawing.Point(8, 319); + this.gbDisplayNames.Location = new System.Drawing.Point(8, 309); this.gbDisplayNames.Name = "gbDisplayNames"; this.gbDisplayNames.Size = new System.Drawing.Size(256, 100); this.gbDisplayNames.TabIndex = 3; @@ -791,20 +793,20 @@ private void InitializeComponent() // this.gbLSLHelper.Controls.Add(this.llLSLHelperInstructios); this.gbLSLHelper.Controls.Add(this.cbLSLHelperEnabled); - this.gbLSLHelper.Controls.Add(this.lblLSLUUID); this.gbLSLHelper.Controls.Add(this.tbLSLAllowedOwner); - this.gbLSLHelper.Controls.Add(this.label3); + this.gbLSLHelper.Controls.Add(this.lblLSLUUID); this.gbLSLHelper.Location = new System.Drawing.Point(8, 218); this.gbLSLHelper.Name = "gbLSLHelper"; - this.gbLSLHelper.Size = new System.Drawing.Size(263, 83); + this.gbLSLHelper.Size = new System.Drawing.Size(263, 170); this.gbLSLHelper.TabIndex = 2; this.gbLSLHelper.TabStop = false; this.gbLSLHelper.Text = "LSL Helper"; // // llLSLHelperInstructios // + this.llLSLHelperInstructios.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.llLSLHelperInstructios.AutoSize = true; - this.llLSLHelperInstructios.Location = new System.Drawing.Point(196, 59); + this.llLSLHelperInstructios.Location = new System.Drawing.Point(196, 146); this.llLSLHelperInstructios.Name = "llLSLHelperInstructios"; this.llLSLHelperInstructios.Size = new System.Drawing.Size(61, 13); this.llLSLHelperInstructios.TabIndex = 4; @@ -814,8 +816,9 @@ private void InitializeComponent() // // cbLSLHelperEnabled // + this.cbLSLHelperEnabled.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.cbLSLHelperEnabled.AutoSize = true; - this.cbLSLHelperEnabled.Location = new System.Drawing.Point(9, 58); + this.cbLSLHelperEnabled.Location = new System.Drawing.Point(9, 145); this.cbLSLHelperEnabled.Name = "cbLSLHelperEnabled"; this.cbLSLHelperEnabled.Size = new System.Drawing.Size(65, 17); this.cbLSLHelperEnabled.TabIndex = 3; @@ -823,33 +826,29 @@ private void InitializeComponent() this.cbLSLHelperEnabled.UseVisualStyleBackColor = true; this.cbLSLHelperEnabled.CheckedChanged += new System.EventHandler(this.cbLSLHelperEnabled_CheckedChanged); // - // lblLSLUUID - // - this.lblLSLUUID.AutoSize = true; - this.lblLSLUUID.Location = new System.Drawing.Point(6, 35); - this.lblLSLUUID.Name = "lblLSLUUID"; - this.lblLSLUUID.Size = new System.Drawing.Size(34, 13); - this.lblLSLUUID.TabIndex = 1; - this.lblLSLUUID.Text = "UUID"; - this.lblLSLUUID.Click += new System.EventHandler(this.lblLSLUUID_Click); - // // tbLSLAllowedOwner // - this.tbLSLAllowedOwner.Location = new System.Drawing.Point(47, 32); - this.tbLSLAllowedOwner.MaxLength = 36; + this.tbLSLAllowedOwner.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.tbLSLAllowedOwner.Location = new System.Drawing.Point(9, 32); + this.tbLSLAllowedOwner.MaxLength = 0; + this.tbLSLAllowedOwner.Multiline = true; this.tbLSLAllowedOwner.Name = "tbLSLAllowedOwner"; - this.tbLSLAllowedOwner.Size = new System.Drawing.Size(210, 20); + this.tbLSLAllowedOwner.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.tbLSLAllowedOwner.Size = new System.Drawing.Size(248, 107); this.tbLSLAllowedOwner.TabIndex = 2; this.tbLSLAllowedOwner.Leave += new System.EventHandler(this.tbLSLAllowedOwner_Leave); // - // label3 + // lblLSLUUID // - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(6, 16); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(108, 13); - this.label3.TabIndex = 0; - this.label3.Text = "Allowed object owner"; + this.lblLSLUUID.AutoSize = true; + this.lblLSLUUID.Location = new System.Drawing.Point(6, 16); + this.lblLSLUUID.Name = "lblLSLUUID"; + this.lblLSLUUID.Size = new System.Drawing.Size(154, 13); + this.lblLSLUUID.TabIndex = 0; + this.lblLSLUUID.Text = "Allowed object owners (UUIDs)"; + this.lblLSLUUID.Click += new System.EventHandler(this.lblLSLUUID_Click); // // pseudoHome // @@ -869,6 +868,7 @@ private void InitializeComponent() // // pseudoHomeSet // + this.pseudoHomeSet.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.pseudoHomeSet.Location = new System.Drawing.Point(94, 73); this.pseudoHomeSet.Name = "pseudoHomeSet"; this.pseudoHomeSet.Size = new System.Drawing.Size(75, 23); @@ -912,6 +912,8 @@ private void InitializeComponent() // // pseudoHomeLocation // + this.pseudoHomeLocation.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.pseudoHomeLocation.Location = new System.Drawing.Point(87, 40); this.pseudoHomeLocation.Name = "pseudoHomeLocation"; this.pseudoHomeLocation.ReadOnly = true; @@ -920,6 +922,7 @@ private void InitializeComponent() // // pseudoHomeClear // + this.pseudoHomeClear.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.pseudoHomeClear.Location = new System.Drawing.Point(182, 73); this.pseudoHomeClear.Name = "pseudoHomeClear"; this.pseudoHomeClear.Size = new System.Drawing.Size(75, 23); @@ -939,8 +942,9 @@ private void InitializeComponent() // // pseudoHomeEnabled // + this.pseudoHomeEnabled.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.pseudoHomeEnabled.AutoSize = true; - this.pseudoHomeEnabled.Location = new System.Drawing.Point(6, 77); + this.pseudoHomeEnabled.Location = new System.Drawing.Point(9, 79); this.pseudoHomeEnabled.Name = "pseudoHomeEnabled"; this.pseudoHomeEnabled.Size = new System.Drawing.Size(65, 17); this.pseudoHomeEnabled.TabIndex = 8; @@ -966,6 +970,7 @@ private void InitializeComponent() // // autoSitEnabled // + this.autoSitEnabled.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.autoSitEnabled.AutoSize = true; this.autoSitEnabled.Location = new System.Drawing.Point(9, 70); this.autoSitEnabled.Name = "autoSitEnabled"; @@ -977,6 +982,7 @@ private void InitializeComponent() // // autoSitSit // + this.autoSitSit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.autoSitSit.Location = new System.Drawing.Point(94, 66); this.autoSitSit.Name = "autoSitSit"; this.autoSitSit.Size = new System.Drawing.Size(75, 23); @@ -987,6 +993,7 @@ private void InitializeComponent() // // autoSitClear // + this.autoSitClear.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.autoSitClear.Location = new System.Drawing.Point(182, 66); this.autoSitClear.Name = "autoSitClear"; this.autoSitClear.Size = new System.Drawing.Size(75, 23); @@ -1007,6 +1014,8 @@ private void InitializeComponent() // // autoSitUUID // + this.autoSitUUID.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.autoSitUUID.Location = new System.Drawing.Point(47, 40); this.autoSitUUID.MaxLength = 36; this.autoSitUUID.Name = "autoSitUUID"; @@ -1016,6 +1025,8 @@ private void InitializeComponent() // // autoSitName // + this.autoSitName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.autoSitName.Location = new System.Drawing.Point(47, 13); this.autoSitName.Name = "autoSitName"; this.autoSitName.ReadOnly = true; @@ -1225,6 +1236,18 @@ private void InitializeComponent() // this.fontDialog1.ShowColor = true; // + // btnChatLogDir + // + this.btnChatLogDir.AccessibleDescription = "Browse for chat log directory"; + this.btnChatLogDir.AccessibleName = "Browse Chat Log Directory"; + this.btnChatLogDir.Location = new System.Drawing.Point(196, 126); + this.btnChatLogDir.Name = "btnChatLogDir"; + this.btnChatLogDir.Size = new System.Drawing.Size(57, 23); + this.btnChatLogDir.TabIndex = 12; + this.btnChatLogDir.Text = "Browse"; + this.btnChatLogDir.UseVisualStyleBackColor = true; + this.btnChatLogDir.Click += new System.EventHandler(this.btnChatLogDir_Click); + // // frmSettings // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -1269,7 +1292,7 @@ private void InitializeComponent() public System.Windows.Forms.TabPage tbpGeneral; public System.Windows.Forms.CheckBox cbIMTimeStamps; public System.Windows.Forms.CheckBox cbChatTimestamps; - public System.Windows.Forms.CheckBox cbTrasactChat; + public System.Windows.Forms.CheckBox cbTransactChat; public System.Windows.Forms.CheckBox cbTrasactDialog; public System.Windows.Forms.CheckBox cbFriendsNotifications; public System.Windows.Forms.CheckBox cbAutoReconnect; @@ -1296,7 +1319,6 @@ private void InitializeComponent() public System.Windows.Forms.RadioButton rbDNOff; public System.Windows.Forms.CheckBox cbTaskBarHighLight; public System.Windows.Forms.TabPage tbpGraphics; - public System.Windows.Forms.CheckBox cbRadegastClientTag; public System.Windows.Forms.GroupBox gnAutoInventory; public System.Windows.Forms.ComboBox cbOnInvOffer; public System.Windows.Forms.CheckBox cbDisableChatIMLog; @@ -1307,7 +1329,6 @@ private void InitializeComponent() public System.Windows.Forms.GroupBox cbHighLight; public System.Windows.Forms.CheckBox cbHighlightGroupIM; public System.Windows.Forms.CheckBox cbHighlightIM; - public System.Windows.Forms.CheckBox cbDisableHTTPInventory; public System.Windows.Forms.CheckBox cbHighlightChat; public System.Windows.Forms.TabPage tbpBot; public System.Windows.Forms.GroupBox autoSit; @@ -1330,9 +1351,8 @@ private void InitializeComponent() private System.Windows.Forms.GroupBox gbLSLHelper; private System.Windows.Forms.LinkLabel llLSLHelperInstructios; public System.Windows.Forms.CheckBox cbLSLHelperEnabled; - public System.Windows.Forms.Label lblLSLUUID; public System.Windows.Forms.TextBox tbLSLAllowedOwner; - private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label lblLSLUUID; public System.Windows.Forms.CheckBox cbShowScriptErrors; public System.Windows.Forms.GroupBox gnAutoScriptPermission; public System.Windows.Forms.ComboBox cbAutoScriptPermission; @@ -1359,5 +1379,8 @@ private void InitializeComponent() private System.Windows.Forms.Label lblPreview; private System.Windows.Forms.Button btnSave; private System.Windows.Forms.Button btnResetFontSettings; + private System.Windows.Forms.TextBox txtChatLogDir; + private System.Windows.Forms.Label lblChatLog; + private System.Windows.Forms.Button btnChatLogDir; } } diff --git a/Radegast/GUI/Dialogs/Settings.cs b/Radegast/GUI/Dialogs/Settings.cs index 42d8b473c..df4fc769d 100644 --- a/Radegast/GUI/Dialogs/Settings.cs +++ b/Radegast/GUI/Dialogs/Settings.cs @@ -1,52 +1,36 @@ - -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/* + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2023, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections.Generic; -using System.ComponentModel; -using System.Data; using System.Drawing; -using System.Linq; using System.Text; using System.Windows.Forms; - +using Newtonsoft.Json; using OpenMetaverse; using OpenMetaverse.StructuredData; - using Radegast.Automation; -using System.Web.Script.Serialization; namespace Radegast { - public enum AutoResponseType : int + public enum AutoResponseType { WhenBusy = 0, WhenFromNonFriend = 1, @@ -60,7 +44,7 @@ public partial class frmSettings : RadegastForm private Settings.FontSetting currentlySelectedFontSetting = null; Dictionary chatFontSettings; - public static void InitSettigs(Settings s, bool mono) + public static void InitSettings(Settings s) { if (s["im_timestamps"].Type == OSDType.Unknown) { @@ -69,22 +53,22 @@ public static void InitSettigs(Settings s, bool mono) if (s["rlv_enabled"].Type == OSDType.Unknown) { - s["rlv_enabled"] = new OSDBoolean(false); + s["rlv_enabled"] = OSD.FromBoolean(false); } if (s["rlv_debugcommands"].Type == OSDType.Unknown) { - s["rlv_debugcommands"] = new OSDBoolean(false); + s["rlv_debugcommands"] = OSD.FromBoolean(false); } if (s["mu_emotes"].Type == OSDType.Unknown) { - s["mu_emotes"] = new OSDBoolean(false); + s["mu_emotes"] = OSD.FromBoolean(false); } if (s["friends_notification_highlight"].Type == OSDType.Unknown) { - s["friends_notification_highlight"] = new OSDBoolean(true); + s["friends_notification_highlight"] = OSD.FromBoolean(true); } if (!s.ContainsKey("no_typing_anim")) s["no_typing_anim"] = OSD.FromBoolean(false); @@ -127,8 +111,6 @@ public static void InitSettigs(Settings s, bool mono) if (!s.ContainsKey("rendering_use_vbo")) s["rendering_use_vbo"] = true; - if (!s.ContainsKey("send_rad_client_tag")) s["send_rad_client_tag"] = true; - if (!s.ContainsKey("log_to_file")) s["log_to_file"] = true; if (!s.ContainsKey("disable_chat_im_log")) s["disable_chat_im_log"] = false; @@ -145,14 +127,14 @@ public static void InitSettigs(Settings s, bool mono) if (!s.ContainsKey("av_name_link")) s["av_name_link"] = false; - if (!s.ContainsKey("disable_http_inventory")) + if (!s.ContainsKey("on_script_question")) { - s["disable_http_inventory"] = false; + s["on_script_question"] = "Ask"; } - if (!s.ContainsKey("on_script_question")) + if (!s.ContainsKey("chat_log_dir")) { - s["on_script_question"] = "Ask"; + s["chat_log_dir"] = OSD.FromString(""); } } @@ -164,18 +146,18 @@ private void InitColorSettings() cbxFontSize.Items.Add((float)i + 0.5f); } - foreach (var font in System.Drawing.FontFamily.Families) + foreach (var font in FontFamily.Families) { cbxFont.Items.Add(font.Name); } //var colorTypes = typeof(System.Drawing.Color); //var props = colorTypes.GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.DeclaredOnly); - var knownColors = typeof(System.Drawing.KnownColor).GetEnumValues(); + var knownColors = typeof(KnownColor).GetEnumValues(); foreach (var item in knownColors) { - var color = System.Drawing.Color.FromKnownColor((System.Drawing.KnownColor)item); + var color = Color.FromKnownColor((KnownColor)item); cbxForeground.Items.Add(color); cbxBackground.Items.Add(color); } @@ -197,9 +179,8 @@ private void ReloadFontSettings() var chatFontsJson = Instance.GlobalSettings["chat_fonts"]; if (chatFontsJson.Type != OSDType.Unknown) { - JavaScriptSerializer serializer = new JavaScriptSerializer(); Dictionary unpacked = new Dictionary(); - chatFontSettings = serializer.Deserialize>(chatFontsJson); + chatFontSettings = JsonConvert.DeserializeObject>(chatFontsJson); } else { @@ -208,13 +189,10 @@ private void ReloadFontSettings() foreach (var item in chatFontSettings) { - if(item.Value.Name != item.Key) - { - item.Value.Name = item.Key; - } + item.Value.Name = item.Key; lbxColorItems.Items.Add(item.Value); } - if(chatFontSettings.Count > 0) + if (chatFontSettings.Count > 0) { lbxColorItems.SetSelected(0, true); } @@ -225,7 +203,7 @@ public frmSettings(RadegastInstance instance) { if (settingInitialized) { - frmSettings.InitSettigs(instance.GlobalSettings, instance.MonoRuntime); + InitSettings(instance.GlobalSettings); } InitializeComponent(); @@ -233,63 +211,62 @@ public frmSettings(RadegastInstance instance) InitColorSettings(); s = instance.GlobalSettings; - tbpGraphics.Controls.Add(new Radegast.Rendering.GraphicsPreferences(instance)); + tbpGraphics.Controls.Add(new Rendering.GraphicsPreferences(instance)); cbChatTimestamps.Checked = s["chat_timestamps"].AsBoolean(); cbIMTimeStamps.Checked = s["im_timestamps"].AsBoolean(); - cbChatTimestamps.CheckedChanged += new EventHandler(cbChatTimestamps_CheckedChanged); - cbIMTimeStamps.CheckedChanged += new EventHandler(cbIMTimeStamps_CheckedChanged); + cbChatTimestamps.CheckedChanged += cbChatTimestamps_CheckedChanged; + cbIMTimeStamps.CheckedChanged += cbIMTimeStamps_CheckedChanged; cbTrasactDialog.Checked = s["transaction_notification_dialog"].AsBoolean(); - cbTrasactChat.Checked = s["transaction_notification_chat"].AsBoolean(); + cbTransactChat.Checked = s["transaction_notification_chat"].AsBoolean(); cbFriendsNotifications.Checked = s["show_friends_online_notifications"].AsBoolean(); - cbFriendsNotifications.CheckedChanged += new EventHandler(cbFriendsNotifications_CheckedChanged); + cbFriendsNotifications.CheckedChanged += cbFriendsNotifications_CheckedChanged; cbAutoReconnect.Checked = s["auto_reconnect"].AsBoolean(); - cbAutoReconnect.CheckedChanged += new EventHandler(cbAutoReconnect_CheckedChanged); + cbAutoReconnect.CheckedChanged += cbAutoReconnect_CheckedChanged; cbResolveURIs.Checked = s["resolve_uris"].AsBoolean(); - cbResolveURIs.CheckedChanged += new EventHandler(cbResolveURIs_CheckedChanged); ; + cbResolveURIs.CheckedChanged += cbResolveURIs_CheckedChanged; cbHideLoginGraphics.Checked = s["hide_login_graphics"].AsBoolean(); - cbHideLoginGraphics.CheckedChanged += new EventHandler(cbHideLoginGraphics_CheckedChanged); + cbHideLoginGraphics.CheckedChanged += cbHideLoginGraphics_CheckedChanged; cbRLV.Checked = s["rlv_enabled"].AsBoolean(); - cbRLV.CheckedChanged += (object sender, EventArgs e) => + cbRLV.CheckedChanged += (sender, e) => { s["rlv_enabled"] = new OSDBoolean(cbRLV.Checked); }; cbRLVDebug.Checked = s["rlv_debugcommands"].AsBoolean(); - cbRLVDebug.CheckedChanged += (object sender, EventArgs e) => + cbRLVDebug.CheckedChanged += (sender, e) => { s["rlv_debugcommands"] = new OSDBoolean(cbRLVDebug.Checked); }; cbMUEmotes.Checked = s["mu_emotes"].AsBoolean(); - cbMUEmotes.CheckedChanged += (object sender, EventArgs e) => + cbMUEmotes.CheckedChanged += (sender, e) => { s["mu_emotes"] = new OSDBoolean(cbMUEmotes.Checked); }; if (!s.ContainsKey("minimize_to_tray")) s["minimize_to_tray"] = OSD.FromBoolean(false); cbMinToTrey.Checked = s["minimize_to_tray"].AsBoolean(); - cbMinToTrey.CheckedChanged += (object sender, EventArgs e) => + cbMinToTrey.CheckedChanged += (sender, e) => { s["minimize_to_tray"] = OSD.FromBoolean(cbMinToTrey.Checked); }; - cbNoTyping.Checked = s["no_typing_anim"].AsBoolean(); - cbNoTyping.CheckedChanged += (object sender, EventArgs e) => + cbNoTyping.CheckedChanged += (sender, e) => { s["no_typing_anim"] = OSD.FromBoolean(cbNoTyping.Checked); }; txtAutoResponse.Text = s["auto_response_text"]; - txtAutoResponse.TextChanged += (object sender, EventArgs e) => + txtAutoResponse.TextChanged += (sender, e) => { s["auto_response_text"] = txtAutoResponse.Text; }; @@ -302,7 +279,7 @@ public frmSettings(RadegastInstance instance) } cbSyntaxHighlight.Checked = s["script_syntax_highlight"].AsBoolean(); - cbSyntaxHighlight.CheckedChanged += (object sender, EventArgs e) => + cbSyntaxHighlight.CheckedChanged += (sender, e) => { s["script_syntax_highlight"] = OSD.FromBoolean(cbSyntaxHighlight.Checked); }; @@ -319,13 +296,6 @@ public frmSettings(RadegastInstance instance) txtResolveURITime.Text = s["resolve_uri_time"].AsInteger().ToString(); - cbRadegastClientTag.Checked = s["send_rad_client_tag"]; - cbRadegastClientTag.CheckedChanged += (sender, e) => - { - s["send_rad_client_tag"] = cbRadegastClientTag.Checked; - instance.SetClientTag(); - }; - cbOnInvOffer.SelectedIndex = s["inv_auto_accept_mode"].AsInteger(); cbOnInvOffer.SelectedIndexChanged += (sender, e) => { @@ -366,7 +336,7 @@ public frmSettings(RadegastInstance instance) }; cbFriendsHighlight.Checked = s["friends_notification_highlight"].AsBoolean(); - cbFriendsHighlight.CheckedChanged += (object sender, EventArgs e) => + cbFriendsHighlight.CheckedChanged += (sender, e) => { s["friends_notification_highlight"] = new OSDBoolean(cbFriendsHighlight.Checked); }; @@ -403,18 +373,14 @@ public frmSettings(RadegastInstance instance) }; } - cbDisableHTTPInventory.Checked = s["disable_http_inventory"]; - cbDisableHTTPInventory.CheckedChanged += (sender, e) => - { - s["disable_http_inventory"] = cbDisableHTTPInventory.Checked; - }; - cbShowScriptErrors.Checked = s["show_script_errors"]; cbShowScriptErrors.CheckedChanged += (sender, e) => { s["show_script_errors"] = cbShowScriptErrors.Checked; }; + txtChatLogDir.Text = s["chat_log_dir"]; + autoSitPrefsUpdate(); pseudoHomePrefsUpdated(); LSLHelperPrefsUpdate(); @@ -423,7 +389,7 @@ public frmSettings(RadegastInstance instance) UpdateEnabled(); - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } void UpdateEnabled() @@ -475,7 +441,7 @@ private void cbTrasactDialog_CheckedChanged(object sender, EventArgs e) private void cbTrasactChat_CheckedChanged(object sender, EventArgs e) { - s["transaction_notification_chat"] = OSD.FromBoolean(cbTrasactChat.Checked); + s["transaction_notification_chat"] = OSD.FromBoolean(cbTransactChat.Checked); } private void rbAutobusy_CheckedChanged(object sender, EventArgs e) @@ -728,10 +694,10 @@ private void LSLHelperPrefsUpdate() } Instance.State.LSLHelper.LoadSettings(); - tbLSLAllowedOwner.Text = Instance.State.LSLHelper.AllowedOwner.ToString(); - cbLSLHelperEnabled.CheckedChanged -=new EventHandler(cbLSLHelperEnabled_CheckedChanged); + tbLSLAllowedOwner.Text = string.Join(Environment.NewLine, Instance.State.LSLHelper.AllowedOwners); + cbLSLHelperEnabled.CheckedChanged -= cbLSLHelperEnabled_CheckedChanged; cbLSLHelperEnabled.Checked = Instance.State.LSLHelper.Enabled; - cbLSLHelperEnabled.CheckedChanged += new EventHandler(cbLSLHelperEnabled_CheckedChanged); + cbLSLHelperEnabled.CheckedChanged += cbLSLHelperEnabled_CheckedChanged; } private void LSLHelperPrefsSave() @@ -742,27 +708,42 @@ private void LSLHelperPrefsSave() } Instance.State.LSLHelper.Enabled = cbLSLHelperEnabled.Checked; - UUID allowedOwnner = UUID.Zero; - UUID.TryParse(tbLSLAllowedOwner.Text, out allowedOwnner); - Instance.State.LSLHelper.AllowedOwner = allowedOwnner; + Instance.State.LSLHelper.AllowedOwners.Clear(); + + var warnings = new StringBuilder(); + foreach (var line in tbLSLAllowedOwner.Lines) + { + if (string.IsNullOrWhiteSpace(line)) + { + continue; + } + + var owner = line.Trim().ToLower(); + if (!UUID.TryParse(owner, out _)) + { + warnings.Append("Invalid owner UUID: ").AppendLine(line); + } + else + { + Instance.State.LSLHelper.AllowedOwners.Add(owner); + } + } + if (warnings.Length > 0) + { + MessageBox.Show(warnings.ToString(), "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); + } + Instance.State.LSLHelper.SaveSettings(); + LSLHelperPrefsUpdate(); } private void llLSLHelperInstructios_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { - Instance.MainForm.ProcessLink("http://radegast.org/wiki/LSL_Helper", false); + Instance.MainForm.ProcessLink("http://radegast.life/documentation/lsl-helper", false); } private void tbLSLAllowedOwner_Leave(object sender, EventArgs e) { - UUID allowedOwner = UUID.Zero; - if (UUID.TryParse(tbLSLAllowedOwner.Text, out allowedOwner)) - { - } - else - { - tbLSLAllowedOwner.Text = UUID.Zero.ToString(); - } LSLHelperPrefsSave(); } @@ -790,17 +771,15 @@ private void cbxForeground_DrawItem(object sender, DrawItemEventArgs e) var graphics = e.Graphics; var bounds = e.Bounds; - if (e.Index >= 0 && sender is ComboBox) + if (e.Index >= 0 && sender is ComboBox sourceControl) { - var sourceControl = sender as ComboBox; var selectedColor = (Color)sourceControl.Items[e.Index]; - if(sourceControl.Items[e.Index] is Color) { var brushPreview = new SolidBrush(selectedColor); e.DrawBackground(); - if(e.State == DrawItemState.Selected) + if (e.State == DrawItemState.Selected) { graphics.DrawRectangle(SystemPens.Highlight, bounds); } @@ -827,29 +806,22 @@ private void cbxFont_DrawItem(object sender, DrawItemEventArgs e) var graphics = e.Graphics; var bounds = e.Bounds; - if (e.Index >= 0 && sender is ComboBox) + if (e.Index >= 0 && sender is ComboBox sourceControl) { - var sourceControl = sender as ComboBox; var fontName = sourceControl.Items[e.Index].ToString(); var fontPreview = new Font(fontName, kPreviewFontSize); e.DrawBackground(); - if(e.State == DrawItemState.Selected) - { - graphics.DrawRectangle(SystemPens.Highlight, bounds); - } - else - { - graphics.DrawRectangle(SystemPens.Window, bounds); - } + graphics.DrawRectangle(e.State == DrawItemState.Selected + ? SystemPens.Highlight : SystemPens.Window, + bounds); graphics.DrawString(fontName, fontPreview, SystemBrushes.ControlText, bounds.X, bounds.Top); - } } @@ -861,33 +833,34 @@ private Settings.FontSetting GetPreviewFontSettings() Color foreColor = SystemColors.ControlText; FontStyle style = FontStyle.Regular; - if(cbxFontSize.SelectedItem is float) + if (cbxFontSize.SelectedItem is float item) { - fontSize = (float)cbxFontSize.SelectedItem; + fontSize = item; } - if(cbxFont.SelectedItem is string) + if (cbxFont.SelectedItem is string selectedItem) { - fontName = (string)cbxFont.SelectedItem; + fontName = selectedItem; } - if(cbxForeground.SelectedItem is Color) + if (cbxForeground.SelectedItem is Color color) { - foreColor = (Color)cbxForeground.SelectedItem; + foreColor = color; } - if(cbxBackground.SelectedItem is Color) + if (cbxBackground.SelectedItem is Color backgroundSelectedItem) { - backColor = (Color)cbxBackground.SelectedItem; + backColor = backgroundSelectedItem; } - if(cbxBold.Checked) + if (cbxBold.Checked) { style |= FontStyle.Bold; } - if(cbxItalic.Checked) + if (cbxItalic.Checked) { style |= FontStyle.Italic; } - var previewFontSettings = new Settings.FontSetting(){ + var previewFontSettings = new Settings.FontSetting() + { Name = string.Empty, Font = new Font(fontName, fontSize, style), ForeColor = foreColor, @@ -919,7 +892,7 @@ private void UpdateSelection(Settings.FontSetting selected) private void SaveCurrentFontSetting() { - if(currentlySelectedFontSetting != null) + if (currentlySelectedFontSetting != null) { try { @@ -928,8 +901,7 @@ private void SaveCurrentFontSetting() chatFontSettings[currentlySelectedFontSetting.Name] = previewFontSettings; - JavaScriptSerializer serializer = new JavaScriptSerializer(); - var json = serializer.Serialize(chatFontSettings); + var json = JsonConvert.SerializeObject(chatFontSettings); Instance.GlobalSettings["chat_fonts"] = json; Instance.GlobalSettings.Save(); @@ -948,8 +920,7 @@ private void ResetFontSettings() { try { - JavaScriptSerializer serializer = new JavaScriptSerializer(); - var json = serializer.Serialize(Settings.DefaultFontSettings); + var json = JsonConvert.SerializeObject(Settings.DefaultFontSettings); Instance.GlobalSettings["chat_fonts"] = json; Instance.GlobalSettings.Save(); ReloadFontSettings(); @@ -977,29 +948,24 @@ private void cbxBold_CheckStateChanged(object sender, EventArgs e) private void lbxColorItems_SelectedIndexChanged(object sender, EventArgs e) { - if(sender is ListBox) + var sourceListbox = sender as ListBox; + if (sourceListbox?.SelectedItem is Settings.FontSetting fontSettings) { - var sourceListbox = sender as ListBox; - if(sourceListbox.SelectedItem is Settings.FontSetting) - { - var fontSettings = sourceListbox.SelectedItem as Settings.FontSetting; - UpdateSelection(fontSettings); - } + UpdateSelection(fontSettings); } } private void lbxColorItems_MouseMove(object sender, MouseEventArgs e) { - if(e.Button != MouseButtons.None) + if (e.Button != MouseButtons.None) { - ListBox sourceListbox = sender as ListBox; - if(sourceListbox != null) + if (sender is ListBox sourceListbox) { int itemIndex = sourceListbox.IndexFromPoint(new Point(e.X, e.Y)); - if(itemIndex != -1) + if (itemIndex != -1) { - var selectedItem = sourceListbox.Items[itemIndex] as Settings.FontSetting; - if(selectedItem != null && selectedItem != currentlySelectedFontSetting) + if (sourceListbox.Items[itemIndex] is Settings.FontSetting selectedItem + && selectedItem != currentlySelectedFontSetting) { UpdateSelection(selectedItem); sourceListbox.SelectedIndex = itemIndex; @@ -1021,12 +987,31 @@ private void btnSave_Click(object sender, EventArgs e) private void btnResetFontSettings_Click(object sender, EventArgs e) { - if(MessageBox.Show("Reset all color settings to the default values?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.Yes) + if (MessageBox.Show("Reset all color settings to the default values?", "Confirmation", + MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.Yes) { ResetFontSettings(); } } - } + private void FrmSettings_FormClosing(object sender, System.Windows.Forms.FormClosingEventArgs e) + { + LSLHelperPrefsSave(); + } + private void btnChatLogDir_Click(object sender, EventArgs e) + { + FolderBrowserDialog folderDlg = new FolderBrowserDialog + { + ShowNewFolderButton = true + }; + // Show the FolderBrowserDialog. + DialogResult result = folderDlg.ShowDialog(); + if (result == DialogResult.OK) + { + txtChatLogDir.Text = folderDlg.SelectedPath; + s["chat_log_dir"] = folderDlg.SelectedPath; + } + } + } } diff --git a/Radegast/GUI/Dialogs/Settings.resx b/Radegast/GUI/Dialogs/Settings.resx index 1f7c74770..93fdf47c6 100644 --- a/Radegast/GUI/Dialogs/Settings.resx +++ b/Radegast/GUI/Dialogs/Settings.resx @@ -120,6 +120,9 @@ 17, 17 + + 49 + diff --git a/Radegast/GUI/Floater.cs b/Radegast/GUI/Floater.cs index 79756e515..20d8bb0b9 100644 --- a/Radegast/GUI/Floater.cs +++ b/Radegast/GUI/Floater.cs @@ -1,38 +1,24 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Drawing; using System.Windows.Forms; @@ -51,21 +37,21 @@ public class Floater : RadegastForm public Floater(RadegastInstance instance, Control control, Control trackedControl) : base(instance) { - this.Control = control; - this.TrackedControl = trackedControl; + Control = control; + TrackedControl = trackedControl; SettingsKeyBase = "tab_window_" + control.GetType().Name; AutoSavePosition = true; FormBorderStyle = FormBorderStyle.SizableToolWindow; Text = Control.Text; - TrackedControl.ParentChanged += new EventHandler(Control_ParentChanged); - Control.TextChanged += new EventHandler(Control_TextChanged); - Activated += new EventHandler(Floater_Activated); - Deactivate += new EventHandler(Floater_Deactivate); - ResizeEnd += new EventHandler(Floater_ResizeEnd); - Shown += new EventHandler(Floater_Shown); - Load += new EventHandler(Floater_Load); + TrackedControl.ParentChanged += Control_ParentChanged; + Control.TextChanged += Control_TextChanged; + Activated += Floater_Activated; + Deactivate += Floater_Deactivate; + ResizeEnd += Floater_ResizeEnd; + Shown += Floater_Shown; + Load += Floater_Load; } @@ -75,7 +61,7 @@ void Floater_Load(object sender, EventArgs e) ClientSize = Control.Size; Controls.Add(Control); SaveMainFormPos(); - parentForm.Move += new EventHandler(parentForm_Move); + parentForm.Move += parentForm_Move; } void Floater_Shown(object sender, EventArgs e) @@ -121,14 +107,14 @@ void Control_ParentChanged(object sender, EventArgs e) { if (parentForm != null) { - parentForm.Move -= new EventHandler(parentForm_Move); + parentForm.Move -= parentForm_Move; } SaveMainFormPos(); if (parentForm != null) { Owner = parentForm; - parentForm.Move += new EventHandler(parentForm_Move); + parentForm.Move += parentForm_Move; UpdatePos(); } } diff --git a/Radegast/GUI/GuiHelpers.cs b/Radegast/GUI/GuiHelpers.cs index bc9971f30..d605f1076 100644 --- a/Radegast/GUI/GuiHelpers.cs +++ b/Radegast/GUI/GuiHelpers.cs @@ -1,7 +1,24 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + +using System; using System.Windows.Forms; namespace Radegast.GUI @@ -12,7 +29,7 @@ public static void ApplyGuiFixes(Object root) { try { - var instance = Radegast.RadegastInstance.GlobalInstance; + var instance = RadegastInstance.GlobalInstance; if (instance.GlobalSettings["theme_compatibility_mode"]) { ApplyThemeCompatibilityModeRecursive(root); @@ -27,9 +44,8 @@ public static void ApplyGuiFixes(Object root) private static void ApplyThemeCompatibilityModeRecursive(Object root) { - if (root is ToolStrip) + if (root is ToolStrip toolstrip) { - var toolstrip = root as ToolStrip; toolstrip.RenderMode = ToolStripRenderMode.System; toolstrip.BackColor = System.Drawing.SystemColors.Control; toolstrip.ForeColor = System.Drawing.SystemColors.ControlText; @@ -40,9 +56,8 @@ private static void ApplyThemeCompatibilityModeRecursive(Object root) ApplyThemeCompatibilityModeRecursive(item); } } - else if (root is ToolStripDropDownItem) + else if (root is ToolStripDropDownItem dropDownItem) { - var dropDownItem = root as ToolStripDropDownItem; dropDownItem.BackColor = System.Drawing.SystemColors.Control; dropDownItem.ForeColor = System.Drawing.SystemColors.ControlText; dropDownItem.DropDown.RenderMode = ToolStripRenderMode.System; @@ -54,9 +69,8 @@ private static void ApplyThemeCompatibilityModeRecursive(Object root) ApplyThemeCompatibilityModeRecursive(item); } } - else if (root is Control && !(root is ProgressBar)) + else if (root is Control control && !(control is ProgressBar)) { - var control = root as Control; control.BackColor = System.Drawing.SystemColors.Control; control.ForeColor = System.Drawing.SystemColors.ControlText; diff --git a/Radegast/GUI/Notifications/FriendshipOfferNotification.cs b/Radegast/GUI/Notifications/FriendshipOfferNotification.cs index aeca91df5..4a11ee1c8 100644 --- a/Radegast/GUI/Notifications/FriendshipOfferNotification.cs +++ b/Radegast/GUI/Notifications/FriendshipOfferNotification.cs @@ -1,36 +1,24 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; -using System.Collections.Generic; -using System.Windows.Forms; using OpenMetaverse; namespace Radegast @@ -54,14 +42,13 @@ public ntfFriendshipOffer(RadegastInstance instance, InstantMessage msg) btnYes.Focus(); // Fire off event - NotificationEventArgs args = new NotificationEventArgs(instance); - args.Text = txtHead.Text; + NotificationEventArgs args = new NotificationEventArgs(instance) {Text = txtHead.Text}; args.Buttons.Add(btnYes); args.Buttons.Add(btnNo); args.Buttons.Add(btnIgnore); FireNotificationCallback(args); - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } private void btnYes_Click(object sender, EventArgs e) diff --git a/Radegast/GUI/Notifications/GenericNotification.cs b/Radegast/GUI/Notifications/GenericNotification.cs index 36e4b8f71..54701c9f7 100644 --- a/Radegast/GUI/Notifications/GenericNotification.cs +++ b/Radegast/GUI/Notifications/GenericNotification.cs @@ -1,33 +1,23 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Windows.Forms; @@ -52,12 +42,11 @@ public ntfGeneric(RadegastInstance instance, string msg) btnOk.Focus(); // Fire off event - NotificationEventArgs args = new NotificationEventArgs(instance); - args.Text = txtMessage.Text; + NotificationEventArgs args = new NotificationEventArgs(instance) {Text = txtMessage.Text}; args.Buttons.Add(btnOk); FireNotificationCallback(args); - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } private void btnOk_Click(object sender, EventArgs e) diff --git a/Radegast/GUI/Notifications/GroupInvitationNotification.cs b/Radegast/GUI/Notifications/GroupInvitationNotification.cs index 7c08f8519..bd2abb955 100644 --- a/Radegast/GUI/Notifications/GroupInvitationNotification.cs +++ b/Radegast/GUI/Notifications/GroupInvitationNotification.cs @@ -1,6 +1,24 @@ +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ using System; -using System.Windows.Forms; using OpenMetaverse; namespace Radegast @@ -23,12 +41,11 @@ public ntfGroupInvitation(RadegastInstance instance, InstantMessage msg) btnYes.Focus(); // Fire off event - NotificationEventArgs args = new NotificationEventArgs(instance); - args.Text = txtMessage.Text; + NotificationEventArgs args = new NotificationEventArgs(instance) {Text = txtMessage.Text}; args.Buttons.Add(btnYes); FireNotificationCallback(args); - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } private void btnYes_Click(object sender, EventArgs e) diff --git a/Radegast/GUI/Notifications/GroupNoticeNotification.cs b/Radegast/GUI/Notifications/GroupNoticeNotification.cs index 6fe691768..83776ba11 100644 --- a/Radegast/GUI/Notifications/GroupNoticeNotification.cs +++ b/Radegast/GUI/Notifications/GroupNoticeNotification.cs @@ -1,33 +1,23 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id: GroupInvitationNotification.cs 118 2009-07-20 00:39:00Z latifer $ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System.Windows.Forms; using OpenMetaverse; @@ -36,7 +26,7 @@ namespace Radegast public partial class ntfGroupNotice : Notification { private RadegastInstance instance; - private GridClient client { get { return instance.Client; } } + private GridClient client => instance.Client; private InstantMessage msg; private AssetType type = AssetType.Unknown; private UUID destinationFolderID; @@ -47,11 +37,11 @@ public ntfGroupNotice(RadegastInstance instance, InstantMessage msg) : base(NotificationType.GroupNotice) { InitializeComponent(); - Disposed += new System.EventHandler(ntfGroupNotice_Disposed); + Disposed += ntfGroupNotice_Disposed; this.instance = instance; this.msg = msg; - client.Groups.GroupProfile += new System.EventHandler(Groups_GroupProfile); + client.Groups.GroupProfile += Groups_GroupProfile; if (msg.BinaryBucket.Length > 18 && msg.BinaryBucket[0] != 0) { @@ -97,7 +87,7 @@ public ntfGroupNotice(RadegastInstance instance, InstantMessage msg) client.Groups.RequestGroupProfile(groupID); } - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } private void ShowNotice() @@ -108,16 +98,18 @@ private void ShowNotice() lblSentBy.Text += ", " + group.Name; // Fire off event - NotificationEventArgs args = new NotificationEventArgs(instance); - args.Text = string.Format("{0}{1}{2}{3}{4}", - lblTitle.Text, System.Environment.NewLine, - lblSentBy.Text, System.Environment.NewLine, - txtNotice.Text - ); - if (btnSave.Visible == true) + NotificationEventArgs args = new NotificationEventArgs(instance) + { + Text = string.Format("{0}{1}{2}{3}{4}", + lblTitle.Text, System.Environment.NewLine, + lblSentBy.Text, System.Environment.NewLine, + txtNotice.Text + ) + }; + if (btnSave.Visible) { args.Buttons.Add(btnSave); - args.Text += string.Format("{0}Attachment: {1}", System.Environment.NewLine, txtItemName.Text); + args.Text += $"{System.Environment.NewLine}Attachment: {txtItemName.Text}"; } args.Buttons.Add(btnOK); FireNotificationCallback(args); @@ -125,7 +117,7 @@ private void ShowNotice() void ntfGroupNotice_Disposed(object sender, System.EventArgs e) { - client.Groups.GroupProfile -= new System.EventHandler(Groups_GroupProfile); + client.Groups.GroupProfile -= Groups_GroupProfile; } void Groups_GroupProfile(object sender, GroupProfileEventArgs e) diff --git a/Radegast/GUI/Notifications/InventoryOfferNotification.cs b/Radegast/GUI/Notifications/InventoryOfferNotification.cs index 03f7b645b..61f1d1c9d 100644 --- a/Radegast/GUI/Notifications/InventoryOfferNotification.cs +++ b/Radegast/GUI/Notifications/InventoryOfferNotification.cs @@ -1,51 +1,34 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id: FriendshipOfferNotification.cs 175 2009-08-29 13:52:32Z latifer@gmail.com $ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Drawing; -using System.Data; using System.Linq; -using System.Text; using System.Windows.Forms; using OpenMetaverse; -using OpenMetaverse.Assets; -using OpenMetaverse.Packets; namespace Radegast { public partial class ntfInventoryOffer : Notification { private RadegastInstance instance; - private GridClient client { get { return instance.Client; } } + private GridClient client => instance.Client; private InstantMessage msg; private AssetType type = AssetType.Unknown; private UUID objectID = UUID.Zero; @@ -55,12 +38,12 @@ public ntfInventoryOffer(RadegastInstance instance, InstantMessage msg) : base (NotificationType.InventoryOffer) { InitializeComponent(); - Disposed += new EventHandler(ntfInventoryOffer_Disposed); + Disposed += ntfInventoryOffer_Disposed; this.instance = instance; this.msg = msg; - instance.Names.NameUpdated += new EventHandler(Avatars_UUIDNameReply); + instance.Names.NameUpdated += Avatars_UUIDNameReply; if (msg.BinaryBucket.Length > 0) { @@ -74,7 +57,7 @@ public ntfInventoryOffer(RadegastInstance instance, InstantMessage msg) if (msg.Dialog == InstantMessageDialog.InventoryOffered) { - txtInfo.Text = string.Format("{0} has offered you {1} \"{2}\".", msg.FromAgentName, type.ToString(), msg.Message); + txtInfo.Text = string.Format("{0} has offered you {1} \"{2}\".", msg.FromAgentName, type, msg.Message); } else if (msg.Dialog == InstantMessageDialog.TaskInventoryOffered) { @@ -82,8 +65,7 @@ public ntfInventoryOffer(RadegastInstance instance, InstantMessage msg) } // Fire off event - NotificationEventArgs args = new NotificationEventArgs(instance); - args.Text = txtInfo.Text; + NotificationEventArgs args = new NotificationEventArgs(instance) {Text = txtInfo.Text}; args.Buttons.Add(btnAccept); args.Buttons.Add(btnDiscard); args.Buttons.Add(btnIgnore); @@ -94,19 +76,19 @@ public ntfInventoryOffer(RadegastInstance instance, InstantMessage msg) Logger.Log("Wrong format of the item offered", Helpers.LogLevel.Warning, client); } - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } void ntfInventoryOffer_Disposed(object sender, EventArgs e) { - instance.Names.NameUpdated -= new EventHandler(Avatars_UUIDNameReply); + instance.Names.NameUpdated -= Avatars_UUIDNameReply; } void Avatars_UUIDNameReply(object sender, UUIDNameReplyEventArgs e) { if (e.Names.Keys.Contains(msg.FromAgentID)) { - instance.Names.NameUpdated -= new EventHandler(Avatars_UUIDNameReply); + instance.Names.NameUpdated -= Avatars_UUIDNameReply; BeginInvoke(new MethodInvoker(() => txtInfo.Text = objectOfferText())); } } diff --git a/Radegast/GUI/Notifications/LoadURLNotification.Designer.cs b/Radegast/GUI/Notifications/LoadURLNotification.Designer.cs index a1d368625..e1554f27b 100644 --- a/Radegast/GUI/Notifications/LoadURLNotification.Designer.cs +++ b/Radegast/GUI/Notifications/LoadURLNotification.Designer.cs @@ -77,7 +77,7 @@ private void InitializeComponent() this.rtbText.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.Vertical; this.rtbText.Size = new System.Drawing.Size(289, 96); this.rtbText.TabIndex = 0; - this.rtbText.Text = "Load web page http://radegast.org/ ?\n\nPlease visit\n\nFrom object: Object, owner La" + + this.rtbText.Text = "Load web page https://radegast.life/ ?\n\nPlease visit\n\nFrom object: Object, owner La" + "tif Khalifa?"; this.rtbText.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(this.rtbText_LinkClicked); // diff --git a/Radegast/GUI/Notifications/LoadURLNotification.cs b/Radegast/GUI/Notifications/LoadURLNotification.cs index 26bb3bee1..c73a04ffe 100644 --- a/Radegast/GUI/Notifications/LoadURLNotification.cs +++ b/Radegast/GUI/Notifications/LoadURLNotification.cs @@ -1,38 +1,24 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Drawing; -using System.Text; using System.Windows.Forms; using OpenMetaverse; @@ -46,35 +32,34 @@ public partial class ntfLoadURL : Notification public ntfLoadURL(RadegastInstance instance, LoadUrlEventArgs e) { InitializeComponent(); - Disposed += new EventHandler(ntfLoadURL_Disposed); + Disposed += ntfLoadURL_Disposed; - this.ev = e; + ev = e; this.instance = instance; - instance.Names.NameUpdated += new EventHandler(Avatars_UUIDNameReply); + instance.Names.NameUpdated += Avatars_UUIDNameReply; SetText(); // Fire off event - NotificationEventArgs args = new NotificationEventArgs(instance); - args.Text = rtbText.Text; + NotificationEventArgs args = new NotificationEventArgs(instance) {Text = rtbText.Text}; args.Buttons.Add(btnGoTo); args.Buttons.Add(btnCancel); FireNotificationCallback(args); - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } void ntfLoadURL_Disposed(object sender, EventArgs e) { - instance.Names.NameUpdated -= new EventHandler(Avatars_UUIDNameReply); + instance.Names.NameUpdated -= Avatars_UUIDNameReply; } void Avatars_UUIDNameReply(object sender, UUIDNameReplyEventArgs e) { if (!e.Names.ContainsKey(ev.OwnerID)) return; - instance.Names.NameUpdated -= new EventHandler(Avatars_UUIDNameReply); + instance.Names.NameUpdated -= Avatars_UUIDNameReply; if (InvokeRequired) { diff --git a/Radegast/GUI/Notifications/Notification.cs b/Radegast/GUI/Notifications/Notification.cs index a6dd17f5e..bba276b51 100644 --- a/Radegast/GUI/Notifications/Notification.cs +++ b/Radegast/GUI/Notifications/Notification.cs @@ -1,41 +1,26 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id: FriendshipOfferNotification.cs 118 2009-07-20 00:39:00Z latifer $ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections.Generic; -#if (COGBOT_LIBOMV || USE_STHREADS) -using ThreadPoolUtil; -using Thread = ThreadPoolUtil.Thread; -using ThreadPool = ThreadPoolUtil.ThreadPool; -using Monitor = ThreadPoolUtil.Monitor; -#endif +using System.Threading; using OpenMetaverse; using System.Windows.Forms; @@ -87,13 +72,13 @@ protected void FireNotificationCallback(NotificationEventArgs e) if (OnNotificationDisplayed == null) return; try { - e.Type = this.Type; - WorkPool.QueueUserWorkItem((object o) => Notificaton_Displayed(this, e)); + e.Type = Type; + ThreadPool.QueueUserWorkItem(o => Notificaton_Displayed(this, e)); } catch (Exception ex) { Console.WriteLine("" + ex); - OpenMetaverse.Logger.Log("Error executing notification callback", OpenMetaverse.Helpers.LogLevel.Warning, ex); + Logger.Log("Error executing notification callback", Helpers.LogLevel.Warning, ex); } } @@ -102,13 +87,12 @@ private void Notificaton_Displayed(Notification notification, NotificationEventA try { e.HookNotification(this); - if (OnNotificationDisplayed != null) - OnNotificationDisplayed(notification, e); + OnNotificationDisplayed?.Invoke(notification, e); } catch (Exception ex) { Console.WriteLine("" + ex); - OpenMetaverse.Logger.Log("Error executing notification displayed", OpenMetaverse.Helpers.LogLevel.Warning, ex); + Logger.Log("Error executing notification displayed", Helpers.LogLevel.Warning, ex); } } } @@ -126,6 +110,7 @@ public enum NotificationType Teleport, InventoryOffer, RequestLure, + RegionRestart, SendLureRequest, SendLureOffer } @@ -197,13 +182,12 @@ internal void Notification_Close() { try { - if (OnNotificationClosed != null) - OnNotificationClosed(this, this); + OnNotificationClosed?.Invoke(this, this); } catch (Exception ex) { - OpenMetaverse.Logger.Log("Error executing OnNotificationClosed " + Text, - OpenMetaverse.Helpers.LogLevel.Warning, ex); + Logger.Log("Error executing OnNotificationClosed " + Text, + Helpers.LogLevel.Warning, ex); } if (!CanClose) Dispose(); } @@ -219,12 +203,11 @@ internal void Notification_Click(object sender, EventArgs e) ButtonSelected = true; try { - if (OnNotificationClicked != null) - OnNotificationClicked(sender, e, this); + OnNotificationClicked?.Invoke(sender, e, this); } catch (Exception ex) { - OpenMetaverse.Logger.Log("Error executing OnNotificationClicked", OpenMetaverse.Helpers.LogLevel.Warning, ex); + Logger.Log("Error executing OnNotificationClicked", Helpers.LogLevel.Warning, ex); } if (CanClose) { diff --git a/Radegast/GUI/Notifications/PermissionsNotification.cs b/Radegast/GUI/Notifications/PermissionsNotification.cs index c97d8bfb9..b9e7b847c 100644 --- a/Radegast/GUI/Notifications/PermissionsNotification.cs +++ b/Radegast/GUI/Notifications/PermissionsNotification.cs @@ -1,35 +1,24 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; -using System.Windows.Forms; using OpenMetaverse; namespace Radegast @@ -59,17 +48,16 @@ public ntfPermissions(RadegastInstance instance, Simulator simulator, UUID taskI this.questions = questions; txtMessage.BackColor = instance.MainForm.NotificationBackground; - txtMessage.Text = "Object " + objectName + " owned by " + objectOwner + " is asking permission to " + questions.ToString() + ". Do you accept?"; + txtMessage.Text = "Object " + objectName + " owned by " + objectOwner + " is asking permission to " + questions + ". Do you accept?"; // Fire off event - NotificationEventArgs args = new NotificationEventArgs(instance); - args.Text = txtMessage.Text; + NotificationEventArgs args = new NotificationEventArgs(instance) {Text = txtMessage.Text}; args.Buttons.Add(btnYes); args.Buttons.Add(btnNo); args.Buttons.Add(btnMute); FireNotificationCallback(args); - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } private void btnYes_Click(object sender, EventArgs e) diff --git a/Radegast/GUI/Notifications/RegionRestartNotification.Designer.cs b/Radegast/GUI/Notifications/RegionRestartNotification.Designer.cs new file mode 100644 index 000000000..ffc8624eb --- /dev/null +++ b/Radegast/GUI/Notifications/RegionRestartNotification.Designer.cs @@ -0,0 +1,137 @@ + +namespace Radegast +{ + partial class ntfRegionRestart + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + CountdownTimer?.Stop(); + + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.btnIgnore = new System.Windows.Forms.Button(); + this.btnElsewhere = new System.Windows.Forms.Button(); + this.btnHome = new System.Windows.Forms.Button(); + this.txtCountdownLabel = new System.Windows.Forms.TextBox(); + this.txtHead = new System.Windows.Forms.TextBox(); + this.txtCountdown = new System.Windows.Forms.TextBox(); + this.SuspendLayout(); + // + // btnIgnore + // + this.btnIgnore.Location = new System.Drawing.Point(178, 97); + this.btnIgnore.Name = "btnIgnore"; + this.btnIgnore.Size = new System.Drawing.Size(75, 23); + this.btnIgnore.TabIndex = 8; + this.btnIgnore.Text = "&Ignore"; + this.btnIgnore.UseVisualStyleBackColor = true; + this.btnIgnore.Click += new System.EventHandler(this.btnIgnore_Click); + // + // btnElsewhere + // + this.btnElsewhere.Location = new System.Drawing.Point(93, 97); + this.btnElsewhere.Name = "btnElsewhere"; + this.btnElsewhere.Size = new System.Drawing.Size(75, 23); + this.btnElsewhere.TabIndex = 9; + this.btnElsewhere.Text = "&Elsewhere"; + this.btnElsewhere.UseVisualStyleBackColor = true; + this.btnElsewhere.Click += new System.EventHandler(this.btnElsewhere_Click); + // + // btnHome + // + this.btnHome.Location = new System.Drawing.Point(9, 97); + this.btnHome.Name = "btnHome"; + this.btnHome.Size = new System.Drawing.Size(75, 23); + this.btnHome.TabIndex = 7; + this.btnHome.Text = "Go &Home"; + this.btnHome.UseVisualStyleBackColor = true; + this.btnHome.Click += new System.EventHandler(this.btnHome_Click); + // + // txtCountdownLabel + // + this.txtCountdownLabel.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.txtCountdownLabel.Location = new System.Drawing.Point(9, 47); + this.txtCountdownLabel.Multiline = true; + this.txtCountdownLabel.Name = "txtCountdownLabel"; + this.txtCountdownLabel.ReadOnly = true; + this.txtCountdownLabel.Size = new System.Drawing.Size(244, 15); + this.txtCountdownLabel.TabIndex = 11; + this.txtCountdownLabel.TabStop = false; + this.txtCountdownLabel.Text = "Time left until restart:"; + this.txtCountdownLabel.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + // + // txtHead + // + this.txtHead.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.txtHead.Location = new System.Drawing.Point(9, 3); + this.txtHead.Multiline = true; + this.txtHead.Name = "txtHead"; + this.txtHead.ReadOnly = true; + this.txtHead.Size = new System.Drawing.Size(244, 46); + this.txtHead.TabIndex = 10; + this.txtHead.TabStop = false; + this.txtHead.Text = "The region you are currently in is about to restart.\r\nIf you remain here, you wil" + + "l be logged out."; + // + // txtCountdown + // + this.txtCountdown.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.txtCountdown.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.txtCountdown.Location = new System.Drawing.Point(9, 68); + this.txtCountdown.Multiline = true; + this.txtCountdown.Name = "txtCountdown"; + this.txtCountdown.ReadOnly = true; + this.txtCountdown.Size = new System.Drawing.Size(244, 23); + this.txtCountdown.TabIndex = 12; + this.txtCountdown.TabStop = false; + this.txtCountdown.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + // + // ntfRegionRestart + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.txtCountdown); + this.Controls.Add(this.btnIgnore); + this.Controls.Add(this.btnElsewhere); + this.Controls.Add(this.btnHome); + this.Controls.Add(this.txtCountdownLabel); + this.Controls.Add(this.txtHead); + this.Name = "ntfRegionRestart"; + this.Size = new System.Drawing.Size(263, 131); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + public System.Windows.Forms.Button btnIgnore; + public System.Windows.Forms.Button btnElsewhere; + public System.Windows.Forms.Button btnHome; + public System.Windows.Forms.TextBox txtCountdownLabel; + public System.Windows.Forms.TextBox txtHead; + public System.Windows.Forms.TextBox txtCountdown; + } +} diff --git a/Radegast/GUI/Notifications/RegionRestartNotification.cs b/Radegast/GUI/Notifications/RegionRestartNotification.cs new file mode 100644 index 000000000..42248e9f8 --- /dev/null +++ b/Radegast/GUI/Notifications/RegionRestartNotification.cs @@ -0,0 +1,100 @@ +/** + * Radegast Metaverse Client + * Copyright(c) 2021, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + +using System; + +namespace Radegast +{ + public partial class ntfRegionRestart : Notification + { + private RadegastInstance instance; + private string RegionName; + private int CountdownSeconds; + private System.Timers.Timer CountdownTimer; + + public ntfRegionRestart(RadegastInstance instance, string region_name, int countdown_seconds) + : base(NotificationType.RegionRestart) + { + InitializeComponent(); + this.instance = instance; + this.RegionName = region_name; + this.CountdownSeconds = countdown_seconds; + + txtHead.BackColor = instance.MainForm.NotificationBackground; + txtCountdownLabel.BackColor = instance.MainForm.NotificationBackground; + txtCountdown.BackColor = instance.MainForm.NotificationBackground; + + CountdownTimer = new System.Timers.Timer + { + Interval = 1000 // 1s + }; + CountdownTimer.Elapsed += OnCountdownTimerEvent; + CountdownTimer.Start(); + + btnHome.Focus(); + + this.instance.MediaManager.PlayUISound(UISounds.Warning); + + GUI.GuiHelpers.ApplyGuiFixes(this); + } + + private void OnCountdownTimerEvent(object sender, System.Timers.ElapsedEventArgs e) + { + Invoke(new Action(() => + { + var ts = TimeSpan.FromSeconds(--CountdownSeconds); + txtCountdown.Text = ts.ToString(@"mm\:ss"); + })); + } + + // TODO: we need a notification closed event to hook up to... + private void OnNotificationClosed(object sender, NotificationEventArgs e) + { + CountdownTimer.Stop(); + } + + private void btnHome_Click(object sender, EventArgs e) + { + instance.Client.Self.RequestTeleport(OpenMetaverse.UUID.Zero); + + instance.MainForm.RemoveNotification(this); + } + + private void btnElsewhere_Click(object sender, EventArgs e) + { + Automation.PseudoHomePreferences prefs = instance.State.PseudoHome?.Preferences; + + if (prefs != null && prefs.Region.Trim() != string.Empty) + { + instance.Client.Self.Teleport(prefs.Region, prefs.Position); + } + else + { + // idk, this is silly and Second Life specific. + instance.Client.Self.Teleport("Hippo Hollow", new OpenMetaverse.Vector3(180, 205, 44)); + } + instance.MainForm.RemoveNotification(this); + } + + private void btnIgnore_Click(object sender, EventArgs e) + { + instance.MainForm.RemoveNotification(this); + } + } +} diff --git a/Radegast/GUI/Notifications/RegionRestartNotification.resx b/Radegast/GUI/Notifications/RegionRestartNotification.resx new file mode 100644 index 000000000..1af7de150 --- /dev/null +++ b/Radegast/GUI/Notifications/RegionRestartNotification.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Radegast/GUI/Notifications/RequestLureNotification.cs b/Radegast/GUI/Notifications/RequestLureNotification.cs index c5e91a30e..2e5841a5f 100644 --- a/Radegast/GUI/Notifications/RequestLureNotification.cs +++ b/Radegast/GUI/Notifications/RequestLureNotification.cs @@ -1,35 +1,24 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; -using System.Windows.Forms; using OpenMetaverse; namespace Radegast @@ -53,13 +42,15 @@ public ntfRequestLure(RadegastInstance instance, InstantMessage msg) btnTeleport.Focus(); // Fire off event - NotificationEventArgs args = new NotificationEventArgs(instance); - args.Text = txtHead.Text + Environment.NewLine + txtMessage.Text; + NotificationEventArgs args = new NotificationEventArgs(instance) + { + Text = txtHead.Text + Environment.NewLine + txtMessage.Text + }; args.Buttons.Add(btnTeleport); args.Buttons.Add(btnCancel); FireNotificationCallback(args); - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } private void btnTeleport_Click(object sender, EventArgs e) diff --git a/Radegast/GUI/Notifications/ScriptDialog.cs b/Radegast/GUI/Notifications/ScriptDialog.cs index 470ead62a..486775536 100644 --- a/Radegast/GUI/Notifications/ScriptDialog.cs +++ b/Radegast/GUI/Notifications/ScriptDialog.cs @@ -1,33 +1,23 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections.Generic; using System.Drawing; @@ -54,8 +44,7 @@ public ntfScriptDialog(RadegastInstance instance, string message, string objectN descBox.BackColor = instance.MainForm.NotificationBackground; descBox.Text = firstName + " " + lastName + "'s " + objectName + "\r\n\r\n" + message.Replace("\n", "\r\n") + "\r\n"; - NotificationEventArgs args = new NotificationEventArgs(instance); - args.Text = descBox.Text; + NotificationEventArgs args = new NotificationEventArgs(instance) {Text = descBox.Text}; int btnWidth = 90; int btnHeight = 23; @@ -71,12 +60,15 @@ public ntfScriptDialog(RadegastInstance instance, string message, string objectN { foreach (string label in buttons) { - Button b = new Button(); - b.Size = new Size(btnWidth, btnHeight); - b.Text = label; - b.Location = new Point(5 + (i % 3) * (btnWidth + 5), btnsPanel.Size.Height - (i / 3) * (btnHeight + 5) - (btnHeight + 5)); - b.Name = i.ToString(); - b.Click += new EventHandler(b_Click); + Button b = new Button + { + Size = new Size(btnWidth, btnHeight), + Text = label, + Location = new Point(5 + (i % 3) * (btnWidth + 5), + btnsPanel.Size.Height - (i / 3) * (btnHeight + 5) - (btnHeight + 5)), + Name = i.ToString() + }; + b.Click += b_Click; b.UseVisualStyleBackColor = true; b.Margin = new Padding(0, 3, 0, 3); b.Padding = new Padding(0); @@ -89,7 +81,7 @@ public ntfScriptDialog(RadegastInstance instance, string message, string objectN args.Buttons.Add(ignoreBtn); FireNotificationCallback(args); - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } void b_Click(object sender, EventArgs e) diff --git a/Radegast/GUI/Notifications/SendLureOffer.cs b/Radegast/GUI/Notifications/SendLureOffer.cs index 1a4c1a51d..3381804b3 100644 --- a/Radegast/GUI/Notifications/SendLureOffer.cs +++ b/Radegast/GUI/Notifications/SendLureOffer.cs @@ -1,35 +1,24 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; -using System.Windows.Forms; using OpenMetaverse; namespace Radegast @@ -56,13 +45,15 @@ public ntfSendLureOffer(RadegastInstance instance, UUID agentID) btnOffer.Focus(); // Fire off event - NotificationEventArgs args = new NotificationEventArgs(instance); - args.Text = txtHead.Text + Environment.NewLine + txtMessage.Text; + NotificationEventArgs args = new NotificationEventArgs(instance) + { + Text = txtHead.Text + Environment.NewLine + txtMessage.Text + }; args.Buttons.Add(btnOffer); args.Buttons.Add(btnCancel); FireNotificationCallback(args); - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } private void btnOffer_Click(object sender, EventArgs e) diff --git a/Radegast/GUI/Notifications/SendLureRequest.cs b/Radegast/GUI/Notifications/SendLureRequest.cs index 3494f2b91..7858b6ab6 100644 --- a/Radegast/GUI/Notifications/SendLureRequest.cs +++ b/Radegast/GUI/Notifications/SendLureRequest.cs @@ -1,35 +1,24 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; -using System.Windows.Forms; using OpenMetaverse; namespace Radegast @@ -55,13 +44,15 @@ public ntfSendLureRequest(RadegastInstance instance, UUID agentID) btnRequest.Focus(); // Fire off event - NotificationEventArgs args = new NotificationEventArgs(instance); - args.Text = txtHead.Text + Environment.NewLine + txtMessage.Text; + NotificationEventArgs args = new NotificationEventArgs(instance) + { + Text = txtHead.Text + Environment.NewLine + txtMessage.Text + }; args.Buttons.Add(btnRequest); args.Buttons.Add(btnCancel); FireNotificationCallback(args); - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } private void btnTeleport_Click(object sender, EventArgs e) diff --git a/Radegast/GUI/Notifications/TeleportNotification.cs b/Radegast/GUI/Notifications/TeleportNotification.cs index aa4303126..18b3729c7 100644 --- a/Radegast/GUI/Notifications/TeleportNotification.cs +++ b/Radegast/GUI/Notifications/TeleportNotification.cs @@ -1,35 +1,24 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; -using System.Windows.Forms; using OpenMetaverse; namespace Radegast @@ -53,13 +42,15 @@ public ntfTeleport(RadegastInstance instance, InstantMessage msg) btnTeleport.Focus(); // Fire off event - NotificationEventArgs args = new NotificationEventArgs(instance); - args.Text = txtHead.Text + Environment.NewLine + txtMessage.Text; + NotificationEventArgs args = new NotificationEventArgs(instance) + { + Text = txtHead.Text + Environment.NewLine + txtMessage.Text + }; args.Buttons.Add(btnTeleport); args.Buttons.Add(btnCancel); FireNotificationCallback(args); - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } private void btnTeleport_Click(object sender, EventArgs e) diff --git a/Radegast/GUI/Rendering/ChatBox.cs b/Radegast/GUI/Rendering/ChatBox.cs index 73d922974..abfda2f31 100644 --- a/Radegast/GUI/Rendering/ChatBox.cs +++ b/Radegast/GUI/Rendering/ChatBox.cs @@ -29,7 +29,6 @@ // $Id$ // -using System; using System.Windows.Forms; namespace Radegast.Rendering diff --git a/Radegast/GUI/Rendering/ChatOverlay.cs b/Radegast/GUI/Rendering/ChatOverlay.cs index dfd7f1920..34353da4e 100644 --- a/Radegast/GUI/Rendering/ChatOverlay.cs +++ b/Radegast/GUI/Rendering/ChatOverlay.cs @@ -1,33 +1,23 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections.Generic; using System.Drawing; @@ -52,15 +42,15 @@ public class ChatOverlay : IDisposable public ChatOverlay(RadegastInstance instance, SceneWindow window) { - this.Instance = instance; - this.Window = window; - Instance.TabConsole.MainChatManger.ChatLineAdded += new EventHandler(MainChatManger_ChatLineAdded); + Instance = instance; + Window = window; + Instance.TabConsole.MainChatManger.ChatLineAdded += MainChatManger_ChatLineAdded; chatLines = new Queue(); } public void Dispose() { - Instance.TabConsole.MainChatManger.ChatLineAdded -= new EventHandler(MainChatManger_ChatLineAdded); + Instance.TabConsole.MainChatManger.ChatLineAdded -= MainChatManger_ChatLineAdded; if (chatLines != null) { @@ -192,7 +182,7 @@ public class ChatLine : IDisposable public int ImgWidth; public int ImgHeight; - public ChatBufferTextStyle Style { get { return item.Style; } } + public ChatBufferTextStyle Style => item.Style; int textureID = -1; int widthForTextureGenerated = -1; @@ -201,7 +191,7 @@ public class ChatLine : IDisposable public ChatLine(ChatBufferItem item, float timeAdded) { this.item = item; - this.TimeAdded = timeAdded; + TimeAdded = timeAdded; } public void Dispose() diff --git a/Radegast/GUI/Rendering/Compat.cs b/Radegast/GUI/Rendering/Compat.cs index 62009bc4d..2203440f8 100644 --- a/Radegast/GUI/Rendering/Compat.cs +++ b/Radegast/GUI/Rendering/Compat.cs @@ -1,33 +1,22 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ using System; using OpenTK.Graphics.OpenGL; @@ -137,7 +126,7 @@ public static void EndQuery(QueryTarget target) } else { - GL.Arb.EndQuery((ArbOcclusionQuery)(int)target); + GL.Arb.EndQuery(target); } } @@ -149,7 +138,7 @@ public static void GetQueryObject(int id, GetQueryObjectParam param, out int res } else { - GL.Arb.GetQueryObject(id, (ArbOcclusionQuery)(int)param, out res); + GL.Arb.GetQueryObject(id, (QueryObjectParameterName)param, out res); } } #endregion Occlusion query functions diff --git a/Radegast/GUI/Rendering/Frustum.cs b/Radegast/GUI/Rendering/Frustum.cs index 5c50d6f18..5742849e1 100644 --- a/Radegast/GUI/Rendering/Frustum.cs +++ b/Radegast/GUI/Rendering/Frustum.cs @@ -1,10 +1,23 @@ -#region --- MIT License --- -/* Licensed under the MIT/X11 license. - * Copyright (c) 2011 mjt - * This notice may not be removed from any source distribution. - * See license.txt for licensing details. +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. */ -#endregion + /* * tutoriaali: * http://www.crownandcutlass.com/features/technicaldetails/frustum.html @@ -165,7 +178,6 @@ public class BoundingVolume { Vector3 Min = new Vector3(float.MaxValue, float.MaxValue, float.MaxValue); Vector3 Max = new Vector3(float.MinValue, float.MinValue, float.MinValue); - float R = 0f; public Vector3 ScaledMin = new Vector3(float.MaxValue, float.MaxValue, float.MaxValue); public Vector3 ScaledMax = new Vector3(float.MinValue, float.MinValue, float.MinValue); @@ -193,7 +205,6 @@ public void CreateBoundingVolume(OpenMetaverse.Rendering.Face mesh, Vector3 scal } Vector3 dist = Max - Min; - R = dist.Length(); mesh.Center = Min + (dist / 2); CalcScaled(scale); } @@ -208,15 +219,14 @@ public void FromScale(Vector3 scale) public void AddVolume(BoundingVolume vol, Vector3 scale) { - if (vol.Min.X < this.Min.X) this.Min.X = vol.Min.X; - if (vol.Min.Y < this.Min.Y) this.Min.Y = vol.Min.Y; - if (vol.Min.Z < this.Min.Z) this.Min.Z = vol.Min.Z; + if (vol.Min.X < Min.X) Min.X = vol.Min.X; + if (vol.Min.Y < Min.Y) Min.Y = vol.Min.Y; + if (vol.Min.Z < Min.Z) Min.Z = vol.Min.Z; - if (vol.Max.X > this.Max.X) this.Max.X = vol.Max.X; - if (vol.Max.Y > this.Max.Y) this.Max.Y = vol.Max.Y; - if (vol.Max.Z > this.Max.Z) this.Max.Z = vol.Max.Z; + if (vol.Max.X > Max.X) Max.X = vol.Max.X; + if (vol.Max.Y > Max.Y) Max.Y = vol.Max.Y; + if (vol.Max.Z > Max.Z) Max.Z = vol.Max.Z; Vector3 dist = Max - Min; - R = dist.Length(); CalcScaled(scale); } diff --git a/Radegast/GUI/Rendering/GraphicsPreferences.cs b/Radegast/GUI/Rendering/GraphicsPreferences.cs index e5d07275f..47dd77da4 100644 --- a/Radegast/GUI/Rendering/GraphicsPreferences.cs +++ b/Radegast/GUI/Rendering/GraphicsPreferences.cs @@ -30,12 +30,6 @@ // using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Drawing; -using System.Data; -using System.Linq; -using System.Text; using System.Windows.Forms; using OpenMetaverse; @@ -44,7 +38,8 @@ namespace Radegast.Rendering public partial class GraphicsPreferences : UserControl { RadegastInstance Instance; - GridClient Client { get { return Instance.Client; } } + GridClient Client => Instance.Client; + SceneWindow Window { get @@ -61,14 +56,14 @@ public GraphicsPreferences() { InitializeComponent(); - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } public GraphicsPreferences(RadegastInstance instance) { - this.Instance = instance; + Instance = instance; InitializeComponent(); - Disposed += new EventHandler(GraphicsPreferences_Disposed); + Disposed += GraphicsPreferences_Disposed; Text = "Graphics preferences"; cbAA.Checked = instance.GlobalSettings["use_multi_sampling"]; @@ -84,7 +79,7 @@ public GraphicsPreferences(RadegastInstance instance) cbShiny.Checked = Instance.GlobalSettings["scene_viewer_shiny"]; cbVBO.Checked = Instance.GlobalSettings["rendering_use_vbo"]; - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } void GraphicsPreferences_Disposed(object sender, EventArgs e) diff --git a/Radegast/GUI/Rendering/ImageUtils.cs b/Radegast/GUI/Rendering/ImageUtils.cs index 89ba660a3..a5e1b7eab 100644 --- a/Radegast/GUI/Rendering/ImageUtils.cs +++ b/Radegast/GUI/Rendering/ImageUtils.cs @@ -1,48 +1,25 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Based on code from Aurora Sim and OpenSimulator -// Copyright (c) Contributors, http://aurora-sim.org/, http://opensimulator.org/ -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ - -using System; -using System.Collections.Generic; using System.Drawing; -using System.Drawing.Imaging; -using System.IO; -using System.Reflection; using OpenMetaverse; -using OpenMetaverse.Imaging; -using OpenMetaverse.Rendering; -using OpenMetaverse.StructuredData; namespace Radegast.Rendering { diff --git a/Radegast/GUI/Rendering/Perlin.cs b/Radegast/GUI/Rendering/Perlin.cs index 2b343a174..d915305bf 100644 --- a/Radegast/GUI/Rendering/Perlin.cs +++ b/Radegast/GUI/Rendering/Perlin.cs @@ -1,36 +1,23 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Based on code from Aurora Sim and OpenSimulator -// Copyright (c) Contributors, http://aurora-sim.org/, http://opensimulator.org/ -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright (c) Contributors, http://aurora-sim.org/, http://opensimulator.org/ + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ using System; using OpenMetaverse; diff --git a/Radegast/GUI/Rendering/PrimWorkshop.Designer.cs b/Radegast/GUI/Rendering/PrimWorkshop.Designer.cs index a933a7a52..1cd2fa088 100644 --- a/Radegast/GUI/Rendering/PrimWorkshop.Designer.cs +++ b/Radegast/GUI/Rendering/PrimWorkshop.Designer.cs @@ -88,7 +88,7 @@ private void InitializeComponent() this.scrollRoll.Name = "scrollRoll"; this.scrollRoll.Size = new System.Drawing.Size(200, 16); this.scrollRoll.TabIndex = 9; - this.scrollRoll.ValueChanged += new System.EventHandler(this.scroll_ValueChanged); + this.scrollRoll.ValueChanged += new System.EventHandler(this.Scroll_ValueChanged); // // scrollPitch // @@ -97,7 +97,7 @@ private void InitializeComponent() this.scrollPitch.Name = "scrollPitch"; this.scrollPitch.Size = new System.Drawing.Size(200, 16); this.scrollPitch.TabIndex = 10; - this.scrollPitch.ValueChanged += new System.EventHandler(this.scroll_ValueChanged); + this.scrollPitch.ValueChanged += new System.EventHandler(this.Scroll_ValueChanged); // // scrollYaw // @@ -107,7 +107,7 @@ private void InitializeComponent() this.scrollYaw.Size = new System.Drawing.Size(200, 16); this.scrollYaw.TabIndex = 11; this.scrollYaw.Value = 90; - this.scrollYaw.ValueChanged += new System.EventHandler(this.scroll_ValueChanged); + this.scrollYaw.ValueChanged += new System.EventHandler(this.Scroll_ValueChanged); // // scrollZoom // @@ -119,7 +119,7 @@ private void InitializeComponent() this.scrollZoom.Size = new System.Drawing.Size(200, 16); this.scrollZoom.TabIndex = 19; this.scrollZoom.Value = -30; - this.scrollZoom.ValueChanged += new System.EventHandler(this.scrollZoom_ValueChanged); + this.scrollZoom.ValueChanged += new System.EventHandler(this.ScrollZoom_ValueChanged); // // gbZoom // @@ -157,7 +157,7 @@ private void InitializeComponent() this.btnResetView.TabIndex = 22; this.btnResetView.Text = "Reset View"; this.btnResetView.UseVisualStyleBackColor = true; - this.btnResetView.Click += new System.EventHandler(this.btnReset_Click); + this.btnResetView.Click += new System.EventHandler(this.BtnReset_Click); // // cbAA // @@ -178,7 +178,7 @@ private void InitializeComponent() this.chkWireFrame.TabIndex = 21; this.chkWireFrame.Text = "Wireframe"; this.chkWireFrame.UseVisualStyleBackColor = true; - this.chkWireFrame.CheckedChanged += new System.EventHandler(this.chkWireFrame_CheckedChanged); + this.chkWireFrame.CheckedChanged += new System.EventHandler(this.ChkWireFrame_CheckedChanged); // // label1 // @@ -200,21 +200,21 @@ private void InitializeComponent() this.deleteToolStripMenuItem}); this.ctxObjects.Name = "ctxObjects"; this.ctxObjects.Size = new System.Drawing.Size(110, 120); - this.ctxObjects.Opening += new System.ComponentModel.CancelEventHandler(this.ctxObjects_Opening); + this.ctxObjects.Opening += new System.ComponentModel.CancelEventHandler(this.CtxObjects_Opening); // // touchToolStripMenuItem // this.touchToolStripMenuItem.Name = "touchToolStripMenuItem"; this.touchToolStripMenuItem.Size = new System.Drawing.Size(109, 22); this.touchToolStripMenuItem.Text = "Touch"; - this.touchToolStripMenuItem.Click += new System.EventHandler(this.touchToolStripMenuItem_Click); + this.touchToolStripMenuItem.Click += new System.EventHandler(this.TouchToolStripMenuItem_Click); // // sitToolStripMenuItem // this.sitToolStripMenuItem.Name = "sitToolStripMenuItem"; this.sitToolStripMenuItem.Size = new System.Drawing.Size(109, 22); this.sitToolStripMenuItem.Text = "Sit"; - this.sitToolStripMenuItem.Click += new System.EventHandler(this.sitToolStripMenuItem_Click); + this.sitToolStripMenuItem.Click += new System.EventHandler(this.SitToolStripMenuItem_Click); // // toolStripMenuItem1 // @@ -226,21 +226,21 @@ private void InitializeComponent() this.takeToolStripMenuItem.Name = "takeToolStripMenuItem"; this.takeToolStripMenuItem.Size = new System.Drawing.Size(109, 22); this.takeToolStripMenuItem.Text = "Take"; - this.takeToolStripMenuItem.Click += new System.EventHandler(this.takeToolStripMenuItem_Click); + this.takeToolStripMenuItem.Click += new System.EventHandler(this.TakeToolStripMenuItem_Click); // // returnToolStripMenuItem // this.returnToolStripMenuItem.Name = "returnToolStripMenuItem"; this.returnToolStripMenuItem.Size = new System.Drawing.Size(109, 22); this.returnToolStripMenuItem.Text = "Return"; - this.returnToolStripMenuItem.Click += new System.EventHandler(this.returnToolStripMenuItem_Click); + this.returnToolStripMenuItem.Click += new System.EventHandler(this.ReturnToolStripMenuItem_Click); // // deleteToolStripMenuItem // this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem"; this.deleteToolStripMenuItem.Size = new System.Drawing.Size(109, 22); this.deleteToolStripMenuItem.Text = "Delete"; - this.deleteToolStripMenuItem.Click += new System.EventHandler(this.deleteToolStripMenuItem_Click); + this.deleteToolStripMenuItem.Click += new System.EventHandler(this.DeleteToolStripMenuItem_Click); // // frmPrimWorkshop // @@ -251,7 +251,7 @@ private void InitializeComponent() this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Name = "frmPrimWorkshop"; this.Text = "Object Viewer"; - this.Shown += new System.EventHandler(this.frmPrimWorkshop_Shown); + this.Shown += new System.EventHandler(this.FrmPrimWorkshop_Shown); this.gbZoom.ResumeLayout(false); this.gbZoom.PerformLayout(); this.ctxObjects.ResumeLayout(false); diff --git a/Radegast/GUI/Rendering/PrimWorkshop.cs b/Radegast/GUI/Rendering/PrimWorkshop.cs index b84156aa6..5f2ac0e4f 100644 --- a/Radegast/GUI/Rendering/PrimWorkshop.cs +++ b/Radegast/GUI/Rendering/PrimWorkshop.cs @@ -1,6 +1,7 @@ // // Radegast Metaverse Client // Copyright (c) 2009-2014, Radegast Development Team +// Copyright (c) 2019-2020, Sjofn LLC // All rights reserved. // // Redistribution and use in source and binary forms, with or without @@ -31,23 +32,17 @@ #region Usings using System; +using System.Collections.Concurrent; using System.Collections.Generic; using System.Drawing; -using System.Drawing.Imaging; -using System.IO; using System.Windows.Forms; -#if (COGBOT_LIBOMV || USE_STHREADS) -using ThreadPoolUtil; -using Thread = ThreadPoolUtil.Thread; -using ThreadPool = ThreadPoolUtil.ThreadPool; -using Monitor = ThreadPoolUtil.Monitor; -#endif using System.Threading; +using CoreJ2K; using OpenTK.Graphics.OpenGL; using OpenMetaverse; using OpenMetaverse.Rendering; -using OpenMetaverse.Assets; -using OpenMetaverse.Imaging; +using SkiaSharp; +using SkiaSharp.Views.Desktop; #endregion Usings @@ -99,7 +94,7 @@ public partial class frmPrimWorkshop : RadegastForm RadegastInstance instance; MeshmerizerR renderer; OpenTK.Graphics.GraphicsMode GLMode = null; - BlockingQueue PendingTextures = new BlockingQueue(); + ConcurrentQueue PendingTextures = new ConcurrentQueue(); float[] lightPos = new float[] { 0f, 0f, 1f, 0f }; TextRendering textRendering; OpenTK.Matrix4 ModelMatrix; @@ -112,10 +107,10 @@ public partial class frmPrimWorkshop : RadegastForm public frmPrimWorkshop(RadegastInstance instance, uint rootLocalID) : base(instance) { - this.RootPrimLocalID = rootLocalID; + RootPrimLocalID = rootLocalID; InitializeComponent(); - Disposed += new EventHandler(frmPrimWorkshop_Disposed); + Disposed += FrmPrimWorkshop_Disposed; AutoSavePosition = true; UseMultiSampling = cbAA.Checked = instance.GlobalSettings["use_multi_sampling"]; cbAA.CheckedChanged += cbAA_CheckedChanged; @@ -125,14 +120,14 @@ public frmPrimWorkshop(RadegastInstance instance, uint rootLocalID) renderer = new MeshmerizerR(); textRendering = new TextRendering(instance); - Client.Objects.TerseObjectUpdate += new EventHandler(Objects_TerseObjectUpdate); - Client.Objects.ObjectUpdate += new EventHandler(Objects_ObjectUpdate); - Client.Objects.ObjectDataBlockUpdate += new EventHandler(Objects_ObjectDataBlockUpdate); + Client.Objects.TerseObjectUpdate += Objects_TerseObjectUpdate; + Client.Objects.ObjectUpdate += Objects_ObjectUpdate; + Client.Objects.ObjectDataBlockUpdate += Objects_ObjectDataBlockUpdate; - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } - void frmPrimWorkshop_Disposed(object sender, EventArgs e) + void FrmPrimWorkshop_Disposed(object sender, EventArgs e) { if (textRendering != null) { @@ -140,14 +135,11 @@ void frmPrimWorkshop_Disposed(object sender, EventArgs e) textRendering = null; } - if (glControl != null) - { - glControl.Dispose(); - } + glControl?.Dispose(); glControl = null; - Client.Objects.TerseObjectUpdate -= new EventHandler(Objects_TerseObjectUpdate); - Client.Objects.ObjectUpdate -= new EventHandler(Objects_ObjectUpdate); - Client.Objects.ObjectDataBlockUpdate -= new EventHandler(Objects_ObjectDataBlockUpdate); + Client.Objects.TerseObjectUpdate -= Objects_TerseObjectUpdate; + Client.Objects.ObjectUpdate -= Objects_ObjectUpdate; + Client.Objects.ObjectDataBlockUpdate -= Objects_ObjectDataBlockUpdate; } #endregion Construction and disposal @@ -182,8 +174,7 @@ public void SetupGLControl() { RenderingEnabled = false; - if (glControl != null) - glControl.Dispose(); + glControl?.Dispose(); glControl = null; GLMode = null; @@ -244,8 +235,8 @@ public void SetupGLControl() glControl.MouseUp += glControl_MouseUp; glControl.MouseMove += glControl_MouseMove; glControl.MouseWheel += glControl_MouseWheel; - glControl.Load += new EventHandler(glControl_Load); - glControl.Disposed += new EventHandler(glControl_Disposed); + glControl.Load += glControl_Load; + glControl.Disposed += glControl_Disposed; glControl.Dock = DockStyle.Fill; Controls.Add(glControl); glControl.BringToFront(); @@ -254,7 +245,10 @@ public void SetupGLControl() void glControl_Disposed(object sender, EventArgs e) { TextureThreadRunning = false; - PendingTextures.Close(); + while (!PendingTextures.IsEmpty) + { + PendingTextures.TryDequeue(out _); + } } void glControl_Load(object sender, EventArgs e) @@ -288,7 +282,7 @@ void glControl_Load(object sender, EventArgs e) GL.Enable(EnableCap.Blend); GL.AlphaFunc(AlphaFunction.Greater, 0.5f); - GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); + GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha); #region Compatibility checks OpenTK.Graphics.IGraphicsContextInternal context = glControl.Context as OpenTK.Graphics.IGraphicsContextInternal; @@ -337,7 +331,7 @@ void glControl_Load(object sender, EventArgs e) // and will also invalidate the GL control glControl_Resize(null, null); - var textureThread = new Thread(() => TextureThread()) + var textureThread = new Thread(TextureThread) { IsBackground = true, Name = "TextureLoadingThread" @@ -361,7 +355,7 @@ private void glControl_Paint(object sender, PaintEventArgs e) glControl.SwapBuffers(); - Primitive prim = null; + Primitive prim; string objName = string.Empty; if (Client.Network.CurrentSim.ObjectsPrimitives.TryGetValue(RootPrimLocalID, out prim)) @@ -523,14 +517,13 @@ private void glControl_MouseUp(object sender, MouseEventArgs e) void TextureThread() { - PendingTextures.Open(); Logger.DebugLog("Started Texture Thread"); while (TextureThreadRunning) { TextureLoadItem item = null; - if (!PendingTextures.Dequeue(Timeout.Infinite, ref item)) continue; + if (!PendingTextures.TryDequeue(out item)) continue; if (TexturesPtrMap.ContainsKey(item.TeFace.TextureID)) { @@ -540,17 +533,10 @@ void TextureThread() if (LoadTexture(item.TeFace.TextureID, ref item.Data.TextureInfo.Texture, false)) { - Bitmap bitmap = (Bitmap)item.Data.TextureInfo.Texture; + Bitmap bitmap = item.Data.TextureInfo.Texture.ToBitmap(); bool hasAlpha; - if (item.Data.TextureInfo.Texture.PixelFormat == System.Drawing.Imaging.PixelFormat.Format32bppArgb) - { - hasAlpha = true; - } - else - { - hasAlpha = false; - } + hasAlpha = bitmap.PixelFormat == System.Drawing.Imaging.PixelFormat.Format32bppArgb; item.Data.TextureInfo.HasAlpha = hasAlpha; @@ -575,17 +561,17 @@ void TextureThread() } #endregion Texture thread - private void frmPrimWorkshop_Shown(object sender, EventArgs e) + private void FrmPrimWorkshop_Shown(object sender, EventArgs e) { SetupGLControl(); - WorkPool.QueueUserWorkItem(sync => + ThreadPool.QueueUserWorkItem(sync => { if (Client.Network.CurrentSim.ObjectsPrimitives.ContainsKey(RootPrimLocalID)) { UpdatePrimBlocking(Client.Network.CurrentSim.ObjectsPrimitives[RootPrimLocalID]); - var children = Client.Network.CurrentSim.ObjectsPrimitives.FindAll((Primitive p) => { return p.ParentID == RootPrimLocalID; }); - children.ForEach(p => UpdatePrimBlocking(p)); + var children = Client.Network.CurrentSim.ObjectsPrimitives.FindAll(p => p.ParentID == RootPrimLocalID); + children.ForEach(UpdatePrimBlocking); } } ); @@ -595,7 +581,7 @@ private void frmPrimWorkshop_Shown(object sender, EventArgs e) #region Public methods public void SetView(Vector3 center, int roll, int pitch, int yaw, int zoom) { - this.Center = center; + Center = center; scrollRoll.Value = roll; scrollPitch.Value = pitch; scrollYaw.Value = yaw; @@ -614,44 +600,43 @@ private void RenderText() { primNr++; Primitive prim = mesh.Prim; - if (!string.IsNullOrEmpty(prim.Text)) + if (string.IsNullOrEmpty(prim.Text)) continue; + + string text = System.Text.RegularExpressions.Regex.Replace(prim.Text, "(\r?\n)+", "\n"); + OpenTK.Vector3 screenPos = OpenTK.Vector3.Zero; + OpenTK.Vector3 primPos = OpenTK.Vector3.Zero; + + // Is it child prim + FacetedMesh parent = null; + if (Prims.TryGetValue(prim.ParentID, out parent)) { - string text = System.Text.RegularExpressions.Regex.Replace(prim.Text, "(\r?\n)+", "\n"); - OpenTK.Vector3 screenPos = OpenTK.Vector3.Zero; - OpenTK.Vector3 primPos = OpenTK.Vector3.Zero; + var newPrimPos = prim.Position * Matrix4.CreateFromQuaternion(parent.Prim.Rotation); + primPos = new OpenTK.Vector3(newPrimPos.X, newPrimPos.Y, newPrimPos.Z); + } - // Is it child prim - FacetedMesh parent = null; - if (Prims.TryGetValue(prim.ParentID, out parent)) - { - var newPrimPos = prim.Position * Matrix4.CreateFromQuaternion(parent.Prim.Rotation); - primPos = new OpenTK.Vector3(newPrimPos.X, newPrimPos.Y, newPrimPos.Z); - } + primPos.Z += prim.Scale.Z * 0.8f; + if (!Math3D.GluProject(primPos, ModelMatrix, ProjectionMatrix, Viewport, out screenPos)) continue; + screenPos.Y = glControl.Height - screenPos.Y; - primPos.Z += prim.Scale.Z * 0.8f; - if (!Math3D.GluProject(primPos, ModelMatrix, ProjectionMatrix, Viewport, out screenPos)) continue; - screenPos.Y = glControl.Height - screenPos.Y; + textRendering.Begin(); - textRendering.Begin(); + Color color = Color.FromArgb((int)(prim.TextColor.A * 255), (int)(prim.TextColor.R * 255), (int)(prim.TextColor.G * 255), (int)(prim.TextColor.B * 255)); + TextFormatFlags flags = TextFormatFlags.HorizontalCenter | TextFormatFlags.Top; - Color color = Color.FromArgb((int)(prim.TextColor.A * 255), (int)(prim.TextColor.R * 255), (int)(prim.TextColor.G * 255), (int)(prim.TextColor.B * 255)); - TextFormatFlags flags = TextFormatFlags.HorizontalCenter | TextFormatFlags.Top; + using (Font f = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Regular)) + { + var size = TextRendering.Measure(text, f, flags); + screenPos.X -= size.Width / 2; + screenPos.Y -= size.Height; - using (Font f = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Regular)) + // Shadow + if (color != Color.Black) { - var size = TextRendering.Measure(text, f, flags); - screenPos.X -= size.Width / 2; - screenPos.Y -= size.Height; - - // Shadow - if (color != Color.Black) - { - textRendering.Print(text, f, Color.Black, new Rectangle((int)screenPos.X + 1, (int)screenPos.Y + 1, size.Width, size.Height), flags); - } - textRendering.Print(text, f, color, new Rectangle((int)screenPos.X, (int)screenPos.Y, size.Width, size.Height), flags); + textRendering.Print(text, f, Color.Black, new Rectangle((int)screenPos.X + 1, (int)screenPos.Y + 1, size.Width, size.Height), flags); } - textRendering.End(); + textRendering.Print(text, f, color, new Rectangle((int)screenPos.X, (int)screenPos.Y, size.Width, size.Height), flags); } + textRendering.End(); } } } @@ -721,16 +706,12 @@ private void RenderObjects(RenderPass pass) case Shininess.High: GL.Material(MaterialFace.Front, MaterialParameter.Shininess, 94f); break; - case Shininess.Medium: GL.Material(MaterialFace.Front, MaterialParameter.Shininess, 64f); break; - case Shininess.Low: GL.Material(MaterialFace.Front, MaterialParameter.Shininess, 24f); break; - - case Shininess.None: default: GL.Material(MaterialFace.Front, MaterialParameter.Shininess, 0f); @@ -870,7 +851,7 @@ private bool TryPick(int x, int y, out FacetedMesh picked, out int faceID) Render(true); byte[] color = new byte[4]; - GL.ReadPixels(x, glControl.Height - y, 1, 1, OpenTK.Graphics.OpenGL.PixelFormat.Rgba, PixelType.UnsignedByte, color); + GL.ReadPixels(x, glControl.Height - y, 1, 1, PixelFormat.Rgba, PixelType.UnsignedByte, color); GL.PopAttrib(); @@ -923,10 +904,10 @@ private void UpdatePrimBlocking(Primitive prim) { if (prim.Sculpt.Type != SculptType.Mesh) { // Regular sculptie - Image img = null; + SKBitmap img = null; if (!LoadTexture(prim.Sculpt.SculptTexture, ref img, true)) return; - mesh = renderer.GenerateFacetedSculptMesh(prim, (Bitmap)img, DetailLevel.Highest); + mesh = renderer.GenerateFacetedSculptMesh(prim, img, DetailLevel.Highest); } else { // Mesh @@ -965,11 +946,13 @@ private void UpdatePrimBlocking(Primitive prim) for (int j = 0; j < mesh.Faces.Count; j++) { Face face = mesh.Faces[j]; - FaceData data = new FaceData(); + FaceData data = new FaceData + { + Vertices = new float[face.Vertices.Count * 3], + Normals = new float[face.Vertices.Count * 3] + }; // Vertices for this face - data.Vertices = new float[face.Vertices.Count * 3]; - data.Normals = new float[face.Vertices.Count * 3]; for (int k = 0; k < face.Vertices.Count; k++) { data.Vertices[k * 3 + 0] = face.Vertices[k].Position.X; @@ -1032,34 +1015,23 @@ private void UpdatePrimBlocking(Primitive prim) SafeInvalidate(); } - private bool LoadTexture(UUID textureID, ref Image texture, bool removeAlpha) + private bool LoadTexture(UUID textureID, ref SKBitmap texture, bool removeAlpha) { if (textureID == UUID.Zero) return false; ManualResetEvent gotImage = new ManualResetEvent(false); - Image img = null; + SKBitmap img = null; try { gotImage.Reset(); - instance.Client.Assets.RequestImage(textureID, (TextureRequestState state, AssetTexture assetTexture) => + instance.Client.Assets.RequestImage(textureID, (state, assetTexture) => { try { if (state == TextureRequestState.Finished) { - ManagedImage mi; - OpenJPEG.DecodeToImage(assetTexture.AssetData, out mi); - - if (removeAlpha) - { - if ((mi.Channels & ManagedImage.ImageChannels.Alpha) != 0) - { - mi.ConvertChannels(mi.Channels & ~ManagedImage.ImageChannels.Alpha); - } - } - - img = LoadTGAClass.LoadTGA(new MemoryStream(mi.ExportTGA())); + img = J2kImage.FromBytes(assetTexture.AssetData).As(); } } finally @@ -1091,7 +1063,7 @@ private void SafeInvalidate() { if (!instance.MonoRuntime || IsHandleCreated) { - BeginInvoke(new MethodInvoker(() => SafeInvalidate())); + BeginInvoke(new MethodInvoker(SafeInvalidate)); } return; } @@ -1101,24 +1073,24 @@ private void SafeInvalidate() #endregion Private methods (the meat) #region Form controls handlers - private void scroll_ValueChanged(object sender, EventArgs e) + private void Scroll_ValueChanged(object sender, EventArgs e) { SafeInvalidate(); } - private void scrollZoom_ValueChanged(object sender, EventArgs e) + private void ScrollZoom_ValueChanged(object sender, EventArgs e) { glControl_Resize(null, null); SafeInvalidate(); } - private void chkWireFrame_CheckedChanged(object sender, EventArgs e) + private void ChkWireFrame_CheckedChanged(object sender, EventArgs e) { Wireframe = chkWireFrame.Checked; SafeInvalidate(); } - private void btnReset_Click(object sender, EventArgs e) + private void BtnReset_Click(object sender, EventArgs e) { scrollYaw.Value = 90; scrollPitch.Value = 0; @@ -1129,10 +1101,9 @@ private void btnReset_Click(object sender, EventArgs e) SafeInvalidate(); } - private void oBJToolStripMenuItem_Click(object sender, EventArgs e) + private void OBJToolStripMenuItem_Click(object sender, EventArgs e) { - SaveFileDialog dialog = new SaveFileDialog(); - dialog.Filter = "OBJ files (*.obj)|*.obj"; + SaveFileDialog dialog = new SaveFileDialog {Filter = "OBJ files (*.obj)|*.obj"}; if (dialog.ShowDialog() == DialogResult.OK) { @@ -1153,7 +1124,7 @@ private void cbAA_CheckedChanged(object sender, EventArgs e) #endregion Form controls handlers #region Context menu - private void ctxObjects_Opening(object sender, System.ComponentModel.CancelEventArgs e) + private void CtxObjects_Opening(object sender, System.ComponentModel.CancelEventArgs e) { e.Cancel = false; @@ -1182,7 +1153,7 @@ private void ctxObjects_Opening(object sender, System.ComponentModel.CancelEvent } } - private void touchToolStripMenuItem_Click(object sender, EventArgs e) + private void TouchToolStripMenuItem_Click(object sender, EventArgs e) { Client.Self.Grab(RightclickedPrim.Prim.LocalID, Vector3.Zero, Vector3.Zero, Vector3.Zero, RightclickedFaceID, Vector3.Zero, Vector3.Zero, Vector3.Zero); @@ -1190,7 +1161,7 @@ private void touchToolStripMenuItem_Click(object sender, EventArgs e) Client.Self.DeGrab(RightclickedPrim.Prim.LocalID, Vector3.Zero, Vector3.Zero, RightclickedFaceID, Vector3.Zero, Vector3.Zero, Vector3.Zero); } - private void sitToolStripMenuItem_Click(object sender, EventArgs e) + private void SitToolStripMenuItem_Click(object sender, EventArgs e) { if (!instance.State.IsSitting) { @@ -1202,24 +1173,24 @@ private void sitToolStripMenuItem_Click(object sender, EventArgs e) } } - private void takeToolStripMenuItem_Click(object sender, EventArgs e) + private void TakeToolStripMenuItem_Click(object sender, EventArgs e) { instance.MediaManager.PlayUISound(UISounds.ObjectDelete); Client.Inventory.RequestDeRezToInventory(RightclickedPrim.Prim.LocalID); Close(); } - private void returnToolStripMenuItem_Click(object sender, EventArgs e) + private void ReturnToolStripMenuItem_Click(object sender, EventArgs e) { instance.MediaManager.PlayUISound(UISounds.ObjectDelete); Client.Inventory.RequestDeRezToInventory(RightclickedPrim.Prim.LocalID, DeRezDestination.ReturnToOwner, UUID.Zero, UUID.Random()); Close(); } - private void deleteToolStripMenuItem_Click(object sender, EventArgs e) + private void DeleteToolStripMenuItem_Click(object sender, EventArgs e) { if (RightclickedPrim.Prim.Properties != null && RightclickedPrim.Prim.Properties.OwnerID != Client.Self.AgentID) - returnToolStripMenuItem_Click(sender, e); + ReturnToolStripMenuItem_Click(sender, e); else { instance.MediaManager.PlayUISound(UISounds.ObjectDelete); diff --git a/Radegast/GUI/Rendering/RenderAvatar.cs b/Radegast/GUI/Rendering/RenderAvatar.cs index a30cdbd94..1320e7f22 100644 --- a/Radegast/GUI/Rendering/RenderAvatar.cs +++ b/Radegast/GUI/Rendering/RenderAvatar.cs @@ -1,49 +1,33 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior CreateReflectionTexture permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id: RenderAvatar.cs 1137 2011-09-05 22:53:46Z latifer $ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2022, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ using System; using System.Collections.Generic; using System.Collections; using System.IO; -using System.Xml; -#if (COGBOT_LIBOMV || USE_STHREADS) -using ThreadPoolUtil; -using Thread = ThreadPoolUtil.Thread; -using ThreadPool = ThreadPoolUtil.ThreadPool; -using Monitor = ThreadPoolUtil.Monitor; -#endif +using System.Linq; using System.Threading; - +using System.Xml; using OpenMetaverse; using OpenMetaverse.Rendering; +using Path = System.IO.Path; namespace Radegast.Rendering { @@ -51,6 +35,7 @@ public class attachment_point { public string name; public string joint; + public string location; public Vector3 position; public Quaternion rotation; public int id; @@ -61,12 +46,15 @@ public class attachment_point public attachment_point(XmlNode node) { + if (node.Attributes == null) { return; } + name = node.Attributes.GetNamedItem("name").Value; joint = node.Attributes.GetNamedItem("joint").Value; + location = node.Attributes.GetNamedItem("location").Value; position = VisualParamEx.XmlParseVector(node.Attributes.GetNamedItem("position").Value); rotation = VisualParamEx.XmlParseRotation(node.Attributes.GetNamedItem("rotation").Value); id = Int32.Parse(node.Attributes.GetNamedItem("id").Value); - group = Int32.Parse(node.Attributes.GetNamedItem("group").Value); + @group = Int32.Parse(node.Attributes.GetNamedItem("group").Value); } } @@ -86,7 +74,7 @@ public class GLMesh : LindenMesh public int teFaceID; public Dictionary _evp = new Dictionary(); - new public class LODMesh : LindenMesh.ReferenceMesh + public new class LODMesh : ReferenceMesh { public ushort[] Indices; @@ -106,9 +94,6 @@ public override void LoadMesh(string filename) } } - /// - /// - /// public struct GLData { public float[] Vertices; @@ -182,9 +167,6 @@ public GLMesh(GLMesh source, GLAvatar av) Array.Copy(source.RenderData.TexCoords, OrigRenderData.TexCoords, source.RenderData.TexCoords.Length); Array.Copy(source.RenderData.Indices, OrigRenderData.Indices, source.RenderData.Indices.Length); - - - } public void setMeshPos(Vector3 pos) @@ -213,10 +195,10 @@ public override void LoadMesh(string filename) { base.LoadMesh(filename); - float minX, minY, minZ; - minX = minY = minZ = Single.MaxValue; - float maxX, maxY, maxZ; - maxX = maxY = maxZ = Single.MinValue; + float minY, minZ; + var minX = minY = minZ = float.MaxValue; + float maxY, maxZ; + var maxX = maxY = maxZ = float.MinValue; // Generate the vertex array RenderData.Vertices = new float[NumVertices * 3]; @@ -367,16 +349,8 @@ public void applyjointweights() } ba = av.skel.mBones[jointname]; - - - if (jointname2 == "") - { - bb = null; - } - else - { - bb = av.skel.mBones[jointname2]; - } + + bb = jointname2 == "" ? null : av.skel.mBones[jointname2]; } //Special cases 0 is not used @@ -519,21 +493,21 @@ public class GLAvatar public GLAvatar() { - lock (_defaultmeshes) foreach (KeyValuePair kvp in _defaultmeshes) - { - GLMesh mesh = new GLMesh(kvp.Value, this); // Instance our meshes - _meshes.Add(kvp.Key, mesh); + lock (_defaultmeshes) foreach (var kvp in _defaultmeshes) + { + GLMesh mesh = new GLMesh(kvp.Value, this); // Instance our meshes + _meshes.Add(kvp.Key, mesh); - } + } } public static void dumptweaks() { - for (int x = 0; x < VisualParamEx.tweakable_params.Count; x++) + for (int x = 0; x < VisualParamEx.TweakableParams.Count; x++) { - VisualParamEx vpe = (VisualParamEx)VisualParamEx.tweakable_params.GetByIndex(x); - Console.WriteLine(string.Format("{0} is {1}", x, vpe.Name)); + VisualParamEx vpe = (VisualParamEx)VisualParamEx.TweakableParams.GetByIndex(x); + Console.WriteLine($"{x} is {vpe.Name}"); } } @@ -546,16 +520,16 @@ public static void loadlindenmeshes2(string LODfilename) attachment_points.Clear(); - string basedir = Directory.GetCurrentDirectory() + System.IO.Path.DirectorySeparatorChar + "character" + System.IO.Path.DirectorySeparatorChar; + string basedir = Path.Combine(Directory.GetCurrentDirectory(), "character"); XmlDocument lad = new XmlDocument(); - lad.Load(basedir + LODfilename); + lad.Load(Path.Combine(basedir, LODfilename)); - //Firstly read the skeleton section this contains attachment point info and the bone deform info for visual params + // First, read the skeleton section this contains attachment point info and the bone deform info for visual params // And load the skeleton file in to the bones class XmlNodeList skeleton = lad.GetElementsByTagName("skeleton"); - string skeletonfilename = skeleton[0].Attributes.GetNamedItem("file_name").Value; + string skeletonfilename = skeleton[0].Attributes?.GetNamedItem("file_name").Value; Bone.loadbones(skeletonfilename); // Next read all the skeleton child nodes, we have attachment points and bone deform params @@ -573,7 +547,7 @@ public static void loadlindenmeshes2(string LODfilename) } // Parse all visual paramaters in one go - // we can dedue type on the fly + // we can deduce type on the fly XmlNodeList paramss = lad.GetElementsByTagName("param"); foreach (XmlNode paramNode in paramss) { @@ -585,15 +559,15 @@ public static void loadlindenmeshes2(string LODfilename) XmlNodeList meshes = lad.GetElementsByTagName("mesh"); foreach (XmlNode meshNode in meshes) { - string type = meshNode.Attributes.GetNamedItem("type").Value; - int lod = Int32.Parse(meshNode.Attributes.GetNamedItem("lod").Value); - string fileName = meshNode.Attributes.GetNamedItem("file_name").Value; + string type = meshNode.Attributes?.GetNamedItem("type").Value; + int lod = Int32.Parse(meshNode.Attributes?.GetNamedItem("lod").Value); + string fileName = meshNode.Attributes?.GetNamedItem("file_name").Value; GLMesh mesh = null; lock (_defaultmeshes) mesh = (_defaultmeshes.ContainsKey(type) ? _defaultmeshes[type] : new GLMesh(type)); - // Set up the texture elemenets for each mesh + // Set up the texture elements for each mesh // And hack the eyeball position switch (mesh.Name) { @@ -635,9 +609,9 @@ public static void loadlindenmeshes2(string LODfilename) } if (lod == 0) - mesh.LoadMesh(basedir + fileName); + mesh.LoadMesh(Path.Combine(basedir, fileName)); else - mesh.LoadLODMesh(lod, basedir + fileName); + mesh.LoadLODMesh(lod, Path.Combine(basedir, fileName)); if (lod == 0) { @@ -658,9 +632,6 @@ public static void loadlindenmeshes2(string LODfilename) case "hairMesh": //mesh.setMeshPos(Bone.mBones["mHead"].getTotalOffset()); break; - - default: - break; } } @@ -675,13 +646,13 @@ public void applyMorph(Avatar av, int param, float weight) { VisualParamEx vpx; - if (VisualParamEx.allParams.TryGetValue(param, out vpx)) + if (VisualParamEx.AllParams.TryGetValue(param, out vpx)) { applyMorph(vpx, av, weight); // a morph ID may apply to more than one mesh (duplicate VP IDs) // in this case also apply to all other identical IDs - foreach (VisualParamEx cvpx in vpx.identicalIds) + foreach (VisualParamEx cvpx in vpx.IdenticalIds) { applyMorph(cvpx, av, weight); } @@ -703,7 +674,7 @@ public void applyMorph(VisualParamEx vpx, Avatar av, float weight) { // Its a morph GLMesh mesh; - if (_meshes.TryGetValue(vpx.morphmesh, out mesh)) + if (_meshes.TryGetValue(vpx.MorphMesh, out mesh)) { foreach (LindenMesh.Morph morph in mesh.Morphs) //optimise me to a dictionary { @@ -721,13 +692,11 @@ public void applyMorph(VisualParamEx vpx, Avatar av, float weight) } } - // Driver type // A driver drives multiple slave visual paramaters if (vpx.pType == VisualParamEx.ParamType.TYPE_DRIVER) { - - foreach (VisualParamEx.driven child in vpx.childparams) + foreach (VisualParamEx.driven child in vpx.ChildParams) { /***** BEGIN UNGRACEFULL CODE STEALING ******/ @@ -749,8 +718,8 @@ public void applyMorph(VisualParamEx vpx, Avatar av, float weight) } float driven_weight = vpx.DefaultValue; - float driven_max = VisualParamEx.allParams[child.id].MaxValue; - float driven_min = VisualParamEx.allParams[child.id].MinValue; + float driven_max = VisualParamEx.AllParams[child.id].MaxValue; + float driven_min = VisualParamEx.AllParams[child.id].MinValue; float input_weight = weight; float min_weight = vpx.MinValue; @@ -769,33 +738,26 @@ public void applyMorph(VisualParamEx vpx, Avatar av, float weight) } } else + { if (input_weight <= child.max1) { - float t = (input_weight - child.min1) / (child.max1 - child.min1); - driven_weight = driven_min + t * (driven_max - driven_min); + float t = (input_weight - child.min1)/(child.max1 - child.min1); + driven_weight = driven_min + t*(driven_max - driven_min); + } + else if (input_weight <= child.max2) + { + driven_weight = driven_max; + } + else if (input_weight <= child.min2) + { + float t = (input_weight - child.max2)/(child.min2 - child.max2); + driven_weight = driven_max + t*(driven_min - driven_max); } else - if (input_weight <= child.max2) - { - driven_weight = driven_max; - } - else - if (input_weight <= child.min2) - { - float t = (input_weight - child.max2) / (child.min2 - child.max2); - driven_weight = driven_max + t * (driven_min - driven_max); - } - else - { - if (child.max2 >= max_weight) - { - driven_weight = driven_max; - } - else - { - driven_weight = driven_min; - } - } + { + driven_weight = child.max2 >= max_weight ? driven_max : driven_min; + } + } /***** END UNGRACEFULL CODE STEALING ******/ @@ -814,7 +776,7 @@ public void applyMorph(VisualParamEx vpx, Avatar av, float weight) // value_min="-1" // value_max="1" - foreach (KeyValuePair kvp in vpx.BoneDeforms) + foreach (var kvp in vpx.BoneDeforms) { skel.scalebone(kvp.Key, Vector3.One + (kvp.Value.scale * value)); skel.offsetbone(kvp.Key, kvp.Value.offset * value); @@ -828,7 +790,7 @@ public void morph(Avatar av) if (av.VisualParameters == null) return; - WorkPool.QueueUserWorkItem(sync => + ThreadPool.QueueUserWorkItem(sync => { int x = 0; @@ -839,14 +801,7 @@ public void morph(Avatar av) { if (av.VisualParameters.Length > 123) { - if (av.VisualParameters[31] > 127) - { - msex = VisualParamEx.EparamSex.SEX_MALE; - } - else - { - msex = VisualParamEx.EparamSex.SEX_FEMALE; - } + msex = av.VisualParameters[31] > 127 ? VisualParamEx.EparamSex.SEX_MALE : VisualParamEx.EparamSex.SEX_FEMALE; } foreach (GLMesh mesh in _meshes.Values) @@ -858,13 +813,13 @@ public void morph(Avatar av) foreach (byte vpvalue in av.VisualParameters) { - if (x >= VisualParamEx.tweakable_params.Count) + if (x >= VisualParamEx.TweakableParams.Count) { //Logger.Log("Two many visual paramaters in Avatar appearance", Helpers.LogLevel.Warning); break; } - VisualParamEx vpe = (VisualParamEx)VisualParamEx.tweakable_params.GetByIndex(x); + VisualParamEx vpe = (VisualParamEx)VisualParamEx.TweakableParams.GetByIndex(x); if (vpe.sex != VisualParamEx.EparamSex.SEX_BOTH && vpe.sex != msex) { @@ -875,12 +830,12 @@ public void morph(Avatar av) VisualAppearanceParameters[x] = vpvalue; float value = (vpvalue / 255.0f); - this.applyMorph(av, vpe.ParamID, value); + applyMorph(av, vpe.ParamID, value); x++; } - this.skel.mNeedsMeshRebuild = true; + skel.mNeedsMeshRebuild = true; // Don't update actual meshes here anymore, we do it every frame because of animation anyway } @@ -982,10 +937,10 @@ public skeleton() mBones = new Dictionary(); lock (Bone.mBones) foreach (Bone src in Bone.mBones.Values) - { - Bone newbone = new Bone(src); - mBones.Add(newbone.name, newbone); - } + { + Bone newbone = new Bone(src); + mBones.Add(newbone.name, newbone); + } //rebuild the skeleton structure on the new copy foreach (Bone src in mBones.Values) @@ -1054,7 +1009,7 @@ public void processAnimation(UUID mAnimID) public void resetbonescales() { - foreach (KeyValuePair src in mBones) + foreach (var src in mBones) { src.Value.scale = Vector3.One; src.Value.offset_pos = Vector3.Zero; @@ -1095,27 +1050,13 @@ public void offsetbone(string name, Vector3 offset) public Vector3 getOffset(string bonename) { Bone b; - if (mBones.TryGetValue(bonename, out b)) - { - return (b.getTotalOffset()); - } - else - { - return Vector3.Zero; - } + return mBones.TryGetValue(bonename, out b) ? (b.getTotalOffset()) : Vector3.Zero; } public Quaternion getRotation(string bonename) { Bone b; - if (mBones.TryGetValue(bonename, out b)) - { - return (b.getTotalRotation()); - } - else - { - return Quaternion.Identity; - } + return mBones.TryGetValue(bonename, out b) ? (b.getTotalRotation()) : Quaternion.Identity; } @@ -1148,7 +1089,7 @@ public void flushanimationsfinal() { foreach (animationwrapper ar in mAnimationsWrapper.Values) { - if (ar.mPotentialyDead == true) + if (ar.mPotentialyDead) { // Logger.Log(string.Format("Animation {0} is being marked for easeout (dead)",ar.mAnimation.ToString()),Helpers.LogLevel.Info); // Should we just stop dead? i think not it may get jerky @@ -1175,12 +1116,12 @@ public static void addanimation(OpenMetaverse.Assets.Asset asset, UUID tid, BinB { b = new BinBVHAnimationReader(asset.AssetData); mAnimationCache[asset.AssetID] = b; - Logger.Log("Adding new decoded animaton known animations " + asset.AssetID.ToString(), Helpers.LogLevel.Info); + Logger.Log($"Adding new decoded animaton known animations {asset.AssetID}", Helpers.LogLevel.Debug); } if (!av.glavatar.skel.mAnimationsWrapper.ContainsKey(animKey)) { - Logger.Log(String.Format("Animation {0} is not in mAnimationsWrapper! ", animKey), Helpers.LogLevel.Warning); + Logger.Log($"Animation {animKey} is not in mAnimationsWrapper! ", Helpers.LogLevel.Warning); return; } @@ -1210,7 +1151,7 @@ public static void addanimation(OpenMetaverse.Assets.Asset asset, UUID tid, BinB state.easeoutfactor = 1.0f; state.easeoutrot = Quaternion.Identity; - if (b.Loop == true) + if (b.Loop) { int frame = 0; foreach (binBVHJointKey key in joint.rotationkeys) @@ -1265,7 +1206,7 @@ public static void recalcpriorities(RenderAvatar av) //pre calculate all joint priorities here av.glavatar.skel.mPriority.Clear(); - foreach (KeyValuePair kvp in av.glavatar.skel.mAnimationsWrapper) + foreach (var kvp in av.glavatar.skel.mAnimationsWrapper) { int jpos = 0; animationwrapper ar = kvp.Value; @@ -1559,7 +1500,7 @@ public void animate(float lastframetime) //end of rotation - joint jointstate = new Rendering.joint(); + joint jointstate = new joint(); if (jointdeforms.TryGetValue(ar.anim.joints[jpos].Name, out jointstate)) { @@ -1567,23 +1508,20 @@ public void animate(float lastframetime) if (ar.playstate != animationwrapper.animstate.STATE_EASEOUT) { - if (easeoutset == true) - { - jointstate.rotation = Quaternion.Slerp(jointstate.rotation, state.easeoutrot, state.easeoutfactor); - } - else - { - jointstate.rotation = rotlerp; - } + jointstate.rotation = easeoutset + ? Quaternion.Slerp(jointstate.rotation, state.easeoutrot, state.easeoutfactor) + : rotlerp; } //jointstate.rotation= Quaternion.Slerp(jointstate.rotation, rotlerp, 0.5f); } else { - jointstate = new joint(); - jointstate.rotation = rotlerp; - jointstate.offset = poslerp; + jointstate = new joint + { + rotation = rotlerp, + offset = poslerp + }; jointdeforms.Add(ar.anim.joints[jpos].Name, jointstate); } @@ -1595,7 +1533,7 @@ public void animate(float lastframetime) } } - foreach (KeyValuePair kvp in jointdeforms) + foreach (var kvp in jointdeforms) { deformbone(kvp.Key, kvp.Value.offset, kvp.Value.rotation); } @@ -1649,7 +1587,7 @@ public Bone() public Bone(Bone source) { - name = String.Copy(source.name); + name = source.name; pos = new Vector3(source.pos); rot = new Quaternion(source.rot); scale = new Vector3(source.scale); @@ -1668,10 +1606,10 @@ public Bone(Bone source) public static void loadbones(string skeletonfilename) { - lock (Bone.mBones) mBones.Clear(); - string basedir = Directory.GetCurrentDirectory() + System.IO.Path.DirectorySeparatorChar + "character" + System.IO.Path.DirectorySeparatorChar; + lock (mBones) mBones.Clear(); + string basedir = Path.Combine(Directory.GetCurrentDirectory(), "character"); XmlDocument skeleton = new XmlDocument(); - skeleton.Load(basedir + skeletonfilename); + skeleton.Load(Path.Combine(basedir, skeletonfilename)); XmlNode boneslist = skeleton.GetElementsByTagName("linden_skeleton")[0]; addbone(boneslist.ChildNodes[0], null); } @@ -1682,8 +1620,7 @@ public static void addbone(XmlNode bone, Bone parent) if (bone.Name != "bone") return; - Bone b = new Bone(); - b.name = bone.Attributes.GetNamedItem("name").Value; + Bone b = new Bone {name = bone.Attributes.GetNamedItem("name").Value}; string pos = bone.Attributes.GetNamedItem("pos").Value; string[] posparts = pos.Split(' '); @@ -1714,10 +1651,10 @@ public static void addbone(XmlNode bone, Bone parent) parent.children.Add(b); } - lock (Bone.mBones) mBones.Add(b.name, b); + lock (mBones) mBones.Add(b.name, b); mIndexedBones.Add(boneaddindex++, b); - Logger.Log("Found bone " + b.name, Helpers.LogLevel.Info); + Logger.Log($"Found bone {b.name}", Helpers.LogLevel.Debug); foreach (XmlNode childbone in bone.ChildNodes) { @@ -1738,7 +1675,7 @@ public void deformbone(Vector3 dpos, Quaternion rot) animation_offset = dpos; //this.pos = Bone.mBones[name].offset_pos + dpos; - lock (Bone.mBones) this.rot = Bone.mBones[name].orig_rot * rot; + lock (mBones) this.rot = mBones[name].orig_rot * rot; markdirty(); } @@ -1751,7 +1688,7 @@ public void scalebone(Vector3 scale) public void offsetbone(Vector3 offset) { - this.offset_pos += offset; + offset_pos += offset; markdirty(); } @@ -1768,7 +1705,7 @@ public void markdirty() public Matrix4 getdeform() { - if (this.parent != null) + if (parent != null) { return mDeformMatrix * parent.getdeform(); } @@ -1813,14 +1750,7 @@ public Vector3 getMyOffset() // Try to save some cycles by not recalculating positions and rotations every time public Vector3 getTotalOffset() { - if (posdirty == false) - { - return mTotalPos; - } - else - { - return getOffset(); - } + return posdirty == false ? mTotalPos : getOffset(); } public Vector3 getDeltaOffset() @@ -1829,11 +1759,8 @@ public Vector3 getDeltaOffset() { return mDeltaPos; } - else - { - getOffset(); - return mDeltaPos; - } + getOffset(); + return mDeltaPos; } private Vector3 getOrigOffset() @@ -1851,16 +1778,9 @@ private Vector3 getOrigOffset() private static Quaternion getRotation(string bonename) { Bone b; - lock (Bone.mBones) + lock (mBones) { - if (mBones.TryGetValue(bonename, out b)) - { - return (b.getRotation()); - } - else - { - return Quaternion.Identity; - } + return mBones.TryGetValue(bonename, out b) ? (b.getRotation()) : Quaternion.Identity; } } @@ -1895,14 +1815,7 @@ private Quaternion getRotation() public Quaternion getTotalRotation() { - if (rotdirty == false) - { - return mTotalRot; - } - else - { - return getRotation(); - } + return rotdirty == false ? mTotalRot : getRotation(); } } @@ -1921,27 +1834,28 @@ public BoneDeform(Vector3 scale, Vector3 offset) public class VisualParamEx { //All visual params indexed by ID - static public Dictionary allParams = new Dictionary(); + public static Dictionary AllParams = new Dictionary(); // The sorted list of tweakable params, this matches the AvatarAppearance packet visual // parameters ordering - static public SortedList tweakable_params = new SortedList(); + public static SortedList TweakableParams = new SortedList(); public Dictionary BoneDeforms = null; public Dictionary VolumeDeforms = null; - public List childparams = null; + public List ChildParams = null; - public List identicalIds = new List(); + public List IdenticalIds = new List(); - public string morphmesh = null; + public string MorphMesh = null; enum GroupType { VISUAL_PARAM_GROUP_TWEAKABLE = 0, VISUAL_PARAM_GROUP_ANIMATABLE, VISUAL_PARAM_GROUP_TWEAKABLE_NO_TRANSMIT, + VISUAL_PARAM_GROUP_TRANSMIT_NOT_TWEAKABLE } public struct VolumeDeform @@ -1953,9 +1867,9 @@ public struct VolumeDeform public enum EparamSex { - SEX_BOTH = 0, - SEX_FEMALE = 1, - SEX_MALE = 2 + SEX_MALE = 0x1, + SEX_FEMALE = 0x2, + SEX_BOTH = 0x3 } public enum ParamType @@ -2032,7 +1946,8 @@ public struct driven /// Array of param IDs that are drivers for this parameter /// Alpha blending/bump info /// Color information - public VisualParamEx(int paramID, string name, int group, string wearable, string label, string labelMin, string labelMax, float def, float min, float max, bool isBumpAttribute, int[] drivers, VisualAlphaParam? alpha, VisualColorParam? colorParams) + public VisualParamEx(int paramID, string name, int group, string wearable, string label, string labelMin, string labelMax, + float def, float min, float max, bool isBumpAttribute, int[] drivers, VisualAlphaParam? alpha, VisualColorParam? colorParams) { ParamID = paramID; Name = name; @@ -2053,13 +1968,7 @@ public VisualParamEx(int paramID, string name, int group, string wearable, strin public bool matchchildnode(string test, XmlNode node) { - foreach (XmlNode n in node.ChildNodes) - { - if (n.Name == test) - return true; - } - - return false; + return node.ChildNodes.Cast().Any(n => n.Name == test); } public VisualParamEx(XmlNode node) @@ -2091,45 +2000,47 @@ public VisualParamEx(XmlNode node) if (sexnode != null) { - if (sexnode.Value == "male") - { - sex = EparamSex.SEX_MALE; - } - else + switch (sexnode.Value) { - sex = EparamSex.SEX_FEMALE; + case "male": + sex = EparamSex.SEX_MALE; + break; + case "female": + sex = EparamSex.SEX_FEMALE; + break; + default: + sex = EparamSex.SEX_BOTH; + break; } } if (node.ParentNode.Name == "mesh") { - this.morphmesh = node.ParentNode.Attributes.GetNamedItem("type").Value; + MorphMesh = node.ParentNode.Attributes.GetNamedItem("type").Value; } - Group = int.Parse(node.Attributes.GetNamedItem("group").Value); - if (Group == (int)GroupType.VISUAL_PARAM_GROUP_TWEAKABLE) { - if (!tweakable_params.ContainsKey(ParamID)) //stupid duplicate shared params + if (!TweakableParams.ContainsKey(ParamID)) //stupid duplicate shared params { - tweakable_params.Add(this.ParamID, this); + TweakableParams.Add(ParamID, this); } else { - Logger.Log(String.Format("Warning duplicate tweakable paramater ID {0} {1}", count, this.Name), Helpers.LogLevel.Warning); + Logger.Log($"Warning duplicate tweakable parameter ID {count} {Name}", Helpers.LogLevel.Warning); } count++; } - if (allParams.ContainsKey(ParamID)) + if (AllParams.ContainsKey(ParamID)) { //Logger.Log("Shared VisualParam id " + ParamID.ToString() + " "+Name, Helpers.LogLevel.Info); - allParams[ParamID].identicalIds.Add(this); + AllParams[ParamID].IdenticalIds.Add(this); } else { //Logger.Log("VisualParam id " + ParamID.ToString() + " " + Name, Helpers.LogLevel.Info); - allParams.Add(ParamID, this); + AllParams.Add(ParamID, this); } if (matchchildnode("param_skeleton", node)) @@ -2157,7 +2068,7 @@ public VisualParamEx(XmlNode node) if (matchchildnode("param_driver", node)) { pType = ParamType.TYPE_DRIVER; - childparams = new List(); + ChildParams = new List(); if (node.HasChildNodes && node.ChildNodes[0].HasChildNodes) //LAZY { ParseDrivers(node.ChildNodes[0].ChildNodes); @@ -2210,27 +2121,18 @@ void ParseVolumeDeforms(XmlNodeList deforms) { if (node.Name == "volume_morph") { - VolumeDeform vd = new VolumeDeform(); - vd.name = node.Attributes.GetNamedItem("name").Value; - vd.name = vd.name.ToLower(); - - if (node.Attributes.GetNamedItem("scale") != null) - { - vd.scale = XmlParseVector(node.Attributes.GetNamedItem("scale").Value); - } - else + VolumeDeform vd = new VolumeDeform { - vd.scale = new Vector3(0, 0, 0); - } - - if (node.Attributes.GetNamedItem("pos") != null) - { - vd.pos = XmlParseVector(node.Attributes.GetNamedItem("pos").Value); - } - else - { - vd.pos = new Vector3(0f, 0f, 0f); - } + name = node.Attributes.GetNamedItem("name").Value.ToLower(), + scale = + node.Attributes.GetNamedItem("scale") != null + ? XmlParseVector(node.Attributes.GetNamedItem("scale").Value) + : new Vector3(0, 0, 0), + pos = + node.Attributes.GetNamedItem("pos") != null + ? XmlParseVector(node.Attributes.GetNamedItem("pos").Value) + : new Vector3(0f, 0f, 0f) + }; VolumeDeforms.Add(vd.name, vd); } @@ -2243,9 +2145,8 @@ void ParseDrivers(XmlNodeList drivennodes) { if (node.Name == "driven") { - driven d = new driven(); + driven d = new driven {id = Int32.Parse(node.Attributes.GetNamedItem("id").Value)}; - d.id = Int32.Parse(node.Attributes.GetNamedItem("id").Value); XmlNode param = node.Attributes.GetNamedItem("max1"); if (param != null) { @@ -2260,7 +2161,7 @@ void ParseDrivers(XmlNodeList drivennodes) d.hasMinMax = false; } - childparams.Add(d); + ChildParams.Add(d); } } @@ -2268,7 +2169,7 @@ void ParseDrivers(XmlNodeList drivennodes) public static Vector3 XmlParseVector(string data) { - string[] posparts = data.Split(' '); + string[] posparts = data.Split(new char[0], StringSplitOptions.RemoveEmptyEntries); return new Vector3(float.Parse(posparts[0], Utils.EnUsCulture), float.Parse(posparts[1], Utils.EnUsCulture), float.Parse(posparts[2], Utils.EnUsCulture)); } @@ -2314,7 +2215,7 @@ public RenderAvatar() public override Primitive BasePrim { - get { return avatar; } + get => avatar; set { if (value is Avatar) diff --git a/Radegast/GUI/Rendering/RenderPrimitive.cs b/Radegast/GUI/Rendering/RenderPrimitive.cs index a8ab82fda..153826b4d 100644 --- a/Radegast/GUI/Rendering/RenderPrimitive.cs +++ b/Radegast/GUI/Rendering/RenderPrimitive.cs @@ -1,33 +1,22 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior CreateReflectionTexture permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ using System; using System.Collections.Generic; @@ -71,7 +60,7 @@ public void Dispose() /// Checks if VBOs are created, if they are, bind them, if not create new /// /// Which face's mesh is uploaded in this VBO - /// True, if face data was succesfully uploaded to the graphics card memory + /// True, if face data was successfully uploaded to the graphics card memory public bool CheckVBO(Face face) { if (VertexVBO == -1) @@ -123,7 +112,7 @@ public class TextureAnimationInfo float TotalTime = 0f; /// - /// Perform texture manupulation to implement texture animations + /// Perform texture manipulation to implement texture animations /// /// Time passed since the last run (in seconds) public void Step(float lastFrameTime) @@ -326,7 +315,7 @@ public void ExperimentalStep(float time) } /// - /// Class that handle rendering of objects: simple primitives, scupties, and meshes + /// Class that handle rendering of objects: simple primitives, sculpties, and meshes /// public class RenderPrimitive : SceneObject { @@ -367,9 +356,8 @@ public override void Dispose() { foreach (Face f in Faces) { - if (f.UserData != null && f.UserData is FaceData) + if (f.UserData is FaceData data) { - FaceData data = (FaceData)f.UserData; data.Dispose(); data = null; } @@ -384,19 +372,18 @@ public override void Dispose() /// public override Primitive BasePrim { - get { return Prim; } + get => Prim; set { Prim = value; - int TEHash = Prim.Textures == null ? 0 : Prim.Textures.GetHashCode(); - int sculptHash, shapeHash; + int TEHash = Prim.Textures?.GetHashCode() ?? 0; if (Meshed) { if (Prim.Type == PrimType.Sculpt || Prim.Type == PrimType.Mesh) { - sculptHash = Prim.Sculpt.GetHashCode(); + var sculptHash = Prim.Sculpt.GetHashCode(); if (Prim.Sculpt.GetHashCode() != prevSculptHash || TEHash != prevTEHash) { Meshed = false; @@ -405,7 +392,7 @@ public override Primitive BasePrim } else { - shapeHash = Prim.PrimData.GetHashCode(); + var shapeHash = Prim.PrimData.GetHashCode(); if (shapeHash != prevShapeHash) { Meshed = false; @@ -444,7 +431,7 @@ public override void Render(RenderPass pass, int pickingID, SceneWindow scene, f // Individual prim matrix GL.PushMatrix(); - // Prim roation and position and scale + // Prim rotation and position and scale GL.MultMatrix(Math3D.CreateSRTMatrix(Prim.Scale, RenderRotation, RenderPosition)); // Do we have animated texture on this face @@ -561,7 +548,7 @@ public override void Render(RenderPass pass, int pickingID, SceneWindow scene, f { scene.DownloadTexture(new TextureLoadItem() { - Prim = this.Prim, + Prim = Prim, TeFace = teFace, Data = data }, false); @@ -581,10 +568,7 @@ public override void Render(RenderPass pass, int pickingID, SceneWindow scene, f data.AnimInfo.Step(time); animatedTexture = true; } - else if (data.AnimInfo != null) // Face texture not animated. Do we have previous anim setting? - { - data.AnimInfo = null; - } + data.AnimInfo = null; GL.Enable(EnableCap.Texture2D); GL.BindTexture(TextureTarget.Texture2D, data.TextureInfo.TexturePointer); @@ -658,7 +642,7 @@ public override string ToString() { uint id = Prim == null ? 0 : Prim.LocalID; float distance = (float)Math.Sqrt(DistanceSquared); - return string.Format("LocalID: {0}, distance {1:0.00}", id, distance); + return $"LocalID: {id}, distance {distance:0.00}"; } } } diff --git a/Radegast/GUI/Rendering/RenderSettings.cs b/Radegast/GUI/Rendering/RenderSettings.cs index d99019700..9e7726ed7 100644 --- a/Radegast/GUI/Rendering/RenderSettings.cs +++ b/Radegast/GUI/Rendering/RenderSettings.cs @@ -1,36 +1,23 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ -using System; -using OpenMetaverse; using OpenMetaverse.Rendering; namespace Radegast.Rendering diff --git a/Radegast/GUI/Rendering/RenderTerrain.cs b/Radegast/GUI/Rendering/RenderTerrain.cs index 3cf4e4b60..dc2dfa5fc 100644 --- a/Radegast/GUI/Rendering/RenderTerrain.cs +++ b/Radegast/GUI/Rendering/RenderTerrain.cs @@ -1,38 +1,27 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior CreateReflectionTexture permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ using System; -using System.Collections.Generic; using OpenTK.Graphics.OpenGL; using System.Drawing; +using System.Threading; using OpenMetaverse; using OpenMetaverse.Rendering; @@ -41,7 +30,7 @@ namespace Radegast.Rendering public class RenderTerrain : SceneObject { RadegastInstance Instance; - GridClient Client { get { return Instance.Client; } } + GridClient Client => Instance.Client; public bool Modified = true; float[,] heightTable = new float[256, 256]; @@ -58,11 +47,11 @@ public class RenderTerrain : SceneObject bool terrainTextureNeedsUpdate = false; float terrainTimeSinceUpdate = RenderSettings.MinimumTimeBetweenTerrainUpdated + 1f; // Update terrain om first run MeshmerizerR renderer; - Simulator sim { get { return Instance.Client.Network.CurrentSim; } } + Simulator sim => Instance.Client.Network.CurrentSim; public RenderTerrain(RadegastInstance instance) { - this.Instance = instance; + Instance = instance; renderer = new MeshmerizerR(); } @@ -108,7 +97,7 @@ private void UpdateTerrain() { if (sim == null || sim.Terrain == null) return; - WorkPool.QueueUserWorkItem(sync => + ThreadPool.QueueUserWorkItem(sync => { int step = 1; @@ -162,13 +151,13 @@ void UpdateTerrainTexture() if (!fetchingTerrainTexture) { fetchingTerrainTexture = true; - WorkPool.QueueUserWorkItem(sync => + ThreadPool.QueueUserWorkItem(sync => { - Simulator sim = Client.Network.CurrentSim; + Simulator currentSim = Client.Network.CurrentSim; terrainImage = TerrainSplat.Splat(Instance, heightTable, - new UUID[] { sim.TerrainDetail0, sim.TerrainDetail1, sim.TerrainDetail2, sim.TerrainDetail3 }, - new float[] { sim.TerrainStartHeight00, sim.TerrainStartHeight01, sim.TerrainStartHeight10, sim.TerrainStartHeight11 }, - new float[] { sim.TerrainHeightRange00, sim.TerrainHeightRange01, sim.TerrainHeightRange10, sim.TerrainHeightRange11 }); + new UUID[] { currentSim.TerrainDetail0, currentSim.TerrainDetail1, currentSim.TerrainDetail2, currentSim.TerrainDetail3 }, + new float[] { currentSim.TerrainStartHeight00, currentSim.TerrainStartHeight01, currentSim.TerrainStartHeight10, currentSim.TerrainStartHeight11 }, + new float[] { currentSim.TerrainHeightRange00, currentSim.TerrainHeightRange01, currentSim.TerrainHeightRange10, currentSim.TerrainHeightRange11 }); fetchingTerrainTexture = false; terrainTextureNeedsUpdate = false; diff --git a/Radegast/GUI/Rendering/Rendering.cs b/Radegast/GUI/Rendering/Rendering.cs index c474514cb..d22e01887 100644 --- a/Radegast/GUI/Rendering/Rendering.cs +++ b/Radegast/GUI/Rendering/Rendering.cs @@ -1,6 +1,7 @@ // // Radegast Metaverse Client // Copyright (c) 2009-2014, Radegast Development Team +// Copyright (c) 2019-2022, Sjofn LLC // All rights reserved. // // Redistribution and use in source and binary forms, with or without @@ -31,27 +32,25 @@ #region Usings using System; +using System.Collections.Concurrent; using System.Collections.Generic; using System.Drawing; -using System.Drawing.Imaging; +using System.Globalization; using System.IO; +using System.Linq; using System.Windows.Forms; -using System.Text; -#if (COGBOT_LIBOMV || USE_STHREADS) -using ThreadPoolUtil; -using Thread = ThreadPoolUtil.Thread; -using ThreadPool = ThreadPoolUtil.ThreadPool; -using Monitor = ThreadPoolUtil.Monitor; -#endif using System.Threading; -using System.Linq; +using CoreJ2K; using OpenTK.Graphics.OpenGL; using OpenMetaverse; using OpenMetaverse.Rendering; using OpenMetaverse.Assets; using OpenMetaverse.Imaging; -using OpenMetaverse.StructuredData; using OpenMetaverse.Packets; +using SkiaSharp; +using SkiaSharp.Views.Desktop; +using MemoryStream = System.IO.MemoryStream; + #endregion Usings namespace Radegast.Rendering @@ -85,7 +84,7 @@ public partial class SceneWindow : RadegastTabControl /// public float DrawDistance { - get { return drawDistance; } + get => drawDistance; set { drawDistance = value; @@ -129,17 +128,20 @@ public float DrawDistance OpenTK.Graphics.GraphicsMode GLMode = null; AutoResetEvent TextureThreadContextReady = new AutoResetEvent(false); + private CancellationTokenSource cancellationTokenSource = null; + delegate void GenericTask(); - BlockingQueue PendingTasks = new BlockingQueue(); + readonly ConcurrentQueue PendingTasks = new ConcurrentQueue(); + private readonly SemaphoreSlim PendingTasksAvailable = new SemaphoreSlim(0); Thread genericTaskThread; - BlockingQueue PendingTextures = new BlockingQueue(); + readonly ConcurrentQueue PendingTextures = new ConcurrentQueue(); - Dictionary AssetFetchFailCount = new Dictionary(); + readonly Dictionary AssetFetchFailCount = new Dictionary(); Font HoverTextFont = new Font(FontFamily.GenericSansSerif, 9f, FontStyle.Regular); Font AvatarTagFont = new Font(FontFamily.GenericSansSerif, 10f, FontStyle.Bold); - Dictionary sculptCache = new Dictionary(); + Dictionary sculptCache = new Dictionary(); OpenTK.Matrix4 ModelMatrix; OpenTK.Matrix4 ProjectionMatrix; System.Diagnostics.Stopwatch renderTimer; @@ -170,14 +172,18 @@ public SceneWindow(RadegastInstance instance) { InitializeComponent(); - this.Instance = instance; - this.Client = instance.Client; + Instance = instance; + Client = instance.Client; UseMultiSampling = Instance.GlobalSettings["use_multi_sampling"]; - genericTaskThread = new Thread(new ThreadStart(GenericTaskRunner)); - genericTaskThread.IsBackground = true; - genericTaskThread.Name = "Generic task queue"; + cancellationTokenSource = new CancellationTokenSource(); + + genericTaskThread = new Thread(GenericTaskRunner) + { + IsBackground = true, + Name = "Generic task queue" + }; genericTaskThread.Start(); renderer = new MeshmerizerR(); @@ -199,36 +205,32 @@ public SceneWindow(RadegastInstance instance) DrawDistance = Instance.GlobalSettings["draw_distance"]; pnlDebug.Visible = Instance.GlobalSettings["scene_viewer_debug_panel"]; - Client.Objects.TerseObjectUpdate += new EventHandler(Objects_TerseObjectUpdate); - Client.Objects.ObjectUpdate += new EventHandler(Objects_ObjectUpdate); - Client.Objects.AvatarUpdate += new EventHandler(Objects_AvatarUpdate); + Client.Objects.TerseObjectUpdate += Objects_TerseObjectUpdate; + Client.Objects.ObjectUpdate += Objects_ObjectUpdate; + Client.Objects.AvatarUpdate += Objects_AvatarUpdate; Client.Network.RegisterCallback(PacketType.KillObject, KillObjectHandler); - Client.Network.SimChanged += new EventHandler(Network_SimChanged); - Client.Terrain.LandPatchReceived += new EventHandler(Terrain_LandPatchReceived); - Client.Avatars.AvatarAnimation += new EventHandler(AvatarAnimationChanged); - Client.Avatars.AvatarAppearance += new EventHandler(Avatars_AvatarAppearance); - Client.Appearance.AppearanceSet += new EventHandler(Appearance_AppearanceSet); - Instance.Netcom.ClientDisconnected += new EventHandler(Netcom_ClientDisconnected); - Application.Idle += new EventHandler(Application_Idle); + Client.Network.SimChanged += Network_SimChanged; + Client.Terrain.LandPatchReceived += Terrain_LandPatchReceived; + Client.Avatars.AvatarAnimation += AvatarAnimationChanged; + Client.Avatars.AvatarAppearance += Avatars_AvatarAppearance; + Client.Appearance.AppearanceSet += Appearance_AppearanceSet; + Instance.Netcom.ClientDisconnected += Netcom_ClientDisconnected; + Application.Idle += Application_Idle; - Radegast.GUI.GuiHelpers.ApplyGuiFixes(this); + GUI.GuiHelpers.ApplyGuiFixes(this); } void DisposeInternal() { RenderingEnabled = false; - Application.Idle -= new EventHandler(Application_Idle); + Application.Idle -= Application_Idle; Instance.State.CameraTracksOwnAvatar = true; Instance.State.SetDefaultCamera(); - - if (!PendingTextures.Closed) - { - TextureThreadContextReady.Reset(); - TextureThreadRunning = false; - PendingTextures.Close(); - TextureThreadContextReady.WaitOne(5000, false); - } + + TextureThreadContextReady.Reset(); + TextureThreadRunning = false; + TextureThreadContextReady.WaitOne(5000, false); if (chatOverlay != null) { @@ -242,19 +244,21 @@ void DisposeInternal() textRendering = null; } - Client.Objects.TerseObjectUpdate -= new EventHandler(Objects_TerseObjectUpdate); - Client.Objects.ObjectUpdate -= new EventHandler(Objects_ObjectUpdate); - Client.Objects.AvatarUpdate -= new EventHandler(Objects_AvatarUpdate); + Client.Objects.TerseObjectUpdate -= Objects_TerseObjectUpdate; + Client.Objects.ObjectUpdate -= Objects_ObjectUpdate; + Client.Objects.AvatarUpdate -= Objects_AvatarUpdate; Client.Network.UnregisterCallback(PacketType.KillObject, KillObjectHandler); - Client.Network.SimChanged -= new EventHandler(Network_SimChanged); - Client.Terrain.LandPatchReceived -= new EventHandler(Terrain_LandPatchReceived); - Client.Avatars.AvatarAnimation -= new EventHandler(AvatarAnimationChanged); - Client.Avatars.AvatarAppearance -= new EventHandler(Avatars_AvatarAppearance); - Client.Appearance.AppearanceSet -= new EventHandler(Appearance_AppearanceSet); + Client.Network.SimChanged -= Network_SimChanged; + Client.Terrain.LandPatchReceived -= Terrain_LandPatchReceived; + Client.Avatars.AvatarAnimation -= AvatarAnimationChanged; + Client.Avatars.AvatarAppearance -= Avatars_AvatarAppearance; + Client.Appearance.AppearanceSet -= Appearance_AppearanceSet; - if (!PendingTasks.Closed) + if (cancellationTokenSource != null) { - PendingTasks.Close(); + cancellationTokenSource.Cancel(); + cancellationTokenSource.Dispose(); + cancellationTokenSource = null; } if (genericTaskThread != null) @@ -265,7 +269,7 @@ void DisposeInternal() if (instance.Netcom != null) { - Instance.Netcom.ClientDisconnected -= new EventHandler(Netcom_ClientDisconnected); + Instance.Netcom.ClientDisconnected -= Netcom_ClientDisconnected; } lock (sculptCache) @@ -333,16 +337,16 @@ void Application_Idle(object sender, EventArgs e) #region Tab Events public void RegisterTabEvents() { - this.RadegastTab.TabAttached += new EventHandler(RadegastTab_TabAttached); - this.RadegastTab.TabDetached += new EventHandler(RadegastTab_TabDetached); - this.RadegastTab.TabClosed += new EventHandler(RadegastTab_TabClosed); + RadegastTab.TabAttached += RadegastTab_TabAttached; + RadegastTab.TabDetached += RadegastTab_TabDetached; + RadegastTab.TabClosed += RadegastTab_TabClosed; } public void UnregisterTabEvents() { - this.RadegastTab.TabAttached -= new EventHandler(RadegastTab_TabAttached); - this.RadegastTab.TabDetached -= new EventHandler(RadegastTab_TabDetached); - this.RadegastTab.TabClosed -= new EventHandler(RadegastTab_TabClosed); + RadegastTab.TabAttached -= RadegastTab_TabAttached; + RadegastTab.TabDetached -= RadegastTab_TabDetached; + RadegastTab.TabClosed -= RadegastTab_TabClosed; } void RadegastTab_TabDetached(object sender, EventArgs e) @@ -357,7 +361,7 @@ void RadegastTab_TabAttached(object sender, EventArgs e) void RadegastTab_TabClosed(object sender, EventArgs e) { - if (this.RadegastTab != null) + if (RadegastTab != null) { UnregisterTabEvents(); } @@ -379,8 +383,7 @@ void Netcom_ClientDisconnected(object sender, DisconnectedEventArgs e) if (InvokeRequired) { if (!IsHandleCreated) return; - BeginInvoke(new MethodInvoker(() => Dispose())); - return; + BeginInvoke(new MethodInvoker(Dispose)); } } @@ -422,9 +425,9 @@ protected void KillObjectHandler(object sender, PacketReceivedEventArgs e) lock (Prims) { - for (int i = 0; i < kill.ObjectData.Length; i++) + foreach (var obj in kill.ObjectData) { - uint id = kill.ObjectData[i].ID; + uint id = obj.ID; if (Prims.ContainsKey(id)) { Prims[id].Dispose(); @@ -435,9 +438,9 @@ protected void KillObjectHandler(object sender, PacketReceivedEventArgs e) lock (Avatars) { - for (int i = 0; i < kill.ObjectData.Length; i++) + foreach (var ob in kill.ObjectData) { - uint id = kill.ObjectData[i].ID; + uint id = ob.ID; if (Avatars.ContainsKey(id)) { Avatars[id].Dispose(); @@ -499,12 +502,12 @@ void AvatarAnimationChanged(object sender, AvatarAnimationEventArgs e) } } - void animRecievedCallback(AssetDownload transfer, Asset asset) + void AnimRecievedCallback(AssetDownload transfer, Asset asset) { if (InvokeRequired) { - BeginInvoke(new MethodInvoker(() => animRecievedCallback(transfer, asset))); + BeginInvoke(new MethodInvoker(() => AnimRecievedCallback(transfer, asset))); return; } @@ -555,10 +558,16 @@ void Appearance_AppearanceSet(object sender, AppearanceSetEventArgs e) #region glControl setup and disposal public void SetupGLControl() { + // Crash fix for users with SDL2.dll in their path. OpenTK will attempt to use + // SDL2 if it's available, but SDL2 is unsupported and will crash users. + OpenTK.Toolkit.Init(new OpenTK.ToolkitOptions + { + Backend = OpenTK.PlatformBackend.PreferNative + }); + RenderingEnabled = false; - if (glControl != null) - glControl.Dispose(); + glControl?.Dispose(); glControl = null; GLMode = null; @@ -611,7 +620,7 @@ public void SetupGLControl() return; } - Logger.Log("Initializing OpenGL mode: " + GLMode.ToString(), Helpers.LogLevel.Info); + Logger.Log("Initializing OpenGL mode: " + GLMode, Helpers.LogLevel.Info); glControl.Paint += glControl_Paint; glControl.Resize += glControl_Resize; @@ -619,8 +628,8 @@ public void SetupGLControl() glControl.MouseUp += glControl_MouseUp; glControl.MouseMove += glControl_MouseMove; glControl.MouseWheel += glControl_MouseWheel; - glControl.Load += new EventHandler(glControl_Load); - glControl.Disposed += new EventHandler(glControl_Disposed); + glControl.Load += glControl_Load; + glControl.Disposed += glControl_Disposed; glControl.Dock = DockStyle.Fill; glControl.VSync = false; Controls.Add(glControl); @@ -635,7 +644,7 @@ void glControl_UnhookEvents() glControl.MouseUp -= glControl_MouseUp; glControl.MouseMove -= glControl_MouseMove; glControl.MouseWheel -= glControl_MouseWheel; - glControl.Load -= new EventHandler(glControl_Load); + glControl.Load -= glControl_Load; glControl.Disposed -= glControl_Disposed; } @@ -683,7 +692,7 @@ void glControl_Load(object sender, EventArgs e) GL.MatrixMode(MatrixMode.Projection); GL.AlphaFunc(AlphaFunction.Greater, 0.5f); - GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); + GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha); // Compatibility checks OpenTK.Graphics.IGraphicsContextInternal context = glControl.Context as OpenTK.Graphics.IGraphicsContextInternal; @@ -734,7 +743,7 @@ void glControl_Load(object sender, EventArgs e) // glControl.Context.MakeCurrent(null); TextureThreadContextReady.Reset(); - var textureThread = new Thread(() => TextureThread()) + var textureThread = new Thread(TextureThread) { IsBackground = true, Name = "TextureDecodingThread" @@ -791,7 +800,7 @@ private void MainRenderLoop() else { // If we're docked but not active tab, throttle - if (!this.RadegastTab.Selected && !this.RadegastTab.Detached) + if (!RadegastTab.Selected && !RadegastTab.Detached) { throttle = true; } @@ -837,7 +846,7 @@ private void glControl_Resize(object sender, EventArgs e) #region Mouse handling bool dragging = false; - int dragX, dragY, downX, downY; + int dragX, dragY; private void glControl_MouseWheel(object sender, MouseEventArgs e) { @@ -855,17 +864,17 @@ private void glControl_MouseDown(object sender, MouseEventArgs e) if (e.Button == MouseButtons.Left) { dragging = true; - downX = dragX = e.X; - downY = dragY = e.Y; + int downX = dragX = e.X; + int downY = dragY = e.Y; if (ModifierKeys == Keys.None) { object picked; if (TryPick(e.X, e.Y, out picked, out LeftclickedFaceID)) { - if (picked is RenderPrimitive) + if (picked is RenderPrimitive primitive) { - TryTouchObject((RenderPrimitive)picked); + TryTouchObject(primitive); } } } @@ -953,11 +962,15 @@ private void glControl_MouseMove(object sender, MouseEventArgs e) int LeftclickedFaceID; if (TryPick(e.X, e.Y, out picked, out LeftclickedFaceID)) { - if (picked is RenderPrimitive) - TryTouchObject((RenderPrimitive)picked); + if (picked is RenderPrimitive primitive) + { + TryTouchObject(primitive); + } } else + { TryEndTouchObject(); + } } // Pan @@ -1009,7 +1022,7 @@ public void GLHUDBegin() GL.MatrixMode(MatrixMode.Projection); GL.PushMatrix(); GL.LoadIdentity(); - GL.Ortho(0, glControl.Width, 0, glControl.Height, -5, 1); + GL.Ortho(0, glControl != null ? glControl.Width : 0, 0, glControl != null ? glControl.Height : 0, -5, 1); GL.MatrixMode(MatrixMode.Modelview); GL.LoadIdentity(); } @@ -1029,23 +1042,18 @@ public void GLHUDEnd() void TextureThread() { - //OpenTK.INativeWindow window = new OpenTK.NativeWindow(); - //OpenTK.Graphics.IGraphicsContext context = new OpenTK.Graphics.GraphicsContext(GLMode, window.WindowInfo); - //context.MakeCurrent(window.WindowInfo); TextureThreadContextReady.Set(); - PendingTextures.Open(); + Logger.DebugLog("Started Texture Thread"); - while (/*window.Exists &&*/ TextureThreadRunning) + while (TextureThreadRunning) { - //window.ProcessEvents(); - TextureLoadItem item = null; - if (!PendingTextures.Dequeue(Timeout.Infinite, ref item)) continue; + if (!PendingTextures.TryDequeue(out item)) { continue; } // Already have this one loaded - if (item.Data.TextureInfo.TexturePointer != 0) continue; + if (item.Data.TextureInfo.TexturePointer != 0) { continue; } byte[] imageBytes = null; if (item.TGAData != null) @@ -1058,9 +1066,10 @@ void TextureThread() { item.TextureData = Client.Assets.Cache.GetCachedAssetBytes(item.Data.TextureInfo.TextureID); } - ManagedImage mi; - if (!OpenJPEG.DecodeToImage(item.TextureData, out mi)) continue; + if (item.TextureData == null) { continue; } + var mi = new ManagedImage(J2kImage.FromBytes(item.TextureData)); + bool hasAlpha = false; bool fullAlpha = false; bool isMask = false; @@ -1070,17 +1079,17 @@ void TextureThread() isMask = true; // Do we really have alpha, is it all full alpha, or is it a mask - for (int i = 0; i < mi.Alpha.Length; i++) + foreach (byte b in mi.Alpha) { - if (mi.Alpha[i] < 255) + if (b < 255) { hasAlpha = true; } - if (mi.Alpha[i] != 0) + if (b != 0) { fullAlpha = false; } - if (mi.Alpha[i] != 0 && mi.Alpha[i] != 255) + if (b != 0 && b != 255) { isMask = false; } @@ -1096,7 +1105,7 @@ void TextureThread() item.Data.TextureInfo.FullAlpha = fullAlpha; item.Data.TextureInfo.IsMask = isMask; - imageBytes = mi.ExportTGA(); + imageBytes = Targa.Encode(mi); if (CacheDecodedTextures) { RHelp.SaveCachedImage(imageBytes, item.TeFace.TextureID, hasAlpha, fullAlpha, isMask); @@ -1105,14 +1114,7 @@ void TextureThread() if (imageBytes != null) { - Image img; - - using (MemoryStream byteData = new MemoryStream(imageBytes)) - { - img = OpenMetaverse.Imaging.LoadTGAClass.LoadTGA(byteData); - } - - Bitmap bitmap = (Bitmap)img; + var bitmap = Targa.Decode(new MemoryStream(imageBytes)).ToBitmap(); bitmap.RotateFlip(RotateFlipType.RotateNoneFlipY); @@ -1138,15 +1140,28 @@ void TextureThread() void GenericTaskRunner() { - PendingTasks.Open(); Logger.DebugLog("Started generic task thread"); - while (true) + try + { + var token = cancellationTokenSource?.Token ?? throw new NullReferenceException(); + while (true) + { + PendingTasksAvailable.Wait(token); + GenericTask task = null; + if (!PendingTasks.TryDequeue(out task)) break; + task.Invoke(); + } + } + catch (ObjectDisposedException e) + { + Logger.Log("GenericTaskRunner was cancelled", Helpers.LogLevel.Debug, e); + } + catch (OperationCanceledException e) { - GenericTask task = null; - if (!PendingTasks.Dequeue(Timeout.Infinite, ref task)) break; - task.Invoke(); + Logger.Log("GenericTaskRunner was cancelled", Helpers.LogLevel.Debug, e); } + Logger.DebugLog("Generic task thread exited"); } @@ -1154,17 +1169,17 @@ void LoadCurrentPrims() { if (!Client.Network.Connected) return; - WorkPool.QueueUserWorkItem(sync => + ThreadPool.QueueUserWorkItem(sync => { if (RenderSettings.PrimitiveRenderingEnabled) { - List mainPrims = Client.Network.CurrentSim.ObjectsPrimitives.FindAll((Primitive root) => root.ParentID == 0); + List mainPrims = Client.Network.CurrentSim.ObjectsPrimitives.FindAll(root => root.ParentID == 0); foreach (Primitive mainPrim in mainPrims) { UpdatePrimBlocking(mainPrim); Client.Network.CurrentSim.ObjectsPrimitives - .FindAll((Primitive child) => child.ParentID == mainPrim.LocalID) - .ForEach((Primitive subPrim) => UpdatePrimBlocking(subPrim)); + .FindAll(child => child.ParentID == mainPrim.LocalID) + .ForEach(UpdatePrimBlocking); } } @@ -1175,16 +1190,13 @@ void LoadCurrentPrims() { UpdatePrimBlocking(avatar); Client.Network.CurrentSim.ObjectsPrimitives - .FindAll((Primitive child) => child.ParentID == avatar.LocalID) - .ForEach((Primitive attachedPrim) => + .FindAll(child => child.ParentID == avatar.LocalID) + .ForEach(attachedPrim => { UpdatePrimBlocking(attachedPrim); Client.Network.CurrentSim.ObjectsPrimitives - .FindAll((Primitive child) => child.ParentID == attachedPrim.LocalID) - .ForEach((Primitive attachedPrimChild) => - { - UpdatePrimBlocking(attachedPrimChild); - }); + .FindAll(child => child.ParentID == attachedPrim.LocalID) + .ForEach(UpdatePrimBlocking); }); } } @@ -1193,7 +1205,7 @@ void LoadCurrentPrims() private void ControlLoaded(object sender, EventArgs e) { - WorkPool.QueueUserWorkItem(sync => + ThreadPool.QueueUserWorkItem(sync => { InitAvatarData(); AvatarDataInitialzied(); @@ -1209,7 +1221,7 @@ private void AvatarDataInitialzied() // Ensure that this is done on the main thread if (InvokeRequired) { - Invoke(new MethodInvoker(() => AvatarDataInitialzied())); + Invoke(new MethodInvoker(AvatarDataInitialzied)); return; } @@ -1253,8 +1265,7 @@ void InitCamera() Vector3 PrimPos(Primitive prim) { Vector3 pos; - Quaternion rot; - PrimPosAndRot(GetSceneObject(prim.LocalID), out pos, out rot); + PrimPosAndRot(GetSceneObject(prim.LocalID), out pos, out _); return pos; } @@ -1289,15 +1300,11 @@ SceneObject GetSceneObject(uint localID) { return parent; } - else if (Avatars.TryGetValue(localID, out avi)) - { - return avi; - } - return null; + return Avatars.TryGetValue(localID, out avi) ? avi : null; } /// - /// Calculates finar rendering position for objects on the scene + /// Calculates finer rendering position for objects on the scene /// /// SceneObject whose position is calculated /// Rendering position @@ -1317,7 +1324,6 @@ void PrimPosAndRot(SceneObject obj, out Vector3 pos, out Quaternion rot) // We are the root prim, return our interpolated position pos = obj.InterpolatedPosition; rot = obj.InterpolatedRotation; - return; } else { @@ -1345,15 +1351,13 @@ void PrimPosAndRot(SceneObject obj, out Vector3 pos, out Quaternion rot) pos = parentPos + obj.InterpolatedPosition * parentRot; rot = parentRot * obj.InterpolatedRotation; } - else if (p is RenderAvatar) + else if (p is RenderAvatar parentav) // Calculating position and rotation of the root prim of an attachment here + // (our parent is an avatar here) { - // Calculating position and rotation of the root prim of an attachment here - // (our parent is an avatar here) - RenderAvatar parentav = (RenderAvatar)p; // Check for invalid attachment point int attachment_index = (int)obj.BasePrim.PrimData.AttachmentPoint; - if (attachment_index >= GLAvatar.attachment_points.Count()) return; + if (attachment_index >= GLAvatar.attachment_points.Count) return; attachment_point apoint = GLAvatar.attachment_points[attachment_index]; skeleton skel = parentav.glavatar.skel; if (!skel.mBones.ContainsKey(apoint.joint)) return; @@ -1387,7 +1391,6 @@ void PrimPosAndRot(SceneObject obj, out Vector3 pos, out Quaternion rot) rot *= obj.BasePrim.Rotation; } - return; } } @@ -1395,16 +1398,17 @@ void PrimPosAndRot(SceneObject obj, out Vector3 pos, out Quaternion rot) /// Finds the closest distance between the given pos and an object /// (Assumes that the object is a box slightly) /// - /// + /// /// /// private float FindClosestDistanceSquared(Vector3 calcPos, SceneObject p) { if (p.BoundingVolume == null || !RenderSettings.HeavierDistanceChecking - || p.BoundingVolume.ScaledR < 10f - ) + || p.BoundingVolume.ScaledR < 10f) + { return Vector3.DistanceSquared(calcPos, p.RenderPosition); + } Vector3 posToCheckFrom = Vector3.Zero; //Get the bounding boxes for this prim @@ -1435,10 +1439,8 @@ private void RenderStats() // This is a FIR filter known as a MMA or Modified Mean Average, using a 20 point sampling width advTimerTick = ((19 * advTimerTick) + lastFrameTime) / 20; // Stats in window title for now - Text = String.Format("Scene Viewer: FPS {0:000.00} Texture decode queue: {1}, Sculpt queue: {2}", - 1d / advTimerTick, - PendingTextures.Count, - PendingTasks.Count); + Text = + $"Scene Viewer: FPS {1d/advTimerTick:000.00} Texture decode queue: {PendingTextures.Count}, Sculpt queue: {PendingTasks.Count}"; #if TURNS_OUT_PRINTER_IS_EXPENISVE int posX = glControl.Width - 100; @@ -1598,7 +1600,7 @@ private void AddAvatarToScene(Avatar av) if (Avatars.ContainsKey(av.LocalID)) { // flag we got an update?? - updateAVtes(Avatars[av.LocalID]); + UpdateAVtes(Avatars[av.LocalID]); Avatars[av.LocalID].glavatar.morph(av); UpdateAvatarAnimations(Avatars[av.LocalID]); } @@ -1607,10 +1609,8 @@ private void AddAvatarToScene(Avatar av) GLAvatar ga = new GLAvatar(); //ga.morph(av); - RenderAvatar ra = new Rendering.RenderAvatar(); - ra.avatar = av; - ra.glavatar = ga; - updateAVtes(ra); + RenderAvatar ra = new RenderAvatar {avatar = av, glavatar = ga}; + UpdateAVtes(ra); Avatars.Add(av.LocalID, ra); ra.glavatar.morph(av); @@ -1655,13 +1655,20 @@ private void UpdateAvatarAnimations(RenderAvatar av) BinBVHAnimationReader bvh; if (skeleton.mAnimationCache.TryGetValue(anim.AnimationID, out bvh)) { - skeleton.addanimation(null, tid, bvh, anim.AnimationID); + try + { + skeleton.addanimation(null, tid, bvh, anim.AnimationID); + } + catch (Exception ex) + { + Logger.Log($"Failure in skel.addanimation: {ex.Message}", Helpers.LogLevel.Error); + } continue; } - Logger.Log("Requesting new animation asset " + anim.AnimationID.ToString(), Helpers.LogLevel.Info); + Logger.Log($"Requesting new animation asset {anim.AnimationID}", Helpers.LogLevel.Debug); - Client.Assets.RequestAsset(anim.AnimationID, AssetType.Animation, false, SourceType.Asset, tid, animRecievedCallback); + Client.Assets.RequestAsset(anim.AnimationID, AssetType.Animation, false, SourceType.Asset, tid, AnimRecievedCallback); } av.glavatar.skel.flushanimationsfinal(); @@ -1669,7 +1676,7 @@ private void UpdateAvatarAnimations(RenderAvatar av) } - private void updateAVtes(RenderAvatar ra) + private void UpdateAVtes(RenderAvatar ra) { if (ra.avatar.Textures == null) return; @@ -1847,8 +1854,12 @@ private void RenderAvatars(RenderPass pass) // If we don't have a hair bake OR the hair bake is invisible don't render it - if (mesh.Name == "hairMesh" && (av.data[(int)AvatarTextureIndex.HairBaked] == null || av.data[(int)AvatarTextureIndex.HairBaked].TextureInfo.IsInvisible)) + if (mesh.Name == "hairMesh" && + (av.data[(int) AvatarTextureIndex.HairBaked] == null + || av.data[(int) AvatarTextureIndex.HairBaked].TextureInfo.IsInvisible)) + { continue; + } GL.Color3(1f, 1f, 1f); @@ -1856,11 +1867,11 @@ private void RenderAvatars(RenderPass pass) { GL.Disable(EnableCap.Texture2D); - for (int i = 0; i < av.data.Length; i++) + foreach (var d in av.data) { - if (av.data[i] != null) + if (d != null) { - av.data[i].PickingID = avatarNr; + d.PickingID = avatarNr; } } byte[] primNrBytes = Utils.Int16ToBytes((short)avatarNr); @@ -1976,11 +1987,11 @@ void CheckKeyboard(float time) if (Client.Self.Movement.TurnLeft) { - Client.Self.Movement.BodyRotation = Client.Self.Movement.BodyRotation * Quaternion.CreateFromAxisAngle(Vector3.UnitZ, time); + Client.Self.Movement.BodyRotation *= Quaternion.CreateFromAxisAngle(Vector3.UnitZ, time); } else if (client.Self.Movement.TurnRight) { - Client.Self.Movement.BodyRotation = Client.Self.Movement.BodyRotation * Quaternion.CreateFromAxisAngle(Vector3.UnitZ, -time); + Client.Self.Movement.BodyRotation *= Quaternion.CreateFromAxisAngle(Vector3.UnitZ, -time); } if (Instance.Keyboard.IsKeyDown(Keys.Escape)) @@ -2074,91 +2085,6 @@ float LODFactor(float distance, float radius) return radius * radius / distance; } - void RenderSphere(float cx, float cy, float cz, float r, int p) - { - GL.PushAttrib(AttribMask.AllAttribBits); - GL.Disable(EnableCap.Fog); - GL.Disable(EnableCap.Texture2D); - GL.Disable(EnableCap.Dither); - GL.Disable(EnableCap.Lighting); - GL.Disable(EnableCap.LineStipple); - GL.Disable(EnableCap.PolygonStipple); - GL.Disable(EnableCap.CullFace); - GL.Disable(EnableCap.Blend); - GL.Disable(EnableCap.AlphaTest); - GL.Disable(EnableCap.DepthTest); - - const float TWOPI = 6.28318530717958f; - const float PIDIV2 = 1.57079632679489f; - - float theta1 = 0.0f; - float theta2 = 0.0f; - float theta3 = 0.0f; - - float ex = 0.0f; - float ey = 0.0f; - float ez = 0.0f; - - float px = 0.0f; - float py = 0.0f; - float pz = 0.0f; - - // Disallow a negative number for radius. - if (r < 0) - r = -r; - - // Disallow a negative number for precision. - if (p < 0) - p = -p; - - // If the sphere is too small, just render a OpenGL point instead. - if (p < 4 || r <= 0) - { - GL.Begin(PrimitiveType.Points); - GL.Vertex3(cx, cy, cz); - GL.End(); - return; - } - - for (int i = 0; i < p / 2; ++i) - { - theta1 = i * TWOPI / p - PIDIV2; - theta2 = (i + 1) * TWOPI / p - PIDIV2; - - GL.Begin(PrimitiveType.TriangleStrip); - { - for (int j = 0; j <= p; ++j) - { - theta3 = j * TWOPI / p; - - ex = (float)(Math.Cos(theta2) * Math.Cos(theta3)); - ey = (float)Math.Sin(theta2); - ez = (float)(Math.Cos(theta2) * Math.Sin(theta3)); - px = cx + r * ex; - py = cy + r * ey; - pz = cz + r * ez; - - GL.Normal3(ex, ey, ez); - GL.TexCoord2(-(j / (float)p), 2 * (i + 1) / (float)p); - GL.Vertex3(px, py, pz); - - ex = (float)(Math.Cos(theta1) * Math.Cos(theta3)); - ey = (float)Math.Sin(theta1); - ez = (float)(Math.Cos(theta1) * Math.Sin(theta3)); - px = cx + r * ex; - py = cy + r * ey; - pz = cz + r * ez; - - GL.Normal3(ex, ey, ez); - GL.TexCoord2(-(j / (float)p), 2 * i / (float)p); - GL.Vertex3(px, py, pz); - } - } - GL.End(); - } - GL.PopAttrib(); - } - void SortCullInterpolate() { SortedObjects = new List(); @@ -2619,9 +2545,9 @@ public bool TryPick(int x, int y, out object picked, out int faceID, out Vector3 Render(true); byte[] color = new byte[4]; - GL.ReadPixels(x, glControl.Height - y, 1, 1, OpenTK.Graphics.OpenGL.PixelFormat.Rgba, PixelType.UnsignedByte, color); + GL.ReadPixels(x, glControl.Height - y, 1, 1, PixelFormat.Rgba, PixelType.UnsignedByte, color); float depth = 0f; - GL.ReadPixels(x, glControl.Height - y, 1, 1, OpenTK.Graphics.OpenGL.PixelFormat.DepthComponent, PixelType.Float, ref depth); + GL.ReadPixels(x, glControl.Height - y, 1, 1, PixelFormat.DepthComponent, PixelType.Float, ref depth); OpenTK.Vector3 worldPosTK = OpenTK.Vector3.Zero; Math3D.GluUnProject(x, glControl.Height - y, depth, ModelMatrix, ProjectionMatrix, Viewport, out worldPosTK); worldPos = RHelp.OMVVector3(worldPosTK); @@ -2648,14 +2574,9 @@ public bool TryPick(int x, int y, out object picked, out int faceID, out Vector3 { foreach (var avatar in VisibleAvatars) { - for (int i = 0; i < avatar.data.Length; i++) + if (avatar.data.Any(face => face != null && face.PickingID == primID)) { - var face = avatar.data[i]; - if (face != null && face.PickingID == primID) - { - picked = avatar; - break; - } + picked = avatar; } } } @@ -2756,22 +2677,22 @@ public void DownloadTexture(TextureLoadItem item, bool force) } else if (!item.Data.TextureInfo.FetchFailed) { - TextureDownloadCallback handler = (state, asset) => + void handler(TextureRequestState state, AssetTexture asset) + { + switch (state) { - switch (state) - { - case TextureRequestState.Finished: - item.TextureData = asset.AssetData; - PendingTextures.Enqueue(item); - break; - - case TextureRequestState.Aborted: - case TextureRequestState.NotFound: - case TextureRequestState.Timeout: - item.Data.TextureInfo.FetchFailed = true; - break; - } - }; + case TextureRequestState.Finished: + item.TextureData = asset.AssetData; + PendingTextures.Enqueue(item); + break; + + case TextureRequestState.Aborted: + case TextureRequestState.NotFound: + case TextureRequestState.Timeout: + item.Data.TextureInfo.FetchFailed = true; + break; + } + } if (item.ImageType == ImageType.ServerBaked && !string.IsNullOrEmpty(item.BakeName)) { // Server side bake @@ -2872,13 +2793,13 @@ private void MeshPrim(RenderPrimitive rprim) else { PendingTasks.Enqueue(GenerateSculptOrMeshPrim(rprim, prim)); - return; + PendingTasksAvailable.Release(); } } private GenericTask GenerateSculptOrMeshPrim(RenderPrimitive rprim, Primitive prim) { - return new GenericTask(() => + return () => { FacetedMesh mesh = null; @@ -2886,7 +2807,7 @@ private GenericTask GenerateSculptOrMeshPrim(RenderPrimitive rprim, Primitive pr { if (prim.Sculpt.Type != SculptType.Mesh) { // Regular sculptie - Image img = null; + SKBitmap img = null; lock (sculptCache) { @@ -2900,7 +2821,7 @@ private GenericTask GenerateSculptOrMeshPrim(RenderPrimitive rprim, Primitive pr { if (LoadTexture(prim.Sculpt.SculptTexture, ref img, true)) { - sculptCache[prim.Sculpt.SculptTexture] = (Bitmap)img; + sculptCache[prim.Sculpt.SculptTexture] = img; } else { @@ -2908,7 +2829,7 @@ private GenericTask GenerateSculptOrMeshPrim(RenderPrimitive rprim, Primitive pr } } - mesh = renderer.GenerateFacetedSculptMesh(prim, (Bitmap)img, RenderSettings.SculptRenderDetail); + mesh = renderer.GenerateFacetedSculptMesh(prim, img, RenderSettings.SculptRenderDetail); } else { // Mesh @@ -2943,46 +2864,53 @@ private GenericTask GenerateSculptOrMeshPrim(RenderPrimitive rprim, Primitive pr Prims.Remove(rprim.BasePrim.LocalID); } } - }); + }; } private void UpdatePrimBlocking(Primitive prim) { if (!RenderingEnabled) return; - if (RenderSettings.AvatarRenderingEnabled && prim.PrimData.PCode == PCode.Avatar) + switch (prim.PrimData.PCode) { - AddAvatarToScene(Client.Network.CurrentSim.ObjectsAvatars[prim.LocalID]); - return; - } + case PCode.Avatar: + AddAvatarToScene(Client.Network.CurrentSim.ObjectsAvatars[prim.LocalID]); + return; + case PCode.Prim: + if (!RenderSettings.PrimitiveRenderingEnabled) return; - // Skip foliage - if (prim.PrimData.PCode != PCode.Prim) return; - if (!RenderSettings.PrimitiveRenderingEnabled) return; + if (prim.Textures == null) return; - if (prim.Textures == null) return; + RenderPrimitive rPrim; + if (Prims.TryGetValue(prim.LocalID, out rPrim)) + { + rPrim.AttachedStateKnown = false; + } + else + { + rPrim = new RenderPrimitive + { + Meshed = false, + BoundingVolume = new BoundingVolume() + }; + rPrim.BoundingVolume.FromScale(prim.Scale); + } - RenderPrimitive rPrim = null; - if (Prims.TryGetValue(prim.LocalID, out rPrim)) - { - rPrim.AttachedStateKnown = false; - } - else - { - rPrim = new RenderPrimitive(); - rPrim.Meshed = false; - rPrim.BoundingVolume = new BoundingVolume(); - rPrim.BoundingVolume.FromScale(prim.Scale); + rPrim.BasePrim = prim; + lock (Prims) Prims[prim.LocalID] = rPrim; + break; + case PCode.ParticleSystem: + // todo + default: + // unimplemented foliage + break; } - - rPrim.BasePrim = prim; - lock (Prims) Prims[prim.LocalID] = rPrim; } - private bool LoadTexture(UUID textureID, ref Image texture, bool removeAlpha) + private bool LoadTexture(UUID textureID, ref SKBitmap texture, bool removeAlpha) { ManualResetEvent gotImage = new ManualResetEvent(false); - Image img = null; + SKBitmap img = null; try { @@ -2991,16 +2919,15 @@ private bool LoadTexture(UUID textureID, ref Image texture, bool removeAlpha) byte[] tgaData; if (RHelp.LoadCachedImage(textureID, out tgaData, out hasAlpha, out fullAlpha, out isMask)) { - img = LoadTGAClass.LoadTGA(new MemoryStream(tgaData)); + img = Targa.Decode(new MemoryStream(tgaData)); } else { - instance.Client.Assets.RequestImage(textureID, (TextureRequestState state, AssetTexture assetTexture) => + instance.Client.Assets.RequestImage(textureID, (state, assetTexture) => { - ManagedImage mi; - if (state == TextureRequestState.Finished && OpenJPEG.DecodeToImage(assetTexture.AssetData, out mi)) + if (state == TextureRequestState.Finished) { - + var mi = new ManagedImage(J2kImage.FromBytes(assetTexture.AssetData)); if (removeAlpha) { if ((mi.Channels & ManagedImage.ImageChannels.Alpha) != 0) @@ -3008,21 +2935,23 @@ private bool LoadTexture(UUID textureID, ref Image texture, bool removeAlpha) mi.ConvertChannels(mi.Channels & ~ManagedImage.ImageChannels.Alpha); } } - tgaData = mi.ExportTGA(); - img = LoadTGAClass.LoadTGA(new MemoryStream(tgaData)); - RHelp.SaveCachedImage(tgaData, textureID, (mi.Channels & ManagedImage.ImageChannels.Alpha) != 0, false, false); + + // This is GROSS. + tgaData = Targa.Encode(mi); + img = Targa.Decode(new MemoryStream(tgaData)); + RHelp.SaveCachedImage(tgaData, textureID, + (mi.Channels & ManagedImage.ImageChannels.Alpha) != 0, false, false); } + gotImage.Set(); } ); gotImage.WaitOne(30 * 1000, false); } - if (img != null) - { - texture = img; - return true; - } - return false; + + if (img == null) { return false; } + texture = img; + return true; } catch (Exception e) { @@ -3064,10 +2993,8 @@ private void ctxObjects_Opening(object csender, System.ComponentModel.CancelEven } // Was it prim that was right clicked - if (RightclickedObject != null && RightclickedObject is RenderPrimitive) + if (RightclickedObject is RenderPrimitive prim) { - RenderPrimitive prim = (RenderPrimitive)RightclickedObject; - // Sit button handling if (!instance.State.IsSitting) { @@ -3128,10 +3055,8 @@ private void ctxObjects_Opening(object csender, System.ComponentModel.CancelEven instance.ContextActionManager.AddContributions(ctxMenu, typeof(Primitive), prim.Prim); } // We right clicked on an avatar, add some context menu items - else if (RightclickedObject != null && RightclickedObject is RenderAvatar) + else if (RightclickedObject is RenderAvatar av) { - RenderAvatar av = (RenderAvatar)RightclickedObject; - // Profile button item = new ToolStripMenuItem("Profile", null, (sender, e) => { @@ -3183,10 +3108,7 @@ private void ctxObjects_Opening(object csender, System.ComponentModel.CancelEven { Control p = Parent; instance.TabConsole.Tabs["scene_window"].AttachTo(instance.TabConsole.tstTabs, instance.TabConsole.toolStripContainer1.ContentPanel); - if (p is Form) - { - ((Form)p).Close(); - } + (p as Form)?.Close(); }); } ctxMenu.Items.Add(item); @@ -3279,15 +3201,15 @@ private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) Bone b; if (av.glavatar.skel.mBones.TryGetValue(bone, out b)) { - textBox_sx.Text = (b.scale.X - 1.0f).ToString(); - textBox_sy.Text = (b.scale.Y - 1.0f).ToString(); - textBox_sz.Text = (b.scale.Z - 1.0f).ToString(); + textBox_sx.Text = (b.scale.X - 1.0f).ToString(CultureInfo.InvariantCulture); + textBox_sy.Text = (b.scale.Y - 1.0f).ToString(CultureInfo.InvariantCulture); + textBox_sz.Text = (b.scale.Z - 1.0f).ToString(CultureInfo.InvariantCulture); float x, y, z; b.rot.GetEulerAngles(out x, out y, out z); - textBox_x.Text = x.ToString(); - textBox_y.Text = y.ToString(); - textBox_z.Text = z.ToString(); + textBox_x.Text = x.ToString(CultureInfo.InvariantCulture); + textBox_y.Text = y.ToString(CultureInfo.InvariantCulture); + textBox_z.Text = z.ToString(CultureInfo.InvariantCulture); } diff --git a/Radegast/GUI/Rendering/RenderingHelpers.cs b/Radegast/GUI/Rendering/RenderingHelpers.cs index 4d78f8384..269657526 100644 --- a/Radegast/GUI/Rendering/RenderingHelpers.cs +++ b/Radegast/GUI/Rendering/RenderingHelpers.cs @@ -1,49 +1,35 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior CreateReflectionTexture permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id: RenderingHelpers.cs 1136 2011-09-05 22:45:11Z latifer $ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ using System; using System.Collections.Generic; -using System.Collections; -using System.Linq; using System.Text; using System.IO; using System.IO.Compression; -using System.Xml; -using System.Threading; using OpenTK.Graphics.OpenGL; using System.Runtime.InteropServices; using System.Drawing; using System.Drawing.Imaging; using OpenMetaverse; using OpenMetaverse.Rendering; +using SkiaSharp; namespace Radegast.Rendering { @@ -68,7 +54,7 @@ public struct ColorVertex public class TextureInfo { - public System.Drawing.Image Texture; + public SKBitmap Texture; public int TexturePointer; public bool HasAlpha; public bool FullAlpha; @@ -86,7 +72,7 @@ public class TextureLoadItem public byte[] TextureData = null; public byte[] TGAData = null; public bool LoadAssetFromCache = false; - public OpenMetaverse.ImageType ImageType = OpenMetaverse.ImageType.Normal; + public ImageType ImageType = ImageType.Normal; public string BakeName = string.Empty; public UUID AvatarID = UUID.Zero; } @@ -114,7 +100,7 @@ public abstract class SceneObject : IComparable, IDisposable #region Public fields /// Interpolated local position of the object public Vector3 InterpolatedPosition; - /// Interpolated local rotation of the object/summary> + /// Interpolated local rotation of the object public Quaternion InterpolatedRotation; /// Rendered position of the object in the region public Vector3 RenderPosition; @@ -231,12 +217,11 @@ public virtual void Render(RenderPass pass, int pickingID, SceneWindow scene, fl public virtual int CompareTo(object other) { SceneObject o = (SceneObject)other; - if (this.DistanceSquared < o.DistanceSquared) + if (DistanceSquared < o.DistanceSquared) return -1; - else if (this.DistanceSquared > o.DistanceSquared) + if (DistanceSquared > o.DistanceSquared) return 1; - else - return 0; + return 0; } #region Occlusion queries @@ -357,8 +342,8 @@ public bool Occluded() public static class RHelp { public static readonly Vector3 InvalidPosition = new Vector3(99999f, 99999f, 99999f); - static float t1 = 0.075f; - static float t2 = t1 / 5.7f; + static readonly float t1 = 0.075f; + static readonly float t2 = t1 / 5.7f; public static Vector3 Smoothed1stOrder(Vector3 curPos, Vector3 targetPos, float lastFrameTime) { @@ -480,7 +465,7 @@ public static bool LoadCachedImage(UUID textureID, out byte[] tgaData, out bool using (var compressed = new DeflateStream(f, CompressionMode.Decompress)) { int read = 0; - while ((read = compressed.Read(tgaData, read, uncompressedSize - read)) > 0) ; + while ((read = compressed.Read(tgaData, read, uncompressedSize - read)) > 0) { } } } @@ -584,7 +569,7 @@ public static int GLLoadImage(Bitmap bitmap, bool hasAlpha) public static int GLLoadImage(Bitmap bitmap, bool hasAlpha, bool useMipmap) { useMipmap = useMipmap && RenderSettings.HasMipmap; - int ret = -1; + int ret; GL.GenTextures(1, out ret); GL.BindTexture(TextureTarget.Texture2D, ret); @@ -663,16 +648,12 @@ public class Camera public bool Manual; Vector3 mPosition; Vector3 mFocalPoint; - bool mModified; /// Camera position public Vector3 Position { - get - { - return mPosition; - } - + get => mPosition; + set { if (mPosition != value) @@ -686,11 +667,8 @@ public Vector3 Position /// Camera target public Vector3 FocalPoint { - get - { - return mFocalPoint; - } - + get => mFocalPoint; + set { if (mFocalPoint != value) @@ -706,7 +684,7 @@ public Vector3 FocalPoint /// Draw distance public float Far; /// Has camera been modified - public bool Modified { get { return mModified; } set { mModified = value; } } + public bool Modified { get; set; } public float TimeToTarget = 0f; @@ -715,7 +693,7 @@ public Vector3 FocalPoint void Modify() { - mModified = true; + Modified = true; } public void Step(float time) @@ -842,15 +820,13 @@ public static bool MeshesToOBJ(Dictionary meshes, string file int primNr = 0; foreach (FacetedMesh mesh in meshes.Values) { - for (int j = 0; j < mesh.Faces.Count; j++) + foreach (var face in mesh.Faces) { - Face face = mesh.Faces[j]; - if (face.Vertices.Count > 2) { - string mtlName = String.Format("material{0}-{1}", primNr, face.ID); + string mtlName = $"material{primNr}-{face.ID}"; Primitive.TextureEntryFace tex = face.TextureFace; - string texName = tex.TextureID.ToString() + ".tga"; + string texName = tex.TextureID + ".tga"; // FIXME: Convert the source to TGA (if needed) and copy to the destination @@ -882,10 +858,8 @@ public static bool MeshesToOBJ(Dictionary meshes, string file mtl.AppendLine(); // Write the vertices, texture coordinates, and vertex normals for this side - for (int k = 0; k < face.Vertices.Count; k++) + foreach (var vertex in face.Vertices) { - Vertex vertex = face.Vertices[k]; - #region Vertex Vector3 pos = vertex.Position; @@ -916,12 +890,17 @@ public static bool MeshesToOBJ(Dictionary meshes, string file #region Vertex Normal // HACK: Sometimes normals are getting set to - if (!Single.IsNaN(vertex.Normal.X) && !Single.IsNaN(vertex.Normal.Y) && !Single.IsNaN(vertex.Normal.Z)) + if (!Single.IsNaN(vertex.Normal.X) && + !Single.IsNaN(vertex.Normal.Y) && + !Single.IsNaN(vertex.Normal.Z)) + { obj.AppendFormat("vn {0} {1} {2}{3}", vertex.Normal.X, vertex.Normal.Y, vertex.Normal.Z, Environment.NewLine); + } else + { obj.AppendLine("vn 0.0 1.0 0.0"); - + } #endregion Vertex Normal } @@ -947,6 +926,7 @@ public static bool MeshesToOBJ(Dictionary meshes, string file #endregion Elements } } + primNr++; } @@ -989,9 +969,9 @@ public static float[] CreateRotationMatrix(Quaternion q) float[] mat = new float[16]; // Transpose the quaternion (don't ask me why) - q.X = q.X * -1f; - q.Y = q.Y * -1f; - q.Z = q.Z * -1f; + q.X *= -1f; + q.Y *= -1f; + q.Z *= -1f; float x2 = q.X + q.X; float y2 = q.Y + q.Y; @@ -1034,9 +1014,9 @@ public static float[] CreateSRTMatrix(Vector3 scale, Quaternion q, Vector3 pos) float[] mat = new float[16]; // Transpose the quaternion (don't ask me why) - q.X = q.X * -1f; - q.Y = q.Y * -1f; - q.Z = q.Z * -1f; + q.X *= -1f; + q.Y *= -1f; + q.Z *= -1f; float x2 = q.X + q.X; float y2 = q.Y + q.Y; @@ -1210,7 +1190,7 @@ class VFSblock public int mSize; public AssetType mAssetType; - public int readblock(byte[] blockdata, int offset) + public int Readblock(byte[] blockdata, int offset) { BitPack input = new BitPack(blockdata, offset); @@ -1230,9 +1210,9 @@ public int readblock(byte[] blockdata, int offset) } - public class staticVFS + public class StaticVFS { - public static void readVFSheaders(string datafile, string indexfile) + public static void ReadVFSheaders(string datafile, string indexfile) { FileStream datastream; FileStream indexstream; @@ -1248,9 +1228,9 @@ public static void readVFSheaders(string datafile, string indexfile) while (offset < indexstream.Length) { VFSblock block = new VFSblock(); - offset = block.readblock(blockdata, offset); + offset = block.Readblock(blockdata, offset); - FileStream writer = File.Open(OpenMetaverse.Settings.RESOURCE_DIR + System.IO.Path.DirectorySeparatorChar + block.mFileID.ToString(), FileMode.Create); + FileStream writer = File.Open(OpenMetaverse.Settings.RESOURCE_DIR + System.IO.Path.DirectorySeparatorChar + block.mFileID, FileMode.Create); byte[] data = new byte[block.mSize]; datastream.Seek(block.mLocation, SeekOrigin.Begin); datastream.Read(data, 0, block.mSize); diff --git a/Radegast/GUI/Rendering/Shader.cs b/Radegast/GUI/Rendering/Shader.cs index 9a819184d..1bf4e5f29 100644 --- a/Radegast/GUI/Rendering/Shader.cs +++ b/Radegast/GUI/Rendering/Shader.cs @@ -1,38 +1,24 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior CreateReflectionTexture permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using System.IO; using OpenMetaverse; using OpenTK.Graphics.OpenGL; @@ -75,7 +61,7 @@ public bool Load(string fileName) ID = -1; return false; } - Logger.DebugLog(string.Format("{0} {1} compiled successfully", type.ToString(), fileName)); + Logger.DebugLog(string.Format("{0} {1} compiled successfully", type, fileName)); return true; } catch @@ -113,9 +99,9 @@ public bool Load(params string[] shaderNames) } ID = GL.CreateProgram(); - for (int i = 0; i < shaders.Length; i++) + foreach (var shader in shaders) { - GL.AttachShader(ID, shaders[i].ID); + GL.AttachShader(ID, shader.ID); } GL.LinkProgram(ID); int res; @@ -126,7 +112,7 @@ public bool Load(params string[] shaderNames) return false; } - Logger.DebugLog(string.Format("Linking shader program consitsting of {0} shaders successful", shaders.Length)); + Logger.DebugLog($"Linking shader program consisting of {shaders.Length} shaders successful"); return true; } @@ -196,9 +182,9 @@ public void Dispose() if (shaders != null) { - for (int i = 0; i < shaders.Length; i++) + foreach (var shader in shaders) { - shaders[i].Dispose(); + shader.Dispose(); } } shaders = null; diff --git a/Radegast/GUI/Rendering/TerrainSplat.cs b/Radegast/GUI/Rendering/TerrainSplat.cs index 76e8da29b..6c0be3057 100644 --- a/Radegast/GUI/Rendering/TerrainSplat.cs +++ b/Radegast/GUI/Rendering/TerrainSplat.cs @@ -1,45 +1,32 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Based on code from Aurora Sim and OpenSimulator -// Copyright (c) Contributors, http://aurora-sim.org/, http://opensimulator.org/ -// -// $Id$ -// - +/* + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2021, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ using System; using System.Diagnostics; using System.Drawing; using System.Drawing.Imaging; using System.Threading; +using CoreJ2K; using OpenMetaverse; -using OpenMetaverse.Imaging; +using SkiaSharp; +using SkiaSharp.Views.Desktop; namespace Radegast.Rendering { @@ -77,8 +64,11 @@ public static class TerrainSplat /// Builds a composited terrain texture given the region texture /// and heightmap settings /// + /// Radegast Instance /// Terrain heightmap - /// Region information including terrain texture parameters + /// + /// + /// /// A composited 256x256 RGB texture ready for rendering /// Based on the algorithm described at http://opensimulator.org/wiki/Terrain_Splatting /// @@ -308,12 +298,9 @@ private static TextureDownloadCallback TextureDownloadCallback(Bitmap[] detailTe { return (state, assetTexture) => { - if (state == TextureRequestState.Finished && assetTexture != null && assetTexture.AssetData != null) + if (state == TextureRequestState.Finished && assetTexture?.AssetData != null) { - Image img; - ManagedImage mi; - OpenJPEG.DecodeToImage(assetTexture.AssetData, out mi, out img); - detailTexture[i] = (Bitmap)img; + detailTexture[i] = J2kImage.FromBytes(assetTexture.AssetData).As().ToBitmap(); } textureDone.Set(); }; diff --git a/Radegast/GUI/Rendering/TextRendering.cs b/Radegast/GUI/Rendering/TextRendering.cs index f0f390e0f..fe9b0deb1 100644 --- a/Radegast/GUI/Rendering/TextRendering.cs +++ b/Radegast/GUI/Rendering/TextRendering.cs @@ -1,39 +1,28 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; using OpenTK.Graphics.OpenGL; -using OpenMetaverse; namespace Radegast.Rendering { @@ -62,11 +51,11 @@ class TextItem public TextItem(string text, Font font, Color color, Rectangle box, TextFormatFlags flags) { - this.Text = text; - this.Font = font; - this.Color = color; - this.Box = box; - this.Flags = flags | TextFormatFlags.NoPrefix; + Text = text; + Font = font; + Color = color; + Box = box; + Flags = flags | TextFormatFlags.NoPrefix; } } @@ -81,7 +70,7 @@ public TextItem(string text, Font font, Color color, Rectangle box, TextFormatFl public TextRendering(RadegastInstance instance) { - this.Instance = instance; + Instance = instance; textItems = new List(); } @@ -96,7 +85,7 @@ public void Print(string text, Font font, Color color, Rectangle box, TextFormat public static Size Measure(string text, Font font, TextFormatFlags flags) { - return TextRenderer.MeasureText(text, font, TextRendering.MaxSize, flags); + return TextRenderer.MeasureText(text, font, MaxSize, flags); } public void Begin() @@ -178,7 +167,7 @@ void PrepareText(TextItem item) s = TextRenderer.MeasureText( item.Text, item.Font, - TextRendering.MaxSize, + MaxSize, item.Flags); } catch diff --git a/Radegast/GUI/Rendering/Water.cs b/Radegast/GUI/Rendering/Water.cs index e8fc3789f..1cca707fa 100644 --- a/Radegast/GUI/Rendering/Water.cs +++ b/Radegast/GUI/Rendering/Water.cs @@ -30,21 +30,10 @@ // #region Usings -using System; -using System.Collections.Generic; + using System.Drawing; -using System.Drawing.Imaging; -using System.IO; -using System.Windows.Forms; -using System.Text; -using System.Threading; -using System.Linq; using OpenTK.Graphics.OpenGL; -using OpenMetaverse; -using OpenMetaverse.Rendering; -using OpenMetaverse.Assets; -using OpenMetaverse.Imaging; -using OpenMetaverse.StructuredData; + #endregion Usings namespace Radegast.Rendering @@ -71,12 +60,12 @@ void SetWaterPlanes() void InitWater() { - Bitmap normal = (Bitmap)Bitmap.FromFile(System.IO.Path.Combine("shader_data", "normalmap.png")); + Bitmap normal = (Bitmap)Image.FromFile(System.IO.Path.Combine("shader_data", "normalmap.png")); reflectionTexture = RHelp.GLLoadImage(normal, false); refractionTexture = RHelp.GLLoadImage(normal, false); normalmap = RHelp.GLLoadImage(normal, false); depthTexture = RHelp.GLLoadImage(normal, false); - dudvmap = RHelp.GLLoadImage((Bitmap)Bitmap.FromFile(System.IO.Path.Combine("shader_data", "dudvmap.png")), false); + dudvmap = RHelp.GLLoadImage((Bitmap)Image.FromFile(System.IO.Path.Combine("shader_data", "dudvmap.png")), false); waterProgram.Load("water.vert", "water.frag"); } @@ -184,7 +173,7 @@ public void CreateRefractionDepthTexture(float waterHeight, int textureSize) GL.CopyTexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, 0, 0, textureSize, textureSize); GL.BindTexture(TextureTarget.Texture2D, depthTexture); - GL.CopyTexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.DepthComponent, 0, 0, textureSize, textureSize, 0); + GL.CopyTexImage2D(TextureTarget.Texture2D, 0, InternalFormat.DepthComponent, 0, 0, textureSize, textureSize, 0); } public void RenderWater() diff --git a/Radegast/GUI/Tabs/IRadegastTabControl.cs b/Radegast/GUI/Tabs/IRadegastTabControl.cs new file mode 100644 index 000000000..79d70f24a --- /dev/null +++ b/Radegast/GUI/Tabs/IRadegastTabControl.cs @@ -0,0 +1,27 @@ +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + +namespace Radegast +{ + public interface IRadegastTabControl + { + void RegisterTab(RadegastTab tab); + } +} diff --git a/Radegast/GUI/Tabs/RadegastTab.cs b/Radegast/GUI/Tabs/RadegastTab.cs new file mode 100644 index 000000000..664d37505 --- /dev/null +++ b/Radegast/GUI/Tabs/RadegastTab.cs @@ -0,0 +1,324 @@ +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + +using System; +using System.Drawing; +using System.Windows.Forms; + +namespace Radegast +{ + public partial class RadegastTab + { + public bool Floater = false; + public bool CloseOnDetachedClose = false; + + private RadegastInstance instance; + + private string label; + private string originalLabel; + + public RadegastTab(RadegastInstance instance, ToolStripButton button, Control control, string name, string label) + { + this.instance = instance; + Button = button; + Control = control; + Name = name; + this.label = label; + } + + public void Close() + { + if (!AllowClose) return; + + if (Control != null) + { + if (Control.Parent is Form) + { + Control.Parent.Dispose(); + } + + if (instance.TabConsole.toolStripContainer1.ContentPanel.Contains(Control)) + { + instance.TabConsole.toolStripContainer1.ContentPanel.Controls.Remove(Control); + } + Control.Dispose(); + Control = null; + } + + if (Button != null) + { + if (instance.TabConsole.tstTabs.Items.Contains(Button)) + { + instance.TabConsole.tstTabs.Items.Remove(Button); + } + Button.Dispose(); + Button = null; + } + + + OnTabClosed(EventArgs.Empty); + } + + public void Select() + { + if (Detached) return; + + if (Hidden) + { + Hidden = false; + } + + Control.Visible = true; + Control.BringToFront(); + + if (!PartiallyHighlighted) Unhighlight(); + Button.Visible = true; + Button.Checked = true; + Selected = true; + + OnTabSelected(EventArgs.Empty); + } + + public void Deselect() + { + if (Detached) return; + + if (Control != null) Control.Visible = false; + if (Button != null) Button.Checked = false; + + Selected = false; + + OnTabDeselected(EventArgs.Empty); + } + + public void Hide() + { + if (!AllowHide || Detached) return; + + if (Control != null) Control.Visible = false; + if (Button != null) Button.Visible = false; + + Hidden = true; + + OnTabHidden(EventArgs.Empty); + } + + public void Show() + { + if (Detached) return; + + if (Button != null) Button.Visible = true; + Select(); + + Hidden = false; + + OnTabShown(EventArgs.Empty); + } + + public void PartialHighlight() + { + if (Detached) + { + //do nothing?! + } + else + { + Button.Image = null; + Button.ForeColor = Color.Blue; + } + + PartiallyHighlighted = true; + OnTabPartiallyHighlighted(EventArgs.Empty); + } + + public void Highlight() + { + if (instance.GlobalSettings["taskbar_highlight"]) + { + if ((Control is ChatConsole && instance.GlobalSettings["highlight_on_chat"]) || + (Control is IMTabWindow && instance.GlobalSettings["highlight_on_im"]) || + (Control is GroupIMTabWindow && instance.GlobalSettings["highlight_on_group_chat"]) || + (Control is ConferenceIMTabWindow && instance.GlobalSettings["highlight_on_group_chat"])) + { + FormFlash.StartFlash(Control.FindForm()); + } + } + + if (Selected) return; + + if (!Detached) + { + Button.Image = Properties.Resources.arrow_forward_16; + Button.ForeColor = Color.Red; + } + + Highlighted = true; + OnTabHighlighted(EventArgs.Empty); + } + + public void Unhighlight() + { + FormFlash.StopFlash(instance.MainForm); + + if (!Detached) + { + Button.Image = null; + Button.ForeColor = Color.FromKnownColor(KnownColor.ControlText); + } + + Highlighted = PartiallyHighlighted = false; + OnTabUnhighlighted(EventArgs.Empty); + } + + public void AttachTo(ToolStrip strip, Panel container) + { + if (!AllowDetach) return; + if (!Detached) return; + + Button.Visible = true; + foreach (Control c in container.Controls) + c.Hide(); + container.Controls.Add(Control); + + Owner = null; + Detached = false; + OnTabAttached(EventArgs.Empty); + } + + public void Detach(RadegastInstance instance) + { + if (!AllowDetach) return; + if (Detached) return; + Button.Visible = false; + Owner = new frmDetachedTab(instance, this); + Owner.Show(); + Owner.Focus(); + Detached = true; + OnTabDetached(EventArgs.Empty); + } + + public void MergeWith(RadegastTab tab) + { + if (!AllowMerge) return; + if (Merged) return; + + SplitContainer container = new SplitContainer + { + Dock = DockStyle.Fill, + BorderStyle = BorderStyle.Fixed3D + }; + container.SplitterDistance = container.Width / 2; + container.Panel1.Controls.Add(Control); + container.Panel2.Controls.Add(tab.Control); + + Control.Visible = true; + tab.Control.Visible = true; + + Control = container; + tab.Control = container; + + MergedTab = tab; + tab.MergedTab = this; + + originalLabel = label; + tab.originalLabel = tab.label; + Label = label + "+" + tab.Label; + + Merged = tab.Merged = true; + + OnTabMerged(EventArgs.Empty); + } + + public RadegastTab Split() + { + if (!AllowMerge) return null; + if (!Merged) return null; + + RadegastTab returnTab = MergedTab; + MergedTab = null; + returnTab.MergedTab = null; + + SplitContainer container = (SplitContainer)Control; + Control = container.Panel1.Controls[0]; + returnTab.Control = container.Panel2.Controls[0]; + Merged = returnTab.Merged = false; + + Label = originalLabel; + OnTabSplit(EventArgs.Empty); + + return returnTab; + } + + public ToolStripButton Button { get; set; } + + public Control Control { get; set; } + + public Button DefaultControlButton { get; set; } + + public string Name { get; } + + public string Label + { + get => label; + set => label = Button.Text = value; + } + + public RadegastTab MergedTab { get; private set; } + + public Form Owner { get; private set; } + + public bool AllowMerge { get; set; } = true; + + public bool AllowDetach { get; set; } = true; + + public bool AllowClose { get; set; } = true; + + public bool PartiallyHighlighted { get; private set; } = false; + + public bool Highlighted { get; private set; } = false; + + public bool Selected { get; private set; } = false; + + public bool Detached { get; private set; } = false; + + public bool Merged { get; private set; } = false; + + public bool AllowHide { get; set; } = true; + + public bool Hidden { get; private set; } = false; + + public bool Visible + { + get => !Hidden; + + set + { + if (value) + { + Show(); + } + else if (AllowHide) + { + Hide(); + } + } + } + } +} diff --git a/Radegast/GUI/Tabs/RadegastTabEvents.cs b/Radegast/GUI/Tabs/RadegastTabEvents.cs new file mode 100644 index 000000000..564c9ebbb --- /dev/null +++ b/Radegast/GUI/Tabs/RadegastTabEvents.cs @@ -0,0 +1,100 @@ +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + +using System; + +namespace Radegast +{ + public partial class RadegastTab + { + public event EventHandler TabSelected; + public event EventHandler TabDeselected; + public event EventHandler TabHighlighted; + public event EventHandler TabUnhighlighted; + public event EventHandler TabPartiallyHighlighted; + public event EventHandler TabMerged; + public event EventHandler TabSplit; + public event EventHandler TabDetached; + public event EventHandler TabAttached; + public event EventHandler TabClosed; + public event EventHandler TabHidden; + public event EventHandler TabShown; + + protected virtual void OnTabSelected(EventArgs e) + { + TabSelected?.Invoke(this, e); + } + + protected virtual void OnTabDeselected(EventArgs e) + { + TabDeselected?.Invoke(this, e); + } + + protected virtual void OnTabHighlighted(EventArgs e) + { + TabHighlighted?.Invoke(this, e); + } + + protected virtual void OnTabUnhighlighted(EventArgs e) + { + TabUnhighlighted?.Invoke(this, e); + } + + protected virtual void OnTabPartiallyHighlighted(EventArgs e) + { + TabPartiallyHighlighted?.Invoke(this, e); + } + + protected virtual void OnTabMerged(EventArgs e) + { + TabMerged?.Invoke(this, e); + } + + protected virtual void OnTabSplit(EventArgs e) + { + TabSplit?.Invoke(this, e); + } + + protected virtual void OnTabDetached(EventArgs e) + { + TabDetached?.Invoke(this, e); + } + + protected virtual void OnTabAttached(EventArgs e) + { + TabAttached?.Invoke(this, e); + } + + protected virtual void OnTabClosed(EventArgs e) + { + TabClosed?.Invoke(this, e); + } + + protected virtual void OnTabHidden(EventArgs e) + { + TabHidden?.Invoke(this, e); + } + + protected virtual void OnTabShown(EventArgs e) + { + TabShown?.Invoke(this, e); + } + } +} diff --git a/Radegast/Netcom/Enums.cs b/Radegast/Netcom/Enums.cs index 84eef15ce..7fe74bb49 100644 --- a/Radegast/Netcom/Enums.cs +++ b/Radegast/Netcom/Enums.cs @@ -1,35 +1,24 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ -namespace Radegast.Netcom +namespace Radegast { public enum StartLocationType { diff --git a/Radegast/Netcom/EventArgs/ChatSentEventArgs.cs b/Radegast/Netcom/EventArgs/ChatSentEventArgs.cs index 41a8b7c78..a90a464ca 100644 --- a/Radegast/Netcom/EventArgs/ChatSentEventArgs.cs +++ b/Radegast/Netcom/EventArgs/ChatSentEventArgs.cs @@ -1,64 +1,41 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using OpenMetaverse; -namespace Radegast.Netcom +namespace Radegast { public class ChatSentEventArgs : EventArgs { - private string message; - private ChatType type; - private int channel; - public ChatSentEventArgs(string message, ChatType type, int channel) { - this.message = message; - this.type = type; - this.channel = channel; + Message = message; + Type = type; + Channel = channel; } - public string Message - { - get { return message; } - } + public string Message { get; } - public ChatType Type - { - get { return type; } - } + public ChatType Type { get; } - public int Channel - { - get { return channel; } - } + public int Channel { get; } } } \ No newline at end of file diff --git a/Radegast/Netcom/EventArgs/InstantMessageSentEventArgs.cs b/Radegast/Netcom/EventArgs/InstantMessageSentEventArgs.cs index 05cdc7a8d..7e7c3b3a5 100644 --- a/Radegast/Netcom/EventArgs/InstantMessageSentEventArgs.cs +++ b/Radegast/Netcom/EventArgs/InstantMessageSentEventArgs.cs @@ -1,71 +1,44 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using OpenMetaverse; -namespace Radegast.Netcom +namespace Radegast { public class InstantMessageSentEventArgs : EventArgs { - private string message; - private UUID targetID; - private UUID sessionID; - private DateTime timestamp; - public InstantMessageSentEventArgs(string message, UUID targetID, UUID sessionID, DateTime timestamp) { - this.message = message; - this.targetID = targetID; - this.sessionID = sessionID; - this.timestamp = timestamp; + Message = message; + TargetID = targetID; + SessionID = sessionID; + Timestamp = timestamp; } - public string Message - { - get { return message; } - } + public string Message { get; } - public UUID TargetID - { - get { return targetID; } - } + public UUID TargetID { get; } - public UUID SessionID - { - get { return sessionID; } - } + public UUID SessionID { get; } - public DateTime Timestamp - { - get { return timestamp; } - } + public DateTime Timestamp { get; } } } \ No newline at end of file diff --git a/Radegast/Netcom/EventArgs/OverrideEventArgs.cs b/Radegast/Netcom/EventArgs/OverrideEventArgs.cs index 2834f1f8f..e186752c9 100644 --- a/Radegast/Netcom/EventArgs/OverrideEventArgs.cs +++ b/Radegast/Netcom/EventArgs/OverrideEventArgs.cs @@ -1,41 +1,29 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; -namespace Radegast.Netcom +namespace Radegast { public class OverrideEventArgs : EventArgs { - private bool _cancel = false; - public OverrideEventArgs() { @@ -43,13 +31,9 @@ public OverrideEventArgs() public OverrideEventArgs(bool cancel) { - _cancel = cancel; + Cancel = cancel; } - public bool Cancel - { - get { return _cancel; } - set { _cancel = value; } - } + public bool Cancel { get; set; } = false; } } \ No newline at end of file diff --git a/Radegast/Netcom/EventArgs/TeleportingEventArgs.cs b/Radegast/Netcom/EventArgs/TeleportingEventArgs.cs deleted file mode 100644 index 601376236..000000000 --- a/Radegast/Netcom/EventArgs/TeleportingEventArgs.cs +++ /dev/null @@ -1,56 +0,0 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// -using OpenMetaverse; - -namespace Radegast.Netcom -{ - public class TeleportingEventArgs : OverrideEventArgs - { - private string _sim; - private Vector3 _coordinates; - - public TeleportingEventArgs(string sim, Vector3 coordinates) : base() - { - _sim = sim; - _coordinates = coordinates; - } - - public string SimName - { - get { return _sim; } - } - - public Vector3 Coordinates - { - get { return _coordinates; } - } - } -} \ No newline at end of file diff --git a/Radegast/Netcom/LoginOptions.cs b/Radegast/Netcom/LoginOptions.cs index 9b97b9e16..398e4dd23 100644 --- a/Radegast/Netcom/LoginOptions.cs +++ b/Radegast/Netcom/LoginOptions.cs @@ -1,133 +1,67 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ using OpenMetaverse; -namespace Radegast.Netcom +namespace Radegast { public class LoginOptions { - private string firstName; - private string lastName; - private string password; - private string version = string.Empty; - private string channel = string.Empty; - - private StartLocationType startLocation = StartLocationType.Home; - private string startLocationCustom = string.Empty; - - private Grid grid; - private string gridCustomLoginUri = string.Empty; - private LastExecStatus lastExecEvent = LastExecStatus.Normal; - - - public LoginOptions() - { - - } - public static bool IsPasswordMD5(string pass) { return pass.Length == 35 && pass.StartsWith("$1$"); } - public string FirstName - { - get { return firstName; } - set { firstName = value; } - } + public string FirstName { get; set; } - public string LastName - { - get { return lastName; } - set { lastName = value; } - } + public string LastName { get; set; } public string FullName { get { - if (string.IsNullOrEmpty(firstName) || string.IsNullOrEmpty(lastName)) + if (string.IsNullOrEmpty(FirstName) || string.IsNullOrEmpty(LastName)) return string.Empty; else - return firstName + " " + lastName; + return FirstName + " " + LastName; } } - public string Password - { - get { return password; } - set { password = value; } - } + public string Password { get; set; } - public StartLocationType StartLocation - { - get { return startLocation; } - set { startLocation = value; } - } + public string MfaToken { get; set; } - public string StartLocationCustom - { - get { return startLocationCustom; } - set { startLocationCustom = value; } - } + public string MfaHash { get; set; } - public string Channel - { - get { return channel; } - set { channel = value; } - } + public StartLocationType StartLocation { get; set; } = StartLocationType.Home; - public string Version - { - get { return version; } - set { version = value; } - } + public string StartLocationCustom { get; set; } = string.Empty; - public Grid Grid - { - get { return grid; } - set { grid = value; } - } + public string Channel { get; set; } = string.Empty; - public string GridCustomLoginUri - { - get { return gridCustomLoginUri; } - set { gridCustomLoginUri = value; } - } + public string Version { get; set; } = string.Empty; - public LastExecStatus LastExecEvent - { - get { return lastExecEvent; } - set { lastExecEvent = value; } - } + public Grid Grid { get; set; } + + public string GridCustomLoginUri { get; set; } = string.Empty; + + public LastExecStatus LastExecEvent { get; set; } = LastExecStatus.Normal; } } diff --git a/Radegast/Netcom/RadegastNetcom/NetCom.cs b/Radegast/Netcom/RadegastNetcom/NetCom.cs index c4a1a791f..e2b38618e 100644 --- a/Radegast/Netcom/RadegastNetcom/NetCom.cs +++ b/Radegast/Netcom/RadegastNetcom/NetCom.cs @@ -1,65 +1,45 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/* + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2023, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; -using System.Collections.Generic; -using System.ComponentModel; using System.Windows.Forms; using OpenMetaverse; -using Radegast; -using OpenMetaverse.Packets; -namespace Radegast.Netcom +namespace Radegast { /// - /// RadegastNetcom is a class built on top of libsecondlife that provides a way to + /// Netcom is a class built on top of libsecondlife that provides a way to /// raise events on the proper thread (for GUI apps especially). /// - public partial class RadegastNetcom : IDisposable + public partial class Netcom : IDisposable { - private RadegastInstance instance; - private GridClient client { get { return instance.Client; } } + private readonly RadegastInstance instance; + private GridClient client => instance.Client; public LoginOptions loginOptions; - private bool loggingIn = false; - private bool loggedIn = false; - private bool teleporting = false; - private bool agreeToTos = false; - public bool AgreeToTos { get { return agreeToTos; } set { agreeToTos = value; } } - private Grid grid; - public Grid Grid { get { return grid; } } + public bool AgreeToTos { get; set; } = false; + public Grid Grid { get; private set; } // NetcomSync is used for raising certain events on the // GUI/main thread. Useful if you're modifying GUI controls // in the client app when responding to those events. - private Control netcomSync; #region ClientConnected event /// The event subscribers, null of no subscribers @@ -71,8 +51,7 @@ public partial class RadegastNetcom : IDisposable protected virtual void OnClientConnected(EventArgs e) { EventHandler handler = m_ClientConnected; - if (handler != null) - handler(this, e); + handler?.Invoke(this, e); } /// Thread sync lock object @@ -89,37 +68,37 @@ public event EventHandler ClientConnected } #endregion ClientConnected event - public RadegastNetcom(RadegastInstance instance) + public Netcom(RadegastInstance instance) { this.instance = instance; loginOptions = new LoginOptions(); - instance.ClientChanged += new EventHandler(instance_ClientChanged); + instance.ClientChanged += instance_ClientChanged; RegisterClientEvents(client); } private void RegisterClientEvents(GridClient client) { - client.Self.ChatFromSimulator += new EventHandler(Self_ChatFromSimulator); - client.Self.IM += new EventHandler(Self_IM); - client.Self.MoneyBalance += new EventHandler(Self_MoneyBalance); - client.Self.TeleportProgress += new EventHandler(Self_TeleportProgress); - client.Self.AlertMessage += new EventHandler(Self_AlertMessage); - client.Network.Disconnected += new EventHandler(Network_Disconnected); - client.Network.LoginProgress += new EventHandler(Network_LoginProgress); - client.Network.LoggedOut += new EventHandler(Network_LoggedOut); + client.Self.ChatFromSimulator += Self_ChatFromSimulator; + client.Self.IM += Self_IM; + client.Self.MoneyBalance += Self_MoneyBalance; + client.Self.TeleportProgress += Self_TeleportProgress; + client.Self.AlertMessage += Self_AlertMessage; + client.Network.Disconnected += Network_Disconnected; + client.Network.LoginProgress += Network_LoginProgress; + client.Network.LoggedOut += Network_LoggedOut; } private void UnregisterClientEvents(GridClient client) { - client.Self.ChatFromSimulator -= new EventHandler(Self_ChatFromSimulator); - client.Self.IM -= new EventHandler(Self_IM); - client.Self.MoneyBalance -= new EventHandler(Self_MoneyBalance); - client.Self.TeleportProgress -= new EventHandler(Self_TeleportProgress); - client.Self.AlertMessage -= new EventHandler(Self_AlertMessage); - client.Network.Disconnected -= new EventHandler(Network_Disconnected); - client.Network.LoginProgress -= new EventHandler(Network_LoginProgress); - client.Network.LoggedOut -= new EventHandler(Network_LoggedOut); + client.Self.ChatFromSimulator -= Self_ChatFromSimulator; + client.Self.IM -= Self_IM; + client.Self.MoneyBalance -= Self_MoneyBalance; + client.Self.TeleportProgress -= Self_TeleportProgress; + client.Self.AlertMessage -= Self_AlertMessage; + client.Network.Disconnected -= Network_Disconnected; + client.Network.LoginProgress -= Network_LoginProgress; + client.Network.LoggedOut -= Network_LoggedOut; } void instance_ClientChanged(object sender, ClientChangedEventArgs e) @@ -128,13 +107,7 @@ void instance_ClientChanged(object sender, ClientChangedEventArgs e) RegisterClientEvents(client); } - private bool CanSyncInvoke - { - get - { - return netcomSync != null && !netcomSync.IsDisposed && netcomSync.IsHandleCreated && netcomSync.InvokeRequired; - } - } + private bool CanSyncInvoke => NetcomSync != null && !NetcomSync.IsDisposed && NetcomSync.IsHandleCreated && NetcomSync.InvokeRequired; public void Dispose() { @@ -147,7 +120,7 @@ public void Dispose() void Self_IM(object sender, InstantMessageEventArgs e) { if (CanSyncInvoke) - netcomSync.BeginInvoke(new OnInstantMessageRaise(OnInstantMessageReceived), new object[] { e }); + NetcomSync.BeginInvoke(new OnInstantMessageRaise(OnInstantMessageReceived), e); else OnInstantMessageReceived(e); } @@ -156,11 +129,11 @@ void Network_LoginProgress(object sender, LoginProgressEventArgs e) { if (e.Status == LoginStatus.Success) { - loggedIn = true; + IsLoggedIn = true; client.Self.RequestBalance(); if (CanSyncInvoke) { - netcomSync.BeginInvoke(new ClientConnectedRaise(OnClientConnected), new object[] { EventArgs.Empty }); + NetcomSync.BeginInvoke(new ClientConnectedRaise(OnClientConnected), EventArgs.Empty); } else { @@ -176,28 +149,25 @@ void Network_LoginProgress(object sender, LoginProgressEventArgs e) LoginProgressEventArgs ea = new LoginProgressEventArgs(e.Status, e.Message, string.Empty); if (CanSyncInvoke) - netcomSync.BeginInvoke(new OnClientLoginRaise(OnClientLoginStatus), new object[] { e }); + NetcomSync.BeginInvoke(new OnClientLoginRaise(OnClientLoginStatus), e); else OnClientLoginStatus(e); } void Network_LoggedOut(object sender, LoggedOutEventArgs e) { - loggedIn = false; + IsLoggedIn = false; if (CanSyncInvoke) - netcomSync.BeginInvoke(new OnClientLogoutRaise(OnClientLoggedOut), new object[] { EventArgs.Empty }); + NetcomSync.BeginInvoke(new OnClientLogoutRaise(OnClientLoggedOut), EventArgs.Empty); else OnClientLoggedOut(EventArgs.Empty); } void Self_TeleportProgress(object sender, TeleportEventArgs e) { - if (e.Status == TeleportStatus.Finished || e.Status == TeleportStatus.Failed) - teleporting = false; - if (CanSyncInvoke) - netcomSync.BeginInvoke(new OnTeleportStatusRaise(OnTeleportStatusChanged), new object[] { e }); + NetcomSync.BeginInvoke(new OnTeleportStatusRaise(OnTeleportStatusChanged), e); else OnTeleportStatusChanged(e); } @@ -205,18 +175,18 @@ void Self_TeleportProgress(object sender, TeleportEventArgs e) private void Self_ChatFromSimulator(object sender, ChatEventArgs e) { if (CanSyncInvoke) - netcomSync.BeginInvoke(new OnChatRaise(OnChatReceived), new object[] { e }); + NetcomSync.BeginInvoke(new OnChatRaise(OnChatReceived), e); else OnChatReceived(e); } void Network_Disconnected(object sender, DisconnectedEventArgs e) { - loggedIn = false; + IsLoggedIn = false; instance.MarkEndExecution(); if (CanSyncInvoke) - netcomSync.BeginInvoke(new OnClientDisconnectRaise(OnClientDisconnected), new object[] { e }); + NetcomSync.BeginInvoke(new OnClientDisconnectRaise(OnClientDisconnected), e); else OnClientDisconnected(e); } @@ -224,7 +194,7 @@ void Network_Disconnected(object sender, DisconnectedEventArgs e) void Self_MoneyBalance(object sender, BalanceEventArgs e) { if (CanSyncInvoke) - netcomSync.BeginInvoke(new OnMoneyBalanceRaise(OnMoneyBalanceUpdated), new object[] { e }); + NetcomSync.BeginInvoke(new OnMoneyBalanceRaise(OnMoneyBalanceUpdated), e); else OnMoneyBalanceUpdated(e); } @@ -232,14 +202,14 @@ void Self_MoneyBalance(object sender, BalanceEventArgs e) void Self_AlertMessage(object sender, AlertMessageEventArgs e) { if (CanSyncInvoke) - netcomSync.BeginInvoke(new OnAlertMessageRaise(OnAlertMessageReceived), new object[] { e }); + NetcomSync.BeginInvoke(new OnAlertMessageRaise(OnAlertMessageReceived), e); else OnAlertMessageReceived(e); } public void Login() { - loggingIn = true; + IsLoggingIn = true; // Report crashes only once and not on relogs/reconnects LastExecStatus execStatus = instance.GetLastExecStatus(); @@ -261,7 +231,7 @@ public void Login() if (ea.Cancel) { - loggingIn = false; + IsLoggingIn = false; return; } @@ -274,6 +244,7 @@ public void Login() } string startLocation = string.Empty; + string loginLocation = string.Empty; switch (loginOptions.StartLocation) { @@ -281,11 +252,8 @@ public void Login() case StartLocationType.Last: startLocation = "last"; break; case StartLocationType.Custom: - startLocation = loginOptions.StartLocationCustom.Trim(); - - StartLocationParser parser = new StartLocationParser(startLocation); - startLocation = NetworkManager.StartLocation(parser.Sim, parser.X, parser.Y, parser.Z); - + var parser = new LocationParser(loginOptions.StartLocationCustom.Trim()); + startLocation = parser.GetStartLocationUri(); break; } @@ -297,31 +265,31 @@ public void Login() } else { - if (loginOptions.Password.Length > 16) - { - password = Utils.MD5(loginOptions.Password.Substring(0, 16)); - } - else - { - password = Utils.MD5(loginOptions.Password); - } + password = Utils.MD5(loginOptions.Password.Length > 16 + ? loginOptions.Password.Substring(0, 16) + : loginOptions.Password); } LoginParams loginParams = client.Network.DefaultLoginParams( loginOptions.FirstName, loginOptions.LastName, password, loginOptions.Channel, loginOptions.Version); - grid = loginOptions.Grid; + Grid = loginOptions.Grid; loginParams.Start = startLocation; + loginParams.LoginLocation = loginLocation; loginParams.AgreeToTos = AgreeToTos; - loginParams.URI = grid.LoginURI; + loginParams.URI = Grid.LoginURI; loginParams.LastExecEvent = loginOptions.LastExecEvent; + loginParams.MfaEnabled = true; + loginParams.MfaHash = loginOptions.MfaHash; + loginParams.Token = loginOptions.MfaToken; + client.Network.BeginLogin(loginParams); } public void Logout() { - if (!loggedIn) + if (!IsLoggedIn) { OnClientLoggedOut(EventArgs.Empty); return; @@ -336,7 +304,7 @@ public void Logout() public void ChatOut(string chat, ChatType type, int channel) { - if (!loggedIn) return; + if (!IsLoggedIn) return; client.Self.Chat(chat, channel, type); OnChatSent(new ChatSentEventArgs(chat, type, channel)); @@ -344,7 +312,7 @@ public void ChatOut(string chat, ChatType type, int channel) public void SendInstantMessage(string message, UUID target, UUID session) { - if (!loggedIn) return; + if (!IsLoggedIn) return; client.Self.InstantMessage( loginOptions.FullName, target, message, session, InstantMessageDialog.MessageFromAgent, @@ -355,7 +323,7 @@ public void SendInstantMessage(string message, UUID target, UUID session) public void SendIMStartTyping(UUID target, UUID session) { - if (!loggedIn) return; + if (!IsLoggedIn) return; client.Self.InstantMessage( loginOptions.FullName, target, "typing", session, InstantMessageDialog.StartTyping, @@ -364,51 +332,23 @@ public void SendIMStartTyping(UUID target, UUID session) public void SendIMStopTyping(UUID target, UUID session) { - if (!loggedIn) return; + if (!IsLoggedIn) return; client.Self.InstantMessage( loginOptions.FullName, target, "typing", session, InstantMessageDialog.StopTyping, InstantMessageOnline.Online, client.Self.SimPosition, client.Network.CurrentSim.ID, null); } - public void Teleport(string sim, Vector3 coordinates) - { - if (!loggedIn) return; - if (teleporting) return; + public bool IsLoggingIn { get; private set; } = false; - TeleportingEventArgs ea = new TeleportingEventArgs(sim, coordinates); - OnTeleporting(ea); - if (ea.Cancel) return; - - teleporting = true; - client.Self.Teleport(sim, coordinates); - } - - public bool IsLoggingIn - { - get { return loggingIn; } - } - - public bool IsLoggedIn - { - get { return loggedIn; } - } - - public bool IsTeleporting - { - get { return teleporting; } - } + public bool IsLoggedIn { get; private set; } = false; public LoginOptions LoginOptions { - get { return loginOptions; } - set { loginOptions = value; } + get => loginOptions; + set => loginOptions = value; } - public Control NetcomSync - { - get { return netcomSync; } - set { netcomSync = value; } - } + public Control NetcomSync { get; set; } } } diff --git a/Radegast/Netcom/RadegastNetcom/NetComEvents.cs b/Radegast/Netcom/RadegastNetcom/NetComEvents.cs index 804056ba2..e0975bd51 100644 --- a/Radegast/Netcom/RadegastNetcom/NetComEvents.cs +++ b/Radegast/Netcom/RadegastNetcom/NetComEvents.cs @@ -1,39 +1,29 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2023, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using OpenMetaverse; -namespace Radegast.Netcom +namespace Radegast { - public partial class RadegastNetcom + public partial class Netcom { // For the NetcomSync stuff private delegate void OnClientLoginRaise(LoginProgressEventArgs e); @@ -54,74 +44,68 @@ public partial class RadegastNetcom public event EventHandler ChatSent; public event EventHandler InstantMessageReceived; public event EventHandler InstantMessageSent; - public event EventHandler Teleporting; public event EventHandler TeleportStatusChanged; public event EventHandler AlertMessageReceived; public event EventHandler MoneyBalanceUpdated; protected virtual void OnClientLoggingIn(OverrideEventArgs e) { - if (ClientLoggingIn != null) ClientLoggingIn(this, e); + ClientLoggingIn?.Invoke(this, e); } protected virtual void OnClientLoginStatus(LoginProgressEventArgs e) { - if (ClientLoginStatus != null) ClientLoginStatus(this, e); + ClientLoginStatus?.Invoke(this, e); } protected virtual void OnClientLoggingOut(OverrideEventArgs e) { - if (ClientLoggingOut != null) ClientLoggingOut(this, e); + ClientLoggingOut?.Invoke(this, e); } protected virtual void OnClientLoggedOut(EventArgs e) { - if (ClientLoggedOut != null) ClientLoggedOut(this, e); + ClientLoggedOut?.Invoke(this, e); } protected virtual void OnClientDisconnected(DisconnectedEventArgs e) { - if (ClientDisconnected != null) ClientDisconnected(this, e); + ClientDisconnected?.Invoke(this, e); } protected virtual void OnChatReceived(ChatEventArgs e) { - if (ChatReceived != null) ChatReceived(this, e); + ChatReceived?.Invoke(this, e); } protected virtual void OnChatSent(ChatSentEventArgs e) { - if (ChatSent != null) ChatSent(this, e); + ChatSent?.Invoke(this, e); } protected virtual void OnInstantMessageReceived(InstantMessageEventArgs e) { - if (InstantMessageReceived != null) InstantMessageReceived(this, e); + InstantMessageReceived?.Invoke(this, e); } protected virtual void OnInstantMessageSent(InstantMessageSentEventArgs e) { - if (InstantMessageSent != null) InstantMessageSent(this, e); - } - - protected virtual void OnTeleporting(TeleportingEventArgs e) - { - if (Teleporting != null) Teleporting(this, e); + InstantMessageSent?.Invoke(this, e); } protected virtual void OnTeleportStatusChanged(TeleportEventArgs e) { - if (TeleportStatusChanged != null) TeleportStatusChanged(this, e); + TeleportStatusChanged?.Invoke(this, e); } protected virtual void OnAlertMessageReceived(AlertMessageEventArgs e) { - if (AlertMessageReceived != null) AlertMessageReceived(this, e); + AlertMessageReceived?.Invoke(this, e); } protected virtual void OnMoneyBalanceUpdated(BalanceEventArgs e) { - if (MoneyBalanceUpdated != null) MoneyBalanceUpdated(this, e); + MoneyBalanceUpdated?.Invoke(this, e); } } } diff --git a/Radegast/Netcom/StartLocationParser.cs b/Radegast/Netcom/StartLocationParser.cs deleted file mode 100644 index 741af6d9a..000000000 --- a/Radegast/Netcom/StartLocationParser.cs +++ /dev/null @@ -1,125 +0,0 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// -using System; - -namespace Radegast.Netcom -{ - public class StartLocationParser - { - private string location; - - public StartLocationParser(string location) - { - if (location == null) throw new Exception("Location cannot be null."); - - this.location = location; - } - - private string GetSim(string location) - { - if (!location.Contains("/")) return location; - - string[] locSplit = location.Split('/'); - return locSplit[0]; - } - - private int GetX(string location) - { - if (!location.Contains("/")) return 128; - - string[] locSplit = location.Split('/'); - - int returnResult; - bool stringToInt = int.TryParse(locSplit[1], out returnResult); - - if (stringToInt) - return returnResult; - else - return 128; - } - - private int GetY(string location) - { - if (!location.Contains("/")) return 128; - - string[] locSplit = location.Split('/'); - - if (locSplit.Length > 2) - { - int returnResult; - bool stringToInt = int.TryParse(locSplit[2], out returnResult); - - if (stringToInt) - return returnResult; - } - - return 128; - } - - private int GetZ(string location) - { - if (!location.Contains("/")) return 0; - - string[] locSplit = location.Split('/'); - - if (locSplit.Length > 3) - { - int returnResult; - bool stringToInt = int.TryParse(locSplit[3], out returnResult); - - if (stringToInt) - return returnResult; - } - - return 0; - } - - public string Sim - { - get { return GetSim(location); } - } - - public int X - { - get { return GetX(location); } - } - - public int Y - { - get { return GetY(location); } - } - - public int Z - { - get { return GetZ(location); } - } - } -} diff --git a/Radegast/OpenMetaverse.dll.config b/Radegast/OpenMetaverse.dll.config deleted file mode 100644 index ccafc0ff5..000000000 --- a/Radegast/OpenMetaverse.dll.config +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/Radegast/OpenTK.Compatibility.dll.config b/Radegast/OpenTK.Compatibility.dll.config deleted file mode 100644 index b06a58dfc..000000000 --- a/Radegast/OpenTK.Compatibility.dll.config +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/Radegast/OpenTK.dll.config b/Radegast/OpenTK.dll.config deleted file mode 100644 index 5620e3d9e..000000000 --- a/Radegast/OpenTK.dll.config +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Radegast/Program.cs b/Radegast/Program.cs index d06b0e580..e2f6c1343 100644 --- a/Radegast/Program.cs +++ b/Radegast/Program.cs @@ -1,95 +1,70 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2021, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Windows.Forms; -using System.Text.RegularExpressions; using System.IO; using System.Reflection; using CommandLine; using CommandLine.Text; -#if (COGBOT_LIBOMV || USE_STHREADS) -using ThreadPoolUtil; -using Thread = ThreadPoolUtil.Thread; -using ThreadPool = ThreadPoolUtil.ThreadPool; -using Monitor = ThreadPoolUtil.Monitor; -#endif using System.Threading; namespace Radegast { - public class CommandLine + public class CommandLineOptions { - [Option("u", "username", HelpText = "Username, use quotes to supply \"First Last\"")] - public string Username = string.Empty; + [Option('u', "username", HelpText = "Username, use quotes to supply \"First Last\"")] + public string Username { get; set; } = string.Empty; - [Option("p", "password", HelpText = "Account password")] - public string Password = string.Empty; + [Option('p', "password", HelpText = "Account password")] + public string Password { get; set; } = string.Empty; - [Option("a", "autologin", HelpText = "Automatially login with provided user credentials")] - public bool AutoLogin = false; + [Option('a', "autologin", HelpText = "Automatically login with provided user credentials")] + public bool AutoLogin { get; set; } = false; - [Option("g", "grid", HelpText = "Grid ID to login into, try --list-grids to see IDs used for this parameter")] - public string Grid = string.Empty; + [Option('g', "grid", HelpText = "Grid ID to login into, try --list-grids to see IDs used for this parameter")] + public string Grid { get; set; } = string.Empty; - [Option("l", "location", HelpText = "Login location: last, home or regionname. Regioname can also be in format regionname/x/y/z")] - public string Location = string.Empty; + [Option('l', "location", HelpText = "Login location: last, home or region name. Region name can also be in format regionname/x/y/z")] + public string Location { get; set; } = string.Empty; - [Option(null, "list-grids", HelpText = "Lists grid IDs used for --grid option")] - public bool ListGrids = false; + [Option("list-grids", HelpText = "Lists grid IDs used for --grid option")] + public bool ListGrids { get; set; } = false; - [Option(null, "loginuri", HelpText = "Use this URI to login (don't use with --grid)")] - public string LoginUri = string.Empty; + [Option("loginuri", HelpText = "Use this URI to login (don't use with --grid)")] + public string LoginUri { get; set; } = string.Empty; - [Option(null, "no-sound", HelpText = "Disable sound")] - public bool DisableSound = false; + [Option("no-sound", HelpText = "Disable sound")] + public bool DisableSound { get; set; } = false; public HelpText GetHeader() { - HelpText header = new HelpText(Properties.Resources.RadegastTitle); - header.AdditionalNewLineAfterOption = true; - header.Copyright = new CopyrightInfo("Radegast Development Team", 2009, 2014); - header.AddPreOptionsLine("http://radegast.org/"); + HelpText header = new HelpText(Properties.Resources.RadegastTitle) + { + AdditionalNewLineAfterOption = true, + Copyright = new CopyrightInfo("Radegast Development Team, Sjofn LLC", 2009, 2021) + }; + header.AddPreOptionsLine("https://radegast.life/"); return header; } - - [HelpOption("h", "help", HelpText = "Display this help screen.")] - public string GetUsage() - { - HelpText usage = GetHeader(); - usage.AddOptions(this); - usage.AddPostOptionsLine("Example: automatically login user called Some Resident to his last location on the Second Life main grid (agni)"); - usage.AddPostOptionsLine("Radegast -a -g agni -u \"Some Resident\" -p \"secret\" -l last"); - return usage.ToString(); - } } public static class MainProgram @@ -97,10 +72,13 @@ public static class MainProgram /// /// Parsed command line options /// - public static CommandLine CommandLine; + public static CommandLineOptions s_CommandLineOpts; + + public static BugSplatDotNetStandard.BugSplat s_BugSplat; - static void RunRadegast(string[] args) + static void RunRadegast(CommandLineOptions args) { + s_CommandLineOpts = args; AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; // Increase the number of IOCP threads available. Mono defaults to a tragically low number @@ -114,33 +92,26 @@ static void RunRadegast(string[] args) ThreadPool.SetMaxThreads(workerThreads, iocpThreads); } - // Read command line options - CommandLine = new CommandLine(); - CommandLineParser parser = new CommandLineParser(new CommandLineParserSettings(Console.Error)); - if (!parser.ParseArguments(args, CommandLine)) - { - Environment.Exit(1); - } - // Change current working directory to Radegast install dir - Directory.SetCurrentDirectory(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)); + Directory.SetCurrentDirectory(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + ?? throw new InvalidOperationException()); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // See if we only wanted to display list of grids - if (CommandLine.ListGrids) + if (s_CommandLineOpts.ListGrids) { - Console.WriteLine(CommandLine.GetHeader()); + Console.WriteLine(s_CommandLineOpts.GetHeader()); Console.WriteLine(); GridManager grids = new GridManager(); Console.WriteLine("Use Grid ID as the parameter for --grid"); Console.WriteLine("{0,-25} - {1}", "Grid ID", "Grid Name"); - Console.WriteLine("========================================================"); + Console.WriteLine(@"========================================================"); for (int i = 0; i < grids.Count; i++) { - Console.WriteLine("{0,-25} - {1}", grids[i].ID, grids[i].Name); + Console.WriteLine(@"{0,-25} - {1}", grids[i].ID, grids[i].Name); } Environment.Exit(0); @@ -148,15 +119,30 @@ static void RunRadegast(string[] args) // Create main Radegast instance RadegastInstance instance = RadegastInstance.GlobalInstance; + + if (!string.IsNullOrEmpty(Generated.BugsplatDatabase)) + { + s_BugSplat = new BugSplatDotNetStandard.BugSplat( + Generated.BugsplatDatabase, "Radegast", + Assembly.GetExecutingAssembly().GetName().Version.ToString()) + { + User = "cinder@cinderblocks.biz", + ExceptionType = BugSplatDotNetStandard.BugSplat.ExceptionTypeId.DotNetStandard, + }; + if (instance.GlobalLogFile != null) + { + s_BugSplat.Attachments.Add(new FileInfo(instance.GlobalLogFile)); + } + } + Application.Run(instance.MainForm); - OpenMetaverse.WorkPool.Shutdown(); } - private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) + private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs exEventArgs) { - var instance = RadegastInstance.GlobalInstance; - instance.Client.Network.Logout(); - OpenMetaverse.WorkPool.Shutdown(); + RadegastInstance.GlobalInstance.Client.Network.Logout(); + Exception ex = (Exception)exEventArgs.ExceptionObject; + s_BugSplat?.Post(ex); } /// @@ -165,37 +151,38 @@ private static void CurrentDomain_UnhandledException(object sender, UnhandledExc [STAThread] static void Main(string[] args) { - if (System.Diagnostics.Debugger.IsAttached) + Core.NativeMethods.Init(); + try { - RunRadegast(args); + var parser = new Parser(x => x.HelpWriter = null); + var result = parser.ParseArguments(args); + result.WithParsed(RunRadegast) + .WithNotParsed(errs => + { + var helpText = HelpText.AutoBuild(result, h => + { + h.AdditionalNewLineAfterOption = false; + return h; + }, e => e); + Console.WriteLine(helpText); + Console.WriteLine("Use Grid ID as the parameter for --grid"); + Console.WriteLine("{0,-25} - {1}", "Grid ID", "Grid Name"); + Console.WriteLine(); + }); } - else + catch (Exception ex) { - try - { - RunRadegast(args); - } - catch (Exception e) - { - string errMsg = "Unhandled " + e.ToString() + ": " + - e.Message + Environment.NewLine + - e.StackTrace + Environment.NewLine; - - OpenMetaverse.Logger.Log(errMsg, OpenMetaverse.Helpers.LogLevel.Error); - - string dlgMsg = "Radegast has encoutered an unrecoverable errror." + Environment.NewLine + - "Would you like to send the error report to help improve Radegast?"; + if (System.Diagnostics.Debugger.IsAttached){ throw; } - var res = MessageBox.Show(dlgMsg, "Unrecoverable error", MessageBoxButtons.YesNo, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); + string errMsg = "Unhandled " + ex + ": " + + ex.Message + Environment.NewLine + + ex.StackTrace + Environment.NewLine; - if (res == DialogResult.Yes) - { - var reporter = new ErrorReporter("http://api.radegast.org/svc/error_report"); - reporter.SendExceptionReport(e); - } + OpenMetaverse.Logger.Log(errMsg, OpenMetaverse.Helpers.LogLevel.Error); + + s_BugSplat?.Post(ex); - Environment.Exit(1); - } + Environment.Exit(1); } } } diff --git a/Radegast/Properties/AssemblyInfo.cs b/Radegast/Properties/AssemblyInfo.cs deleted file mode 100644 index 091155b5c..000000000 --- a/Radegast/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,63 +0,0 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2013, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Radegast")] -[assembly: AssemblyDescription("Radegast - http://radegast.org/")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Radegast Development Team")] -[assembly: AssemblyProduct("Radegast Metaverse Client")] -[assembly: AssemblyCopyright("Copyright (c) 2009-2015, Radegast Development Team")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("9b31339a-b5e3-47ad-b6a3-0be444974cf2")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -[assembly: AssemblyVersion(Radegast.RadegastBuild.VersionString + ".*")] -[assembly: AssemblyFileVersion(Radegast.RadegastBuild.VersionString + ".0")] diff --git a/Radegast/Properties/Resources.Designer.cs b/Radegast/Properties/Resources.Designer.cs index 819ed013f..4feeea3da 100644 --- a/Radegast/Properties/Resources.Designer.cs +++ b/Radegast/Properties/Resources.Designer.cs @@ -19,7 +19,7 @@ namespace Radegast.Properties { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { @@ -905,9 +905,9 @@ internal static System.Drawing.Icon radegast_icon { /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// - internal static System.Drawing.Bitmap radegast_large { + internal static System.Drawing.Bitmap radegast_logo { get { - object obj = ResourceManager.GetObject("radegast_large", resourceCulture); + object obj = ResourceManager.GetObject("radegast_logo", resourceCulture); return ((System.Drawing.Bitmap)(obj)); } } @@ -932,7 +932,7 @@ internal static string RadegastAuthor { } /// - /// Looks up a localized string similar to Radegast. + /// Looks up a localized string similar to Radegast-ng. /// internal static string RadegastTitle { get { @@ -1039,14 +1039,5 @@ internal static System.Drawing.Bitmap target_map_pos { return ((System.Drawing.Bitmap)(obj)); } } - - /// - /// Looks up a localized string similar to http://update.radegast.org/svc/get_latest. - /// - internal static string UpdateCheckUri { - get { - return ResourceManager.GetString("UpdateCheckUri", resourceCulture); - } - } } } diff --git a/Radegast/Properties/Resources.resx b/Radegast/Properties/Resources.resx index 2eedde3f3..2effa8f93 100644 --- a/Radegast/Properties/Resources.resx +++ b/Radegast/Properties/Resources.resx @@ -166,9 +166,6 @@ ../Resources/inv_item_skin.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ../Resources/radegast_large.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - ../Resources/inv_folder_sound.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -182,7 +179,7 @@ ../Resources/inv_folder_animation.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - Radegast + Radegast-ng ../Resources/inv_folder_plain_closed.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -292,9 +289,6 @@ ../Resources/client_signatures.txt;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 - - http://update.radegast.org/svc/get_latest - ../Resources/delete_16.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -406,4 +400,7 @@ ../Resources/inv_folder_sys.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\radegast.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/Radegast/Radegast.csproj b/Radegast/Radegast.csproj new file mode 100644 index 000000000..2dba0c1ac --- /dev/null +++ b/Radegast/Radegast.csproj @@ -0,0 +1,2045 @@ + + + WinExe + net48 + Radegast-ng + true + true + false + true + AnyCPU;x64;x86 + ..\bin\$(Configuration)\ + + + full + TRACE;DEBUG + + + portable + TRACE + + + radegast.ico + + + TRACE + true + portable + MinimumRecommendedRules.ruleset + true + + + TRACE + true + portable + MinimumRecommendedRules.ruleset + true + + + TRACE + true + portable + MinimumRecommendedRules.ruleset + true + + + + + + Radegast.MainProgram + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + MapControl.cs + Dependency + + + + MapControl.cs + DesignerType + + + + + + + + + + AnimDetail.cs + Dependency + + + + AnimDetail.cs + DesignerType + + + AnimTab.cs + Dependency + + + + AnimTab.cs + DesignerType + + + Gesture.cs + Dependency + + + + Gesture.cs + DesignerType + + + Landmark.cs + Dependency + + + + Landmark.cs + DesignerType + + + Notecard.cs + Dependency + + + + Notecard.cs + DesignerType + + + SLImageHandler.cs + Dependency + + + + SLImageHandler.cs + DesignerType + + + ScriptEditor.cs + Dependency + + + + ScriptEditor.cs + DesignerType + + + AttachmentDetail.cs + Dependency + + + + AttachmentDetail.cs + DesignerType + + + AttachmentTab.cs + Dependency + + + + AttachmentTab.cs + DesignerType + + + AvatarPicker.cs + Dependency + + + + AvatarPicker.cs + DesignerType + + + ChatConsole.cs + Dependency + + + + ChatConsole.cs + DesignerType + + + ConferenceIMTabWindow.cs + Dependency + + + + ConferenceIMTabWindow.cs + DesignerType + + + DebugConsole.cs + Dependency + + + + DebugConsole.cs + DesignerType + + + ExportCollada.cs + Dependency + + + + ExportCollada.cs + DesignerType + + + ExportConsole.cs + Dependency + + + + ExportConsole.cs + DesignerType + + + FindPeopleConsole.cs + Dependency + + + + FindPeopleConsole.cs + DesignerType + + + FriendsConsole.cs + Dependency + + + + FriendsConsole.cs + DesignerType + + + GroupDetails.cs + Dependency + + + + GroupDetails.cs + DesignerType + + + GroupIMTabWindow.cs + Dependency + + + + GroupIMTabWindow.cs + DesignerType + + + GroupsConsole.cs + Dependency + + + + GroupsConsole.cs + DesignerType + + + IMTabWindow.cs + Dependency + + + + IMTabWindow.cs + DesignerType + + + ImageUploadConsole.cs + Dependency + + + + ImageUploadConsole.cs + DesignerType + + + ImportConsole.cs + Dependency + + + + ImportConsole.cs + DesignerType + + + InventoryBackup.cs + Dependency + + + + InventoryBackup.cs + DesignerType + + + InventoryConsole.cs + Dependency + + + + InventoryConsole.cs + DesignerType + + + LoginConsole.cs + Dependency + + + + LoginConsole.cs + DesignerType + + + MapConsole.cs + Dependency + + + + MapConsole.cs + DesignerType + + + MasterTab.cs + Dependency + + + + MasterTab.cs + DesignerType + + + MediaConsole.cs + Dependency + + + + MediaConsole.cs + DesignerType + + + MeshUploadConsole.cs + Dependency + + + + MeshUploadConsole.cs + DesignerType + + + MuteList.cs + Dependency + + + + MuteList.cs + DesignerType + + + ObjectsConsole.cs + Dependency + + + + ObjectsConsole.cs + DesignerType + + + OutfitTextures.cs + Dependency + + + + OutfitTextures.cs + DesignerType + + + PluginsTab.cs + Dependency + + + + PluginsTab.cs + DesignerType + + + RegionInfo.cs + Dependency + + + + RegionInfo.cs + DesignerType + + + SearchConsole.cs + Dependency + + + + SearchConsole.cs + DesignerType + + + TabsConsole.cs + Dependency + + + + TabsConsole.cs + DesignerType + + + VoiceConsole.cs + Dependency + + + + VoiceConsole.cs + DesignerType + + + About.cs + Dependency + + + + About.cs + DesignerType + + + BanGroupMember.cs + Dependency + + + + BanGroupMember.cs + DesignerType + + + DetachedTab.cs + Dependency + + + + DetachedTab.cs + DesignerType + + + DisplayNameChange.cs + Dependency + + + + DisplayNameChange.cs + DesignerType + + + GroupInfo.cs + Dependency + + + + GroupInfo.cs + DesignerType + + + GroupInvite.cs + Dependency + + + + GroupInvite.cs + DesignerType + + + + HoverHeight.cs + + + KeyboardShortcuts.cs + Dependency + + + + HoverHeight.cs + + + KeyboardShortcuts.cs + DesignerType + + + MainForm.cs + Dependency + + + + MainForm.cs + DesignerType + + + MuteResident.cs + Dependency + + + + MuteResident.cs + DesignerType + + + Pay.cs + Dependency + + + + Pay.cs + DesignerType + + + Profile.cs + Dependency + + + + Profile.cs + DesignerType + + + Reconnect.cs + Dependency + + + + Reconnect.cs + DesignerType + + + Settings.cs + Dependency + + + + Settings.cs + DesignerType + + + + FriendshipOfferNotification.cs + Dependency + + + + FriendshipOfferNotification.cs + DesignerType + + + GenericNotification.cs + Dependency + + + + GenericNotification.cs + DesignerType + + + GroupInvitationNotification.cs + Dependency + + + + GroupInvitationNotification.cs + DesignerType + + + GroupNoticeNotification.cs + Dependency + + + + GroupNoticeNotification.cs + DesignerType + + + InventoryOfferNotification.cs + Dependency + + + + InventoryOfferNotification.cs + DesignerType + + + LoadURLNotification.cs + Dependency + + + + LoadURLNotification.cs + DesignerType + + + + PermissionsNotification.cs + Dependency + + + + PermissionsNotification.cs + DesignerType + + + RequestLureNotification.cs + Dependency + + + + RequestLureNotification.cs + DesignerType + + + ScriptDialog.cs + Dependency + + + + ScriptDialog.cs + DesignerType + + + SendLureOffer.cs + Dependency + + + + SendLureOffer.cs + DesignerType + + + SendLureRequest.cs + Dependency + + + + SendLureRequest.cs + DesignerType + + + TeleportNotification.cs + Dependency + + + + TeleportNotification.cs + DesignerType + + + + GraphicsPreferences.cs + Dependency + + + + GraphicsPreferences.cs + DesignerType + + + PrimWorkshop.cs + Dependency + + + + PrimWorkshop.cs + DesignerType + + + Rendering.cs + Dependency + + + + Rendering.cs + DesignerType + + + + True + Resources.resx + True + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Radegast/Radegast.exe.config b/Radegast/Radegast.exe.config deleted file mode 100644 index 267e2a82c..000000000 --- a/Radegast/Radegast.exe.config +++ /dev/null @@ -1,25 +0,0 @@ - - - - -
- - - - - - - - - - - - - - - - - - - - diff --git a/Radegast/RadegastBuild.cs b/Radegast/RadegastBuild.cs deleted file mode 100644 index d3a74b543..000000000 --- a/Radegast/RadegastBuild.cs +++ /dev/null @@ -1,9 +0,0 @@ -// Placeholder for automated build systems to implement their build number. -namespace Radegast -{ - public static class RadegastBuild - { - public const string VersionString = "2.19.0"; - public const string BuildName = "Homebrew"; - } -} diff --git a/Radegast/Resources/radegast-main screen2.jpg b/Radegast/Resources/radegast-main screen2.jpg index 4fec805be..4a69d9808 100644 Binary files a/Radegast/Resources/radegast-main screen2.jpg and b/Radegast/Resources/radegast-main screen2.jpg differ diff --git a/Radegast/Resources/radegast.png b/Radegast/Resources/radegast.png new file mode 100644 index 000000000..0b450b91f Binary files /dev/null and b/Radegast/Resources/radegast.png differ diff --git a/Radegast/Resources/radegast_icon.ico b/Radegast/Resources/radegast_icon.ico index f1282c694..80e2e85a5 100644 Binary files a/Radegast/Resources/radegast_icon.ico and b/Radegast/Resources/radegast_icon.ico differ diff --git a/Radegast/Resources/radegast_large.png b/Radegast/Resources/radegast_large.png deleted file mode 100644 index b6d5ede94..000000000 Binary files a/Radegast/Resources/radegast_large.png and /dev/null differ diff --git a/Radegast/app.config b/Radegast/app.config new file mode 100644 index 000000000..db68e1822 --- /dev/null +++ b/Radegast/app.config @@ -0,0 +1,34 @@ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Radegast/assemblies/CommandLine.dll b/Radegast/assemblies/CommandLine.dll deleted file mode 100644 index f88b092d4..000000000 Binary files a/Radegast/assemblies/CommandLine.dll and /dev/null differ diff --git a/Radegast/assemblies/OpenTK.GLControl.dll b/Radegast/assemblies/OpenTK.GLControl.dll deleted file mode 100644 index 8fad65c90..000000000 Binary files a/Radegast/assemblies/OpenTK.GLControl.dll and /dev/null differ diff --git a/Radegast/assemblies/OpenTK.dll b/Radegast/assemblies/OpenTK.dll deleted file mode 100644 index e792eef0f..000000000 Binary files a/Radegast/assemblies/OpenTK.dll and /dev/null differ diff --git a/Radegast/assemblies/PrimMesher.dll b/Radegast/assemblies/PrimMesher.dll deleted file mode 100644 index c63db9384..000000000 Binary files a/Radegast/assemblies/PrimMesher.dll and /dev/null differ diff --git a/Radegast/assemblies/Tools.dll b/Radegast/assemblies/Tools.dll deleted file mode 100644 index 08dcf42fd..000000000 Binary files a/Radegast/assemblies/Tools.dll and /dev/null differ diff --git a/Radegast/assemblies/XMLRPC.dll b/Radegast/assemblies/XMLRPC.dll deleted file mode 100644 index b4c0bcc36..000000000 Binary files a/Radegast/assemblies/XMLRPC.dll and /dev/null differ diff --git a/Radegast/assemblies/fmod.dll.config b/Radegast/assemblies/fmod.dll.config new file mode 100644 index 000000000..4389dca56 --- /dev/null +++ b/Radegast/assemblies/fmod.dll.config @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/Radegast/assemblies/fmodex-dotnet.dll b/Radegast/assemblies/fmodex-dotnet.dll deleted file mode 100644 index 9c4327017..000000000 Binary files a/Radegast/assemblies/fmodex-dotnet.dll and /dev/null differ diff --git a/Radegast/assemblies/libfmod.dylib b/Radegast/assemblies/libfmod.dylib new file mode 100644 index 000000000..e0f86eee5 Binary files /dev/null and b/Radegast/assemblies/libfmod.dylib differ diff --git a/Radegast/assemblies/libfmod.so b/Radegast/assemblies/libfmod.so new file mode 120000 index 000000000..e69de29bb diff --git a/Radegast/assemblies/libfmod.so.12 b/Radegast/assemblies/libfmod.so.12 new file mode 100644 index 000000000..e69de29bb diff --git a/Radegast/assemblies/libfmod.so.12.10 b/Radegast/assemblies/libfmod.so.12.10 new file mode 100644 index 000000000..389629211 Binary files /dev/null and b/Radegast/assemblies/libfmod.so.12.10 differ diff --git a/Radegast/assemblies/log4net.dll b/Radegast/assemblies/log4net.dll deleted file mode 100644 index ffc57e112..000000000 Binary files a/Radegast/assemblies/log4net.dll and /dev/null differ diff --git a/Radegast/assemblies/x64/UniversalSpeech.dll b/Radegast/assemblies/x64/UniversalSpeech.dll new file mode 100644 index 000000000..e9e3f99b9 Binary files /dev/null and b/Radegast/assemblies/x64/UniversalSpeech.dll differ diff --git a/Radegast/assemblies/x64/fmod.dll b/Radegast/assemblies/x64/fmod.dll new file mode 100644 index 000000000..157729a44 Binary files /dev/null and b/Radegast/assemblies/x64/fmod.dll differ diff --git a/Radegast/assemblies/x64/nvdacontrollerClient64.dll b/Radegast/assemblies/x64/nvdacontrollerClient64.dll new file mode 100644 index 000000000..6b4fff788 Binary files /dev/null and b/Radegast/assemblies/x64/nvdacontrollerClient64.dll differ diff --git a/Radegast/assemblies/x86/UniversalSpeech.dll b/Radegast/assemblies/x86/UniversalSpeech.dll new file mode 100644 index 000000000..497761520 Binary files /dev/null and b/Radegast/assemblies/x86/UniversalSpeech.dll differ diff --git a/Radegast/assemblies/x86/fmod.dll b/Radegast/assemblies/x86/fmod.dll new file mode 100644 index 000000000..a12d6c58b Binary files /dev/null and b/Radegast/assemblies/x86/fmod.dll differ diff --git a/Radegast/assemblies/x86/nvdacontrollerClient32.dll b/Radegast/assemblies/x86/nvdacontrollerClient32.dll new file mode 100644 index 000000000..1d061b18c Binary files /dev/null and b/Radegast/assemblies/x86/nvdacontrollerClient32.dll differ diff --git a/Radegast/assemblies/zlib.net.dll b/Radegast/assemblies/zlib.net.dll deleted file mode 100755 index 9d156547f..000000000 Binary files a/Radegast/assemblies/zlib.net.dll and /dev/null differ diff --git a/Radegast/character/avatar_hair.llm b/Radegast/character/avatar_hair.llm index df99de8db..0ef53828d 100644 Binary files a/Radegast/character/avatar_hair.llm and b/Radegast/character/avatar_hair.llm differ diff --git a/Radegast/character/avatar_hair_1.llm b/Radegast/character/avatar_hair_1.llm index 6de31fdc2..f36203163 100644 Binary files a/Radegast/character/avatar_hair_1.llm and b/Radegast/character/avatar_hair_1.llm differ diff --git a/Radegast/character/avatar_hair_2.llm b/Radegast/character/avatar_hair_2.llm index 47d02ba9c..01b1305dd 100644 Binary files a/Radegast/character/avatar_hair_2.llm and b/Radegast/character/avatar_hair_2.llm differ diff --git a/Radegast/character/avatar_hair_3.llm b/Radegast/character/avatar_hair_3.llm index 107f9e2a5..ee8e65f69 100644 Binary files a/Radegast/character/avatar_hair_3.llm and b/Radegast/character/avatar_hair_3.llm differ diff --git a/Radegast/character/avatar_hair_4.llm b/Radegast/character/avatar_hair_4.llm index 1b9a12a0c..c9bf9e8f2 100644 Binary files a/Radegast/character/avatar_hair_4.llm and b/Radegast/character/avatar_hair_4.llm differ diff --git a/Radegast/character/avatar_hair_5.llm b/Radegast/character/avatar_hair_5.llm index 1b9a12a0c..c9bf9e8f2 100644 Binary files a/Radegast/character/avatar_hair_5.llm and b/Radegast/character/avatar_hair_5.llm differ diff --git a/Radegast/character/avatar_head.llm b/Radegast/character/avatar_head.llm index 8d8b5e044..f3a04b058 100644 Binary files a/Radegast/character/avatar_head.llm and b/Radegast/character/avatar_head.llm differ diff --git a/Radegast/character/avatar_head_1.llm b/Radegast/character/avatar_head_1.llm index 26291e658..f0c98f6ad 100644 Binary files a/Radegast/character/avatar_head_1.llm and b/Radegast/character/avatar_head_1.llm differ diff --git a/Radegast/character/avatar_head_2.llm b/Radegast/character/avatar_head_2.llm index c2b808b1a..af21c3246 100644 Binary files a/Radegast/character/avatar_head_2.llm and b/Radegast/character/avatar_head_2.llm differ diff --git a/Radegast/character/avatar_head_3.llm b/Radegast/character/avatar_head_3.llm index a0676b1f1..0244666a0 100644 Binary files a/Radegast/character/avatar_head_3.llm and b/Radegast/character/avatar_head_3.llm differ diff --git a/Radegast/character/avatar_head_4.llm b/Radegast/character/avatar_head_4.llm index 503558577..e8f6832d3 100644 Binary files a/Radegast/character/avatar_head_4.llm and b/Radegast/character/avatar_head_4.llm differ diff --git a/Radegast/character/avatar_lad.xml b/Radegast/character/avatar_lad.xml index 87cba7c52..2cdd86267 100644 --- a/Radegast/character/avatar_lad.xml +++ b/Radegast/character/avatar_lad.xml @@ -1,6 +1,6 @@ + version="2.0" wearable_definition_version="22"> @@ -21,6 +22,7 @@ pie_slice="2" name="Skull" joint="mHead" + location="ATTACH_HEAD" position="0 0 0.15" rotation="0 0 90" visible_in_first_person="false" /> @@ -31,6 +33,7 @@ pie_slice="3" name="Left Shoulder" joint="mCollarLeft" + location="ATTACH_LSHOULDER" position="0 0 0.08" rotation="0 0 0" visible_in_first_person="true" /> @@ -41,6 +44,7 @@ pie_slice="1" name="Right Shoulder" joint="mCollarRight" + location="ATTACH_RSHOULDER" position="0 0 0.08" rotation="0 0 0" visible_in_first_person="true"/> @@ -50,6 +54,7 @@ group="4" name="Left Hand" joint="mWristLeft" + location="ATTACH_LHAND" position="0 0.08 -0.02" rotation="0 0 0" visible_in_first_person="true" @@ -60,6 +65,7 @@ group="0" name="Right Hand" joint="mWristRight" + location="ATTACH_RHAND" position="0 -0.08 -0.02" rotation="0 0 0" visible_in_first_person="true" @@ -71,6 +77,7 @@ pie_slice="6" name="Left Foot" joint="mFootLeft" + location="ATTACH_LFOOT" position="0 0.0 0.0" rotation="0 0 0" visible_in_first_person="true"/> @@ -81,6 +88,7 @@ pie_slice="6" name="Right Foot" joint="mFootRight" + location="ATTACH_RFOOT" position="0 0.0 0.0" rotation="0 0 0" visible_in_first_person="true"/> @@ -91,6 +99,7 @@ pie_slice="7" name="Spine" joint="mChest" + location="ATTACH_BACK" position="-0.15 0 -0.1" rotation="0 -90 90" visible_in_first_person="true" /> @@ -101,6 +110,7 @@ pie_slice="6" name="Pelvis" joint="mPelvis" + location="ATTACH_PELVIS" position="0 0 -0.15" rotation="0 0 0" visible_in_first_person="true" /> @@ -111,6 +121,7 @@ pie_slice="6" name="Mouth" joint="mHead" + location="ATTACH_MOUTH" position="0.12 0 0.001" rotation="0 0 0" visible_in_first_person="false"/> @@ -121,6 +132,7 @@ pie_slice="7" name="Chin" joint="mHead" + location="ATTACH_CHIN" position="0.12 0 -0.04" rotation="0 0 0" visible_in_first_person="false" /> @@ -131,6 +143,7 @@ pie_slice="4" name="Left Ear" joint="mHead" + location="ATTACH_LEAR" position="0.015 0.08 0.017" rotation="0 0 0" visible_in_first_person="false" /> @@ -141,6 +154,7 @@ pie_slice="0" name="Right Ear" joint="mHead" + location="ATTACH_REAR" position="0.015 -0.08 0.017" rotation="0 0 0" visible_in_first_person="false" /> @@ -151,6 +165,7 @@ pie_slice="3" name="Left Eyeball" joint="mEyeLeft" + location="ATTACH_LEYE" position="0 0 0" rotation="0 0 0" visible_in_first_person="false"/> @@ -161,6 +176,7 @@ pie_slice="1" name="Right Eyeball" joint="mEyeRight" + location="ATTACH_REYE" position="0 0 0" rotation="0 0 0" visible_in_first_person="false" /> @@ -171,6 +187,7 @@ pie_slice="5" name="Nose" joint="mHead" + location="ATTACH_NOSE" position="0.1 0 0.05" rotation="0 0 0" visible_in_first_person="false"/> @@ -181,6 +198,7 @@ pie_slice="0" name="R Upper Arm" joint="mShoulderRight" + location="ATTACH_RUARM" position="0.01 -0.13 0.01" rotation="0 0 0" visible_in_first_person="true" /> @@ -191,6 +209,7 @@ pie_slice="7" name="R Forearm" joint="mElbowRight" + location="ATTACH_RLARM" position="0 -0.12 0" rotation="0 0 0" visible_in_first_person="true"/> @@ -201,6 +220,7 @@ pie_slice="4" name="L Upper Arm" joint="mShoulderLeft" + location="ATTACH_LUARM" position="0.01 0.15 -0.01" rotation="0 0 0" visible_in_first_person="true" /> @@ -211,6 +231,7 @@ pie_slice="5" name="L Forearm" joint="mElbowLeft" + location="ATTACH_LLARM" position="0 0.113 0" rotation="0 0 0" visible_in_first_person="true" /> @@ -221,6 +242,7 @@ pie_slice="1" name="Right Hip" joint="mHipRight" + location="ATTACH_RHIP" position="0 0 0" rotation="0 0 0" visible_in_first_person="true" /> @@ -231,6 +253,7 @@ pie_slice="0" name="R Upper Leg" joint="mHipRight" + location="ATTACH_RULEG" position="-0.017 0.041 -0.310" rotation="0 0 0" visible_in_first_person="true" /> @@ -241,6 +264,7 @@ pie_slice="7" name="R Lower Leg" joint="mKneeRight" + location="ATTACH_RLLEG" position="-0.044 -0.007 -0.262" rotation="0 0 0" visible_in_first_person="true" /> @@ -251,6 +275,7 @@ pie_slice="3" name="Left Hip" joint="mHipLeft" + location="ATTACH_LHIP" position="0 0 0" rotation="0 0 0" visible_in_first_person="true" /> @@ -261,6 +286,7 @@ pie_slice="4" name="L Upper Leg" joint="mHipLeft" + location="ATTACH_LULEG" position="-0.019 -0.034 -0.310" rotation="0 0 0" visible_in_first_person="true"/> @@ -271,6 +297,7 @@ pie_slice="5" name="L Lower Leg" joint="mKneeLeft" + location="ATTACH_LLLEG" position="-0.044 -0.007 -0.261" rotation="0 0 0" visible_in_first_person="true" /> @@ -281,6 +308,7 @@ pie_slice="5" name="Stomach" joint="mPelvis" + location="ATTACH_BELLY" position="0.092 0.0 0.088" rotation="0 0 0" visible_in_first_person="true" /> @@ -291,6 +319,7 @@ pie_slice="3" name="Left Pec" joint="mTorso" + location="ATTACH_LEFT_PEC" position="0.104 0.082 0.247" rotation="0 0 0" visible_in_first_person="true" /> @@ -301,15 +330,17 @@ pie_slice="1" name="Right Pec" joint="mTorso" + location="ATTACH_RIGHT_PEC" position="0.104 -0.082 0.247" rotation="0 0 0" visible_in_first_person="true" /> - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + name="mSpine3" + scale="0 0 .05" /> + + + + + + + + + + + + + + + + + @@ -533,8 +769,12 @@ scale="0 0 0.05" /> + name="mSpine3" + scale="0 0 0.05" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -605,10 +935,26 @@ name="mTorso" scale="0.1 0.1 0" /> + + + + + + + + @@ -624,6 +970,37 @@ + + + + + + + + + + + + + + + + + + + + + @@ -631,7 +1008,7 @@ id="36" group="0" name="Shoulders" - label="Shoulders" + label="Shoulders" wearable="shape" edit_group="shape_torso" edit_group_order="4" @@ -662,6 +1039,17 @@ + + + + + @@ -669,7 +1057,7 @@ id="37" group="0" name="Hip Width" - label="Hip Width" + label="Hip Width" wearable="shape" edit_group="shape_legs" edit_group_order="3" @@ -684,6 +1072,14 @@ name="mPelvis" scale="0 0.1 0" /> + + + + + + + + + + + + + + + @@ -712,7 +1127,19 @@ - + + + + + + + + + + + + + + + @@ -751,6 +1194,26 @@ + + + + + + + + + + @@ -774,6 +1237,78 @@ name="mEyeRight" scale="0 0 0" offset="0 -.009 0" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -797,19 +1332,169 @@ name="mEyeRight" scale="0 0 0" offset="0 0 -.004" /> - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -850,7 +1610,7 @@ id="655" group="1" name="Head Size" - label="Head Size" + label="Head Size" wearable="shape" edit_group="shape_head" label_min="Small Head" @@ -859,6 +1619,36 @@ value_min="-.25" value_max=".10"> + + + + + + + + + + + + + + - - - - - + + name="mFaceEyeAltLeft" + scale="1 1 1" + offset="0 0 -0.001" /> - - - - - + name="mFaceEyeAltRight" + scale="1 1 1" + offset="0 0 -0.001" /> + + name="mFaceForeheadLeft" + scale="1 1 1" + offset="0 0 0" /> - - + name="mFaceForeheadCenter" + scale="1 1 1" + offset="0 0 0" /> - - - - - - - - - - + name="mFaceEyebrowInnerLeft" + scale="1 1 1" + offset="0 0 0" /> - - - - + name="mFaceEyebrowOuterRight" + scale="1 1 1" + offset="0 0 0" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + name="mFootRight" + scale="0 0 0" + offset="0 0 -.08" /> + name="mFootLeft" + scale="0 0 0" + offset="0 0 -.08" /> + name="mHindLimb4Left" + scale="0 0 0" + offset="0 0 -.08" /> + name="mHindLimb4Right" + scale="0 0 0" + offset="0 0 -.08" /> + + + + + + + + + + + + + + + edit_group_order="10" + label_min="Small Hands" + label_max="Large Hands" + value_min="-.3" + value_max=".3" + camera_elevation=".1" + camera_distance="1.4" + camera_angle="0"> + name="mWristRight" + scale="1 1 1" + offset="0 0 0" /> + name="mWristLeft" + scale="1 1 1" + offset="0 0 0" /> - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + scale="1 1 0" + offset="0 0 0" /> - - - - - - - - - - - - + value_max="1"> + + + + + + + + + + + + + + + + + + + + + + + + - + camera_distance="2.5"> + + + + + + + + + + + + + + + + + - + value_default=".6" + camera_distance="1.5"> + + + + + + + + + - + value_default="0" + camera_elevation=".3" + camera_distance=".8" + camera_angle="15"> + + + - + - + value_default="0" + camera_distance="2.5"> + - + - - + id="30002" + group="1" + name="Nose_Big_Out" + value_min="-0.8" + value_max="2.5"> + + + + + + + + - + id="30004" + group="1" + name="Broad_Nostrils" + value_min="-.5" + value_max="1"> + + + + - + - - + > + + + + + + + - + name="Wide_Nose" + value_min="-.5" + value_max="1"> + + + + + - - + name="Crooked_Nose" + value_min="-2" + value_max="2"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + name="Lip Width" + value_min="-0.9" + value_max="1.3" + value_default="0"> + + + + + + + + + + + + + + - - + name="Tall_Lips" + value_min="-1" + value_max="2"> + + + + + + + + + + + + + + + + + + + - - + value_max="0.7"> + + + + + + + + + + + + + + + + + + + + - - + value_max="1"> + + + + + + + + + + + + + + + + + + + + - + value_max="1.5"> + + + + + + + + + + + + + + + + + + + - + value_max="1.5"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + value_max="1.4"> + + - - - + + + + + - - + + + + + + + + - - + value_max="1.4"> + + + - - - + + + + + - - - + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + value_max="2"> + + + + + + + + + + + + + + + + - - + value_max="2"> + + - - - + + + + + + + + + + + + + - + name="Big_Ears" + value_min="-1" + value_max="2"> + + + + - + - + value_max="1.5"> + + + + + + + + + + + + - + - + + + + - - + + + + - + - - - - - + name="Jaw_Angle" + value_min="-1.2" + value_max="2" + value_default="0"> + + + - + + - - + - - - + - - - + - - + - + - - - - - + value_max="1.5"> + + + + - + - + name="Weak_Chin" + value_min="-.5" + value_max=".5"> + + + + + + + + + + + + + + + + + - + + - - + name="Wide_Eyes" + value_min="-1.5" + value_max="2"> + + + + + + + + + + + + + + + + - - + name="Eyelid_Corner_Up" + value_min="-1.3" + value_max="1.2"> + + + + + + - - + name="Eyelid_Inner_Corner_Up" + value_min="-1.3" + value_max="1.2"> + + + + + + - + name="Puffy_Lower_Lids" + value_min="-.3" + value_max="2.5"> + + + + + + + + + + + - - + + + + + + + + + + - - + - - + - - + - - + - - + + + + + + + + + + + + + - - + - - + + + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + id="32629" + group="1" + name="Forehead Angle" + value_min="0" + value_max="1"> + + + + + + + + + + + + + + + + + - + id="42629" + group="1" + name="Forehead Angle" + value_min="0" + value_max="1"> + + + + + + + + + + + + + + + + + - - + id="30001" + group="1" + name="Big_Brow" + value_min="-.3" + value_max="2"> + + + + + + + + + + + + + + + + + + - + value_max="1.5"> + + + + + + + - + id="30758" + group="1" + name="Lower_Bridge_Nose" + value_min="-1.5" + value_max="1.5"> + + + + + + + - - + id="30027" + group="1" + name="Wide_Nose_Bridge" + value_min="-1.3" + value_max="1.2"> + + + + + + - - - - - - + value_default="0.5"> + + + + + + + + - + value_max="3"> + + + + + + - - + id="30017" + group="1" + name="Square_Jaw" + value_min="-0.5" + value_max="1"> + + + + + + + + + + + + + + + + + + + + + - - + value_max="2.5"> + - - - + + + + + + - + id="30021" + group="1" + name="Upper_Eyelid_Fold" + value_min="-0.2" + value_max="1.3"> + + + + + + + - + value_max="1.5"> + + + + + + + - - + value_max="1"> + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + value_default="0"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + id="30689" + group="1" + name="EyeBone_Big_Eyes" + value_min="-1.1" + value_max="1.1"> + + + + + + + + + + + + - + id="30772" + group="1" + name="EyeBone_Head_Elongate" + value_min="-1" + value_max="1"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + value_default="0.5"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + value_max="3"> + + + + + + + + + + + + + + + + + + + + + camera_distance=".5" + camera_angle="20"> + camera_distance=".5" + camera_angle="20"> + camera_distance=".5" + camera_angle="90"> + camera_distance=".5" + camera_angle="90"> + + + + + camera_distance=".5" + camera_angle="20"> + name="Hair_Part_Middle" + label="Middle Part" + wearable="hair" + edit_group="hair_style" + edit_group_order="17" + label_min="No Part" + label_max="Part" + value_min="0" + value_max="2" + camera_elevation=".1" + camera_distance=".5" + camera_angle="0"> + name="Hair_Part_Right" + label="Right Part" + wearable="hair" + edit_group="hair_style" + edit_group_order="18" + label_min="No Part" + label_max="Part" + value_min="0" + value_max="2" + camera_elevation=".1" + camera_distance=".5" + camera_angle="0"> + value_max="2" + camera_elevation=".1" + camera_distance=".5" + camera_angle="0"> + camera_distance=".5" + camera_angle="20"> + value_max="1" + camera_elevation=".1" + camera_distance=".5" + camera_angle="20"> + clothing_morph="true" + name="Bangs_Front_Down" + label="Front Bangs Down" + wearable="hair" + edit_group="hair_style" + label_min="Bangs" + label_max="Bangs Down" + value_min="0" + value_max="5" + camera_elevation=".1" + camera_distance=".5" + camera_angle="20"> + name="Bangs_Sides_Up" + label="Side Bangs Up" + wearable="hair" + edit_group="hair_style" + label_min="Side Bangs" + label_max="Side Bangs Up" + value_min="0" + value_max="1" + camera_elevation=".1" + camera_distance=".5" + camera_angle="20"> - + value_max="2" + camera_elevation=".1" + camera_distance=".5" + camera_angle="20"> - + edit_group="hair_style" + label_min="Back Bangs" + label_max="Back Bangs Up" + value_min="0" + value_max="1" + camera_elevation=".1" + camera_distance=".5" + camera_angle="150"> + camera_distance=".5" + camera_angle="150"> + camera_distance=".5" + camera_angle="20"> + camera_distance=".5" + camera_angle="20"> - - - + + camera_angle="150"> + camera_angle="150"> + id="177" + group="0" + name="Hair_Rumpled" + label="Rumpled Hair" + show_simple="true" + wearable="hair" + clothing_morph="true" + edit_group="hair_style" + edit_group_order="14.5" + label_min="Smooth Hair" + label_max="Rumpled Hair" + value_min="0" + value_max="1" + camera_elevation=".1" + camera_distance=".5" + camera_angle="20"> - - - - + value_max="1" + camera_elevation=".1" + camera_distance=".5" + camera_angle="90"> - + camera_elevation=".1" + camera_distance=".5" + camera_angle="90"> + + value_max="1" + camera_elevation=".1" + camera_distance=".5" + camera_angle="0"> + value_max="1" + camera_elevation=".1" + camera_distance=".5" + camera_angle="0"> + camera_distance=".5" + camera_angle="0"> + id="640" + group="1" + name="Hair_Egg_Head" + wearable="hair" + edit_group="hair_style" + cross_wearable="true" + value_min="-1.3" + value_max="1"> - + id="641" + group="1" + name="Hair_Squash_Stretch_Head" + wearable="hair" + edit_group="hair_style" + cross_wearable="true" + value_min="-.5" + value_max="1"> + id="642" + group="1" + name="Hair_Square_Head" + wearable="hair" + edit_group="hair_style" + cross_wearable="true" + value_min="0" + value_max="1"> + value_max="1"> + value_max="1"> + value_max="1"> + name="Shear_Head_Hair" + wearable="hair" + edit_group="hair_style" + cross_wearable="true" + value_min="-2" + value_max="2"> + name="Elongate_Head_Hair" + wearable="hair" + edit_group="hair_style" + cross_wearable="true" + value_min="-1" + value_max="1"> - - - + camera_angle="100"> + + name="Hair_Shear_Front" + wearable="hair" + edit_group="hair_style" + edit_group_order="11.8" + label="Shear Front" + show_simple="true" + label_min="Full Front" + label_max="Sheared Front" + value_min="0" + value_max="3" + camera_elevation=".1" + camera_distance=".5" + camera_angle="30"> + camera_distance=".5" + camera_angle="160"> - - - - - - - - - - - - + camera_angle="20"> - - + + + + + + + + + + + + + + + + + + + + + name="Big_Brow" + value_min="-.3" + value_max="2"> + name="Nose_Big_Out" + value_min="-0.8" + value_max="2.5"> + name="Bulbous_Nose" + value_min="-.5" + value_max="1.5"> - + + name="Crooked_Nose" + value_min="-2" + value_max="2"> - + + name="Tall_Lips" + value_min="-1" + value_max="2"> - + + name="Mouth_Height" + value_min="-2" + value_max="2"> + + + + - + name="Wide_Lip_Cleft" + value_min="-.8" + value_max="1.5"> + - + + name="Shift_Mouth" + value_min="-2" + value_max="2" + value_default="0"> - + - + name="Big_Ears" + value_min="-1" + value_max="2"> + - + + name="Ears_Out" + value_min="-.5" + value_max="1.5"> + + + + - + - - - + + name="Jaw_Jut" + value_min="-2" + value_max="2"> - + + name="Wide_Eyes" + value_min="-1.5" + value_max="2"> - - + + name="Eyelid_Corner_Up" + value_min="-1.3" + value_max="1.2"> - + + name="Puffy_Lower_Lids" + value_min="-.3" + value_max="2.5"> - + name="Low_Septum_Nose" + value_min="-1" + value_max="1.5" + value_default="0.5"> + id="5" + group="0" + name="Cleft_Chin" + label="Chin Cleft" + wearable="shape" + edit_group="shape_chin" + edit_group_order="6" + label_min="Round" + label_max="Cleft" + value_min="-.1" + value_max="1" + camera_elevation="0" + camera_distance=".28" + camera_angle="-20"> + name="Weak_Chin" + value_min="-.5" + value_max=".5"> + name="Double_Chin" + value_min="-.5" + value_max="1.5"> + name="Sunken_Cheeks" + value_min="-1.5" + value_max="3"> + name="Noble_Nose_Bridge" + value_min="-.5" + value_max="1.5"> - - - - - - - - - - - - - - - - + name="Lower_Bridge_Nose" + value_min="-1.5" + value_max="1.5"> + edit_group="shape_chin" + edit_group_order="5" + label_min="Less" + label_max="More" + value_min="-.5" + value_max="2.5" + camera_elevation=".1" + camera_distance=".4" + camera_angle="0"> - - - - + id="20014" + group="1" + name="High_Cheek_Bones" + value_min="-.5" + value_max="1"> + + camera_distance=".3"> + value_max="1"> + name="Puffy_Upper_Cheeks" + value_min="-1.5" + value_max="2.5"> + id="20019" + group="1" + name="Upturned_Nose_Tip" + value_min="-1.5" + value_max="1"> - + + id="20021" + group="1" + name="Upper_Eyelid_Fold" + value_min="-0.2" + value_max="1.3"> - + camera_distance=".3" + camera_angle="45"> + name="Baggy_Eyes" + value_min="-.5" + value_max="1.5"> + name="Lips_Thin" + edit_group="driven" + value_min="0" + value_max=".7"> - + name="Wide_Nose_Bridge" + value_min="-1.3" + value_max="1.2"> + value_max="2"> + name="Wide_Upper_Lip" + wearable="shape" + edit_group="driven" + value_min="-.7" + value_max="1.3"> + name="Wide_Lower_Lip" + wearable="shape" + edit_group="driven" + value_min="-.7" + value_max="1.3"> + + + name="Lower_Eyebrows" + label="Eyebrow Height" + show_simple="true" + wearable="hair" + edit_group="hair_eyebrows" + edit_group_order="2.5" + label_min="Higher" + label_max="Lower" + value_min="-2" + value_max="2"> + name="Egg_Head" + label="Egg Head" + wearable="shape" + edit_group="shape_head" + label_min="Chin Heavy" + label_max="Forehead Heavy" + value_min="-1.3" + value_max="1" + camera_elevation=".1" + camera_distance=".5" + camera_angle="20"> - + name="Squash_Stretch_Head" + label="Squash/Stretch Head" + wearable="shape" + edit_group="shape_head" + label_min="Squash Head" + label_max="Stretch Head" + value_min="-.5" + value_max="1" + camera_elevation=".1" + camera_distance=".5" + camera_angle="20"> + + + + value_max=".7" + camera_elevation=".1" + camera_distance=".5" + camera_angle="20"> + value_max="1" + camera_elevation=".1" + camera_distance=".5" + camera_angle="20"> + name="Eye_Spread" + wearable="shape" + edit_group="shape_eyes" + label_min="Eyes Together" + label_max="Eyes Spread" + value_min="-2" + value_max="2"> + value_max="2"> - + value_max="1" + camera_elevation=".3"> + + + + + + value_max="1.4" + camera_distance=".3" + camera_elevation=".04"> + value_max="1.2" + camera_distance=".3" + camera_elevation=".04"> - + value_max="1.5" + camera_distance=".3" + camera_elevation=".04"> - + value_max="1.5" + camera_distance=".3" + camera_elevation=".04"> + name="Shear_Head" + wearable="shape" + label="Shear Face" + edit_group="shape_head" + label_min="Shear Left" + label_max="Shear Right" + value_min="-2" + value_max="2" + value_default="0" + camera_distance=".5" + camera_elevation=".04"> - - - - + label="Shear Face" + edit_group="shape_head" + label_min="Flat Head" + label_max="Long Head" + value_min="-1" + value_max="1" + value_default="0" + camera_distance=".5" + camera_elevation=".04"> + name="HEAD" + scale="0.02 0.0 0.0"/> + camera_distance=".35"> + name="Jaw_Angle" + value_min="-1.2" + value_max="2" + value_default="0"> + label="Eye Size" + edit_group="shape_eyes" + label_min="Beady Eyes" + label_max="Anime Eyes" + show_simple="true" + value_min="-2" + value_max="2" + value_default="0"> - - - - - - - - + label="Eye Depth" + edit_group="shape_eyes" + edit_group_order="4.5" + label_min="Sunken Eyes" + label_max="Bug Eyes" + value_min="-2" + value_max="2" + value_default="0"> + + + - - - - - - - - - - + value_max="1"> + - - - - - - - - - - + value_max="1"> + - - - - - - - - - - - - + value_max="1"> + + + + + id="304" + group="1" + name="Express_Embarrassed_Emote" + value_min="0" + value_max="1"> + value_max="1"> + value_max="1"> - - - + name="Express_Bored_Emote" + value_min="0" + value_max="1"> + + id="308" + group="1" + name="Express_Repulsed_Emote" + value_min="0" + value_max="1"> + id="309" + group="1" + name="Express_Disdain" + value_min="0" + value_max="1"> - - - - - - - - - - - - - + - + + + - - - - + ############## + # animatable morphs + ############## + --> + + + - - - - - - - - - - - - - - - + - - - + - - - - - - + value_max="1"> + - - - - - - + value_max="1"> + - - - - - - + + + + + + + + + + + + + + + + + + name="Shear_Head" + wearable="shape" + label="Shear Face" + edit_group="shape_head" + label_min="Shear Left" + label_max="Shear Right" + value_min="-2" + value_max="2" + value_default="0" + camera_distance=".5" + camera_elevation=".04"> + value_default="0" + camera_distance=".5" + camera_elevation=".04"> + value_default="0" + camera_distance=".5" + camera_elevation=".04" + camera_angle="-20"> + camera_elevation=".1" + camera_distance=".5" + camera_angle="20"> + camera_elevation=".1" + camera_distance=".5" + camera_angle="20"> + name="Eye_Spread" + edit_group="shape_eyes" + label_min="Eyes Together" + label_max="Eyes Spread" + value_min="-2" + value_max="2"> + id="518" + group="0" + name="Eyelashes_Long" + wearable="shape" + label="Eyelash Length" + edit_group="shape_eyes" + edit_group_order="7" + label_min="Short" + label_max="Long" + value_min="-.3" + value_max="1.5" + camera_elevation=".1" + camera_distance=".30" + camera_angle="-20"> + show_simple="true" + value_default="0"> - - - - + label="Eye Depth" + edit_group="shape_eyes" + edit_group_order="4.5" + label_min="Sunken Eyes" + label_max="Bug Eyes" + value_min="-2" + value_max="2" + value_default="0"> + + name="Upper_Eyelid_Fold" + value_min="-0.2" + value_max="1.3"> + shared="1" + id="20024" + group="1" + name="Wide_Eyes" + value_min="-1.5" + value_max="2"> + name="Eyelid_Corner_Up" + value_min="-1.3" + value_max="1.2"> + + + + + + value_max="1"> - - - - - - - + - - - - + name="Express_Wink_Emote" + value_min="0" + value_max="1"> + + shared="1" + id="304" + group="1" + name="Express_Embarrassed_Emote" + value_min="0" + value_max="1"> - - - - - - - - - - - - - - - - - - - - + name="Express_Kiss" + value_min="0" + value_max="1"> + name="Express_Bored_Emote" + value_min="0" + value_max="1"> - - - + name="Express_Repulsed_Emote" + value_min="0" + value_max="1"> + name="Express_Disdain" + value_min="0" + value_max="1"> - - - - + name="Express_Afraid_Emote" + value_min="0" + value_max="1"> + name="Express_Cry_Emote" + value_min="0" + value_max="1"> - - - + name="Express_Sad_Emote" + value_min="0" + value_max="1"> + name="Express_Anger_Emote" + value_min="0" + value_max="1"> - - + value_max="1"> + + value_max="1"> + + name="Blink_Left" + value_min="0" + value_max="1"> + + + + - + + + + - + name="Big_Chest" + label="Chest Size" + wearable="shape" + edit_group="shape_torso" + label_min="Small" + label_max="Large" + value_min="0" + value_max="1" + camera_elevation=".1" + camera_distance="1" + camera_angle="15"> + + + + - + camera_elevation="0" + camera_distance=".28"> + + + + - + name="No_Chest" + label="Chest Size" + wearable="shape" + edit_group="shape_torso" + label_min="Some" + label_max="None" + value_min="0" + value_max="1" + camera_elevation="0" + camera_distance=".28"> + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + value_max="1.4" + camera_elevation=".3" + camera_distance="1.2"> + + + + + + + + - - - + value_max="1.4" + camera_elevation=".3" + camera_distance="1.2"> + + + + + + + + - - - - - - - - - - - - - - - - - + value_max="1.3" + camera_elevation=".3" + camera_distance="1.2"> + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - + value_max="1.3" + camera_elevation=".3" + camera_distance="1.2"> + + + + + + + + + + + - - - - - + camera_elevation=".3"> + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + value_default="0"> + - - - - - - - - - - - - - - - - - + value_max="1.5" + camera_distance="1.8" + camera_angle="30" + camera_elevation="-.3"> + - - - - - - + value_min="-1" + value_max="2"> + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + - - + + + + - - + + + - - + + + - - + + + - - + + + - - + + + - - + + + - - + + + - - + + - - + value_max="1"> + + - - + + - - - - - - + + + - - - + + + - - - + + + + + + + - - + + + + + + - - - + + + + + - - + + + + + + - + - - - - + - - - + + - - - + + - - + + - - - + + - - - - + + + + + + - - + + + + + - - - + + + + + + + + + + + + + + - - - - - - + + + + + + + + - - - + + + + + + + + - - - - + + + - - + + + - - - + + + - - - - + + + - - - - - + + + - - - - - - - - + + + - - - + + + - - - + + + - - - - + + + + + + - - + + + - - - - - - - - - - - - - - - - - - - - - + wearable="pants" + edit_group="pants" + edit_group_order="3" + clothing_morph="true" + label_min="Tight Cuffs" + label_max="Flared Cuffs" + value_min="0" + value_max="1.5" + camera_distance="1.8" + camera_angle="30" + camera_elevation="-.3"> + + - + + + - + + + - - - - - + + + + + + + + + - + + + + - - - + - - - - + + + - - - - - + + + + - - - - + + + + - - - + + + + + + - + + + + + - + - + - + + - + + - + + - - - + + - - - - - - - - - - - - - - - + + + + + + + - + + + + - + + + + + - + + + + - + + + + + + - + + + + - + + + + + - + + + + - + + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + + - + + + + - + - + + - - - + + - - - + + - - - + + - - - - + + + + + - - - - - - + - + - + + + - + + + + + - + + + - + - + - + - + - + - + - + + + + - + + + + + - + - + - + - + - + - + - + - + - + - + + + - - - + + + - - - + + + - - - + + + - - - - + + + - - - - + + + - - - + - - + - - + - - + - - + - - + - - + + + + - - + + + + + + - - + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + name="hair texture alpha layer" + visibility_mask="TRUE"> + local_texture="hair_grain" /> + + + + + + - - + value_max="1" + value_default="1"> + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -6679,11 +8988,11 @@ render_pass="bump"> @@ -6700,31 +9009,34 @@ render_pass="bump"> - + + body_region="head" + width="512" + height="512"> + name="head bump base" + fixed_color = "128,128,128,255" + render_pass="bump"> + + + + tga_file="bump_head_base.tga" + file_is_mask="FALSE"/> name="base" global_color="skin_color"> + tga_file="head_skingrain.tga" /> + name="headcolor"> + tga_file="head_color.tga" /> @@ -6771,1065 +9083,958 @@ render_pass="bump"> + tga_file="head_highlights_alpha.tga" +file_is_mask="TRUE" /> + +color="255, 255, 255, 0" /> + - + name="rosyface"> - + tga_file="rosyface_alpha.tga" + file_is_mask="true" /> - - - - - - - - - + camera_distance=".3" + camera_elevation=".07"> + color="198, 71, 71, 0" /> + color="198, 71, 71, 255" /> + - - - - - - - + + + camera_distance=".25"> + color="220, 115, 115, 0" /> + color="220, 115, 115, 128" /> - - - - + fixed_color="0,0,0,100"> + wearable="skin" + name="Wrinkles" + value_min="0" + value_max="1"> + tga_file="bump_face_wrinkles.tga" + skip_if_zero="true" + domain="0.3" /> + + + + id="165" + group="0" + wearable="skin" + edit_group="skin_facedetail" + edit_group_order="2" + name="Freckles" + label_min="Less" + label_max="More" + value_min="0" + value_max="1" + camera_distance=".3" +camera_elevation=".07"> + tga_file="freckles_alpha.tga" + skip_if_zero="true" +domain="0.5" /> + + + + value_max="1"> + tga_file="eyebrows_alpha.tga" + domain="0.1" /> - + value_max="1"> + + + + + + name="eyebrows" + global_color="hair_color"> + tga_file="head_hair.tga" + file_is_mask="false" /> - + value_default="0.5"> + + + + + + color="255,255,255,0" /> + color="255,255,255,255" /> + + + value_default=".25" + camera_distance=".25"> + color="245,161,177,200" /> - - + color="216,37,67,200" /> - - + color="178,48,76,200" /> - - + color="68,0,11,200" /> - - - + - - + + + + + + + + + + + value_max=".9" + value_default="0.0" + camera_distance=".25"> + + + camera_distance=".25"> + tga_file="lipgloss_alpha.tga" + skip_if_zero="true" + domain="0.2" /> + name="blush"> + value_max=".9" + value_default="0" + camera_distance=".3" + camera_elevation=".07" + camera_angle="20"> + domain="0.3" /> + value_default=".5" + camera_distance=".3" + camera_elevation=".07" + camera_angle="20"> - - + color="253,162,193,200" /> + color="247,131,152,200" /> + color="213,122,140,200" /> + color="253,152,144,200" /> + color="236,138,103,200" /> + color="195,128,122,200" /> + color="148,103,100,200" /> + color="168,95,62,200" /> - - - - - - - - - - - - - - - - - + value_default=".5" + camera_distance=".3" + camera_elevation=".07" + camera_angle="20"> + + color="255,255,255,0" /> + color="255,255,255,255" /> + + + camera_distance=".3" + camera_elevation=".14"> + color="252,247,246,255" /> - - + color="255,206,206,255" /> - - + color="233,135,149,255" /> - - + color="220,168,192,255" /> - - - + - - - - + - - + - - + color="255,147,86,255" /> - - + color="228,110,89,255" /> - - - + - - - + - - - + - - - - + - - + - - - + - - + + + + + + + + + + + + + + + + + + + + - + id="706" + group="0" + wearable="skin" + edit_group="skin_makeup" + edit_group_order="12" + name="Out Shdw Opacity" + label_min="Clear" + label_max="Opaque" + value_min=".2" + value_max="1" + value_default=".6" + camera_distance=".3" + camera_elevation=".14"> + + + + + + value_max=".7" + camera_distance=".3" + camera_elevation=".14"> - - - - + name="Inner Eye Shadow"> + camera_distance=".3" + camera_elevation=".14"> + color="252,247,246,255" /> - - + color="255,206,206,255" /> - - - + - - - + - - - + - - - - + - - + - - + color="255,147,86,255" /> - - + color="228,110,89,255" /> - - + color="228,150,120,255" /> + color="223,227,213,255" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + value_default=".7" + camera_distance=".3" + camera_elevation=".14"> + + color="255,255,255,0" /> + color="255,255,255,255" /> + value_max="1" + value_default="0" + camera_distance=".3" + camera_elevation=".14"> + tga_file="eyeshadow_inner_alpha.tga" + skip_if_zero="true" + domain="0.2" /> + + + value_default="0.0" + camera_distance=".3" + camera_elevation=".14"> + tga_file="eyeliner_alpha.tga" + skip_if_zero="true" + domain="0.1" /> - - + camera_distance=".3" + camera_elevation=".14"> + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + name="facialhair bump" + render_pass="bump"> + tga_file="head_hair.tga" + file_is_mask="false" /> + tga_file="facehair_sideburns_alpha.tga" + skip_if_zero="true" + domain="0.05" /> + tga_file="facehair_soulpatch_alpha.tga" + skip_if_zero="true" + domain="0.1" /> + tga_file="facehair_chincurtains_alpha.tga" + skip_if_zero="true" + domain="0.03" /> - - - - - - - - - - - + color="255,255,255,255" /> + color="255,255,255,0" /> + - - - + + + + tga_file="facehair_soulpatch_alpha.tga" + skip_if_zero="true" + domain="0.1" /> + tga_file="facehair_chincurtains_alpha.tga" + skip_if_zero="true" + domain="0.03" /> - - - - - + value_default="0.7" + camera_elevation=".1" + camera_distance=".3"> + + color="255,255,255,255" /> + color="255,255,255,30" /> + + + + + + + + + + + + @@ -7838,16 +10043,16 @@ render_pass="bump"> color="0, 0, 0, 255" /> + color="255, 0, 0, 255" /> @@ -7856,121 +10061,110 @@ render_pass="bump"> color="0, 0, 0, 255" /> + color="0, 255, 0, 255" /> - - - - - + value_max="1" + value_default="1"> + + + + + + + + - + value_max="1" + value_default="1"> + + + + + - + value_default="1"> + + + + + - + value_default="1"> + + + + + - - - + name="base_upperbody bump" + render_pass="bump" + fixed_color="128,128,128,255"> + tga_file="bump_upperbody_base.tga" + file_is_mask="FALSE"/> tga_file="body_skingrain.tga" /> + + + + @@ -8017,14 +10216,14 @@ render_pass="bump"> @@ -8038,45 +10237,39 @@ render_pass="bump"> - - - - + name="upper_bodypaint"> + local_texture="upper_bodypaint" /> + name="upper_tattoo"> + local_texture="upper_tattoo" /> @@ -8090,11 +10283,11 @@ render_pass="bump"> @@ -8108,11 +10301,11 @@ render_pass="bump"> @@ -8126,73 +10319,52 @@ render_pass="bump"> - + name="upper_universal_tattoo"> - + local_texture="upper_universal_tattoo" /> - + value_default="1"> + + + + + - - - - - - - - - - + value_default="1"> + + + color="0, 255, 0, 255" /> @@ -8201,94 +10373,93 @@ render_pass="bump"> color="0, 0, 0, 255" /> + color="0, 0, 255, 255" /> + + + + + - - - - - + value_default=".4"> + + value_default=".8"> + tga_file="shirt_bottom_alpha.tga" + multiply_blend="true" + domain="0.05" /> - - - - + value_default=".8"> + tga_file="shirt_collar_back_alpha.tga" + multiply_blend="true" + domain="0.05" /> + name="upper_undershirt"> + local_texture="upper_undershirt" /> @@ -8302,11 +10473,11 @@ render_pass="bump"> @@ -8320,11 +10491,11 @@ render_pass="bump"> @@ -8338,940 +10509,4511 @@ render_pass="bump"> + value_default=".4"> + + + + + + + + + + + + - + name="Nail Polish"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + - - + - - - + - - - + + + - - - + + + - - - + - - - + - - - + - - - - + + + - - + + + - - - + - - - + - - - + + + - - - - + + + - - + - - - + - - - - + + + - - + + + - + - - - + - - - + + + - - - + + + - - - - + - - + - - - + + + - - - + + + - - - + - - - + - - - + - - - + - - - + + + + - - - - + + + - - + + + - - - + + + - - - - + - - + + + - - + + + + + + - - - + + + - - - + + + + - - - + + - - - - + + + - - + + + - - - + + + + - - - + + + - - - + + + - - - + + - - - + + + - - - + + + - - - + + + - - - - + + + - - - + + + - + + + - - - - - + + + - - - + + + - - - + + + - + + + - - - - + + + - - - + + + - - - + + + - - - + - - - + - - - + + + + + + - - - - + + + - - - - + - - - + + + - - - + + + - - - + - - - - + - + + + - - + value_default=".45" + camera_elevation=".1" + camera_distance=".5" + camera_angle="20"> + id="144" + min1="0" + max1="0" + max2="0" + min2=".5" /> + value_default=".5" + camera_elevation=".1" + camera_distance=".5" + camera_angle="90"> + id="146" + min1="0" + max1="0" + max2="0" + min2=".5" /> + value_default=".39" + camera_elevation=".1" + camera_distance=".5" + camera_angle="160"> + id="148" + min1="0" + max1="0" + max2="0" + min2=".5" /> + id="149" + min1=".5" + max1="1" + max2="1" + min2="1" /> + + + + + id="172" + min1="0" + max1="0" + max2="0" + min2=".5" /> + value_default=".5" + camera_elevation=".1" + camera_distance=".5" + camera_angle="90"> + max1="0" + max2="0" + min2=".5" /> + + + + + max1="0" + max2="0" + min2=".5" /> + + + + + + + value_default=".5" + camera_elevation=".1" + camera_distance=".5" + camera_angle="0"> - - - - + id="190" + min1="0" + max1="0" + max2="0" + min2=".5" /> @@ -9279,240 +15021,272 @@ render_pass="bump"> + id="620" /> + id="1025" /> + id="1037" /> + id="621" /> + + + + + id="622" /> + id="1026" /> + id="1038" /> + id="623" /> + + + + + camera_angle="30"> - - + id="843" + min1="0" + max1="0" + max2="0" + min2=".01" /> + id="627" + min1="0" + max1="0.01" + max2="0.01" + min2=".5" /> + value_default=".5" + camera_elevation=".1" + camera_distance=".5" + camera_angle="70"> - - - - - - + id="630" + min1="0" + max1="0" + max2="0" + min2=".5" /> + id="644" + min1="0" + max1="0" + max2="0" + min2=".5" /> - - - + id="631" + min1=".5" + max1="1" + max2="1" + min2="1" /> - - + id="645" + min1=".5" + max1="1" + max2="1" + min2="1" /> + + + id="32629" + min1=".5" + max1="1" + max2="1" + min2="1" /> + + value_default="0" + camera_elevation=".1" + camera_distance=".5" + camera_angle="20"> + id="640" /> + id="186" /> + + - + value_default="0" + camera_elevation=".1" + camera_distance=".5" + camera_angle="20"> - + id="641" /> + + + + + + camera_elevation=".1" + camera_distance="1" + camera_angle="15"> + camera_elevation=".1" + camera_distance="1.2" + camera_angle="0"> - - - - - - - - + value_default=".5" + camera_distance="1.3" + camera_elevation="-.5" + camera_angle="15"> + id="651" + min1="0" + max1="0" + max2="0" + min2=".5" /> + id="152" + min1=".5" + max1="1" + max2="1" + min2="1" /> + value_max="1"> + id="32" /> - - + id="153" /> - - + id="40" /> + id="100" /> + + + camera_elevation="0" + camera_distance=".28"> + + + + + + camera_elevation=".1" + camera_distance=".5"> + id="660" /> + + + id="774" /> + camera_angle="75"> + id="770" /> + id="771" /> + + + + + + + + + + camera_distance=".5"> + id="679" /> + id="694" /> + id="680" /> + id="681" /> + + + value_default=".5" + show_simple="true" + camera_elevation=".1" + camera_distance=".35"> + + id="686" /> + id="687" /> + id="695" /> + + + + + + + + + + value_default=".5" + camera_elevation="0" + camera_distance=".28"> - - + id="751" + min1="0" + max1="0" + max2="0" + min2=".2" /> + id="1012" + min1="0" + max1="0" + max2=".2" + min2=".6" /> + id="400" + min1=".2" + max1="1" + max2="1" + min2="1" /> + value_default="1"> + max1="1" + max2="1" + min2="1" /> @@ -9909,31 +15679,51 @@ render_pass="bump"> + value_default="1"> + max1="1" + max2="1" + min2="1" /> + + + + + + + + @@ -9941,31 +15731,46 @@ render_pass="bump"> + camera_angle="15"> + + + + @@ -9973,31 +15778,38 @@ render_pass="bump"> + camera_angle="180"> + max1=".10" + max2=".10" + min2=".66" /> + + @@ -10005,32 +15817,45 @@ render_pass="bump"> + value_default=".25" + camera_angle="180" + camera_distance=".6"> + min2=".3" /> + + + + @@ -10038,62 +15863,136 @@ render_pass="bump"> + + + + + + + + + value_default="0" + camera_distance="1.3" + camera_elevation="-.5"> + id="853" /> + id="847" /> + + + + + + + + + + + + + + + + + value_default=".333" + camera_distance="1.3" + camera_elevation="-.5"> + + + max1=".5" + max2=".5" + min2="1" /> + value_default="0.5" + camera_elevation=".1" + camera_distance=".3"> - - + id="1000" /> + id="1001" /> + + - + + + + + id="1002" /> + id="1003" /> + value_default="0.0" + camera_elevation=".1" + camera_distance=".3" + camera_angle="30"> + id="1004" /> + id="1005" /> + + + + + id="1006" /> + id="1007" /> + + + + + id="1008" /> + id="1009" /> + value_default="0.0" + camera_elevation="-.1" + camera_distance=".3" + camera_angle="45"> - - + id="1010" /> + id="1011" /> + value_default=".8" + camera_distance="1.2" + camera_angle="30" + camera_elevation=".2"> - - + id="1019" /> + id="1039" /> + id="1020" /> + value_default=".8" + camera_distance="1.2" + camera_angle="15" + camera_elevation=".2"> + id="1021" /> + + + id="1022" /> + value_default=".8" + camera_distance="1.2" + camera_angle="195" + camera_elevation=".2"> + id="1023" /> + id="1041" /> + + + value_default=".4" + camera_distance="1.2" + camera_angle="30" + camera_elevation=".2"> + id="1042" /> + id="1043" /> + camera_angle="30" + camera_elevation=".2"> + id="1044" /> + id="1045" /> + value_default=".84" + camera_distance=".8" + camera_angle="15" + camera_elevation=".2"> + id="1046" /> + id="1047" /> + value_max="1" + value_default=".84" + camera_distance=".8" + camera_angle="195" + camera_elevation=".2"> - - - - - - + id="1048" /> + id="1049" /> + value_default="0.35" + camera_distance=".95" + camera_angle="30" + camera_elevation="-.75"> + id="1050" /> + id="1051" /> + value_default="0.1" + camera_distance="1.2" + camera_angle="30" + camera_elevation="-.75"> - - + id="1052" /> + id="1053" /> + value_default=".3" + camera_distance="1.2" + camera_angle="30" + camera_elevation="-.3"> - - + id="1054" /> + id="1055" /> + value_default=".8" + camera_distance="1.2" + camera_angle="30" + camera_elevation="-.3"> - - - - - - + id="1056" /> + id="1057" /> + value_default=".8" + camera_distance="1.2" + camera_angle="30" + camera_elevation=".2"> - - - - - - - - + id="1058" /> + id="1059" /> + value_default="1" + camera_distance="1.2" + camera_angle="30" + camera_elevation=".2"> - - + id="1060" /> + id="1061" /> + + camera_distance=".3"> + id="870" /> + + + + + + + id="871" /> + + + value_max="2" + value_default=".5" + camera_elevation=".1" + camera_distance=".3"> - - + id="872" /> + + + value_default="0" + camera_elevation=".1" + camera_distance=".3"> + id="875" /> + + id="876" /> - + + + + value_default="1"> - - + max1="1" + max2="1" + min2="1" /> - + @@ -10794,862 +16636,837 @@ render_pass="bump"> + value_default="1"> + max1="1" + max2="1" + min2="1" /> + + value_default="1"> + max1="1" + max2="1" + min2="1" /> - - - - - - - - - - - - - - - - - - - - - - + id="1208" + min1="0" + max1="1" + max2="1" + min2="1" /> - - + id="1211" + min1="0" + max1="1" + max2="1" + min2="1" /> - - + max1="1" + max2="1" + min2="1" /> - - - - - + + id="1220" + min1="0" + max1="1" + max2="1" + min2="1" /> + id="1223" + min1="0" + max1="1" + max2="1" + min2="1" /> + + + + value_default="1"> + id="1230" + min1="0" + max1="1" + max2="1" + min2="1" /> - - + id="1233" + min1="0" + max1="1" + max2="1" + min2="1" /> - - + id="1236" + min1="0" + max1="1" + max2="1" + min2="1" /> - - + id="1209" + min1="0" + max1="1" + max2="1" + min2="1" /> - - + id="1212" + min1="0" + max1="1" + max2="1" + min2="1" /> - - + id="925" + min1="0" + max1="1" + max2="1" + min2="1" /> - - + id="1215" + min1="0" + max1="1" + max2="1" + min2="1" /> - - + id="1218" + min1="0" + max1="1" + max2="1" + min2="1" /> - - + id="1221" + min1="0" + max1="1" + max2="1" + min2="1" /> + id="1224" + min1="0" + max1="1" + max2="1" + min2="1" /> + + + + value_default="1"> + id="1231" + min1="0" + max1="1" + max2="1" + min2="1" /> + id="1234" + min1="0" + max1="1" + max2="1" + min2="1" /> - - + id="1237" + min1="0" + max1="1" + max2="1" + min2="1" /> - - + id="1210" + min1="0" + max1="1" + max2="1" + min2="1" /> + id="1213" + min1="0" + max1="1" + max2="1" + min2="1" /> - - + id="926" + min1="0" + max1="1" + max2="1" + min2="1" /> + + + + - - + id="1222" + min1="0" + max1="1" + max2="1" + min2="1" /> + id="1225" + min1="0" + max1="1" + max2="1" + min2="1" /> + id="1228" + min1="0" + max1="1" + max2="1" + min2="1" /> + + + - + value_default="0"> + id="1200" /> + + + + - + id="1201" /> + + value_default="0"> - + id="1202" /> + id="1203" /> + + value_default="0"> - - + id="1205" /> + value_default="0"> - - + id="1206" /> + value_default="0"> - - + id="1207" /> + + + - - + value_max="30"> + + - - + + + + + - - - - - + value_max="100"> + + + + + + + + + + - - + value_max="100"> + + + + + + + + - - + + + + + + + + + + + + + + + + + - - - - - - + name="Belly_Physics_UpDown_Damping" + label="Belly Physics UpDown Damping" + wearable="physics" + edit_group="physics_belly_updown" + value_default=".2" + value_min="0" + value_max="1"> + + + + + + + - - - - - + value_min="0" + value_max="10"> + - + + + - - - + name="Butt_Physics_UpDown_Spring" + label="Butt Physics UpDown Spring" + wearable="physics" + edit_group="physics_butt_updown" + value_default="10" + value_min="0" + value_max="100"> + - - - - - + name="Butt_Physics_UpDown_Gain" + label="Butt Physics UpDown Gain" + wearable="physics" + edit_group="physics_butt_updown" + value_default="10" + value_min="1" + value_max="100"> + - - - - - + value_max="1"> + - + + + - - - - - - + value_max="100"> + - + + + - - - - - - - + value_max="1"> + + + + - - - - - - - + value_max="100"> + - + + + - - - - - - - - + value_max="1"> + + + + diff --git a/Radegast/character/avatar_lower_body.llm b/Radegast/character/avatar_lower_body.llm index 042089973..d7fb1f9f5 100644 Binary files a/Radegast/character/avatar_lower_body.llm and b/Radegast/character/avatar_lower_body.llm differ diff --git a/Radegast/character/avatar_lower_body_1.llm b/Radegast/character/avatar_lower_body_1.llm index 1394eb848..5ce0a486c 100644 Binary files a/Radegast/character/avatar_lower_body_1.llm and b/Radegast/character/avatar_lower_body_1.llm differ diff --git a/Radegast/character/avatar_lower_body_2.llm b/Radegast/character/avatar_lower_body_2.llm index 0da9c1249..3056feae6 100644 Binary files a/Radegast/character/avatar_lower_body_2.llm and b/Radegast/character/avatar_lower_body_2.llm differ diff --git a/Radegast/character/avatar_lower_body_3.llm b/Radegast/character/avatar_lower_body_3.llm index f3c49a156..0f3668889 100644 Binary files a/Radegast/character/avatar_lower_body_3.llm and b/Radegast/character/avatar_lower_body_3.llm differ diff --git a/Radegast/character/avatar_lower_body_4.llm b/Radegast/character/avatar_lower_body_4.llm index e71721063..2e389abb7 100644 Binary files a/Radegast/character/avatar_lower_body_4.llm and b/Radegast/character/avatar_lower_body_4.llm differ diff --git a/Radegast/character/avatar_skeleton.xml b/Radegast/character/avatar_skeleton.xml index 5e73804f2..2241a1254 100644 --- a/Radegast/character/avatar_skeleton.xml +++ b/Radegast/character/avatar_skeleton.xml @@ -1,74 +1,232 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Radegast/character/avatar_skirt.llm b/Radegast/character/avatar_skirt.llm index 08ce3d170..bf088d60d 100644 Binary files a/Radegast/character/avatar_skirt.llm and b/Radegast/character/avatar_skirt.llm differ diff --git a/Radegast/character/avatar_skirt_1.llm b/Radegast/character/avatar_skirt_1.llm index 88076c321..fb35ffe37 100644 Binary files a/Radegast/character/avatar_skirt_1.llm and b/Radegast/character/avatar_skirt_1.llm differ diff --git a/Radegast/character/avatar_skirt_2.llm b/Radegast/character/avatar_skirt_2.llm index 73b3effbc..e4fb03f96 100644 Binary files a/Radegast/character/avatar_skirt_2.llm and b/Radegast/character/avatar_skirt_2.llm differ diff --git a/Radegast/character/avatar_skirt_3.llm b/Radegast/character/avatar_skirt_3.llm index ded546fde..6f8ebf95d 100644 Binary files a/Radegast/character/avatar_skirt_3.llm and b/Radegast/character/avatar_skirt_3.llm differ diff --git a/Radegast/character/avatar_skirt_4.llm b/Radegast/character/avatar_skirt_4.llm index b9d5cb945..bc56961fa 100644 Binary files a/Radegast/character/avatar_skirt_4.llm and b/Radegast/character/avatar_skirt_4.llm differ diff --git a/Radegast/character/avatar_upper_body.llm b/Radegast/character/avatar_upper_body.llm index da7d99054..80c560fb5 100644 Binary files a/Radegast/character/avatar_upper_body.llm and b/Radegast/character/avatar_upper_body.llm differ diff --git a/Radegast/character/avatar_upper_body_1.llm b/Radegast/character/avatar_upper_body_1.llm index 31e104cc2..0f11ed624 100644 Binary files a/Radegast/character/avatar_upper_body_1.llm and b/Radegast/character/avatar_upper_body_1.llm differ diff --git a/Radegast/character/avatar_upper_body_2.llm b/Radegast/character/avatar_upper_body_2.llm index c1f4199b9..e21ab966e 100644 Binary files a/Radegast/character/avatar_upper_body_2.llm and b/Radegast/character/avatar_upper_body_2.llm differ diff --git a/Radegast/character/avatar_upper_body_3.llm b/Radegast/character/avatar_upper_body_3.llm index 9e89ed8b3..d52a407f2 100644 Binary files a/Radegast/character/avatar_upper_body_3.llm and b/Radegast/character/avatar_upper_body_3.llm differ diff --git a/Radegast/character/avatar_upper_body_4.llm b/Radegast/character/avatar_upper_body_4.llm index ec836d1dc..394a1e873 100644 Binary files a/Radegast/character/avatar_upper_body_4.llm and b/Radegast/character/avatar_upper_body_4.llm differ diff --git a/Radegast/fmodex-dotnet.dll.config b/Radegast/fmodex-dotnet.dll.config deleted file mode 100644 index 387a0745e..000000000 --- a/Radegast/fmodex-dotnet.dll.config +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/Radegast/fmodex.dll b/Radegast/fmodex.dll deleted file mode 100644 index 01c719bf7..000000000 Binary files a/Radegast/fmodex.dll and /dev/null differ diff --git a/Radegast/grids.xml b/Radegast/grids.xml index aceb58f26..a7708ba5e 100644 --- a/Radegast/grids.xml +++ b/Radegast/grids.xml @@ -62,19 +62,19 @@ platform OpenSim loginuri - http://hypergrid.org:8002/ + http://login.metro.land/ loginpage - http://metropolis.hypergrid.org + http://metro.land/splash/ helperuri - http://metropolis.hypergrid.org/currency/helper/ + http://metro.land/helper/ website - http://metropolis.hypergrid.org + http://www.metro.land support - http://metropolis.hypergrid.org + http://www.metro.land register - http://metropolis.hypergrid.org/oswi.php + http://www.metro.land/metro_rg.php password - http://metropolis.hypergrid.org/oswi.php + http://www.metro.land/password.php version 1 @@ -105,32 +105,6 @@ 1 - - - gridnick - reactiongrid - gridname - ReactionGrid - platform - OpenSim - - loginuri - http://reactiongrid.com:8008/ - loginpage - http://gsquared.info/portal - website - http://reactiongrid.com/Default.aspx - support - http://reactiongrid.com/Support.aspx - register - http://reactiongrid.com/Register.aspx - - password - http://reactiongrid.com/Support/ResetPassword.aspx - version - 0 - - @@ -189,36 +163,6 @@ 0 - - - - gridname - Inworldz - gridnick - inworldz - platform - OpenSim - - loginuri - http://inworldz.com:8002/ - loginpage - http://inworldz.com/welcome - helperuri - http://inworldz.com/ - password - http://inworldz.com/wpassword - - register - http://inworldz.com/register - support - http://inworldz.com/help - website - http://inworldz.com/about/ - version - 0 - - - gridnick @@ -247,62 +191,6 @@ 0 - - - gridnick - legendcityonline - gridname - Legend City Online - - platform - OpenSim - loginuri - http://login.legendcityonline.com - loginpage - http://www.legendcityonline.com/welcome.php - helperuri - https://secure.legendcityonline.com/ - website - http://www.legendcityonline.com/ - - support - http://www.legendcityonline.com/ - register - http://www.legendcityonline.com/ - password - http://www.legendcityonline.com/ - version - 0 - - - - - gridnick - worldsimterra - gridname - WorldSimTerra - platform - OpenSim - - loginuri - http://wsterra.com:8002 - loginpage - http://wsterra.com/log.php - helperuri - http://wsterra.com/ - website - http://www.worldsimterra.com/ - support - http://www.worldsimterra.com/ - - register - http://www.worldsimterra.com/ - password - http://www.worldsimterra.com/ - version - 0 - - @@ -333,101 +221,6 @@ - - - gridnick - thenewworldgrid - - gridname - The New World Grid - platform - OpenSim - loginuri - http://grid.newworldgrid.com:8002/ - loginpage - http://account.newworldgrid.com/loginscreen.php - helperuri - http://account.newworldgrid.com/ - - website - http://www.newworldgrid.com/ - support - http://www.newworldgrid.com/ - register - http://www.newworldgrid.com/register - password - http://account.newworldgrid.com/ - version - 0 - - - - - - gridnick - cyberlandia - - gridname - Cyberlandia - platform - OpenSim - loginuri - http://grid.cyberlandia.net:8002 - loginpage - - helperuri - - - website - http://www.cyberlandia.net - version - 0 - - - - - gridnick - thegorgrid - - gridname - The Gor Grid - platform - OpenSim - loginuri - http://thegorgrid.com:8002 - loginpage - http://thegorgrid.com/loginscreen.php - website - http://thegorgrid.com/ - - register - http://thegorgrid.com/index.php?page=create - password - http://thegorgrid.com/index.php?page=change - version - 0 - - - - - - gridnick - giantgrid - gridname - GiantGrid - platform - OpenSim - loginuri - http://Gianttest.no-ip.biz:8002/ - - loginpage - http://gianttest.no-ip.biz:80/gridsplash?method=login - helperuri - http://gianttest.no-ip.biz/giantmap/ - version - 0 - - diff --git a/Radegast/libfmodex-4.44.08.dylib b/Radegast/libfmodex-4.44.08.dylib deleted file mode 100644 index e5797af66..000000000 Binary files a/Radegast/libfmodex-4.44.08.dylib and /dev/null differ diff --git a/Radegast/libfmodex-4.44.08.so b/Radegast/libfmodex-4.44.08.so deleted file mode 100755 index 11e2be6c9..000000000 Binary files a/Radegast/libfmodex-4.44.08.so and /dev/null differ diff --git a/Radegast/libfmodex64-4.44.08.so b/Radegast/libfmodex64-4.44.08.so deleted file mode 100755 index 65e355da3..000000000 Binary files a/Radegast/libfmodex64-4.44.08.so and /dev/null differ diff --git a/Radegast/libopenjpeg-dotnet-2-1.5.0-dotnet-1-i686.so b/Radegast/libopenjpeg-dotnet-2-1.5.0-dotnet-1-i686.so deleted file mode 100755 index 193eca4b3..000000000 Binary files a/Radegast/libopenjpeg-dotnet-2-1.5.0-dotnet-1-i686.so and /dev/null differ diff --git a/Radegast/libopenjpeg-dotnet-2-1.5.0-dotnet-1-x86_64.so b/Radegast/libopenjpeg-dotnet-2-1.5.0-dotnet-1-x86_64.so deleted file mode 100755 index 7a9bdfcd1..000000000 Binary files a/Radegast/libopenjpeg-dotnet-2-1.5.0-dotnet-1-x86_64.so and /dev/null differ diff --git a/Radegast/libopenjpeg-dotnet-2-1.5.0-dotnet-1.dylib b/Radegast/libopenjpeg-dotnet-2-1.5.0-dotnet-1.dylib deleted file mode 100755 index 91f7264fd..000000000 Binary files a/Radegast/libopenjpeg-dotnet-2-1.5.0-dotnet-1.dylib and /dev/null differ diff --git a/Radegast/license.txt b/Radegast/license.txt index 408f0eb63..cbf24ccab 100644 --- a/Radegast/license.txt +++ b/Radegast/license.txt @@ -1,26 +1,17 @@ Radegast Metaverse Client Copyright (c) 2009-2014, Radegast Development Team +Copyright (c) 2016-2020, Sjofn, LLC All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: +Radegast is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published +by the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the application "Radegast", nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +You should have received a copy of the GNU Lesser General Public License +along with this program. If not, see . diff --git a/Radegast/openjpeg-dotnet-x86_64.dll b/Radegast/openjpeg-dotnet-x86_64.dll deleted file mode 100644 index 9e8cd2150..000000000 Binary files a/Radegast/openjpeg-dotnet-x86_64.dll and /dev/null differ diff --git a/Radegast/openjpeg-dotnet.dll b/Radegast/openjpeg-dotnet.dll deleted file mode 100644 index 6377b8d97..000000000 Binary files a/Radegast/openjpeg-dotnet.dll and /dev/null differ diff --git a/Radegast/openmetaverse_data/avatar_lad.xml b/Radegast/openmetaverse_data/avatar_lad.xml index 80925eb8f..2cdd86267 100644 --- a/Radegast/openmetaverse_data/avatar_lad.xml +++ b/Radegast/openmetaverse_data/avatar_lad.xml @@ -1,316 +1,346 @@ - - - - - - - - + version="2.0" wearable_definition_version="22"> + + + + - - - + - - - - - - - - - - - - - - - - - - - + - - - - - + - + - + - + - - - - - - - - - - - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - - - + - - - + - + - + - + - + - + + + + + - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + - + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + - - - - - - - - - - - - - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - - - + + + - - - + + + - - - + + + - - - + + + - + + + - + + + - - - + + + - - - + + + - + + + - + + + - - - + + + - - - - - - - - - - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + - - - + + + - - - + + + + + + + + + + + - - - + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + + + + + + - - - + + + - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + + + + + + + + + + + - - - + + + - - - + + + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - + + + + - - + name="Eyelid_Inner_Corner_Up" + value_min="-1.3" + value_max="1.2"> + + + + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + + + - - - + + + - - - + + + - - - + + + - - - + + + + + + + + + - - - + + + - - - + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + value_max="1" + value_default="1"> + + - - + + - + value_max="1" + value_default="1"> + + + + + - + edit_group="colorpicker_driven" + wearable="universal" + name="tattoo_hair_blue" + value_min="0" + value_max="1" + value_default="1"> + + + + + + + + + + + + + + + + + + + + - + edit_group_order="12" + name="Bump base" + value_min="0" + value_max="1"> + + + + + + + + + + + + + - - - + + - - - + + + + + + + - + id="159" + group="1" + name="Shading" + wearable="skin" + value_min="0" + value_max="1"> + + + + + + + + + - + camera_elevation=".07"> + + + + + + + + + - - + camera_distance=".25"> + + - - + + + + - - - - - - + + + + + + + + + + + + + + - + value_max="1"> + - + value_max="1"> + + + + + + + + + - + wearable="hair" + edit_group="hair_eyebrows" + name="Eyebrow Size" + show_simple="true" + value_min="0" + value_max="1" + value_default="0.5"> + - - + value_max="1"> + + - - + + + + - - + value_default=".25" + camera_distance=".25"> + + - - + + + + + + + + + + + + + + + + + + - + value_max=".9" + value_default="0.0" + camera_distance=".25"> + + + + + + + + + - + name="Blush" + label_min="No Blush" + label_max="More Blush" + value_min="0" + value_max=".9" + value_default="0" + camera_distance=".3" + camera_elevation=".07" + camera_angle="20"> + - - - - - + camera_elevation=".07" + camera_angle="20"> + + + + + + + + + + + + + + + + + - + camera_elevation=".07" + camera_angle="20"> + + + + + + + - + camera_elevation=".14"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + camera_elevation=".14"> + + + + + - + camera_elevation=".14"> + + + - - + camera_elevation=".14"> + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + value_default=".7" + camera_distance=".3" + camera_elevation=".14"> + + + + + - + camera_distance=".3" + camera_elevation=".14"> + + + - + wearable="skin" + edit_group="skin_makeup" + edit_group_order="13" + name="Eyeliner" + label_min="No Eyeliner" + label_max="Full Eyeliner" + value_min="0" + value_max="1" + value_default="0.0" + camera_distance=".3" + camera_elevation=".14"> + - - + wearable="skin" + edit_group="skin_makeup" + edit_group_order="14" + name="Eyeliner Color" + label_min="Dark Green" + label_max="Black" + value_min="0" + value_max="1" + camera_distance=".3" + camera_elevation=".14"> + + - - - + + - - - + + - - - + + - - - - - + + - - + + + + + + + + + + + + + + + + + + - + - + - + - + - + + + + + + + + + + - + - + - + - + - - - - + + + + + + + + + + + + + + + + + + + + - + value_max="1" + value_default="1"> + + + + + - + value_max="1" + value_default="1"> + + + + + - + value_max="1" + value_default="1"> + + + + + + + + - + value_max="1" + value_default="1"> + + + + + - + value_max="1" + value_default="1"> + + + + + - - - - + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + - + + + + + + - + + - + + + + + + + + + + + - + + + + + - - + value_max="1" + value_default="1"> + + + + + - + value_max="1" + value_default="1"> + + + + + - - + value_max="1" + value_default="1"> + + + + + + + + - + value_max="1" + value_default="1"> + + + + + - + value_max="1" + value_default="1"> + + + + + - + value_max="1" + value_default="1"> + + + + + + + + + + - + wearable="undershirt" + edit_group="driven" + name="Sleeve Length bump" + value_min=".01" + value_max="1" + value_default=".4"> + - + value_max="1" + value_default=".8"> + - - - - - - - - - - - - - - - - - - - - - + value_max="1" + value_default=".8"> + - + value_default=".8"> + + + + + - + wearable="undershirt" + edit_group="colorpicker" + name="undershirt_red" + value_min="0" + value_max="1" + value_default="1"> + + + + + - + wearable="undershirt" + edit_group="colorpicker" + name="undershirt_green" + value_min="0" + value_max="1" + value_default="1"> + + + + + - + wearable="undershirt" + edit_group="colorpicker" + name="undershirt_blue" + value_min="0" + value_max="1" + value_default="1"> + + + + + - + value_default=".4"> + - + value_default=".8"> + - + wearable="undershirt" + edit_group="driven" + name="Collar Front" + value_min="0" + value_max="1" + value_default=".8"> + - + id="1048" + group="1" + wearable="undershirt" + edit_group="driven" + name="Collar Back" + label_min="Low" + label_max="High" + value_min="0" + value_max="1" + value_default=".8"> + + + - + wearable="skin" + edit_group="skin_makeup" + edit_group_order="15" + name="Nail Polish" + label_min="No Polish" + label_max="Painted Nails" + value_min="0" + value_max="1" + value_default="0.0" + camera_distance="1.6" + camera_elevation="-.4" + camera_angle="70"> + - + - - + wearable="skin" + edit_group="skin_makeup" + edit_group_order="16" + name="Nail Polish Color" + label_min="Pink" + label_max="Black" + value_min="0" + value_max="1" + camera_distance="1.6" + camera_elevation="-.4" + camera_angle="70"> + + - - + + + + + + + + + + + + + + + + + + + + - + wearable="gloves" + edit_group="driven" + name="Glove Length bump" + value_min=".01" + value_max="1" + value_default=".8"> + - - + wearable="gloves" + edit_group="driven" + name="Glove Fingers bump" + value_min=".01" + value_max="1" + value_default="1"> + + + + + - + value_max="1" + value_default="1"> + + + + + - + value_max="1" + value_default="1"> + + + + + - + value_max="1" + value_default="1"> + + + + + - + wearable="gloves" + edit_group="driven" + name="Glove Length" + value_min=".01" + value_max="1" + value_default=".8"> + - + wearable="gloves" + edit_group="driven" + name="Glove Fingers" + value_min=".01" + value_max="1" + value_default="1"> + + + + + - + value_max="1" + value_default="0"> + + + + + - + wearable="shirt" + edit_group="driven" + name="Sleeve Length Shadow" + value_min="0.02" + value_max=".87" + value_default="0.02"> + - + - + - + + + + + - + value_max="0.85"> + - + - + - + + + + + + + - + value_max="1" + value_default="0"> + + + + + - + value_max="0.85"> + - - + - - + - - - - - - - - - - - + + + + + - + value_default="1"> + + + + + - + value_default="1"> + + + + + - + value_default="1"> + + + + + - - - - - - - - - - - - - - - - - - - - - - + wearable="shirt" + edit_group="driven" + name="Sleeve Length Cloth" + value_min="0" + value_max="0.85" + value_default=".7"> + + - - - - - - - - - - - + wearable="shirt" + edit_group="driven" + name="Shirt Bottom Cloth" + value_min="0" + value_max="1" + value_default=".8"> + + - - - - - - - - - - - - - - - - - + wearable="shirt" + edit_group="driven" + name="Collar Front Height Cloth" + value_min="0" + value_max="1" + value_default=".8"> + - + value_default=".8"> + + + + + - + value_max="1"> + - - - + wearable="jacket" + edit_group="driven" + name="Jacket Collar Front bump" + value_min="0" + value_max="1"> + - + id="1041" + group="1" + wearable="jacket" + edit_group="driven" + edit_group_order="3.5" + name="Jacket Collar Back bump" + value_min="0" + value_max="1"> + - + id="1037" + group="1" + wearable="jacket" + edit_group="driven" + name="jacket bottom length upper bump" + value_min="0" + value_max="1"> + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - + - + - + - + - + + + + + - + value_max="1" + value_default="1"> + + + + + - + value_max="1" + value_default="1"> + + + + + - + value_max="1" + value_default="1"> + + + + + - + - + - + - + value_max="1" + value_default=".8" + camera_distance="1.2" + camera_angle="30" + camera_elevation=".2"> + + + + + + + + + + + + + + + + + + + - + + - - - - - - - - - - - - - - - - - - - + + + + + + + - + + + + + + + + + - - - + + + + + + + + + + + + + + + - - - + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + - + value_default="1"> + + + + + - + value_default="1"> + + + + + + + + - + id="1235" + group="1" + edit_group="colorpicker_driven" + wearable="universal" + name="tattoo_lower_universal_red" + value_min="0" + value_max="1" + value_default="1"> + + + + + - + value_default="1"> + + + + + - + value_default="1"> + + + + + + + + + - + value_default=".3"> + - + value_default=".8"> + + + + + - + value_max="1" + value_default="1"> + + + + + - - - - - + wearable="underpants" + edit_group="colorpicker" + name="underpants_green" + value_min="0" + value_max="1" + value_default="1"> + + + + + + - + value_default="1"> + + + + + - + - + value_max="1" + value_default=".8"> + + + + + - + value_max="1" + value_default="0.35"> + + + + + - - - - - - - - - - - - - - - - - - + wearable="socks" + edit_group="colorpicker" + name="socks_red" + value_min="0" + value_max="1" + value_default="1"> + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - + value_max="1" + value_default="1"> + + + + + - - - + id="820" + group="0" + wearable="socks" + edit_group="colorpicker" + name="socks_blue" + value_min="0" + value_max="1" + value_default="1"> + + - - - - + + - - - - - - - - - + wearable="socks" + edit_group="driven" + name="Socks Length bump" + value_min="0" + value_max="1" + value_default="0.35"> + + + + + - + wearable="shoes" + edit_group="driven" + name="Shoe Height bump" + value_min="0" + value_max="1" + value_default="0.1"> + - + + + + - - - + id="812" + group="0" + wearable="shoes" + edit_group="colorpicker" + name="shoes_red" + value_min="0" + value_max="1" + value_default="1"> + + + + + - + id="813" + group="0" + wearable="shoes" + edit_group="colorpicker" + name="shoes_green" + value_min="0" + value_max="1" + value_default="1"> + + + + + - - - + value_max="1" + value_default="1"> + + + + + - + value_max="1" + value_default="0.1"> + + + + + - + value_max="1" + value_default="0"> + + + + + - + - + id="915" + group="1" + edit_group="driven" + wearable="pants" + name="Pants Length Shadow" + value_min="0.02" + value_max="1"> + + - - - + + - + - + + - - - + + + + - - + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - + value_max="1"> + + + + + - - - - - - - - - - - - - - + value_default="1"> + + - - + + - - - - - - - - - - - - - - - - - - - - - - - + value_default="1"> + + - - + + - - + value_default="1"> + + - - + + - - - - - + value_default=".8"> + - - - - - - - - - - - - - - - - - + value_default=".8"> + - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + value_max="1"> + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + value_max="1"> + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + value_default="0"> + + + + + + - - + + - - - - - + value_max="1"> + + + + + - - - - - - + value_default="1"> + + - - + + - - - - - - - - - - - - - - - - - - - - + value_default="1"> + + - - + + - - - - - - + value_default="1"> + + - - + + - - - - - - - - - + - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - - - - - - - - - - - + value_default="1"> + + - + + - - + value_default="1"> + + - - + + - - - + - - - - + + + + + + - - - - + value_default="1"> + + + + + - - + value_default="1"> + + - - + + - - + value_default="1"> + + - - + + + + - - - - - + name="Skirt Length" + show_simple="true" + label_min="Short" + label_max="Long" + value_min=".01" + value_max="1" + value_default=".4" + simple_percent_min="40" + simple_percent_max="100" + camera_distance="1.3" + camera_elevation="-.5" + camera_angle="30"> + - - - - - + value_default="1" + camera_distance="1.3" + camera_elevation="-.5" + camera_angle="30"> + - - - - - + value_default="1" + camera_distance="1.3" + camera_elevation="-.5" + camera_angle="160"> + - - - - - + value_default="1" + camera_distance="1.3" + camera_elevation="-.5" + camera_angle="30"> + - - - - - - - - - - - - - - - - + + + + + + - - + value_default="1"> + + - - + + - - - - - - - - - - - - - - - - + value_default="1"> + + - - + + + + + + + + + + + + + + + + + + + + + + - - - - - - + value_default="1"> + + - - + + - - + value_default="1"> + + - - + + - - - - - - - - + + + + + + + + + + + + + + + + + + + - - + value_default="1"> + + - - + + - - + value_default="1"> + + - - + + - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - + value_default="1"> + + - - + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - + value_default="1"> + + - - + + - - - - - - - - - - + value_default="1"> + + - - + + - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - + value_default="1"> + + - - + + - - + value_default="1"> + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - + value_default="1"> + + - + + + - + - + - - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - + camera_distance=".30"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + - - - + + + + + + + + + + + + - - - + + + + + + + + + + - + + + + + + + - - - + + + + + + + - - - + + + + + + + - + + + + + + + - + + + + + + + - + + + + + + + - - - + + + + + + + + + + + + + + - - - + + + + + + + + + - + + + + + + + + + + + - + + + + + + + - + + + + + + + - + + + + + + + - - - + + + + + + + - - - - - - - - - - - - - + + + + + + + - - - + + + + + + + - - - + + + + + + + - - - + + + + + + + - - - + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + - - - + + + + + + + + + - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + - - - + + + + + + + + + + - - - + + + + + + + - - - + + + + + + + - - - + + + + + + + - - - + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + - - - + + + + + + + + + - - - + + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + - - - + + + + + + + - - - + + + + + + + - - - + + + + + + + - - - + + + + + + + - - - + + + + + + + + + + + - - - + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + - - - + + + + + + + - - - + + + + + + + - + + + + + + + - - - + + + + + + + - - - + + + + + + + + + - + + + + + + + + + - - - + + + + + + + + + - - - + + + + + + + - - - + + + + + + + - - - + + + + + + + - - - + + + + + + + - - - + + + + + + + - - - + + + + + + + - - - + + + + + + + - - - + + + + + + + - - - + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + - - - + + + + + + + + + + + + + - - - + + + + + + + + + - - - + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + - - - + + + + + - - - + + + + + - - - - - - + + + + + - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Radegast/openmetaverse_data/avatar_skeleton.xml b/Radegast/openmetaverse_data/avatar_skeleton.xml index 6b07bbc1d..2241a1254 100755 --- a/Radegast/openmetaverse_data/avatar_skeleton.xml +++ b/Radegast/openmetaverse_data/avatar_skeleton.xml @@ -1,81 +1,232 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Radegast/radegast.icns b/Radegast/radegast.icns new file mode 100644 index 000000000..428c1174b Binary files /dev/null and b/Radegast/radegast.icns differ diff --git a/Radegast/radegast.ico b/Radegast/radegast.ico index ad64d2c56..80e2e85a5 100644 Binary files a/Radegast/radegast.ico and b/Radegast/radegast.ico differ diff --git a/Radegast/radegast.nsi b/Radegast/radegast.nsi deleted file mode 100644 index 32e364652..000000000 --- a/Radegast/radegast.nsi +++ /dev/null @@ -1,279 +0,0 @@ -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Includes -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -!include "LogicLib.nsh" -!include WordFunc.nsh -!include "FileFunc.nsh" -!insertmacro VersionCompare - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Compiler flags -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -SetOverwrite on ; overwrite files -SetCompress auto ; compress iff saves space -SetCompressor /solid lzma ; compress whole installer as one block -SetDatablockOptimize off ; only saves us 0.1%, not worth it -XPStyle on ; add an XP manifest to the installer -RequestExecutionLevel admin ; on Vista we must be admin because we write to Program Files - -LangString LanguageCode ${LANG_ENGLISH} "en" -!define DOTNET_URL "http://download.microsoft.com/download/0/6/1/061F001C-8752-4600-A198-53214C69B51F/dotnetfx35setup.exe" -!define MSI31_URL "http://download.microsoft.com/download/1/4/7/147ded26-931c-4daf-9095-ec7baf996f46/WindowsInstaller-KB893803-v2-x86.exe" - -!define APPNAME "Radegast" -!define VERSION "2.19" -!define MAINEXEC "${APPNAME}.exe" -!define DOTNET_VERSION "3.5" -!define VOICEPACK "RadegastVoicepack-1.0.exe" -!define UNINST_REG "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" - -; The name of the installer -Name "${APPNAME}" - -; The file to write -OutFile "..\${APPNAME}-${VERSION}-installer.exe" - -; The default installation directory -InstallDir "$PROGRAMFILES\${APPNAME}" - -; Registry key to check for directory (so if you install again, it will -; overwrite the old one automatically) -InstallDirRegKey HKLM "Software\${APPNAME}" "Install_Dir" - -;-------------------------------- - -LicenseText "Please review the license terms before installing Radegast" -LicenseData "license.txt" - -; Pages -Page license -Page components -Page directory -Page instfiles - -UninstPage uninstConfirm -UninstPage instfiles - -;-------------------------------- -; Check MSI and .NET -Section ".NET check" - ; Comment out below if not mandatory - ; SectionIn RO - - ; Set output path to the installation directory. - SetOutPath $TEMP - ReadRegDWORD $0 HKLM "SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5" "SP" - ${If} $0 < "1" - goto CheckMSI - ${EndIf} - goto NewDotNET - - CheckMSI: - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - ; MSI ; - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - GetDLLVersion "$SYSDIR\msi.dll" $R0 $R1 - IntOp $R2 $R0 / 0x00010000 ; $R2 now contains major version - IntOp $R3 $R0 & 0x0000FFFF ; $R3 now contains minor version - IntOp $R4 $R1 / 0x00010000 ; $R4 now contains release - IntOp $R5 $R1 & 0x0000FFFF ; $R5 now contains build - StrCpy $0 "$R2.$R3.$R4.$R5" ; $0 now contains string like "1.2.0.192" - DetailPrint "MSI version $0" - - ${If} $R2 < '3' - goto AskMSI - ${ElseIf} $R2 == '3' - DetailPrint "MSI3.x" - ${If} $R3 < '1' - goto AskMSI - ${EndIf} - ${Else} - DetailPrint "MSI3.1 already installed" - goto DownloadDotNET - ${EndIf} - - AskMSI: - SetOutPath "$TEMP" - SetOverwrite on - - MessageBox MB_YESNOCANCEL|MB_ICONEXCLAMATION \ - "Your MSI version: $0.$\nRequired Version: 3.1 or greater.$\nDownload MSI version from www.microsoft.com?" \ - /SD IDYES IDYES DownloadMSI IDNO DownloadDotNET - goto GiveUpDotNET ;IDCANCEL - - DownloadMSI: - DetailPrint "Beginning download of MSI3.1." - NSISDL::download ${MSI31_URL} "$TEMP\WindowsInstaller-KB893803-v2-x86.exe" - DetailPrint "Completed download." - Pop $0 - ${If} $0 == "cancel" - MessageBox MB_YESNO|MB_ICONEXCLAMATION \ - "Download cancelled. Continue Installation?" \ - IDYES DownloadDotNET IDNO GiveUpDotNET - ${ElseIf} $0 != "success" - MessageBox MB_YESNO|MB_ICONEXCLAMATION \ - "Download failed:$\n$0$\n$\nContinue Installation?" \ - IDYES DownloadDotNET IDNO GiveUpDotNET - ${EndIf} - DetailPrint "Pausing installation while downloaded MSI3.1 installer runs." - ExecWait '$TEMP\WindowsInstaller-KB893803-v2-x86.exe /quiet /norestart' $0 - DetailPrint "Completed MSI3.1 install/update. Exit code = '$0'. Removing MSI3.1 installer." - Delete "$TEMP\WindowsInstaller-KB893803-v2-x86.exe" - DetailPrint "MSI3.1 installer removed." - goto DownloadDotNET - - DownloadDotNET: - DetailPrint "Beginning download of .NET 3.5SP1." - NSISdl::download /TIMEOUT=30000 ${DOTNET_URL} "$TEMP\dotnetfx35.exe" /END - Pop $0 - DetailPrint "Result: $0" - StrCmp $0 "success" InstallDotNet - StrCmp $0 "cancel" GiveUpDotNET - NSISdl::download /TIMEOUT=30000 /NOPROXY ${DOTNET_URL} "$TEMP\dotnetfx35.exe" /END - Pop $0 - DetailPrint "Result: $0" - StrCmp $0 "success" InstallDotNet - - MessageBox MB_ICONSTOP "Download failed: $0" - goto NewDotNET - - GiveUpDotNET: - DetailPrint "Installation cancelled by user." - goto NewDotNET - - InstallDotNet: - DetailPrint "Completed download." - Pop $0 - ${If} $0 == "cancel" - MessageBox MB_YESNO|MB_ICONEXCLAMATION \ - "Download cancelled. Continue Installation?" \ - IDYES NewDotNET IDNO GiveUpDotNET - ${EndIf} - DetailPrint "Pausing installation while downloaded .NET Framework installer runs." - MessageBox MB_OKCANCEL "Setup will now install .NET Framework$\nThis will take a while." \ - IDOK +1 IDCANCEL GiveUpDotNET - ExecWait '$TEMP\dotnetfx35.exe /q /norestart /c:"install /q"' - DetailPrint "Completed .NET Framework install/update. Removing .NET Framework installer." - Delete "$TEMP\dotnetfx35.exe" - DetailPrint ".NET Framework installer removed." - goto NewDotNET - - NewDotNET: - DetailPrint ".NET Framework check complete." - -SectionEnd - - -;-------------------------------- -; The stuff to install -; Main Section -;-------------------------------- -Section "${APPNAME} core (required)" - - SectionIn RO - - ; Set output path to the installation directory. - SetOutPath $INSTDIR - - ; Put file there - File /r /x *.nsi /x *.bak /x *.mdb /x *.application /x *vshost*.* /x *installer*.* /x *.so /x *.dylib *.* - ; File Radegast.exe - - ; Write the installation path into the registry - WriteRegStr HKLM "SOFTWARE\${APPNAME}" "Install_Dir" "$INSTDIR" - - ; Write the uninstall keys for Windows - WriteRegStr HKLM ${UNINST_REG} "DisplayName" "${APPNAME} ${VERSION}" - WriteRegStr HKLM ${UNINST_REG} "UninstallString" '"$INSTDIR\uninstall.exe"' - WriteRegStr HKLM ${UNINST_REG} "QuietUninstallString" '"$INSTDIR\uninstall.exe" /S' - WriteRegStr HKLM ${UNINST_REG} "Publisher" "Radegast Development Team" - WriteRegStr HKLM ${UNINST_REG} "DisplayVersion" "${VERSION}" - WriteRegStr HKLM ${UNINST_REG} "DisplayIcon" "$INSTDIR\${MAINEXEC}" - ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2 - IntFmt $0 "0x%08X" $0 - WriteRegDWORD HKLM "${UNINST_REG}" "EstimatedSize" "$0" - WriteRegDWORD HKLM ${UNINST_REG} "NoModify" 1 - WriteRegDWORD HKLM ${UNINST_REG} "NoRepair" 1 - WriteUninstaller "uninstall.exe" - -SectionEnd - -;-------------------------------- -; Voice pack download and install -Section /o "${APPNAME} Voice Pack (extra download)" - AddSize 6662 - IfFileExists "$INSTDIR\SLVoice.exe" voice_download_exists - NSISdl::download /TIMEOUT=30000 "http://radegast.googlecode.com/files/${VOICEPACK}" "$INSTDIR\${VOICEPACK}" - Pop $R0 - StrCmp $R0 "success" voice_download_success voice_download_failed - - voice_download_success: - ExecWait '"$INSTDIR\${VOICEPACK}" /D=$INSTDIR' $0 - Delete "$INSTDIR\${VOICEPACK}" - goto voice_download_end - - voice_download_failed: - MessageBox MB_OK "Download failed: $R0. Skipping installation of voice." - goto voice_download_end - - voice_download_exists: - DetailPrint "Voice pack already present, skipping the install" - goto voice_download_end - - voice_download_end: -SectionEnd - -;-------------------------------- -; Start menu -Section "Start Menu Shortcuts" - - CreateDirectory "$SMPROGRAMS\${APPNAME}" - CreateShortCut "$SMPROGRAMS\${APPNAME}\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0 - CreateShortCut "$SMPROGRAMS\${APPNAME}\${APPNAME}.lnk" "$INSTDIR\${MAINEXEC}" "" "$INSTDIR\${MAINEXEC}" 0 - -SectionEnd - -;-------------------------------- -; Desktop shortcut -Section "Desktop shortcut" - - CreateShortCut "$DESKTOP\${APPNAME}.lnk" "$INSTDIR\${MAINEXEC}" "" "$INSTDIR\${MAINEXEC}" 0 - -SectionEnd - -;-------------------------------- -; Uninstaller - -Section "Uninstall" - IfFileExists "$INSTDIR\uninstall_voice.exe" +1 +2 - ExecWait '"$INSTDIR\uninstall_voice.exe" /S' $0 - - ; Remove registry keys - DeleteRegKey HKLM ${UNINST_REG} - DeleteRegKey HKLM "SOFTWARE\${APPNAME}" - - ; Remove files and uninstaller - Delete $INSTDIR\*.* - Delete $INSTDIR\aiml\*.* - RMDir $INSTDIR\aiml - Delete $INSTDIR\aiml_config\*.* - RMDir $INSTDIR\aiml_config - Delete $INSTDIR\character\*.* - RMDir $INSTDIR\character - Delete $INSTDIR\openmetaverse_data\static_assets\*.* - RMDir $INSTDIR\openmetaverse_data\static_assets - RMDir $INSTDIR\openmetaverse_data - Delete $INSTDIR\openmetaverse_data\*.* - RMDir $INSTDIR\openmetaverse_data - Delete $INSTDIR\shader_data\*.* - RMDir $INSTDIR\shader_data - - ; Remove shortcuts, if any - Delete "$DESKTOP\${APPNAME}.lnk" - Delete "$SMPROGRAMS\${APPNAME}\*.*" - - ; Remove directories used - RMDir "$SMPROGRAMS\${APPNAME}" - RMDir "$INSTDIR" - -SectionEnd diff --git a/Radegast/radegast.png b/Radegast/radegast.png index b6d5ede94..0b450b91f 100644 Binary files a/Radegast/radegast.png and b/Radegast/radegast.png differ diff --git a/build/README.txt b/build/README.txt deleted file mode 100644 index 6f58b2ce3..000000000 --- a/build/README.txt +++ /dev/null @@ -1 +0,0 @@ -You can find the most current version of premake5 at https://premake.github.io/download.html \ No newline at end of file diff --git a/build/linux/premake5 b/build/linux/premake5 deleted file mode 100755 index 59bca8a8a..000000000 Binary files a/build/linux/premake5 and /dev/null differ diff --git a/build/linux/version.txt b/build/linux/version.txt deleted file mode 100644 index 5bea22315..000000000 --- a/build/linux/version.txt +++ /dev/null @@ -1 +0,0 @@ -build-7-linux-travis_ci-2016-07-24 diff --git a/build/macosx/premake5 b/build/macosx/premake5 deleted file mode 100755 index 1ce41a0e0..000000000 Binary files a/build/macosx/premake5 and /dev/null differ diff --git a/build/macosx/version.txt b/build/macosx/version.txt deleted file mode 100644 index 5cb89dade..000000000 --- a/build/macosx/version.txt +++ /dev/null @@ -1 +0,0 @@ -build-7-osx-travis_ci-2016-07-24 diff --git a/build/windows/premake5.exe b/build/windows/premake5.exe deleted file mode 100755 index 28bccbcb8..000000000 Binary files a/build/windows/premake5.exe and /dev/null differ diff --git a/ci/before_deploy.sh b/ci/before_deploy.sh deleted file mode 100755 index 38c693cd3..000000000 --- a/ci/before_deploy.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -git config --global user.email "builds@travis-ci.com" -git config --global user.name "Travis CI" -git tag $GIT_TAG -a -m "Generated tag from TravisCI build $TRAVIS_BUILD_NUMBER" -git push -q "https://$GH_TOKEN@github.com/nooperation/radegast" $GIT_TAG -cd bin -echo $GIT_TAG > version.txt -zip -r ../$GIT_ARTIFACT . -cd .. diff --git a/ci/install.sh b/ci/install.sh deleted file mode 100755 index 51da1a0bb..000000000 --- a/ci/install.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -echo '// Placeholder for automated build systems to implement their build number.' > Radegast/RadegastBuild.cs -echo 'namespace Radegast ' >> Radegast/RadegastBuild.cs -echo '{ ' >> Radegast/RadegastBuild.cs -echo ' public static class RadegastBuild ' >> Radegast/RadegastBuild.cs -echo ' {' >> Radegast/RadegastBuild.cs -echo ' public const string VersionString = "'$BUILD_MAJOR'.'$BUILD_MINOR'.'$TRAVIS_BUILD_NUMBER'";' >> Radegast/RadegastBuild.cs -echo ' public const string BuildName = "'$GIT_TAG'";' >> Radegast/RadegastBuild.cs -echo ' }' >> Radegast/RadegastBuild.cs -echo '}' >> Radegast/RadegastBuild.cs -./runprebuild.sh diff --git a/libopenmetaverse b/libopenmetaverse deleted file mode 160000 index 757d6fa26..000000000 --- a/libopenmetaverse +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 757d6fa2626c077646b8b72d9e5ce104d672ddfc diff --git a/plugins/IdealistRadegastPlugin/IdealistPlugin.cs b/plugins/IdealistRadegastPlugin/IdealistPlugin.cs deleted file mode 100644 index b6c41f1ea..000000000 --- a/plugins/IdealistRadegastPlugin/IdealistPlugin.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading; -using IdealistViewer; -using log4net; -using log4net.Config; -using Nini; -using Nini.Config; -using ArgvConfigSource = Nini.Config.ArgvConfigSource; -using Radegast; - -namespace IdealistRadegastPlugin -{ - public class IdealistPlugin : IRadegastPlugin - { - private RadegastInstance Instance; - private RadegastViewer IV; - private IdealistUserControl idealistUserControl; - - public IdealistPlugin() - { - - } - public void StartPlugin(RadegastInstance inst) - { - return; - Instance = inst; - XmlConfigurator.Configure(); - - - ArgvConfigSource configSource = new ArgvConfigSource(new string[0]); - configSource.Alias.AddAlias("On", true); - configSource.Alias.AddAlias("Off", false); - configSource.Alias.AddAlias("True", true); - configSource.Alias.AddAlias("False", false); - - idealistUserControl = new IdealistUserControl(); - IV = new RadegastViewer(inst, configSource, idealistUserControl); - IV.Startup(); - inst.TabConsole.AddTab("Idealist", "Idealist", idealistUserControl); - //while (true) - //{ - // if (MainConsole.Instance != null) - // { - // MainConsole.Instance.Prompt(); - // Thread.Sleep(100); - // } - //} - } - - public void StopPlugin(RadegastInstance inst) - { - // throw new NotImplementedException(); - } - } -} diff --git a/plugins/IdealistRadegastPlugin/IdealistRadegastPlugin.csproj b/plugins/IdealistRadegastPlugin/IdealistRadegastPlugin.csproj deleted file mode 100644 index ecc181914..000000000 --- a/plugins/IdealistRadegastPlugin/IdealistRadegastPlugin.csproj +++ /dev/null @@ -1,193 +0,0 @@ - - - Local - 9.0.30729 - 2.0 - {8FB7F368-3916-47A3-B274-96FA898F4B9A} - Debug - AnyCPU - - - - - IdealistRadegastPlugin - JScript - Grid - IE50 - false - v3.5 - Library - - - IdealistRadegastPlugin - - - - - - - True - 285212672 - False - - - TRACE;VISUAL_STUDIO - - - False - 4096 - True - ..\..\bin\ - False - False - False - 3 - False - 1591,1574,0419,0618,0414,0169 - x86 - - - True - 285212672 - False - - - TRACE;DEBUG;VISUAL_STUDIO - - - True - 4096 - False - ..\..\bin\ - False - False - False - 3 - False - 1591,1574,0419,0618,0414,0169 - x86 - - - - HttpServer - - - Irrlicht.Extensions - - - Irrlicht.NET - - - log4net - - - MXP - - - Nini - - - PrimMesher - - - protobuf-net - - - System - - - System.Core - - - System.Drawing - - - System.Windows.Forms - - - System.Xml.Linq - - - System.Data.DataSetExtensions - - - System.Data - - - System.Xml - - - - - OpenMetaverse - {A09AB4F6-EA97-4860-93A0-D06778177FBB} - {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - - - OpenMetaverseTypes - {5455C710-2CE4-4BC2-8E8A-50BCF3A87B1A} - {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - - - OpenMetaverseCore - {C0901414-E66C-4BAC-AAE6-236C12B40206} - {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - - - IdealistViewer - {3CAE4FD8-F513-40B1-A540-793E213AA394} - {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - - - Radegast - {F216BEA5-6C63-4803-BD0B-0EAFF20CDF3F} - {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - - - - - - - - - - - - - True - Resources.resx - - - Component - - - IdealistViewControl.cs - - - UserControl - - - ParentWindowForm.cs - - - - - ResXFileCodeGenerator - Resources.Designer.cs - Designer - - - IdealistViewControl.cs - - - ParentWindowForm.cs - - - - - - - - - - \ No newline at end of file diff --git a/plugins/IdealistRadegastPlugin/Network/LibOmvNetworkModule.cs b/plugins/IdealistRadegastPlugin/Network/LibOmvNetworkModule.cs deleted file mode 100644 index 6e6460744..000000000 --- a/plugins/IdealistRadegastPlugin/Network/LibOmvNetworkModule.cs +++ /dev/null @@ -1,1148 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Reflection; -using IdealistViewer; -using IdealistViewer.Network; -using OpenMetaverse; -using OpenMetaverse.Assets; -using OpenMetaverse.Imaging; -using OpenMetaverse.Packets; -using log4net; -using System.Drawing; -using IdealistViewer.Scene; -using System.Drawing.Imaging; -using Radegast; - -namespace IdealistRadegastPlugin -{ - - public class SimulatorCull - { - public Dictionary> PrimsAwaitingParent = new Dictionary>(); - public Dictionary ParentsSent = new Dictionary(); - public Dictionary> ChildsSent = new Dictionary>(); - public Dictionary ParentsCulled = new Dictionary(); - public Dictionary> ChildsCulled = new Dictionary>(); - public List PatchesSent = new List(); - public List PatchesCulled = new List(); - readonly public Simulator simulator; - public SimulatorCull(Simulator sim) - { - simulator = sim; - } - } - public class SimPatchInfo - { - public SimPatchInfo(Simulator simulator0, int x0, int y0, int width0, float[] data0) - { - simulator = simulator0; - x = x0; - y = y0; - width = width0; - data = data0; - float w2 = (float) width/2; - pos = RadegastNetworkModule.GlobalPos(simulator.Handle, new Vector3(width * x + w2, width * y + w2, data[0])); - } - public override int GetHashCode() - { - return ((int) simulator.Handle*width*width) + x + y*width; - } - public override bool Equals(object obj) - { - if (obj is SimPatchInfo) - { - SimPatchInfo other = (SimPatchInfo)obj; - return simulator == other.simulator && x == other.x && y == other.y; - } - return false; - } - public Vector3d pos; - public Simulator simulator; - public int x; - public int y; - public int width; - public float[] data; - } - - public class RadegastNetworkModule : INetworkInterface - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - public Dictionary SimulatorCullings = new Dictionary(); - /// - /// Basically so we don't add 8 neighbors terrain into scene until we need it - /// - public double LandSightDistance = 96.0; - /// - /// When set true will try to limit the number of objects sent to the native layer based on avatars camera distance - /// - public bool ObjectsToManagedLayerIsRangeBased = true; - /// - /// The maximum prims at a time we send to the native layer. TODO: Implement! - /// - public int MAX_PRIMS = 8000; - /// - /// The Count of prims we've already sent to the native layer. TODO: Implement! - /// - public int CURRENT_PRIMS = 0; - /// - /// How far to look - /// - public double MAX_DIST - { - get - { - return m_user.Self.Movement.Camera.Far; - } - } - public Vector3d CameraPosition - { - get - { - return m_user.Self.GlobalPosition; - } - } - - static internal Vector3d GlobalPos(ulong regionHandle, Vector3 pos) - { - uint globalX, globalY; - Utils.LongToUInts(regionHandle, out globalX, out globalY); - return new Vector3d( - (double)globalX + (double)pos.X, - (double)globalY + (double)pos.Y, - (double)pos.Z); - } - - private bool Sendable(Primitive primitive) - { - - if (m_user.Network.CurrentSim == null) //;// || primitive.RegionHandle != m_user.Network.CurrentSim.Handle) - return false; - double d = Vector3d.Distance(CameraPosition, GlobalPos(primitive.RegionHandle, primitive.Position)); - return d < MAX_DIST; - } - - public void Statistics() - { - } - - private Vector3 _lastKnownSimPostion = Vector3.Zero; - private readonly object _lastKnownPosLock = new object(); - private void OnSelfUpdated(Simulator simulator, ObjectUpdate update, ulong regionhandle) - { - lock (_lastKnownPosLock) - { - if (_lastKnownSimPostion == Vector3.Zero) - { - _lastKnownSimPostion = update.Position; - return; - } - if (Vector3.Distance(update.Position, _lastKnownSimPostion) < 8) return; - _lastKnownSimPostion = update.Position; - } - - List simCulls = null; - List sendpatches = new List(); - lock (SimulatorCullings) - { - simCulls = new List(SimulatorCullings.Values); - } - - - foreach (SimulatorCull sc in simCulls) - { - lock (sc) - { - foreach (var p in sc.PatchesCulled) - { - - if (Vector3d.Distance(CameraPosition, p.pos) < LandSightDistance) - { - sendpatches.Add(p); - } - } - foreach (var p in sendpatches) - { - sc.PatchesCulled.Remove(p); - sc.PatchesSent.Add(p); - } - } - } - foreach (var p in sendpatches) - { - landPatchCallback(p.simulator, p.x, p.y, p.width, p.data); - } - - if (!ObjectsToManagedLayerIsRangeBased) return; - - foreach (SimulatorCull sc in simCulls) - { - lock (sc) OnSelfUpdatedObjects(sc); - } - } - - private void OnSelfUpdatedObjects(SimulatorCull sc) - { - List sendprims = new List(); - - foreach (var p in sc.ParentsCulled.Values) - { - - if (Vector3d.Distance(CameraPosition, GlobalPos(p.RegionHandle, p.Position)) < - MAX_DIST) - { - sendprims.Add(p); - } - } - foreach (var p in sendprims) - { - sc.ParentsCulled.Remove(p.LocalID); - if (sc.ChildsCulled.ContainsKey(p.LocalID)) - { - sc.PrimsAwaitingParent[p.LocalID] = sc.ChildsCulled[p.LocalID]; - } - newPrimCulled(sc.simulator, p, sc.simulator.Handle, 0); - } - sendprims.Clear(); - foreach (var p in sc.ParentsSent.Values) - { - if (Vector3d.Distance(CameraPosition, GlobalPos(p.RegionHandle, p.Position)) > - MAX_DIST) - { - sendprims.Add(p); - } - } - foreach (var p in sendprims) - { - sc.ParentsSent.Remove(p.LocalID); - sc.ParentsCulled[p.LocalID] = p; - if (sc.ChildsSent.ContainsKey(p.LocalID)) - { - sc.ChildsCulled[p.LocalID] = new List(sc.ChildsSent[p.LocalID]); - foreach (var pc in sc.ChildsSent[p.LocalID]) - { - objectKilledCallback(sc.simulator, pc.LocalID); - } - sc.ChildsSent[p.LocalID].Clear(); - } - objectKilledCallback(sc.simulator, p.LocalID); - } - } - - private void landPatchCallbackCulled(Simulator simulator, int x, int y, int width, float[] data) - { - SimulatorCull sc; - ulong regionhandle = simulator.Handle; - lock (SimulatorCullings) - if (!SimulatorCullings.TryGetValue(regionhandle, out sc)) - { - SimulatorCullings[regionhandle] = sc = new SimulatorCull(simulator); - } - lock (sc) - { - SimPatchInfo p = new SimPatchInfo(simulator, x, y, width, data); - Vector3d p3d = p.pos; - p3d.Z = CameraPosition.Z; - if (Vector3d.Distance(CameraPosition, p3d) > LandSightDistance) - { - sc.PatchesCulled.Add(p); - return; - } - else - { - if (sc.PatchesSent.Contains(p)) return; - sc.PatchesSent.Add(p); - } - } - landPatchCallback(simulator, x, y, width, data); - } - - private void objectKilledCallbackCulled(Simulator simulator, uint objectid) - { - if (!ObjectsToManagedLayerIsRangeBased) - { - objectKilledCallback(simulator, objectid); - return; - } - SimulatorCull sc; - ulong regionhandle = simulator.Handle; - lock (SimulatorCullings) if (!SimulatorCullings.TryGetValue(regionhandle, out sc)) - { - SimulatorCullings[regionhandle] = sc = new SimulatorCull(simulator); - } - lock (sc) - { - - List childs; - if (sc.ChildsCulled.TryGetValue(objectid, out childs)) - { - childs.Clear(); - sc.ChildsCulled.Remove(objectid); - } - if (sc.ChildsSent.TryGetValue(objectid, out childs)) - { - childs.Clear(); - sc.ChildsSent.Remove(objectid); - } - if (sc.ParentsCulled.ContainsKey(objectid)) - { - sc.ParentsCulled.Remove(objectid); - return; - } - if (sc.ParentsSent.ContainsKey(objectid)) - { - sc.ParentsSent.Remove(objectid); - objectKilledCallback(simulator, objectid); - return; - } - // this is a child - Primitive prim = null; - foreach (List ch in sc.PrimsAwaitingParent.Values) - { - foreach (var p in ch) - { - if (p.LocalID == objectid) - { - prim = p; - break; - } - } - if (prim == null) continue; - ch.Remove(prim); - break; - } - //if (prim != null) return; - foreach (List ch in sc.ChildsCulled.Values) - { - foreach (var p in ch) - { - if (p.LocalID == objectid) - { - prim = p; - break; - } - } - if (prim == null) continue; - ch.Remove(prim); - return; - } - foreach (List ch in sc.ChildsSent.Values) - { - foreach (var p in ch) - { - if (p.LocalID == objectid) - { - prim = p; - break; - } - } - if (prim == null) continue; - ch.Remove(prim); - break; - } - objectKilledCallback(simulator, objectid); - } - - } - - private void newPrimCulled(Simulator simulator, Primitive prim, ulong regionhandle, ushort timedilation) - { - if (prim.RegionHandle == 0) - { - prim.RegionHandle = regionhandle; - } - SimulatorCull sc; - lock (SimulatorCullings) if (!SimulatorCullings.TryGetValue(regionhandle, out sc)) - { - SimulatorCullings[regionhandle] = sc = new SimulatorCull(simulator); - } - - if (!ObjectsToManagedLayerIsRangeBased) - { - newPrim(sc, simulator, prim, regionhandle, timedilation); - return; - } - lock (sc) - { - List prims; - if (prim.ParentID == 0) - { - if (sc.PrimsAwaitingParent.TryGetValue(prim.LocalID, out prims)) - { - if (Sendable(prim)) - { - //sc.PrimsAwaitingParent.Remove(prim.LocalID); - //// send the childs - //foreach (Primitive p in prims) - //{ - // newPrim(sc, simulator, p, regionhandle, timedilation); - //} - newPrim(sc, simulator, prim, regionhandle, timedilation); - return; - } - else - { - sc.PrimsAwaitingParent.Remove(prim.LocalID); - sc.ParentsCulled[prim.LocalID] = prim; - sc.ChildsCulled[prim.LocalID] = prims; - return; - } - } - else - { - if (Sendable(prim)) - { - newPrim(sc, simulator, prim, regionhandle, timedilation); - return; - } - else - { - sc.ParentsCulled[prim.LocalID] = prim; - return; - } - } - } - - if (sc.ParentsCulled.ContainsKey(prim.ParentID)) - { - if (!sc.ChildsCulled.TryGetValue(prim.ParentID, out prims)) - { - sc.ChildsCulled[prim.ParentID] = prims = new List(); - prims.Add(prim); - return; - } - else - { - if (!prims.Contains(prim)) - { - prims.Add(prim); - return; - } - } - } - // child with parent already sent - if (sc.ParentsSent.ContainsKey(prim.ParentID)) - { - //this is an update - newPrim(sc, simulator, prim, regionhandle, timedilation); - return; - } - // child with culled parent - if (sc.ParentsCulled.ContainsKey(prim.ParentID)) - { - if (!sc.ChildsCulled.TryGetValue(prim.ParentID, out prims)) - { - sc.ChildsCulled[prim.ParentID] = prims = new List(); - prims.Add(prim); - } - else - { - if (!prims.Contains(prim)) - { - prims.Add(prim); - } - } - return; - } - if (sc.ChildsSent.ContainsKey(prim.ParentID)) - { - //this is an update - newPrim(sc, simulator, prim, regionhandle, timedilation); - return; - } - if (sc.ParentsSent.ContainsKey(prim.ParentID)) - { - //this is an update - newPrim(sc, simulator, prim, regionhandle, timedilation); - return; - } - if (!sc.PrimsAwaitingParent.TryGetValue(prim.ParentID, out prims)) - { - sc.PrimsAwaitingParent[prim.ParentID] = prims = new List(); - prims.Add(prim); - return; - } - else - { - if (!prims.Contains(prim)) - { - prims.Add(prim); - return; - } - return; - } - } - } - - public event NetworkAvatarAddDelegate OnAvatarAdd; - public event NetworkChatDelegate OnChat; - public event NetworkConnectedDelegate OnConnected; - public event NetworkSimulatorConnectedDelegate OnSimulatorConnected; - public event NetworkLandUpdateDelegate OnLandUpdate; - public event NetworkLoginDelegate OnLoggedIn; - public event NetworkObjectAddDelegate OnObjectAdd; - public event NetworkObjectRemoveDelegate OnObjectRemove; - public event NeworkObjectUpdateDelegate OnObjectUpdate; - public event NetworkTextureDownloadedDelegate OnTextureDownloaded; - public event NetworkFriendsListUpdateDelegate OnFriendsListUpdate; - - private Vector3 lastCameraPos = Vector3.Zero; - private Vector3 lastCameraTarget = Vector3.Zero; - - public string loginURI; - public string LoginURI - { - get - { - return loginURI; - } - } - public string firstName; - public string FirstName - { - get - { - return firstName; - } - } - public string lastName; - public string LastName - { - get - { - return lastName; - } - } - public string username; - public string UserName - { - get - { - return username; - } - } - public string password; - public string Password - { - get - { - return password; - } - } - public string startlocation; - public string StartLocation - { - get - { - return startlocation; - } - } - - // received animations are stored here before being processed in the main frame loop - public Dictionary> avatarAnimations = new Dictionary>(); - public Dictionary> AvatarAnimations - { - get - { - return avatarAnimations; - } - set - { - avatarAnimations = value; - } - } - - public GridClient m_user; - private RadegastInstance radegastInstance; - - public RadegastNetworkModule(RadegastInstance inst) - { - radegastInstance = inst; - m_user = inst.Client; - - //dm m_user.Settings.USE_LLSD_LOGIN = true; - - //m_user.Settings.STORE_LAND_PATCHES = true; - //m_user.Settings.MULTIPLE_SIMS = false; - //m_user.Settings.OBJECT_TRACKING = true; - //m_user.Settings.AVATAR_TRACKING = true; - //dm m_user.Settings.USE_TEXTURE_CACHE = false; - //m_user.Settings.USE_TEXTURE_CACHE = true; - //m_user.Settings. - //dm m_user.Settings.ALWAYS_DECODE_OBJECTS = false; - - //m_user.Settings.SEND_AGENT_UPDATES = true; - //m_user.Settings.SEND_AGENT_THROTTLE = true; - //m_user.Settings.SEND_PINGS = true; - - // m_user.Self.Movement.Camera.Far = 512.0f; - - //dm m_user.Settings.MAX_CONCURRENT_TEXTURE_DOWNLOADS = 2; - //dm m_user.Settings.PIPELINE_REQUEST_TIMEOUT = 30 * 1000; - - m_user.Network.OnConnected += gridConnectedCallback; - m_user.Network.OnDisconnected += disconnectedCallback; - m_user.Network.OnSimConnected += simConnectedCallback; - m_user.Network.OnLogin += loginStatusCallback; - m_user.Terrain.OnLandPatch += landPatchCallbackCulled; - // m_user.Self.OnChat += chatCallback; - m_user.Objects.OnNewAvatar += newAvatarCallback; - m_user.Objects.OnNewPrim += newPrimCulled; - m_user.Objects.OnObjectKilled += objectKilledCallbackCulled; - m_user.Network.OnLogin += loginCallback; - m_user.Objects.OnObjectUpdated += objectUpdatedCallback; - //m_user.Assets.OnImageReceived += imageReceivedCallback; - //m_user.Friends.OnFriendNamesReceived += Friends_OnFriendNamesReceived; - //m_user.Friends.OnFriendOnline += Friends_OnFriendOnline; - //m_user.Friends.OnFriendOffline += Friends_OnFriendOffline; - - //m_user.Assets.RequestImage( - //m_user.Assets.Cache..RequestImage(UUID.Zero, ImageType.Normal); - - m_user.Network.RegisterCallback(OpenMetaverse.Packets.PacketType.AvatarAnimation, AvatarAnimationHandler); - - } - - private void Friends_OnFriendOffline(FriendInfo friend) - { - if( OnFriendsListUpdate != null ) - { - OnFriendsListUpdate(); - } - } - - private void Friends_OnFriendOnline(FriendInfo friend) - { - if (OnFriendsListUpdate != null) - { - OnFriendsListUpdate(); - } - } - - private void Friends_OnFriendNamesReceived(Dictionary names) - { - if (OnFriendsListUpdate != null) - { - OnFriendsListUpdate(); - } - } - - public InternalDictionary Friends - { - get - { - return m_user.Friends.FriendList; - //return null; - } - } - - public void AvatarAnimationHandler(OpenMetaverse.Packets.Packet packet, Simulator sim) - { - // When animations for any avatar are received put them in the AvatarAnimations dictionary - // in this module. They should be processed and deleted inbetween frames in the main frame loop - // or deleted when an avatar is deleted from the scene. - AvatarAnimationPacket animation = (AvatarAnimationPacket)packet; - - UUID avatarID = animation.Sender.ID; - List currentAnims = new List(); - - for (int i = 0; i < animation.AnimationList.Length; i++) - currentAnims.Add(animation.AnimationList[i].AnimID); - - lock (AvatarAnimations) - { - if (AvatarAnimations.ContainsKey(avatarID)) - AvatarAnimations[avatarID] = currentAnims; - else - AvatarAnimations.Add(avatarID, currentAnims); - } - } - - public void loginStatusCallback(LoginStatus login, string message) - { - if (login == LoginStatus.Failed) - { - m_log.ErrorFormat("[CONNECTION]: Login Failed:{0}",message); - } - } - - private void imageReceivedCallback(TextureRequestState state, AssetTexture asset) - { - if (state == TextureRequestState.Timeout) - { - // need a re-request if a texture times out but doing it here borks libomv - //m_user.Assets.RequestImage(asset.AssetID, ImageType.Normal, imageReceivedCallback); - return; - } - - if (state != TextureRequestState.Finished) - return; - - if (OnTextureDownloaded != null) - { - - VTexture texture = new VTexture(); - texture.TextureId = asset.AssetID; - - ManagedImage managedImage; - Image tempImage; - - try - { - if (OpenJPEG.DecodeToImage(asset.AssetData, out managedImage, out tempImage)) - { - Bitmap textureBitmap = new Bitmap(tempImage.Width, tempImage.Height, PixelFormat.Format32bppArgb); - Graphics graphics = Graphics.FromImage(textureBitmap); - graphics.DrawImage(tempImage, 0, 0); - graphics.Flush(); - graphics.Dispose(); - texture.Image = textureBitmap; - OnTextureDownloaded(texture); - } - } - catch (Exception e) - { - m_log.Error(":( :( :( :( got exception decoding image ): ): ): ):\nException: " + e.ToString()); - } - } - } - private void objectKilledCallback(Simulator simulator, uint objectID) - { - if (OnObjectRemove != null) - { - OnObjectRemove(new VSimulator(simulator), objectID); - } - } - - public void Login(string loginURI, string username, string password, string startlocation) - { - - string firstname; - string lastname; - - this.loginURI = loginURI; - this.username = username; - this.password = password; - this.startlocation = startlocation; - - Util.separateUsername(username, out firstname, out lastname); - - this.firstName = firstname; - this.lastName = lastname; - - - LoginParams loginParams = getLoginParams(loginURI, username, password, startlocation); - - m_user.Network.BeginLogin(loginParams); - } - - private void gridConnectedCallback(object sender) - { - - m_user.Appearance.SetPreviousAppearance(false); - - - - if (OnConnected != null) - { - OnConnected(); - } - } - private void simConnectedCallback(Simulator sender) - { - m_user.Throttle.Total = 600000; - m_user.Throttle.Land = 80000; - m_user.Throttle.Task = 200000; - m_user.Throttle.Texture = 100000; - m_user.Throttle.Wind = 10000; - m_user.Throttle.Resend = 100000; - m_user.Throttle.Asset = 100000; - m_user.Throttle.Cloud = 10000; - m_user.Self.Movement.Camera.Far = 64f; - - // this line creates a not found exception but for some unknown reason allows more prims - // to show up on the linden grid - //m_user.Self.Movement.Camera.Position = m_user.Network.CurrentSim.AvatarPositions[m_user.Self.AgentID]; - - // this line *should* work in all cases - m_user.Self.Movement.Camera.Position = m_user.Self.SimPosition; - - SetHeightWidth(768, 1024); - if (OnSimulatorConnected != null) - { - OnSimulatorConnected(new VSimulator(sender)); - } - } - private void loginCallback(LoginStatus status, string message) - { - if (OnLoggedIn != null) - { - OnLoggedIn((LoginStatus)status, message); - } - } - public void Logout() - { - if (m_user.Network.Connected) - { - m_user.Network.Logout(); - } - } - public void disconnectedCallback(NetworkManager.DisconnectType reason, string message) - { - m_log.ErrorFormat("[CONNECTION]: Disconnected{0}: Message:{1}",reason.ToString(), message); - } - public bool Connected - { - get { return m_user.Network.Connected; } - } - public void Whisper(string message) - { - m_user.Self.Chat(message, 0, ChatType.Whisper); - } - - public void Say(string message) - { - m_user.Self.Chat(message, 0, ChatType.Normal); - } - - public void Shout(string message) - { - m_user.Self.Chat(message, 0, ChatType.Shout); - } - - public void Teleport(string region, float x, float y, float z) - { - m_user.Self.Teleport(region, new Vector3(x, y, z)); - } - - private LoginParams getLoginParams(string loginURI, string username, string password, string startlocation) - { - string firstname; - string lastname; - - Util.separateUsername(username, out firstname, out lastname); - - LoginParams loginParams = m_user.Network.DefaultLoginParams( - firstname, lastname, password, "IdealistViewer", "0.0.0.1");//Constants.Version); - - - loginURI = Util.getSaneLoginURI(loginURI); - - if (startlocation.Length == 0) - { - - if (!loginURI.EndsWith("/")) - loginURI += "/"; - - string[] locationparse = loginURI.Split('/'); - try - { - startlocation = locationparse[locationparse.Length - 2]; - if (startlocation == locationparse[2]) - { - startlocation = "last"; - } - else - { - loginURI = ""; - for (int i = 0; i < locationparse.Length - 2; i++) - { - loginURI += locationparse[i] + "/"; - } - } - - } - catch (Exception) - { - startlocation = "last"; - } - - } - else - { - - - //if (!loginURI.EndsWith("/")) - // loginURI += "/"; - - // string[] locationparse = loginURI.Split('/'); - // try - // { - // string end = locationparse[locationparse.Length - 2]; - // if (end != locationparse[2]) - // { - // loginURI = ""; - // for (int i = 0; i < 3; i++) - // { - // if (locationparse[i].Length != 0 || i==1) - // loginURI += locationparse[i] + "/"; - // } - // } - - //} - // catch (Exception) - //{ - //startlocation = "last"; - // m_log.Warn("[URLPARSING]: Unable to parse URL provided!"); - //} - - - } - - loginParams.URI = loginURI; - - - if (startlocation != "last" && startlocation != "home") - startlocation = "uri:" + startlocation + "&128&128&20"; - - loginParams.Start = startlocation; - - return loginParams; - } - - private void chatCallback(string message, ChatAudibleLevel audible, ChatType type, ChatSourceType sourcetype, - string fromName, UUID id, UUID ownerid, Vector3 position) - { - // This is weird -- we get start/stop typing chats from - // other avatars, and we get messages back that we sent. - // (Tested on OpenSim r3187) - // So we explicitly check for those cases here. - if ((int)type < 4 && id != m_user.Self.AgentID) - { - m_log.Debug("Chat: " + fromName + ": " + message); - if (OnChat != null) - { - OnChat(message, audible, type, sourcetype, - fromName, id, ownerid, position); - } - } - } - - - - private void newPrim(SimulatorCull sc, Simulator simulator, Primitive prim, ulong regionHandle, - ushort timeDilation) - { - lock (sc) - { - - List prims; - if (prim.ParentID == 0) - { - sc.ParentsSent[prim.LocalID] = prim; - if (sc.ChildsCulled.TryGetValue(prim.LocalID, out prims)) - { - sc.ChildsCulled.Remove(prim.LocalID); - foreach (var p in prims) - { - newPrim(sc, simulator, p, regionHandle, timeDilation); - } - } - if (sc.PrimsAwaitingParent.TryGetValue(prim.LocalID, out prims)) - { - sc.PrimsAwaitingParent.Remove(prim.LocalID); - foreach (var p in prims) - { - newPrim(sc, simulator, p, regionHandle, timeDilation); - } - } - } - else - { - if (!sc.ChildsSent.TryGetValue(prim.ParentID, out prims)) - { - sc.ChildsSent[prim.ParentID] = prims = new List(); - prims.Add(prim); - } - else - { - if (!prims.Contains(prim)) - { - prims.Add(prim); - } - } - } - } - if (OnObjectAdd != null) - { - OnObjectAdd(new VSimulator(simulator), prim, regionHandle, timeDilation); - } - } - - - private void landPatchCallback(Simulator simulator, int x, int y, int width, float[] data) - { - if (OnLandUpdate != null) - { - OnLandUpdate(new VSimulator(simulator), x, y, width, data); - } - } - private void newAvatarCallback(Simulator simulator, Avatar avatar, ulong regionHandle, - ushort timeDilation) - { - if (OnAvatarAdd != null) - { - //avatar.Velocity - OnAvatarAdd(new VSimulator(simulator), avatar, regionHandle, timeDilation); - } - } - private void objectUpdatedCallback(Simulator simulator, ObjectUpdate update, ulong regionHandle, - ushort timeDilation) - { - if (simulator == m_user.Network.CurrentSim) - { - if (m_user.Self.LocalID == update.LocalID) - { - OnSelfUpdated(simulator, update, regionHandle); - } - } - if (OnObjectUpdate != null) - { - OnObjectUpdate(new VSimulator(simulator), update, regionHandle, timeDilation); - } - } - - public void RequestTexture(UUID assetID) - { - m_user.Assets.RequestImage(assetID, ImageType.Normal, imageReceivedCallback); - } - - public void SendCameraViewMatrix(Vector3[] camdata) - { - - //for (int i=0;i 1.0f || Vector3.Distance(lastCameraTarget, currTarget) > 1.0f) - { - - m_user.Self.Movement.Camera.LookDirection(currTarget); - m_user.Self.Movement.Camera.Position = currPos; - - lastCameraPos = currPos; - lastCameraTarget = currTarget; - //m_log.Debug("[CAMERA UPDATE] - " + m_user.Self.Movement.Camera.Position.ToString() + ", " + currTarget.ToString()); - m_log.Debug("[CAMERA UPDATE] - pos: " + myPos.ToString() + " cam: " + currPos.ToString() + " tgt: " + currTarget.ToString()); - - } - - } - - public void SetHeightWidth(uint height, uint width) - { - m_user.Self.SetHeightWidth((ushort)height, (ushort)width); - } - - public UUID GetSelfUUID - { - get { return m_user.Self.AgentID; } - } - - public bool StraffLeft - { - set {m_user.Self.Movement.LeftPos = value;} - get { return m_user.Self.Movement.LeftPos; } - } - public bool StraffRight - { - set { m_user.Self.Movement.LeftNeg = value; } - get { return m_user.Self.Movement.LeftNeg; } - } - - public void UpdateFromHeading(double heading) - { - m_user.Self.Movement.UpdateFromHeading(heading ,false); - } - - public void TurnToward(Vector3 target) - { - m_user.Self.Movement.TurnToward(target); - } - - public bool Forward - { - set {m_user.Self.Movement.AtPos = value;} - get { return m_user.Self.Movement.AtPos; } - } - - public bool Backward - { - set { m_user.Self.Movement.AtNeg = value; } - get { return m_user.Self.Movement.AtNeg; } - } - - public bool Jump - { - set { m_user.Self.Jump(value); } - } - - public bool Flying - { - get { return m_user.Self.Movement.Fly; } - set { m_user.Self.Movement.Fly = value; } - } - - public bool Up - { - get { return m_user.Self.Movement.UpPos; } - set { m_user.Self.Movement.UpPos = value; } - } - - public bool Down - { - get { return m_user.Self.Movement.UpNeg; } - set { m_user.Self.Movement.UpNeg = value; } - } - - public bool MultipleSims - { - get - { - return m_user.Settings.MULTIPLE_SIMS; - } - set - { - m_user.Settings.MULTIPLE_SIMS=value; - } - } - - - #region IProtocol Members - - - public void Process() - { - } - - #endregion - } -} diff --git a/plugins/IdealistRadegastPlugin/Properties/AssemblyInfo.cs b/plugins/IdealistRadegastPlugin/Properties/AssemblyInfo.cs deleted file mode 100644 index f45bcb5bb..000000000 --- a/plugins/IdealistRadegastPlugin/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("IdealistRadegastPlugin")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("PANDOR")] -[assembly: AssemblyProduct("IdealistRadegastPlugin")] -[assembly: AssemblyCopyright("Copyright © PANDOR 2009")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("94d460c3-465f-4e04-b373-c001f9bb1d3d")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/plugins/IdealistRadegastPlugin/Properties/Resources.Designer.cs b/plugins/IdealistRadegastPlugin/Properties/Resources.Designer.cs deleted file mode 100644 index 254d31577..000000000 --- a/plugins/IdealistRadegastPlugin/Properties/Resources.Designer.cs +++ /dev/null @@ -1,63 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.3053 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace IdealistRadegastPlugin.Properties { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("IdealistRadegastPlugin.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - } -} diff --git a/plugins/IdealistRadegastPlugin/Renderer/IdealistViewControl.Designer.cs b/plugins/IdealistRadegastPlugin/Renderer/IdealistViewControl.Designer.cs deleted file mode 100644 index d2c466dd4..000000000 --- a/plugins/IdealistRadegastPlugin/Renderer/IdealistViewControl.Designer.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System.Windows.Forms; - -namespace IdealistRadegastPlugin -{ - partial class IdealistViewControl - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.IdealistView = new System.Windows.Forms.PictureBox(); - ((System.ComponentModel.ISupportInitialize)(this.IdealistView)).BeginInit(); - this.SuspendLayout(); - // - // IdealistView - // - this.IdealistView.Dock = System.Windows.Forms.DockStyle.Fill; - //this.IdealistView.Image = global::IdealistRadegastPlugin.Properties.Resources.radegast; - this.IdealistView.Location = new System.Drawing.Point(0, 0); - this.IdealistView.Name = "IdealistView"; - this.IdealistView.Size = new System.Drawing.Size(893, 835); - this.IdealistView.TabIndex = 0; - this.IdealistView.TabStop = false; - this.IdealistView.Click += new System.EventHandler(this.IdealistView_Click); - // - // IdealistViewControl - // - this.Controls.Add(this.IdealistView); - this.Name = "IdealistViewControl"; - this.Size = new System.Drawing.Size(893, 835); - this.Click += new System.EventHandler(this.UIFace_Click); - ((System.ComponentModel.ISupportInitialize)(this.IdealistView)).EndInit(); - this.ResumeLayout(false); - - } - - #endregion - - public Control IdealistView; - - - - } -} \ No newline at end of file diff --git a/plugins/IdealistRadegastPlugin/Renderer/IdealistViewControl.cs b/plugins/IdealistRadegastPlugin/Renderer/IdealistViewControl.cs deleted file mode 100644 index fd35c33ad..000000000 --- a/plugins/IdealistRadegastPlugin/Renderer/IdealistViewControl.cs +++ /dev/null @@ -1,69 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Runtime.InteropServices; -using System.Text; -using System.Windows.Forms; -using IrrlichtNETCP; - -namespace IdealistRadegastPlugin -{ - public partial class IdealistViewControl : Control, System.ComponentModel.ISupportInitialize - { - [DllImport("user32")] - public static extern int SendMessage(IntPtr IntPtr, int wMsg, int wParam, IntPtr lParam); - public IntPtr msgTarget; - - public IdealistViewControl() - { - InitializeComponent(); - this.SizeChanged += Viewer_OnResize; - } - - private void UIFace_Click(object sender, EventArgs e) - { - - } - - protected override void WndProc(ref Message m) - { - //where is the handle? SendMessage(this.Parent.Handle, m.Msg, m.WParam.ToInt32(), m.LParam); - base.WndProc(ref m); - } - - private void Viewer_OnResize(object sender, EventArgs e) - { - // Dimension2D size = new Dimension2D(this.ClientSize.Height, this.ClientSize.Width); - // Rect rect = new Rect(new Position2D(0,0),size); - // if (this.Renderer!=null) this.Renderer.Device.VideoDriver.ViewPort = rect; - //// SendMessage(msgTarget,0,0,0) - // //??Renderer.GuiEnvironment.VideoDriver.ScreenSize = size; - } - - protected override void OnPaint(PaintEventArgs pe) - { - // base.OnPaint(pe); - } - protected override void OnPaintBackground(PaintEventArgs pevent) - { - // base.OnPaintBackground(pevent); - } - - private void IdealistView_Click(object sender, EventArgs e) - { - - } - - public void BeginInit() - { - // throw new NotImplementedException(); - } - - public void EndInit() - { - // throw new NotImplementedException(); - } - } -} diff --git a/plugins/IdealistRadegastPlugin/Renderer/ParentWindowForm.Designer.cs b/plugins/IdealistRadegastPlugin/Renderer/ParentWindowForm.Designer.cs deleted file mode 100644 index 85769f8b5..000000000 --- a/plugins/IdealistRadegastPlugin/Renderer/ParentWindowForm.Designer.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System.Windows.Forms; - -namespace IdealistRadegastPlugin -{ - partial class IdealistUserControl - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - public void InitializeComponent() - { - this.IdealistView = new IdealistViewControl(); - ((System.ComponentModel.ISupportInitialize)(this.IdealistView)).BeginInit(); - this.SuspendLayout(); - // - // IdealistView - // - this.IdealistView.Dock = System.Windows.Forms.DockStyle.Fill; - //this.IdealistView.Image = global::IdealistRadegastPlugin.Properties.Resources.radegast; - this.IdealistView.Location = new System.Drawing.Point(0, 0); - this.IdealistView.Name = "IdealistView"; - this.IdealistView.Size = new System.Drawing.Size(893, 835); - this.IdealistView.TabIndex = 0; - this.IdealistView.TabStop = false; - this.IdealistView.Click += new System.EventHandler(this.IdealistView_Click); - // - // IdealistUserControl - // - this.Controls.Add(this.IdealistView); - this.Name = "IdealistUserControl"; - this.Size = new System.Drawing.Size(893, 835); - this.Click += new System.EventHandler(this.UIFace_Click); - ((System.ComponentModel.ISupportInitialize)(this.IdealistView)).EndInit(); - this.ResumeLayout(false); - } - - #endregion - - public Control IdealistView; - - - - } -} \ No newline at end of file diff --git a/plugins/IdealistRadegastPlugin/Renderer/ParentWindowForm.cs b/plugins/IdealistRadegastPlugin/Renderer/ParentWindowForm.cs deleted file mode 100644 index 77e7f69b6..000000000 --- a/plugins/IdealistRadegastPlugin/Renderer/ParentWindowForm.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Runtime.InteropServices; -using System.Text; -using System.Windows.Forms; -using IrrlichtNETCP; - -namespace IdealistRadegastPlugin -{ - public partial class IdealistUserControl : UserControl - { - [DllImport("user32")] - public static extern int SendMessage(IntPtr IntPtr, int wMsg, int wParam, IntPtr lParam); - public IntPtr msgTarget; - - public IdealistUserControl() - { - this.SizeChanged += Viewer_OnResize; - } - - private void UIFace_Click(object sender, EventArgs e) - { - - } - - protected override void WndProc(ref Message m) - { - //where is the handle? SendMessage(this.Parent.Handle, m.Msg, m.WParam.ToInt32(), m.LParam); - base.WndProc(ref m); - } - - private void Viewer_OnResize(object sender, EventArgs e) - { - // Dimension2D size = new Dimension2D(this.ClientSize.Height, this.ClientSize.Width); - // Rect rect = new Rect(new Position2D(0,0),size); - // if (this.Renderer!=null) this.Renderer.Device.VideoDriver.ViewPort = rect; - //// SendMessage(msgTarget,0,0,0) - // //??Renderer.GuiEnvironment.VideoDriver.ScreenSize = size; - } - - protected override void OnPaint(PaintEventArgs pe) - { - // base.OnPaint(pe); - } - protected override void OnPaintBackground(PaintEventArgs pevent) - { - // base.OnPaintBackground(pevent); - } - - private void IdealistView_Click(object sender, EventArgs e) - { - - } - } -} diff --git a/plugins/IdealistRadegastPlugin/Renderer/Renderer.cs b/plugins/IdealistRadegastPlugin/Renderer/Renderer.cs deleted file mode 100644 index 9b6358ce6..000000000 --- a/plugins/IdealistRadegastPlugin/Renderer/Renderer.cs +++ /dev/null @@ -1,83 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Windows.Forms; -using IdealistViewer; -using IrrlichtNETCP; -using System.Xml; -using System.IO; -using IrrlichtNETCP.Extensions; -using System.Windows; -using Viewer = IdealistRadegastPlugin.RadegastViewer; -namespace IdealistRadegastPlugin -{ - public class RaegastRenderer: IdealistViewer.Renderer - { - // public IrrlichtNETCP.Quaternion CoordinateConversion_XYZ_XZY = new IrrlichtNETCP.Quaternion(); - - private RadegastViewer m_viewer; - - /// - /// Irrlicht Instance. A handle to the Irrlicht device. - /// - //public IrrlichtDevice Device; - //public VideoDriver Driver; - - //public SceneManager SceneManager; - //public GUIEnvironment GuiEnvironment; - //public IdealistUserControl ViewerControl; - public RaegastRenderer(RadegastViewer viewer, IrrlichtDevice device) - : base(viewer) - { - // ViewerControl = viewer.ViewerControl; - m_viewer = viewer; - Device = device; - } - - public override void Startup() - { - - //Create a New Irrlicht Device - //device.Timer.Stop(); - Device.Timer.Speed = 1; - Device.WindowCaption = "IdealistViewer 0.001"; - // viewerRenderPlane.Device = Device; - // viewerRenderPlane.Renderer = this; - // Device.Resizeable = true; - - // Sets directory to load assets from - Device.FileSystem.WorkingDirectory = m_viewer.StartupDirectory + "/" + Util.MakePath("media", "materials", "textures", ""); //We set Irrlicht's current directory to %application directory%/media - - - Driver = Device.VideoDriver; - SceneManager = Device.SceneManager; - - GuiEnvironment = Device.GUIEnvironment; - - // Compose Coordinate space converter quaternion - IrrlichtNETCP.Matrix4 m4 = new IrrlichtNETCP.Matrix4(); - m4.SetM(0, 0, 1); - m4.SetM(1, 0, 0); - m4.SetM(2, 0, 0); - m4.SetM(3, 0, 0); - m4.SetM(0, 1, 0); - m4.SetM(1, 1, 0); - m4.SetM(2, 1, 1); - m4.SetM(3, 1, 0); - m4.SetM(0, 2, 0); - m4.SetM(1, 2, 1); - m4.SetM(2, 2, 0); - m4.SetM(3, 2, 0); - m4.SetM(0, 3, 0); - m4.SetM(1, 3, 0); - m4.SetM(2, 3, 0); - m4.SetM(3, 3, 1); - - - CoordinateConversion_XYZ_XZY = new IrrlichtNETCP.Quaternion(m4); - CoordinateConversion_XYZ_XZY.makeInverse(); - - } - } - -} diff --git a/plugins/IdealistRadegastPlugin/Viewer.cs b/plugins/IdealistRadegastPlugin/Viewer.cs deleted file mode 100644 index 0561089f9..000000000 --- a/plugins/IdealistRadegastPlugin/Viewer.cs +++ /dev/null @@ -1,1404 +0,0 @@ -//#define DebugObjectPipeline -#define DebugTexturePipeline - -using System; -using System.Collections.Generic; -using System.IO; -using System.Windows.Forms; -using System.Xml; -using System.Reflection; -using System.Threading; -using IdealistViewer; -using log4net; -using IrrlichtNETCP; -using IrrlichtNETCP.Extensions; -using OpenMetaverse; -using Radegast; -using IConfig = Nini.Config.IConfig; -using IConfigSource = Nini.Config.IConfigSource; -using IniConfigSource = Nini.Config.IniConfigSource; -using Console = IdealistViewer.Console; -using MainConsole=IdealistViewer.MainConsole; -using Renderer = IdealistRadegastPlugin.RaegastRenderer; - -namespace IdealistRadegastPlugin -{ - /// - /// Viewer binds the managers together through centralized main loop and event handling. - /// - public class RadegastViewer : IdealistViewer.Viewer - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - #region Viewer Components - - //public Renderer Renderer; - //public UserInterfaceManager UserInterface; - //public INetworkInterface NetworkInterface; - //public Console Console; - - //public TextureManager TextureManager; - //public MeshManager MeshManager; - //public AnimationManager AnimationManager; - //public VSceneGraph SceneGraph; - //public ITerrainManager TerrainManager; - - //public AvatarController AvatarController; - //public CameraController CameraController; - - private Thread m_consoleThread; - private Thread m_mainThread; - private Thread m_formsThread; - - #endregion - - #region Configuration Fields - - //public IdealistViewerConfigSource m_configSource = null; - - ///// - ///// Flag to allow viewer to run. Set to false with File->Quit - ///// - //public bool Running = true; - ///// - ///// Configuration option to control backface culling. - ///// - //public bool BackFaceCulling = true; - ///// - ///// Configuration option to control foliage processing. - ///// - //public bool ProcessFoliage = true; - ///// - ///// Configuration option to load the textures - ///// - //public bool LoadTextures = true; - ///// - ///// Configuration option to enable meshing sculpted prims - ///// - //public bool MeshSculpties = true; - ///// - ///// Configuration option to represent the avatar mesh. - ///// - //public string AvatarMesh = "sydney.md2"; - ///// - ///// Configuration option. Texture to apply to avatarMesh - ///// - //public string AvatarMaterial = "sydney.BMP"; - ///// - ///// Configuration option. Scale factor for the avatar mesh - ///// - //public float AvatarScale = 0.035f; - ///// - ///// If the neighbor returned is a 0 ulong region handle, use this one for testing - ///// - //public ulong TestNeighbor = 1099511628032256; - /// - /// Process avatar modifications every second scene update. - /// - private const int m_avatarModificationProcessingRate = 2; - /// - /// Process object modifications every second scene update. - /// - private int m_objectModificationProcessingRate = 2; - /// - /// The base time period for scene updates. - /// - private const int m_baseSceneUpdateTimePeriod = 100; - /// - /// Maximum frames per second to limit CPU usage. - /// - private int m_maximumFramesPerSecond = 60; - /// - /// limit FPS to m_maximumFramesPerSecond if true - /// - private bool m_limitFramesPerSecond = true; - - #endregion - - #region Viewer Internal State Fields - - /// - /// Server version information. Usually VersionInfo + information about svn revision, operating system, etc. - /// - // public string Version; - /// - /// Time at which this server was started - /// - // public DateTime StartupTime; - /// - /// Record the initial startup directory for info purposes - /// - // public string StartupDirectory = Environment.CurrentDirectory; - - /// - /// Held Controls - /// - private bool m_ctrlPressed = false; - private bool m_shiftPressed = false; - // private bool m_appPressed = false; - private bool m_leftMousePressed = false; - private bool m_rightMousePressed = false; - //private bool m_middleMousePressed = false; - - /// - /// Last window or screen size. - /// - private Dimension2D m_lastScreenSize; - - /// - /// Stored Mouse cordinates used to determine change. - /// - private int m_oldMouseX = 0; - private int m_oldMouseY = 0; - - /// - /// Window size. - /// - //public int WindowWidth = 1024; - //public int WindowHeight = 768; - //public float WindowAspect = 1024 / (float)768; - - /// - /// Target Position of the camera - /// - private Vector3 m_lastTargetPos = Vector3.Zero; - /// - /// List of held keys. Used to process multiple keypresses simulataniously - /// - private List m_pressedKeys = new List(); - /// - /// System tick count at the beginning of the loop. - /// - private int m_lastTickCount = 0; - /// - /// The time in milliseconds since last scene update occured. - /// - private int m_timeSinceLastSceneUpdate = 0; - /// - /// Number of scene updates occured since startup. - /// - private int m_sceneUpdateCounter = 0; - /// - /// Time dilation between client and server. - /// - private float m_timeDilation = 0; - - readonly private RadegastInstance RInstance; - readonly public IdealistUserControl ViewerControl; - private IrrlichtDevice Device; - - #endregion - - #region Startup - - public RadegastViewer(RadegastInstance inst, IConfigSource iconfig, IdealistUserControl control):base(iconfig) - - { - RInstance = inst; - m_configSource = new IdealistViewerConfigSource(); - m_configSource.Source = new IniConfigSource(); - ViewerControl = control; - - - string iniconfig = Path.Combine(Util.configDir(), "IdealistViewer.ini"); - if (File.Exists(iniconfig)) - { - m_configSource.Source.Merge(new IniConfigSource(iniconfig)); - } - m_configSource.Source.Merge(iconfig); - StartupTime = DateTime.UtcNow; - } - - private GUISkin skin; - private Color skincolor; - - /// - /// Performs initialisation of the scene, such as loading configuration from disk. - /// - public override void Startup() - { - m_consoleThread = Thread.CurrentThread; - if (true) - { - m_mainThread = new Thread(new ThreadStart(() => - { - ViewerControl.InitializeComponent(); - Device = new IrrlichtDevice(DriverType.OpenGL, - new Dimension2D(WindowWidth, - WindowHeight), - 32, false, true, true, true - ); - - StartupComponents(); - MainLoop(skin, skincolor); - })); - } - else - { - m_mainThread = new Thread(new ThreadStart(() => - { - ViewerControl.InitializeComponent(); - Device = new IrrlichtDevice(DriverType.OpenGL, - new Dimension2D(WindowWidth, - WindowHeight), - 32, false, true, true, true, - - ViewerControl.IdealistView.Handle - ); - - StartupComponents(); - MainLoop(skin, skincolor); - })); - - } - - - m_mainThread.Start(); - } - - /// - /// Must be overriden by child classes for their own server specific startup behaviour. - /// - protected override void StartupComponents() - { - m_log.Info("[STARTUP]: Beginning startup processing"); - - Version = Util.EnhanceVersionInformation(); - - m_log.Info("[STARTUP]: Version: " + Version + "\n"); - - Console = new Console(this,"Region", this); - IConfig cnf = m_configSource.Source.Configs["Startup"]; - string loginURI = "http://127.0.0.1:9000/"; - string firstName = string.Empty; - string lastName = string.Empty; - string password = string.Empty; - string startlocation = ""; - bool loadtextures = true; - bool multipleSims = false; - - if (cnf != null) - { - loginURI = cnf.GetString("login_uri", ""); - firstName = cnf.GetString("first_name", "test"); - lastName = cnf.GetString("last_name", "user"); - password = cnf.GetString("pass_word", "nopassword"); - loadtextures = cnf.GetBoolean("load_textures", true); - MeshSculpties = cnf.GetBoolean("mesh_sculpties", MeshSculpties); - BackFaceCulling = cnf.GetBoolean("backface_culling", BackFaceCulling); - AvatarMesh = cnf.GetString("avatar_mesh", AvatarMesh); - AvatarMaterial = cnf.GetString("avatar_material", AvatarMaterial); - AvatarScale = cnf.GetFloat("avatar_scale", AvatarScale); - startlocation = cnf.GetString("start_location", ""); - multipleSims = cnf.GetBoolean("multiple_sims", multipleSims); - ProcessFoliage = cnf.GetBoolean("process_foliage", ProcessFoliage); - m_limitFramesPerSecond = cnf.GetBoolean("limitfps", m_limitFramesPerSecond); - } - LoadTextures = loadtextures; - MainConsole.Instance = Console; - - // Initialize LibOMV - if (NetworkInterface == null) NetworkInterface = new RadegastNetworkModule(RInstance); - NetworkInterface.MultipleSims = multipleSims; - NetworkInterface.OnLandUpdate += OnNetworkLandUpdate; - NetworkInterface.OnConnected += OnNetworkConnected; - NetworkInterface.OnObjectAdd += OnNetworkObjectAdd; - NetworkInterface.OnSimulatorConnected += OnNetworkSimulatorConnected; - NetworkInterface.OnObjectUpdate += OnNetworkObjectUpdate; - NetworkInterface.OnObjectRemove += OnNetworkObjectRemove; - NetworkInterface.OnAvatarAdd += OnNetworkAvatarAdd; - //NetworkInterface.OnChat +=new NetworkChatDelegate(OnNetworkChat); - //NetworkInterface.OnFriendsListUpdate +=new NetworkFriendsListUpdateDelegate(OnNetworkFriendsListChange); - - //NetworkInterface.Login(loginURI, firstName + " " + lastName, password, startlocation); - - // Startup the GUI - Renderer = new RaegastRenderer(this,Device); - Renderer.Startup(); - - GUIFont defaultFont = Renderer.GuiEnvironment.GetFont("defaultfont.png"); - - skin = Renderer.GuiEnvironment.Skin; - skin.Font = defaultFont; - skincolor = skin.GetColor(GuiDefaultColor.Face3D); - skincolor.A = 255; - skin.SetColor(GuiDefaultColor.Face3D, skincolor); - skincolor = skin.GetColor(GuiDefaultColor.Shadow3D); - skincolor.A = 255; - skin.SetColor(GuiDefaultColor.Shadow3D, skincolor); - // Set up event handler for the GUI window events. - Renderer.Device.OnEvent += new OnEventDelegate(OnDeviceEvent); - - Renderer.Device.Resizeable = true; - - MeshManager = new MeshManager(Renderer.SceneManager.MeshManipulator, Renderer.Device); - - SceneGraph = new VSceneGraph(this); - - // Set up the picker. - SceneGraph.TrianglePicker = new TrianglePickerMapper(Renderer.SceneManager.CollisionManager); - SceneGraph.TriangleSelector = Renderer.SceneManager.CreateMetaTriangleSelector(); - - // Only create a texture manager if the user configuration option is enabled for downloading textures - if (LoadTextures) - { - TextureManager = new TextureManager(this,Renderer.Device, Renderer.Driver, SceneGraph.TrianglePicker, SceneGraph.TriangleSelector, "IdealistCache", NetworkInterface); - TextureManager.OnTextureLoaded += OnNetworkTextureDownloaded; - } - - AvatarController = new AvatarController(NetworkInterface, null); - - TerrainManager = ModuleManager.GetTerrainManager(this, m_configSource); - - Renderer.SceneManager.SetAmbientLight(new Colorf(1f, 0.2f, 0.2f, 0.2f)); - - // This light simulates the sun - //SceneNode light2 = Renderer.SceneManager.AddLightSceneNode(Renderer.SceneManager.RootSceneNode, new Vector3D(0, 255, 0), new Colorf(0f, 0.5f, 0.5f, 0.5f), 250, -1); - SceneNode light2 = Renderer.SceneManager.AddLightSceneNode(Renderer.SceneManager.RootSceneNode, new Vector3D(0, 255, 0), new Colorf(0f, 0.6f, 0.6f, 0.6f), 512, -1); - - // Fog is on by default, this line disables it. - //Renderer.SceneManager.VideoDriver.SetFog(new Color(0, 255, 255, 255), false, 9999, 9999, 0, false, false); - float fogBrightness = 0.8f; - Renderer.SceneManager.VideoDriver.SetFog(new Color(0, (int)(0.5f * 255 * fogBrightness), (int)(0.5f * 255 * fogBrightness), (int)(1.0f * 255 * fogBrightness)), true, 50, 100, 0, true, true); - - //ATMOSkySceneNode skynode = new ATMOSkySceneNode(Renderer.Driver.GetTexture("irrlicht2_up.jpg"), null, Renderer.SceneManager, 100, -1); - - //ATMOSphere atmosphere = new ATMOSphere(Renderer.Device.Timer, null, Renderer.SceneManager, -1); - //atmosphere.SkyTexture = Renderer.Driver.GetTexture("irrlicht2_up.jpg"); - - - Renderer.Driver.SetTextureFlag(TextureCreationFlag.CreateMipMaps, false); - bool Broken = false; - if (!Broken) Renderer.SceneManager.AddSkyBoxSceneNode(null, new Texture[] { - Renderer.Driver.GetTexture("topax2.jpg"), - Renderer.Driver.GetTexture("irrlicht2_dn.jpg"), - Renderer.Driver.GetTexture("rightax2.jpg"), - Renderer.Driver.GetTexture("leftax2.jpg"), - Renderer.Driver.GetTexture("frontax2.jpg"), - Renderer.Driver.GetTexture("backax2.jpg")}, -0); - - Renderer.Driver.SetTextureFlag(TextureCreationFlag.CreateMipMaps, true); - - - CameraController = new CameraController(this,Renderer.SceneManager); - - SceneGraph.WaterNode = new WaterSceneNode(null, Renderer.SceneManager, new Dimension2Df(180, 180), new Dimension2D(100, 100), new Dimension2D(512, 512)); - SceneGraph.WaterNode.Position = new Vector3D(0, 30, 0); - //SceneGraph.WaterNode.WaveHeight *= .4f; - SceneGraph.WaterNode.RefractionFactor = 0.3f; - SceneGraph.WaterNode.WaveDisplacement = 2f; - SceneGraph.WaterNode.WaveHeight = 2f; - SceneGraph.WaterNode.WaveLength = 2f; - SceneGraph.WaterNode.WaveSpeed = 5f; - SceneGraph.WaterNode.WaveRepetition = 20f; - SceneGraph.WaterNode.Scale = new Vector3D(0.2f,0.2f,0.2f); - SceneGraph.WaterNode.MultiColor = new Colorf(0.9f, 0.7f, 0.7f, 1.0f); - - UserInterface = new UserInterfaceManager(this, Renderer.Driver, Renderer.SceneManager, Renderer.GuiEnvironment, CameraController, AvatarController); - UserInterface.DefaultFont = defaultFont; - - XmlReader xml = Broken? null: XmlReader.Create(new StreamReader("../../../media/About.xml")); - while (xml != null && xml.Read()) - { - switch (xml.NodeType) - { - case XmlNodeType.Text: - UserInterface.AboutText = xml.ReadContentAsString(); - break; - case XmlNodeType.Element: - if (xml.Name.Equals("startUpModel")) - { - } - else if (xml.Name.Equals("messageText")) - UserInterface.AboutCaption = xml.GetAttribute("caption"); - break; - } - } - - string formsUiConfigurationOption = m_configSource.Source.Configs["Startup"].GetString("forms", "true"); - if (formsUiConfigurationOption == "true") - { - frmCommunications f = new frmCommunications(NetworkInterface); - f.Visible = true; - this.m_formsThread = new Thread(delegate() { Application.DoEvents(); Thread.Sleep(50); }); - m_formsThread.Start(); - } - - AnimationManager = new AnimationManager(this); - - TimeSpan timeTaken = DateTime.UtcNow - StartupTime; - - m_log.InfoFormat("[STARTUP]: Startup took {0}m {1}s", timeTaken.Minutes, timeTaken.Seconds); - - } - - #endregion - - #region Shutdown - /// - /// Should be overriden and referenced by descendents if they need to perform extra shutdown processing - /// - public override void Shutdown() - { - Renderer.Device.Close(); - Renderer.Device.Dispose(); - NetworkInterface.Logout(); - - m_log.Info("[SHUTDOWN]: Shutdown processing on main thread complete. Exiting..."); - - Environment.Exit(0); - } - - #endregion - - #region Main Loop - - public void MainLoop(GUISkin skin, Color skincolor) - { - // Main Render Loop - int minFrameTime = (int) (1000/((float) m_maximumFramesPerSecond)); - - m_lastScreenSize = Renderer.Driver.ScreenSize; - - while (Running) - { - try - { - NetworkInterface.Process(); - } - catch (Exception e) - { - m_log.Error("Error processing network messages: " + e); - } - - try - { - - // If you close the gui window, device.Run returns false. - Running = Renderer.Device.Run(); - } - catch (AccessViolationException e) - { - m_log.Error("[VIDEO]: Error in device" + e.ToString()); - } - catch (OutOfMemoryException e) - { - m_log.Error("[VIDEO]: Error in device" + e.ToString()); - continue; - } - if (!Running) - break; - try - { - // SceneGraph.WaterNode.Update(); - } - catch ( /*AccessViolation*/ Exception) - { - m_log.Warn("[water]: Unable to update this round"); - } - - Renderer.Driver.BeginScene(true, true, new Color(0, 255, 255, 255)); - try - { - Renderer.SceneManager.DrawAll(); - } - catch (Exception e) - { - - System.Console.WriteLine("" + e); - } - try - { - Renderer.GuiEnvironment.DrawAll(); - } - catch (Exception e) - { - - System.Console.WriteLine("" + e); - } - Renderer.Driver.EndScene(); - - m_timeSinceLastSceneUpdate += System.Environment.TickCount - m_lastTickCount; - int frameTime = System.Environment.TickCount - m_lastTickCount; - m_lastTickCount = System.Environment.TickCount; - - // Update Interpolation targets - SceneGraph.UpdateMovingObjects(); - // Update camera position and rotation. - CameraController.CheckTarget(); - - if (m_timeSinceLastSceneUpdate > m_baseSceneUpdateTimePeriod) - { - // Repeat any held keys - UpdatePressedKeys(); - - m_timeSinceLastSceneUpdate = 0; - m_sceneUpdateCounter++; - - if (m_sceneUpdateCounter == int.MaxValue) - m_sceneUpdateCounter = 0; - } - - if ((m_sceneUpdateCounter%m_avatarModificationProcessingRate) == 0) - { - AvatarController.UpdateRemote(); - NetworkInterface.SendCameraViewMatrix(CameraController.GetCameraViewMatrix()); - // process avatar animation changes - SceneGraph.ProcessAnimations(); - // Process Avatar Mod Queue - SceneGraph.ProcessObjectModifications(20, ref SceneGraph.AvatarModifications); - } - - try - { - TerrainManager.Process(); - } - catch (Exception e) - { - System.Console.WriteLine("" + e); - } - - if ((m_sceneUpdateCounter%m_objectModificationProcessingRate) == 0) - { - // Process Object Mod Queue. Parameter is 'Items' - try - { - SceneGraph.ProcessObjectModifications(20, ref SceneGraph.ObjectModifications); - } - catch (Exception ex) - { - System.Console.WriteLine("MAINLOOP: ProcessObjectModifications" + ex); - } - // Process Mesh Queue. Parameter is 'Items' - try - { - SceneGraph.ProcessMeshModifications(20); - } - catch (System.Exception ex) - { - - System.Console.WriteLine("MAINLOOP: ProcessMeshModifications" + ex); - } - // Check the UnAssigned Child Queue for parents that have since rezed - try - { - SceneGraph.ProcessParentWaitingObjects(5); - } - catch (System.Exception ex) - { - System.Console.WriteLine("MAINLOOP: ProcessParentWaitingObjects" + ex); - } - // Apply textures - try - { - SceneGraph.ProcessTextureModifications(10); - } - catch (System.Exception ex) - { - System.Console.WriteLine("MAINLOOP: ProcessTextureModifications" + ex); - } - // Update foliage. - try - { - SceneGraph.ProcessFoliageMeshModifications(3); - } - catch (System.Exception ex) - { - System.Console.WriteLine("MAINLOOP: ProcessFoliageMeshModifications" + ex); - } - // Set the FPS in the window title. - Renderer.Device.WindowCaption = "IdealistViewer 0.001, FPS:" + Renderer.Driver.FPS.ToString(); - - } - - // process chat - if (UserInterface.OutboundChatMessages.Count > 0) - lock (UserInterface.OutboundChatMessages) - for (int i = 0; i < UserInterface.OutboundChatMessages.Count; i++) - NetworkInterface.Say(UserInterface.OutboundChatMessages.Dequeue()); - - UserInterface.UpdateChatWindow(); - - // Sleep until full frame time has been used. - if (m_limitFramesPerSecond && frameTime < minFrameTime) - Thread.Sleep(minFrameTime - frameTime); - - } - //In the end, delete the Irrlicht device. - Shutdown(); - } - - #endregion - - #region Console Event Processing - - /// - /// Runs commands issued by the server console from the operator - /// - /// The first argument of the parameter (the command) - /// Additional arguments passed to the command - public override void OnConsoleCommand(string command, string[] cmdparams) - { - switch (command) - { - case "a": // experimental for animation debugging - try - { - int.TryParse(cmdparams[0], out AnimationManager.StartFrame); - int.TryParse(cmdparams[1], out AnimationManager.StopFrame); - AnimationManager.FramesDirty = true; - } - catch - { - m_log.Warn("usage: a - where startFrame and endFrame are integers"); - } - break; - case "fly": - AvatarController.Fly = !AvatarController.Fly; - break; - case "goto": - float x = 128f; - float y = 128f; - float z = 22f; - string cmdStr = ""; - foreach (string arg in cmdparams) - cmdStr += arg + " "; - cmdStr = cmdStr.Trim(); - string[] dest = cmdStr.Split(new char[] { '/' }); - if (float.TryParse(dest[1], out x) && - float.TryParse(dest[2], out y) && - float.TryParse(dest[3], out z)) - { - NetworkInterface.Teleport(dest[0], x, y, z); - } - else - m_log.Warn("Usage: goto simname x y z"); - break; - case "help": - Console.ShowHelp(cmdparams); - Console.Notice(""); - break; - case "q": - string qMsg = " ***************QUEUE STATUS*****************"; - qMsg += "\nfoliageObjectQueue.........................: " + SceneGraph.FoliageMeshModifications.Count.ToString(); - qMsg += "\nobjectModQueue.............................: " + SceneGraph.ObjectModifications.Count.ToString(); - qMsg += "\nobjectMeshQueue............................: " + SceneGraph.ObjectMeshModifications.Count.ToString(); - qMsg += "\nUnAssignedChildObjectModQueue..............: " + SceneGraph.ParentWaitingObjects.Count.ToString(); - qMsg += "\noutgoingChatQueue..........................: " + UserInterface.OutboundChatMessages.Count.ToString(); - - m_log.Debug(qMsg); - break; - - case "cq": - m_log.Debug("*************** UnAssignedChildObjectModQueue info ************"); - lock (SceneGraph.ParentWaitingObjects) - { - foreach (VObject v in SceneGraph.ParentWaitingObjects) - { - Primitive prim = v.Primitive; - - m_log.Debug( - " UUID: " + prim.ID.ToString() - + " parentID: " + prim.ParentID.ToString() - + " localID: " + prim.LocalID.ToString() - ); - } - } - break; - - case "relog": - NetworkInterface.Login(NetworkInterface.LoginURI, NetworkInterface.FirstName + " " + NetworkInterface.LastName, NetworkInterface.Password, NetworkInterface.StartLocation); - break; - case "say": - string message = ""; - foreach (string word in cmdparams) - message += word + " "; - NetworkInterface.Say(message); - break; - case "set": - if (cmdparams.Length < 2) - return; - - if (cmdparams[0] == "log" && cmdparams[1] == "level") - { - string[] setParams = new string[cmdparams.Length - 2]; - Array.Copy(cmdparams, 2, setParams, 0, cmdparams.Length - 2); - - Console.SetConsoleLogLevel(setParams); - } - break; - - case "show": - if (cmdparams.Length > 0) - { - Console.Show(cmdparams); - } - break; - - case "quit": - case "shutdown": - Shutdown(); - break; - } - } - - #endregion - - #region Network Event Processing - - protected void OnNetworkConnected() - { - UserInterface.UpdateFriendsList(); - } - - protected void OnNetworkSimulatorConnected(VSimulator sim) - { - SceneGraph.OnNetworkSimulatorConnected(sim); - } - - private void OnNetworkFriendsListChange() - { - UserInterface.UpdateFriendsList(); - } - - private void OnNetworkChat(string message, ChatAudibleLevel audible, ChatType type, ChatSourceType sourcetype, string fromName, UUID id, UUID ownerid, Vector3 position) - { - UserInterface.OnNetworkChat(message, audible, type, sourcetype, fromName, id, ownerid, position); - } - - private void OnNetworkAvatarAdd(VSimulator sim, Avatar avatar, ulong regionHandle, ushort timeDilation) - { - m_timeDilation = (float)(timeDilation / ushort.MaxValue); - SceneGraph.OnNetworkAvatarAdd(sim, avatar, regionHandle, timeDilation); - } - - public void OnNetworkObjectAdd(VSimulator sim, Primitive prim, ulong regionHandle, ushort timeDilation) - { - m_timeDilation = (float)(timeDilation / ushort.MaxValue); - - SceneGraph.OnNetworkObjectAdd(sim, prim, regionHandle, timeDilation); - - } - - private void OnNetworkObjectUpdate(VSimulator simulator, ObjectUpdate update, ulong regionHandle, ushort timeDilation) - { - m_timeDilation = (float)(timeDilation / ushort.MaxValue); - SceneGraph.OnNetworkObjectUpdate(simulator, update, regionHandle, timeDilation); - } - - private void OnNetworkObjectRemove(VSimulator psim, uint pLocalID) - { - SceneGraph.OnNetworkObjectRemove(psim, pLocalID); - } - - private void OnNetworkLandUpdate(VSimulator sim, int x, int y, int width, float[] data) - { - TerrainManager.OnNetworkLandUpdate(sim, x, y, width, data); - SceneGraph.WaterNode.Position = new Vector3D(0, sim.WaterHeight - 0.5f, 0); - } - - public void OnNetworkTextureDownloaded(string tex, VObject vObj, UUID AssetID) - { - SceneGraph.OnNetworkTextureDownloaded(tex, vObj, AssetID); - } - - #endregion - - #region Key Input Processing - - /// - /// Processes held keys. This allows us to do multiple keypresses. - /// - private void UpdatePressedKeys() - { - lock (m_pressedKeys) - { - foreach (KeyCode ky in m_pressedKeys) - { - ProcessPressedKey(ky); - } - - } - } - - /// - /// Manage held keys - /// - /// - /// - public override void UpdateKeyPressState(KeyCode ky, bool held) - { - lock (m_pressedKeys) - { - if (held) - { - if (!m_pressedKeys.Contains(ky)) - { - m_pressedKeys.Add(ky); - } - } - else - { - if (m_pressedKeys.Contains(ky)) - { - m_pressedKeys.Remove(ky); - } - } - - } - } - - /// - /// Does an avatar movement based on provided key - /// - /// - private void ProcessPressedKey(KeyCode ky, bool kydown, bool held) - { - //m_log.DebugFormat("{0},{1},{2}", ky.ToString(), kydown, held); - switch (ky) - { - case KeyCode.Key_W: - case KeyCode.Up: - - AvatarController.Forward = kydown; - break; - - case KeyCode.Key_S: - case KeyCode.Down: - AvatarController.Back = kydown; - break; - - case KeyCode.Key_A: - case KeyCode.Left: - CameraController.SetRotationDelta(-1, 0); - break; - - case KeyCode.Key_D: - case KeyCode.Right: - CameraController.SetRotationDelta(1, 0); - break; - - case KeyCode.Prior: - if (AvatarController.Fly) - AvatarController.Up = kydown; - else - if (kydown) - AvatarController.Jump = true; - else - AvatarController.Jump = false; - - break; - - case KeyCode.Next: - AvatarController.Down = kydown; - break; - - case KeyCode.Home: - case KeyCode.Key_F: - if (!held && !kydown) - AvatarController.Fly = !AvatarController.Fly; - break; - - } - } - - /// - /// does an action for a held key - /// - /// - private void ProcessPressedKey(KeyCode ky) - { - switch (ky) - { - case KeyCode.Up: - if (!m_shiftPressed && !m_ctrlPressed) - { - if (CameraController.CameraMode == ECameraMode.Build) - { - if (SceneGraph.m_avatarObject != null) - { - CameraController.SetTarget(SceneGraph.m_avatarObject.SceneNode); - CameraController.SwitchMode(ECameraMode.Third); - } - } - - ProcessPressedKey(ky, true, true); - } - else - { - if (m_ctrlPressed) - { - CameraController.DoKeyAction(ky); - } - } - break; - - case KeyCode.Down: - if (!m_shiftPressed && !m_ctrlPressed) - { - if (CameraController.CameraMode == ECameraMode.Build) - { - if (SceneGraph.m_avatarObject != null) - { - CameraController.SetTarget(SceneGraph.m_avatarObject.SceneNode); - CameraController.SwitchMode(ECameraMode.Third); - } - } - - ProcessPressedKey(ky, true, true); - } - else - { - if (m_ctrlPressed) - { - CameraController.SwitchMode(ECameraMode.Build); - CameraController.DoKeyAction(ky); - } - - } - break; - - case KeyCode.Left: - if (!m_shiftPressed && !m_ctrlPressed) - { - if (CameraController.CameraMode == ECameraMode.Build) - { - if (SceneGraph.m_avatarObject != null) - { - CameraController.SetTarget(SceneGraph.m_avatarObject.SceneNode); - CameraController.SwitchMode(ECameraMode.Third); - } - } - - ProcessPressedKey(ky, true, true); - } - else - { - if (m_ctrlPressed) - { - //vOrbit.X -= 2f; - CameraController.SwitchMode(ECameraMode.Build); - CameraController.DoKeyAction(ky); - } - - } - break; - - case KeyCode.Right: - if (!m_shiftPressed && !m_ctrlPressed) - { - if (CameraController.CameraMode == ECameraMode.Build) - { - if (SceneGraph.m_avatarObject != null) - { - CameraController.SetTarget(SceneGraph.m_avatarObject.SceneNode); - CameraController.SwitchMode(ECameraMode.Third); - } - } - - ProcessPressedKey(ky, true, true); - } - else - { - if (m_ctrlPressed) - { - //vOrbit.X += 2f; - //vOrbit.X -= 2f; - CameraController.SwitchMode(ECameraMode.Build); - CameraController.DoKeyAction(ky); - } - - } - break; - case KeyCode.Prior: - if (!m_shiftPressed && !m_ctrlPressed) - { - if (CameraController.CameraMode == ECameraMode.Build) - { - if (SceneGraph.m_avatarObject != null) - { - CameraController.SetTarget(SceneGraph.m_avatarObject.SceneNode); - CameraController.SwitchMode(ECameraMode.Third); - } - } - - ProcessPressedKey(ky, true, true); - } - else - { - if (m_ctrlPressed) - { - //vOrbit.Y -= 2f; - CameraController.SwitchMode(ECameraMode.Build); - CameraController.DoKeyAction(ky); - } - - } - break; - - case KeyCode.Next: - if (!m_shiftPressed && !m_ctrlPressed) - { - if (CameraController.CameraMode == ECameraMode.Build) - { - if (SceneGraph.m_avatarObject != null) - { - CameraController.SetTarget(SceneGraph.m_avatarObject.SceneNode); - CameraController.SwitchMode(ECameraMode.Third); - } - } - - ProcessPressedKey(ky, true, true); - } - else - { - if (m_ctrlPressed) - { - CameraController.SwitchMode(ECameraMode.Build); - CameraController.DoKeyAction(ky); - } - - } - break; - - } - - } - - #endregion - - #region Device Event Processing - /// - /// The Irrlicht window has had an event. - /// - /// - /// - public override bool OnDeviceEvent(Event p_event) - { - - //m_log.Warn(p_event.Type.ToString()); - if (p_event.Type == EventType.LogTextEvent) - { - string eventype = p_event.LogText; - if (eventype.Contains("Resizing window")) - { - int pos = eventype.IndexOf('('); - int pos2 = eventype.IndexOf(')'); - // - string resizeto = eventype.Substring(pos + 1, pos2 - (pos + 1)); - string[] xy = resizeto.Split(' '); - - WindowWidth = Convert.ToInt32(xy[0]); - WindowHeight = Convert.ToInt32(xy[1]); - WindowAspect = (float)WindowWidth / WindowHeight; - } - } - - if (p_event.Type == EventType.GUIEvent) - { - int id = p_event.Caller.ID; - GUIEnvironment env = Renderer.Device.GUIEnvironment; - - - - //m_log.InfoFormat("{0} {1} {2} {3}", p_event.Type, p_event.Caller, p_event.GUIEvent, p_event.Caller.ID); - switch (p_event.GUIEvent) - { - case GUIEventType.ElementFocused: - this.UserInterface.FocusedElement = p_event.Caller as GUIElement; - break; - case GUIEventType.ElementFocusLost: - this.UserInterface.FocusedElement = null; - break; - case GUIEventType.MenuItemSelected: - // a menu item was clicked - GUIContextMenu menu = ((GUIContextMenu)p_event.Caller); - id = menu.GetItemCommandID(menu.SelectedItem); - switch (id) - { - case (int)MenuItems.FileOpen: - env.AddFileOpenDialog("Please select a model file to open", false, Renderer.Device.GUIEnvironment.RootElement, 0); - break; - case (int)MenuItems.FileQuit: // File -> Quit - Shutdown(); - break; - case (int)MenuItems.ShowChat: - UserInterface.ShowChatWindow(); - break; - case (int)MenuItems.ShowPrimcount: - { - uint texcount = 0; - if (TextureManager != null) - texcount = TextureManager.TextureCacheCount; - m_log.DebugFormat("FullUpdateCount:{0}, PrimCount:{1}, TextureCount:{2}, UniquePrim:{3}", SceneGraph.PrimitiveCount, SceneGraph.Objects.Count, texcount, MeshManager.UniqueObjects); - } - break; - case (int)MenuItems.ClearCache: - { - if (TextureManager != null) - { - TextureManager.ClearMemoryCache(); - - } - } - break; - case (int)MenuItems.ViewModeOne: // View -> Material -> Solid - //CFK nothing yet, circa Thanksgiving eve 08 - //CFK if (Model != null) - //CFK Model.SetMaterialType(MaterialType.Solid); - break; - case (int)MenuItems.ViewModeTwo: // View -> Material -> Transparent - //CFK nothing yet, circa Thanksgiving eve 08 - //CFK if (Model != null) - //CFK Model.SetMaterialType(MaterialType.TransparentAddColor); - break; - case (int)MenuItems.ViewModeThree: // View -> Material -> Reflection - //CFK nothing yet, circa Thanksgiving eve 08 - //CFK if (Model != null) - //CFK Model.SetMaterialType(MaterialType.SphereMap); - break; - default: - UserInterface.HandleMenuAction(id); - break; - } - break;//case GUIEventType.MenuItemSelected: - - case GUIEventType.FileSelected: - //CFK nothing yet, circa Thanksgiving eve 08 - // load the model file, selected in the file open dialog - //CFK GUIFileOpenDialog dialog = ((GUIFileOpenDialog)p_event.Caller); - //CFK loadModel(dialog.Filename); - break; - case GUIEventType.EditBoxEnter: - if (p_event.Caller == UserInterface.ChatBoxInput) - { - lock (UserInterface.OutboundChatMessages) - UserInterface.OutboundChatMessages.Enqueue(UserInterface.ChatBoxInput.Text); - - lock (UserInterface.MessageHistory) - { - UserInterface.MessageHistory.Add("You: " + UserInterface.ChatBoxInput.Text); - UserInterface.NewChat = true; - } - - UserInterface.ChatBoxInput.Text = ""; - } - break; - } - } - - - // !Mouse event (we do this so that we don't process the rest of this each mouse move - if (p_event.Type != EventType.MouseInputEvent) - { - - //Keyboard event - if (p_event.Type == EventType.KeyInputEvent) - { - //If we have focus on the 3d screen and not a control - if (UserInterface.FocusedElement == null) - { - - switch (p_event.KeyCode) - { - - case KeyCode.Control: - m_ctrlPressed = p_event.KeyPressedDown; - if (m_ctrlPressed) - { - - CameraController.ResetMouseOffsets(); - } - else - { - CameraController.ApplyMouseOffsets(); - } - break; - case KeyCode.Shift: - m_shiftPressed = p_event.KeyPressedDown; - break; - case KeyCode.Up: - case KeyCode.Down: - case KeyCode.Left: - case KeyCode.Right: - case KeyCode.Prior: - case KeyCode.Next: - case KeyCode.Key_W: - case KeyCode.Key_S: - case KeyCode.Key_A: - case KeyCode.Key_D: - case KeyCode.Home: - case KeyCode.Key_F: - if (!m_ctrlPressed) - ProcessPressedKey(p_event.KeyCode, p_event.KeyPressedDown, false); - - UpdateKeyPressState(p_event.KeyCode, p_event.KeyPressedDown); - break; - - case KeyCode.Key_P: - if (p_event.KeyPressedDown) - { - uint texcount = 0; - if (TextureManager != null) - texcount = TextureManager.TextureCacheCount; - m_log.DebugFormat("FullUpdateCount:{0}, PrimCount:{1}, TextureCount:{2}, UniquePrim:{3}", SceneGraph.PrimitiveCount, SceneGraph.Objects.Count, texcount, MeshManager.UniqueObjects); - } - break; - - case KeyCode.Key_C: - if (p_event.KeyPressedDown) - { - if (TextureManager != null) - { - TextureManager.ClearMemoryCache(); - - } - } - break; - } - } - } - UpdatePressedKeys(); - } - - if (p_event.Type == EventType.MouseInputEvent) - { - return OnMouseEvent(p_event); - } - - return false; - } - #endregion - - #region Mouse Event Processing - public override bool OnMouseEvent(Event p_event) - { - if (p_event.MouseInputEvent == MouseInputEvent.MouseWheel) - { - CameraController.MouseWheelAction(p_event.MouseWheelDelta); - } - if (p_event.MouseInputEvent == MouseInputEvent.LMouseLeftUp) - { - if (m_ctrlPressed) - { - CameraController.ApplyMouseOffsets(); - } - m_leftMousePressed = false; - } - if (p_event.MouseInputEvent == MouseInputEvent.LMousePressedDown) - { - - m_leftMousePressed = true; - if (m_ctrlPressed) - { - CameraController.SwitchMode(ECameraMode.Build); - // Pick! - - CameraController.ResetMouseOffsets(); - Vector3D[] projection = CameraController.ProjectRayPoints(p_event.MousePosition, WindowWidth/2, WindowHeight/2, WindowAspect); - Line3D projectedray = new Line3D(projection[0], projection[1]); - - Vector3D collisionpoint = new Vector3D(0, 0, 0); - Triangle3D tri = new Triangle3D(0, 0, 0, 0, 0, 0, 0, 0, 0); - - // Check if we have a node under the mouse - SceneNode node = SceneGraph.TrianglePicker.GetSceneNodeFromRay(projectedray, 0x0128, true, CameraController.CameraNode.Position); //smgr.CollisionManager.GetSceneNodeFromScreenCoordinates(new Position2D(p_event.MousePosition.X, p_event.MousePosition.Y), 0, false); - if (node == null) - { - if (SceneGraph.TriangleSelector != null) - { - // Collide test against the terrain - if (Renderer.SceneManager.CollisionManager.GetCollisionPoint(projectedray, SceneGraph.TriangleSelector, out collisionpoint, out tri)) - { - if (CameraController.CameraMode == ECameraMode.Build) - { - CameraController.SetTarget(collisionpoint); - CameraController.TargetNode = null; - } - } - } - } - else - { - // Sometimes the terrain picker returns weird values. - // If it's weird try the general 'everything' triangle picker. - m_log.WarnFormat("[PICK]: Picked <{0},{1},{2}>", node.Position.X, node.Position.Y, node.Position.Z); - if (node.Position.X == 0 && node.Position.Z == 0) - { - if (SceneGraph.TriangleSelector != null) - { - if (Renderer.SceneManager.CollisionManager.GetCollisionPoint(projectedray, SceneGraph.TriangleSelector, out collisionpoint, out tri)) - { - if (CameraController.CameraMode == ECameraMode.Build) - { - CameraController.SetTarget(collisionpoint); - CameraController.TargetNode = null; - } - } - } - } - else - { - // Target the node - if (CameraController.CameraMode == ECameraMode.Build) - { - CameraController.SetTarget(node.Position); - CameraController.TargetNode = node; - } - } - } - } - } - if (p_event.MouseInputEvent == MouseInputEvent.RMouseLeftUp) - { - m_rightMousePressed = false; - } - if (p_event.MouseInputEvent == MouseInputEvent.RMousePressedDown) - { - m_rightMousePressed = true; - } - - if (p_event.MouseInputEvent == MouseInputEvent.MouseMoved) - { - if (m_leftMousePressed && m_ctrlPressed) - { - int deltaX = p_event.MousePosition.X - m_oldMouseX; - int deltaY = p_event.MousePosition.Y - m_oldMouseY; - - CameraController.SetDeltaFromMouse(deltaX, deltaY); - } - - if (m_rightMousePressed) - { - - int deltaX = p_event.MousePosition.X - m_oldMouseX; - int deltaY = p_event.MousePosition.Y - m_oldMouseY; - - CameraController.SetRotationDelta(deltaX, deltaY); - } - - m_oldMouseX = p_event.MousePosition.X; - m_oldMouseY = p_event.MousePosition.Y; - } - return false; - } - - #endregion - - #region Helper Methods - //public void SetViewerAvatar(VObject self) - //{ - // if (SceneGraph.m_avatarObject == null) - // { - // SceneGraph.m_avatarObject = self; - // AvatarController.AvatarNode = SceneGraph.m_avatarObject.SceneNode; - // CameraController.SetTarget(SceneGraph.m_avatarObject.SceneNode); - // CameraController.SwitchMode(ECameraMode.Third); - // } - //} - #endregion - - } - -} diff --git a/plugins/Radegast.Plugin.Alice/Alice.cs b/plugins/Radegast.Plugin.Alice/Alice.cs index 27e67fc9d..559670707 100644 --- a/plugins/Radegast.Plugin.Alice/Alice.cs +++ b/plugins/Radegast.Plugin.Alice/Alice.cs @@ -1,55 +1,43 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id: Map.cs 152 2009-08-24 14:19:58Z latifer@gmail.com $ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.IO; +using System.Threading; using System.Windows.Forms; -using Radegast; using OpenMetaverse; using OpenMetaverse.StructuredData; using AIMLbot; namespace Radegast.Plugin.Alice { - [Radegast.Plugin(Name = "ALICE Chatbot", Description = "A.L.I.C.E. based AI chat bot", Version = "1.1")] + [Plugin(Name = "ALICE Chatbot", Description = "A.L.I.C.E. based AI chat bot", Version = "1.1")] public class AliceAI : IRadegastPlugin { private RadegastInstance Instance; - private GridClient Client { get { return Instance.Client; } } + private GridClient Client => Instance.Client; private bool Enabled = false; private Avatar.AvatarProperties MyProfile; - private AIMLbot.Bot Alice; + private Bot Alice; private Hashtable AliceUsers = new Hashtable(); private ToolStripMenuItem MenuButton, EnabledButton; private TalkToAvatar talkToAvatar; @@ -66,7 +54,7 @@ public class AliceAI : IRadegastPlugin public void StartPlugin(RadegastInstance inst) { Instance = inst; - Instance.ClientChanged += new EventHandler(Instance_ClientChanged); + Instance.ClientChanged += Instance_ClientChanged; if (!Instance.GlobalSettings.Keys.Contains("plugin.alice.enabled")) { @@ -89,14 +77,14 @@ public void StartPlugin(RadegastInstance inst) { Enabled = false; } - btn_DisableOnStart = new ToolStripMenuItem("Disable on start", null, (object sender, EventArgs e) => + btn_DisableOnStart = new ToolStripMenuItem("Disable on start", null, (sender, e) => { DisableOnStart = btn_DisableOnStart.Checked = !DisableOnStart; Instance.GlobalSettings["plugin.alice.disableOnStart"] = OSD.FromBoolean(DisableOnStart); }); btn_DisableOnStart.Checked = DisableOnStart; - EnabledButton = new ToolStripMenuItem("Enabled", null, (object sender, EventArgs e) => + EnabledButton = new ToolStripMenuItem("Enabled", null, (sender, e) => { Enabled = SetEnabled(!Enabled); EnabledButton.Checked = MenuButton.Checked = Enabled; @@ -112,7 +100,7 @@ public void StartPlugin(RadegastInstance inst) respondWithoutName = Instance.GlobalSettings["plugin.alice.respondWithoutName"].AsBoolean(); } - respondWithoutNameButton = new ToolStripMenuItem("Respond without name", null, (object sender, EventArgs e) => + respondWithoutNameButton = new ToolStripMenuItem("Respond without name", null, (sender, e) => { respondWithoutName = respondWithoutNameButton.Checked = !respondWithoutName; Instance.GlobalSettings["plugin.alice.respondWithoutName"] = OSD.FromBoolean(respondWithoutName); @@ -127,7 +115,7 @@ public void StartPlugin(RadegastInstance inst) respondRange = Instance.GlobalSettings["plugin.alice.respondRange"]; } - distance_5m = new ToolStripMenuItem("5m range", null, (object sender, EventArgs e) => + distance_5m = new ToolStripMenuItem("5m range", null, (sender, e) => { distance_5m.Checked = !distance_5m.Checked; if (distance_5m.Checked) @@ -145,7 +133,7 @@ public void StartPlugin(RadegastInstance inst) } }); - distance_10m = new ToolStripMenuItem("10m range", null, (object sender, EventArgs e) => + distance_10m = new ToolStripMenuItem("10m range", null, (sender, e) => { distance_10m.Checked = !distance_10m.Checked; if (distance_10m.Checked) @@ -163,7 +151,7 @@ public void StartPlugin(RadegastInstance inst) } }); - distance_15m = new ToolStripMenuItem("15m range", null, (object sender, EventArgs e) => + distance_15m = new ToolStripMenuItem("15m range", null, (sender, e) => { distance_15m.Checked = !distance_15m.Checked; if (distance_15m.Checked) @@ -181,7 +169,7 @@ public void StartPlugin(RadegastInstance inst) } }); - distance_20m = new ToolStripMenuItem("20m range", null, (object sender, EventArgs e) => + distance_20m = new ToolStripMenuItem("20m range", null, (sender, e) => { distance_20m.Checked = !distance_20m.Checked; if (distance_20m.Checked) @@ -208,7 +196,7 @@ public void StartPlugin(RadegastInstance inst) shout2shout = Instance.GlobalSettings["plugin.alice.shout2shout"].AsBoolean(); } - btn_shout2shout = new ToolStripMenuItem("Shout response to Shout", null, (object sender, EventArgs e) => + btn_shout2shout = new ToolStripMenuItem("Shout response to Shout", null, (sender, e) => { shout2shout = btn_shout2shout.Checked = !shout2shout; Instance.GlobalSettings["plugin.alice.shout2shout"] = OSD.FromBoolean(shout2shout); @@ -223,13 +211,13 @@ public void StartPlugin(RadegastInstance inst) whisper2whisper = Instance.GlobalSettings["plugin.alice.whisper2whisper"].AsBoolean(); } - btn_whisper2whisper = new ToolStripMenuItem("Whisper response to Whisper", null, (object sender, EventArgs e) => + btn_whisper2whisper = new ToolStripMenuItem("Whisper response to Whisper", null, (sender, e) => { whisper2whisper = btn_whisper2whisper.Checked = !whisper2whisper; Instance.GlobalSettings["plugin.alice.whisper2whisper"] = OSD.FromBoolean(whisper2whisper); }); - MenuButton = new ToolStripMenuItem("ALICE chatbot", null, (object sender, EventArgs e) => + MenuButton = new ToolStripMenuItem("ALICE chatbot", null, (sender, e) => { Enabled = SetEnabled(!Enabled); EnabledButton.Checked = MenuButton.Checked = Enabled; @@ -278,7 +266,7 @@ public void StartPlugin(RadegastInstance inst) MenuButton.DropDownItems.Add(btn_enableDelay); MenuButton.DropDownItems.Add(btn_DisableOnStart); - MenuButton.DropDownItems.Add("Reload AIML", null, (object sender, EventArgs e) => + MenuButton.DropDownItems.Add("Reload AIML", null, (sender, e) => { Alice = null; GC.Collect(); @@ -309,10 +297,15 @@ private bool LoadALICE() { try { - Alice = new AIMLbot.Bot(); - Alice.isAcceptingUserInput = false; - Alice.loadSettings(); - AIMLbot.Utils.AIMLLoader loader = new AIMLbot.Utils.AIMLLoader(Alice); + Alice = new Bot + { + isAcceptingUserInput = false + }; + string configFile = Path.Combine( + Directory.GetCurrentDirectory(), + "aiml_config", "Settings.xml"); + Alice.loadSettings(configFile); + var loader = new AIMLbot.Utils.AIMLLoader(Alice); Alice.isAcceptingUserInput = false; loader.loadAIML(Alice.PathToAIML); Alice.isAcceptingUserInput = true; @@ -320,7 +313,7 @@ private bool LoadALICE() } catch (Exception ex) { - System.Console.WriteLine("Failed loading ALICE: " + ex.Message); + Console.WriteLine("Failed loading ALICE: " + ex.Message); return false; } } @@ -342,18 +335,18 @@ public void StopPlugin(RadegastInstance Instance) private void RegisterClientEvents(GridClient client) { - Client.Self.ChatFromSimulator += new EventHandler(Self_ChatFromSimulator); - Client.Self.IM += new EventHandler(Self_IM); - Client.Avatars.AvatarPropertiesReply += new EventHandler(Avatars_AvatarPropertiesReply); - Instance.Netcom.ClientConnected += new EventHandler(Netcom_ClientConnected); + Client.Self.ChatFromSimulator += Self_ChatFromSimulator; + Client.Self.IM += Self_IM; + Client.Avatars.AvatarPropertiesReply += Avatars_AvatarPropertiesReply; + Instance.Netcom.ClientConnected += Netcom_ClientConnected; } private void UnregisterClientEvents(GridClient client) { - Client.Self.ChatFromSimulator -= new EventHandler(Self_ChatFromSimulator); - Client.Self.IM -= new EventHandler(Self_IM); - Client.Avatars.AvatarPropertiesReply -= new EventHandler(Avatars_AvatarPropertiesReply); - Instance.Netcom.ClientConnected -= new EventHandler(Netcom_ClientConnected); + Client.Self.ChatFromSimulator -= Self_ChatFromSimulator; + Client.Self.IM -= Self_IM; + Client.Avatars.AvatarPropertiesReply -= Avatars_AvatarPropertiesReply; + Instance.Netcom.ClientConnected -= Netcom_ClientConnected; } void Instance_ClientChanged(object sender, ClientChangedEventArgs e) @@ -398,7 +391,19 @@ void Avatars_AvatarPropertiesReply(object sender, AvatarPropertiesReplyEventArgs void Self_ChatFromSimulator(object sender, ChatEventArgs e) { // We ignore everything except normal chat from other avatars - if (!Enabled || e.SourceType != ChatSourceType.Agent || e.FromName == Client.Self.Name || e.Message.Trim().Length == 0) return; + if (!Enabled + || e.SourceType != ChatSourceType.Agent + || e.FromName == Client.Self.Name + || e.Message.Trim().Length == 0) + { + return; + } + + // Ignore muted agents + if (Client.Self.MuteList.Find(me => me.Type == MuteType.Resident && me.ID == e.SourceID) != null) + { + return; + } bool parseForResponse = Alice != null && Alice.isAcceptingUserInput && Enabled; if (parseForResponse && respondRange >= 0) @@ -413,17 +418,17 @@ void Self_ChatFromSimulator(object sender, ChatEventArgs e) if (parseForResponse) { - WorkPool.QueueUserWorkItem(sync => + ThreadPool.QueueUserWorkItem(sync => { lock (syncChat) { Alice.GlobalSettings.updateSetting("location", "region " + Client.Network.CurrentSim.Name); string msg = e.Message.ToLower(); msg = msg.Replace(FirstName(Client.Self.Name).ToLower(), ""); - AIMLbot.User user; + User user; if (AliceUsers.ContainsKey(e.FromName)) { - user = (AIMLbot.User)AliceUsers[e.FromName]; + user = (User)AliceUsers[e.FromName]; } else { @@ -433,23 +438,28 @@ void Self_ChatFromSimulator(object sender, ChatEventArgs e) AliceUsers[e.FromName] = user; } + var typingAnimationIsEnabled = !Instance.GlobalSettings["no_typing_anim"].AsBoolean(); + Client.Self.Movement.TurnToward(e.Position); - if (EnableRandomDelay) System.Threading.Thread.Sleep(1000 + 1000 * rand.Next(2)); - if (!Instance.State.IsTyping) + if (EnableRandomDelay) Thread.Sleep(1000 + 1000 * rand.Next(2)); + if (!Instance.State.IsTyping && typingAnimationIsEnabled) { Instance.State.SetTyping(true); } if (EnableRandomDelay) { - System.Threading.Thread.Sleep(2000 + 1000 * rand.Next(5)); + Thread.Sleep(2000 + 1000 * rand.Next(5)); } else { - System.Threading.Thread.Sleep(1000); + Thread.Sleep(1000); + } + if (typingAnimationIsEnabled) + { + Instance.State.SetTyping(false); } - Instance.State.SetTyping(false); - AIMLbot.Request req = new Request(msg, user, Alice); - AIMLbot.Result res = Alice.Chat(req); + Request req = new Request(msg, user, Alice); + Result res = Alice.Chat(req); string outp = res.Output; if (outp.Length > 1000) { @@ -484,7 +494,7 @@ void Self_IM(object sender, InstantMessageEventArgs e) { Instance.MainForm.BeginInvoke( new MethodInvoker( - delegate() + delegate () { Self_IM(sender, e); } @@ -492,60 +502,69 @@ void Self_IM(object sender, InstantMessageEventArgs e) return; } - // We need to filter out all sorts of things that come in as a instante message - if (e.IM.Dialog == InstantMessageDialog.MessageFromAgent // Message is not notice, inv. offer, etc etc + // We need to filter out all sorts of things that come in as an instant message + if (!(e.IM.Dialog == InstantMessageDialog.MessageFromAgent // Message is not notice, inv. offer, etc etc && !Instance.Groups.ContainsKey(e.IM.IMSessionID) // Message is not group IM (sessionID == groupID) && e.IM.BinaryBucket.Length < 2 // Session is not ad-hoc friends conference && e.IM.FromAgentName != "Second Life" // Not a system message && Alice.isAcceptingUserInput // Alice bot loaded successfully - ) + )) + { + return; + } + + // Ignore muted agents + if (Client.Self.MuteList.Find(muteEntry => muteEntry.Type == MuteType.Resident + && muteEntry.ID == e.IM.FromAgentID) != null) { - WorkPool.QueueUserWorkItem(sync => + return; + } + + ThreadPool.QueueUserWorkItem(sync => + { + lock (syncChat) { - lock (syncChat) + Alice.GlobalSettings.updateSetting("location", "region " + Client.Network.CurrentSim.Name); + User user; + if (AliceUsers.ContainsKey(e.IM.FromAgentName)) { - Alice.GlobalSettings.updateSetting("location", "region " + Client.Network.CurrentSim.Name); - AIMLbot.User user; - if (AliceUsers.ContainsKey(e.IM.FromAgentName)) - { - user = (AIMLbot.User)AliceUsers[e.IM.FromAgentName]; - } - else - { - user = new User(e.IM.FromAgentName, Alice); - user.Predicates.removeSetting("name"); - user.Predicates.addSetting("name", FirstName(e.IM.FromAgentName)); - AliceUsers[e.IM.FromAgentName] = user; - } - AIMLbot.Request req = new Request(e.IM.Message, user, Alice); - AIMLbot.Result res = Alice.Chat(req); - string msg = res.Output; - if (msg.Length > 1000) - { - msg = msg.Substring(0, 1000); - } - if (EnableRandomDelay) System.Threading.Thread.Sleep(2000 + 1000 * rand.Next(3)); - Instance.Netcom.SendIMStartTyping(e.IM.FromAgentID, e.IM.IMSessionID); - if (EnableRandomDelay) - { - System.Threading.Thread.Sleep(2000 + 1000 * rand.Next(5)); - } - else - { - System.Threading.Thread.Sleep(1000); - } - Instance.Netcom.SendIMStopTyping(e.IM.FromAgentID, e.IM.IMSessionID); - if (Instance.MainForm.InvokeRequired) - { - Instance.MainForm.BeginInvoke(new MethodInvoker(() => Instance.Netcom.SendInstantMessage(msg, e.IM.FromAgentID, e.IM.IMSessionID))); - } - else - { - Instance.Netcom.SendInstantMessage(msg, e.IM.FromAgentID, e.IM.IMSessionID); - } + user = (User)AliceUsers[e.IM.FromAgentName]; } - }); - } + else + { + user = new User(e.IM.FromAgentName, Alice); + user.Predicates.removeSetting("name"); + user.Predicates.addSetting("name", FirstName(e.IM.FromAgentName)); + AliceUsers[e.IM.FromAgentName] = user; + } + Request req = new Request(e.IM.Message, user, Alice); + Result res = Alice.Chat(req); + string msg = res.Output; + if (msg.Length > 1000) + { + msg = msg.Substring(0, 1000); + } + if (EnableRandomDelay) Thread.Sleep(2000 + 1000 * rand.Next(3)); + Instance.Netcom.SendIMStartTyping(e.IM.FromAgentID, e.IM.IMSessionID); + if (EnableRandomDelay) + { + Thread.Sleep(2000 + 1000 * rand.Next(5)); + } + else + { + Thread.Sleep(1000); + } + Instance.Netcom.SendIMStopTyping(e.IM.FromAgentID, e.IM.IMSessionID); + if (Instance.MainForm.InvokeRequired) + { + Instance.MainForm.BeginInvoke(new MethodInvoker(() => Instance.Netcom.SendInstantMessage(msg, e.IM.FromAgentID, e.IM.IMSessionID))); + } + else + { + Instance.Netcom.SendInstantMessage(msg, e.IM.FromAgentID, e.IM.IMSessionID); + } + } + }); } private string FirstName(string name) diff --git a/plugins/Radegast.Plugin.Alice/Properties/AssemblyInfo.cs b/plugins/Radegast.Plugin.Alice/Properties/AssemblyInfo.cs deleted file mode 100644 index 2520fa5f8..000000000 --- a/plugins/Radegast.Plugin.Alice/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Radegast.Plugin.Alice")] -[assembly: AssemblyDescription("Chat AI for Radegast")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Radegast Development Team")] -[assembly: AssemblyProduct("Radegast.Plugin.Alice")] -[assembly: AssemblyCopyright("Copyright (c) 2009-2014, Radegast Development Team")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("d548ed53-d171-49d9-8b4e-a70597b1b0ae")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/plugins/Radegast.Plugin.Alice/Radegast.Plugin.Alice.csproj b/plugins/Radegast.Plugin.Alice/Radegast.Plugin.Alice.csproj new file mode 100644 index 000000000..5da976b7e --- /dev/null +++ b/plugins/Radegast.Plugin.Alice/Radegast.Plugin.Alice.csproj @@ -0,0 +1,203 @@ + + + net48 + true + false + AnyCPU;x64;x86 + + + full + ..\..\bin\$(Configuration)\ + TRACE;DEBUG + + + portable + ..\..\bin\$(Configuration)\ + TRACE + + + ..\..\bin\$(Configuration)\ + TRACE + true + portable + MinimumRecommendedRules.ruleset + + + ..\..\bin\$(Configuration)\ + TRACE + true + portable + MinimumRecommendedRules.ruleset + + + ..\..\bin\$(Configuration)\ + TRACE + true + portable + MinimumRecommendedRules.ruleset + + + ..\..\bin\$(Configuration)\ + + + ..\..\bin\$(Configuration)\ + + + ..\..\bin\$(Configuration)\ + + + ..\..\bin\$(Configuration)\ + + + ..\..\bin\$(Configuration)\ + + + ..\..\bin\$(Configuration)\ + + + + + + + + + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/plugins/Radegast.Plugin.Alice/TalkToAvatar.cs b/plugins/Radegast.Plugin.Alice/TalkToAvatar.cs index ca125dab5..9069afe4e 100644 --- a/plugins/Radegast.Plugin.Alice/TalkToAvatar.cs +++ b/plugins/Radegast.Plugin.Alice/TalkToAvatar.cs @@ -1,7 +1,4 @@ -using System; using System.Windows.Forms; - -using AIMLbot; using AIMLBot = AIMLbot.Bot; using OpenMetaverse; @@ -25,11 +22,6 @@ public override bool Contributes(object o, System.Type type) return type == typeof(FriendInfo) || type == typeof(Avatar); } - public override object DeRef(object o) - { - return base.DeRef(o); - } - public override bool IsEnabled(object target) { if (!IsEnabledInRadegast) return false; @@ -37,10 +29,7 @@ public override bool IsEnabled(object target) return (a != null && !string.IsNullOrEmpty(a.Name)) || base.IsEnabled(target); } - protected bool IsEnabledInRadegast - { - get { return Instance.GlobalSettings["plugin.alice.enabled"].AsBoolean(); } - } + protected bool IsEnabledInRadegast => Instance.GlobalSettings["plugin.alice.enabled"].AsBoolean(); public override void OnInvoke(object sender, System.EventArgs e, object target) { diff --git a/plugins/Radegast.Plugin.Alice/assemblies/AIMLbot.dll b/plugins/Radegast.Plugin.Alice/assemblies/AIMLbot.dll deleted file mode 100644 index 8481b02e2..000000000 Binary files a/plugins/Radegast.Plugin.Alice/assemblies/AIMLbot.dll and /dev/null differ diff --git a/plugins/Radegast.Plugin.DemoTab/Radegast.Plugin.DemoTab.csproj b/plugins/Radegast.Plugin.DemoTab/Radegast.Plugin.DemoTab.csproj index 7c1d62e71..b411ce387 100644 --- a/plugins/Radegast.Plugin.DemoTab/Radegast.Plugin.DemoTab.csproj +++ b/plugins/Radegast.Plugin.DemoTab/Radegast.Plugin.DemoTab.csproj @@ -77,15 +77,15 @@ - + {E63618CF-B21B-44CD-BBDE-BCE26CF6AF0D} OpenMetaverse.StructuredData - + {1A303634-82F1-4C91-9E1C-C96B8B03D10A} OpenMetaverseTypes - + {30D9F2AE-42FE-4ACD-9E52-A819CB36EE05} OpenMetaverse @@ -102,4 +102,4 @@ --> - \ No newline at end of file + diff --git a/plugins/Radegast.Plugin.IRC/Properties/AssemblyInfo.cs b/plugins/Radegast.Plugin.IRC/Properties/AssemblyInfo.cs deleted file mode 100644 index 98ddbd71f..000000000 --- a/plugins/Radegast.Plugin.IRC/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Radegast.Plugin.IRC")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Radegast Development Team")] -[assembly: AssemblyProduct("Radegast.Plugin.IRC")] -[assembly: AssemblyCopyright("Copyright (c) 2009-2014, Radegast Development Team")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("f186b63f-c2a9-4b0f-a39e-7f047dde93d6")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.1.0.0")] -[assembly: AssemblyFileVersion("0.1.0.0")] diff --git a/plugins/Radegast.Plugin.IRC/Radegast.Plugin.IRC.cs b/plugins/Radegast.Plugin.IRC/Radegast.Plugin.IRC.cs index 06e50822b..15c094573 100644 --- a/plugins/Radegast.Plugin.IRC/Radegast.Plugin.IRC.cs +++ b/plugins/Radegast.Plugin.IRC/Radegast.Plugin.IRC.cs @@ -1,49 +1,35 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections.Generic; -using System.Text; -using System.Threading; using System.Windows.Forms; -using Radegast; using OpenMetaverse; -using OpenMetaverse.StructuredData; namespace Radegast.Plugin.IRC { - [Radegast.Plugin(Name = "IRC Relay", Description = "Relays SL group chat to a IRC network", Version = "0.1")] + [Plugin(Name = "IRC Relay", Description = "Relays SL group chat to a IRC network", Version = "0.1")] public class IRCPlugin : IRadegastPlugin { RadegastInstance instance; - GridClient Client { get { return instance.Client; } } + GridClient Client => instance.Client; ToolStripMenuItem IRCButton; int relayNr = 0; @@ -53,7 +39,7 @@ public void StartPlugin(RadegastInstance inst) instance = inst; IRCButton = new ToolStripMenuItem("New IRC Relay..."); - IRCButton.Click += new EventHandler(IRCButton_Click); + IRCButton.Click += IRCButton_Click; instance.MainForm.PluginsMenu.DropDownItems.Add(IRCButton); } @@ -66,8 +52,8 @@ public void StopPlugin(RadegastInstance instance) toRemove.Add(tab); } - for (int i = 0; i < toRemove.Count; i++) - toRemove[i].Close(); + foreach (var tab in toRemove) + tab.Close(); if (IRCButton != null) { @@ -79,9 +65,9 @@ public void StopPlugin(RadegastInstance instance) void IRCButton_Click(object sender, EventArgs e) { relayNr++; - string tabName = "irc_relay_" + relayNr.ToString(); + string tabName = "irc_relay_" + relayNr; - instance.TabConsole.AddTab(tabName, "IRC Relay " + relayNr.ToString(), new RelayConsole(instance)); + instance.TabConsole.AddTab(tabName, "IRC Relay " + relayNr, new RelayConsole(instance)); instance.TabConsole.SelectTab(tabName); } } diff --git a/plugins/Radegast.Plugin.IRC/Radegast.Plugin.IRC.csproj b/plugins/Radegast.Plugin.IRC/Radegast.Plugin.IRC.csproj new file mode 100644 index 000000000..d2362c4b3 --- /dev/null +++ b/plugins/Radegast.Plugin.IRC/Radegast.Plugin.IRC.csproj @@ -0,0 +1,95 @@ + + + net48 + true + false + AnyCPU;x64;x86 + + + full + ..\..\bin\$(Configuration)\ + TRACE;DEBUG + + + portable + ..\..\bin\$(Configuration)\ + TRACE + + + ..\..\bin\$(Configuration)\ + TRACE + true + portable + MinimumRecommendedRules.ruleset + + + ..\..\bin\$(Configuration)\ + TRACE + true + portable + MinimumRecommendedRules.ruleset + + + ..\..\bin\$(Configuration)\ + TRACE + true + portable + MinimumRecommendedRules.ruleset + + + ..\..\bin\$(Configuration)\ + + + ..\..\bin\$(Configuration)\ + + + ..\..\bin\$(Configuration)\ + + + ..\..\bin\$(Configuration)\ + + + ..\..\bin\$(Configuration)\ + + + ..\..\bin\$(Configuration)\ + + + + + + + + + + + + RelayConsole.cs + Dependency + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/plugins/Radegast.Plugin.IRC/RelayConsole.cs b/plugins/Radegast.Plugin.IRC/RelayConsole.cs index 42b6715ec..8b2adab23 100644 --- a/plugins/Radegast.Plugin.IRC/RelayConsole.cs +++ b/plugins/Radegast.Plugin.IRC/RelayConsole.cs @@ -1,33 +1,22 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id$ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ using System; using System.Collections.Generic; @@ -38,14 +27,13 @@ using System.Windows.Forms; using Meebey.SmartIrc4net; using OpenMetaverse; -using OpenMetaverse.Packets; using OpenMetaverse.StructuredData; namespace Radegast.Plugin.IRC { public partial class RelayConsole : RadegastTabControl { - enum RelaySourceType + private enum RelaySourceType { Unknown, Group, @@ -54,7 +42,7 @@ enum RelaySourceType IM } - class RelaySource + private class RelaySource { public RelaySource(string name, RelaySourceType sourcetype, UUID sessionId) { @@ -84,6 +72,30 @@ public override string ToString() return !(left == right); } + protected bool Equals(RelaySource other) + { + return string.Equals(Name, other.Name) && SourceType == other.SourceType && SessionId.Equals(other.SessionId); + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() != GetType()) return false; + return Equals((RelaySource)obj); + } + + public override int GetHashCode() + { + unchecked + { + var hashCode = Name?.GetHashCode() ?? 0; + hashCode = (hashCode * 397) ^ (int)SourceType; + hashCode = (hashCode * 397) ^ SessionId.GetHashCode(); + return hashCode; + } + } + public string Name; public RelaySourceType SourceType; public UUID SessionId; @@ -91,7 +103,7 @@ public override string ToString() public IrcClient irc; - TabsConsole TC { get { return instance.TabConsole; } } + TabsConsole TC => instance.TabConsole; RichTextBoxPrinter textPrinter; private List chatHistory = new List(); private int chatPointer; @@ -113,14 +125,16 @@ public RelayConsole(RadegastInstance instance) if (config == null) { - config = new OSDMap(); - config["server"] = new OSDString("irc.freenode.net"); - config["port"] = new OSDInteger(6667); - config["nick"] = new OSDString(string.Empty); - config["channel"] = new OSDString("#"); - config["send_delay"] = new OSDInteger(200); - config["auto_reconnect"] = new OSDBoolean(true); - config["ctcp_version"] = new OSDString("Radegast IRC"); + config = new OSDMap + { + ["server"] = new OSDString("irc.freenode.net"), + ["port"] = new OSDInteger(6667), + ["nick"] = new OSDString(string.Empty), + ["channel"] = new OSDString("#"), + ["send_delay"] = new OSDInteger(200), + ["auto_reconnect"] = new OSDBoolean(true), + ["ctcp_version"] = new OSDString("Radegast IRC") + }; instance.GlobalSettings["plugin.irc"] = config; } @@ -144,11 +158,13 @@ public RelayConsole(RadegastInstance instance) txtPort.Text = config["port"].AsString(); txtServer.Text = config["server"].AsString(); - irc = new IrcClient(); - irc.SendDelay = config["send_delay"].AsInteger(); - irc.AutoReconnect = config["auto_reconnect"].AsBoolean(); - irc.CtcpVersion = config["ctcp_version"].AsString(); - irc.Encoding = Encoding.UTF8; + irc = new IrcClient + { + SendDelay = config["send_delay"].AsInteger(), + AutoReconnect = config["auto_reconnect"].AsBoolean(), + CtcpVersion = config["ctcp_version"].AsString(), + Encoding = Encoding.UTF8 + }; TC.OnTabAdded += TC_OnTabAdded; TC.OnTabRemoved += TC_OnTabRemoved; @@ -387,9 +403,11 @@ private void btnConnect_Click(object sender, EventArgs e) try { - Thread IRCConnection = new Thread(IrcThread); - IRCConnection.Name = "IRC Thread"; - IRCConnection.IsBackground = true; + Thread IRCConnection = new Thread(IrcThread) + { + Name = "IRC Thread", + IsBackground = true + }; int port = 6667; int.TryParse(txtPort.Text, out port); IRCConnection.Start(new object[] { txtServer.Text, port, txtNick.Text, txtChan.Text }); @@ -483,23 +501,23 @@ private void ProcessMessage(string message, string from) { string[] lines = Regex.Split(message, "\n+"); - for (int l = 0; l < lines.Length; l++) + foreach (var line in lines) { - string[] words = lines[l].Split(' '); + string[] words = line.Split(' '); string outstr = string.Empty; - for (int i = 0; i < words.Length; i++) + foreach (var word in words) { - outstr += words[i] + " "; + outstr += word + " "; if (outstr.Length > 380) { - PrintMsg(irc.Nickname, string.Format("{0}: {1}", from, outstr.Remove(outstr.Length - 1))); - irc.SendMessage(SendType.Message, txtChan.Text, string.Format("{0}: {1}", from, outstr.Remove(outstr.Length - 1))); + PrintMsg(irc.Nickname, $"{@from}: {outstr.Remove(outstr.Length - 1)}"); + irc.SendMessage(SendType.Message, txtChan.Text, $"{@from}: {outstr.Remove(outstr.Length - 1)}"); outstr = string.Empty; } } - PrintMsg(irc.Nickname, string.Format("{0}: {1}", from, outstr.Remove(outstr.Length - 1))); - irc.SendMessage(SendType.Message, txtChan.Text, string.Format("{0}: {1}", from, outstr.Remove(outstr.Length - 1))); + PrintMsg(irc.Nickname, $"{@from}: {outstr.Remove(outstr.Length - 1)}"); + irc.SendMessage(SendType.Message, txtChan.Text, $"{@from}: {outstr.Remove(outstr.Length - 1)}"); } } diff --git a/plugins/Radegast.Plugin.IRC/assemblies/Meebey.SmartIrc4net.dll b/plugins/Radegast.Plugin.IRC/assemblies/Meebey.SmartIrc4net.dll deleted file mode 100644 index e5a7c7830..000000000 Binary files a/plugins/Radegast.Plugin.IRC/assemblies/Meebey.SmartIrc4net.dll and /dev/null differ diff --git a/plugins/Radegast.Plugin.SimpleBuilder/Properties/AssemblyInfo.cs b/plugins/Radegast.Plugin.SimpleBuilder/Properties/AssemblyInfo.cs deleted file mode 100644 index fd539335e..000000000 --- a/plugins/Radegast.Plugin.SimpleBuilder/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("SimpleBuilder Plugin")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Microsoft")] -[assembly: AssemblyProduct("SimpleBuilder Plugin")] -[assembly: AssemblyCopyright("")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("4781EEC7-B7AD-43A2-896B-BD6B0B032AC6")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/plugins/Radegast.Plugin.SimpleBuilder/Radegast.Plugin.SimpleBuilder.csproj b/plugins/Radegast.Plugin.SimpleBuilder/Radegast.Plugin.SimpleBuilder.csproj new file mode 100644 index 000000000..f0bb287bf --- /dev/null +++ b/plugins/Radegast.Plugin.SimpleBuilder/Radegast.Plugin.SimpleBuilder.csproj @@ -0,0 +1,93 @@ + + + net48 + true + false + AnyCPU;x64;x86 + + + full + ..\..\bin\$(Configuration)\ + TRACE;DEBUG + + + portable + ..\..\bin\$(Configuration)\ + TRACE + + + ..\..\bin\$(Configuration)\ + TRACE + true + portable + MinimumRecommendedRules.ruleset + + + ..\..\bin\$(Configuration)\ + TRACE + true + portable + MinimumRecommendedRules.ruleset + + + ..\..\bin\$(Configuration)\ + TRACE + true + portable + MinimumRecommendedRules.ruleset + + + ..\..\bin\$(Configuration)\ + + + ..\..\bin\$(Configuration)\ + + + ..\..\bin\$(Configuration)\ + + + ..\..\bin\$(Configuration)\ + + + ..\..\bin\$(Configuration)\ + + + ..\..\bin\$(Configuration)\ + + + + + + + + + + SimpleBuilder.cs + Dependency + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/plugins/Radegast.Plugin.SimpleBuilder/SimpleBuilder.cs b/plugins/Radegast.Plugin.SimpleBuilder/SimpleBuilder.cs index 575ea994b..31f1df737 100644 --- a/plugins/Radegast.Plugin.SimpleBuilder/SimpleBuilder.cs +++ b/plugins/Radegast.Plugin.SimpleBuilder/SimpleBuilder.cs @@ -35,10 +35,6 @@ #region Usings using System; using System.Collections.Generic; -using System.ComponentModel; -using System.Drawing; -using System.Data; -using System.Linq; using System.Text; using System.Windows.Forms; using Radegast; @@ -51,7 +47,7 @@ namespace SimpleBuilderNamespace /// Example implementation of a control that can be used /// as Radegast tab and loeaded as a plugin ///
- [Radegast.Plugin(Name = "SimpleBuilder Plugin", Description = "Allows you to build some basic prims, like boxes, cylinder, tubes, ... (requires permission!)", Version = "1.0")] + [Plugin(Name = "SimpleBuilder Plugin", Description = "Allows you to build some basic prims, like boxes, cylinder, tubes, ... (requires permission!)", Version = "1.0")] public partial class SimpleBuilder : RadegastTabControl, IRadegastPlugin { System.Threading.AutoResetEvent primDone = new System.Threading.AutoResetEvent(false); @@ -72,10 +68,7 @@ public partial class SimpleBuilder : RadegastTabControl, IRadegastPlugin private Primitive m_selectedPrim; public Primitive selectedPrim { - get - { - return m_selectedPrim; - } + get => m_selectedPrim; set { if(value == null){ @@ -110,8 +103,8 @@ public SimpleBuilder(RadegastInstance instance, bool unused) : base(instance) { InitializeComponent(); - Disposed += new EventHandler(DemoTab_Disposed); - instance.ClientChanged += new EventHandler(instance_ClientChanged); + Disposed += DemoTab_Disposed; + instance.ClientChanged += instance_ClientChanged; RegisterClientEvents(client); selectedPrim = null; @@ -128,7 +121,7 @@ public SimpleBuilder(RadegastInstance instance, bool unused) void DemoTab_Disposed(object sender, EventArgs e) { UnregisterClientEvents(client); - instance.ClientChanged -= new EventHandler(instance_ClientChanged); + instance.ClientChanged -= instance_ClientChanged; } /// @@ -139,10 +132,10 @@ void DemoTab_Disposed(object sender, EventArgs e) /// Main RadegastInstance public void StartPlugin(RadegastInstance inst) { - this.instance = inst; + instance = inst; propRequester = new PropertiesQueue(instance); - propRequester.OnTick += new PropertiesQueue.TickCallback(propRequester_OnTick); + propRequester.OnTick += propRequester_OnTick; ActivateTabButton = new ToolStripMenuItem(tabLabel, null, MenuButtonClicked); instance.MainForm.PluginsMenu.DropDownItems.Add(ActivateTabButton); @@ -194,8 +187,7 @@ void propRequester_OnTick(int remaining) if(lstPrims != null) lstPrims.VirtualListSize = Prims.Count; } - if(lstPrims != null) - lstPrims.Invalidate(); + lstPrims?.Invalidate(); } private bool IncludePrim(Primitive prim) @@ -221,18 +213,16 @@ private string GetObjectName(Primitive prim, int distance) UUID.Zero != prim.Properties.GroupID) { System.Threading.AutoResetEvent nameReceivedSignal = new System.Threading.AutoResetEvent(false); - EventHandler cbGroupName = new EventHandler( - delegate(object sender, GroupNamesEventArgs e) + EventHandler cbGroupName = delegate(object sender, GroupNamesEventArgs e) + { + if (e.GroupNames.ContainsKey(prim.Properties.GroupID)) { - if (e.GroupNames.ContainsKey(prim.Properties.GroupID)) - { - e.GroupNames.TryGetValue(prim.Properties.GroupID, out ownerName); - if (string.IsNullOrEmpty(ownerName)) - ownerName = "Loading..."; - if (null != nameReceivedSignal) - nameReceivedSignal.Set(); - } - }); + e.GroupNames.TryGetValue(prim.Properties.GroupID, out ownerName); + if (string.IsNullOrEmpty(ownerName)) + ownerName = "Loading..."; + nameReceivedSignal.Set(); + } + }; client.Groups.GroupNamesReply += cbGroupName; client.Groups.RequestGroupName(prim.Properties.GroupID); nameReceivedSignal.WaitOne(5000, false); @@ -245,7 +235,7 @@ private string GetObjectName(Primitive prim, int distance) if (prim.ParentID == client.Self.LocalID) { - return string.Format("{0} attached to {1}", name, prim.PrimData.AttachmentPoint.ToString()); + return string.Format("{0} attached to {1}", name, prim.PrimData.AttachmentPoint); } else if (ownerName != "Loading...") { @@ -282,9 +272,11 @@ private void lstPrims_RetrieveVirtualItem(object sender, RetrieveVirtualItemEven } string name = GetObjectName(prim); - var item = new ListViewItem(name); - item.Tag = prim; - item.Name = prim.ID.ToString(); + var item = new ListViewItem(name) + { + Tag = prim, + Name = prim.ID.ToString() + }; e.Item = item; } @@ -307,7 +299,7 @@ void instance_ClientChanged(object sender, ClientChangedEventArgs e) /// void RegisterClientEvents(GridClient client) { - client.Self.ChatFromSimulator += new EventHandler(Self_ChatFromSimulator); + client.Self.ChatFromSimulator += Self_ChatFromSimulator; } /// @@ -318,7 +310,7 @@ void RegisterClientEvents(GridClient client) void UnregisterClientEvents(GridClient client) { if (client == null) return; - client.Self.ChatFromSimulator -= new EventHandler(Self_ChatFromSimulator); + client.Self.ChatFromSimulator -= Self_ChatFromSimulator; } /// @@ -349,7 +341,6 @@ void Self_ChatFromSimulator(object sender, ChatEventArgs e) if (InvokeRequired) { BeginInvoke(new MethodInvoker(() => Self_ChatFromSimulator(sender, e))); - return; } //txtChat.Text = e.Message; @@ -363,7 +354,7 @@ private void btnBuild_Click(object sender, EventArgs e) PrimType primType = (PrimType)Enum.Parse(typeof(PrimType), btn.Text); - this.BuildAndRez(primType); + BuildAndRez(primType); } private void BuildAndRez(PrimType primType) @@ -379,7 +370,7 @@ private void BuildAndRez(PrimType primType) rezpos = client.Self.SimPosition + rezpos * client.Self.Movement.BodyRotation; ObjectName = txt_ObjectName.Text; - client.Objects.ObjectUpdate += new EventHandler(Objects_OnNewPrim); + client.Objects.ObjectUpdate += Objects_OnNewPrim; client.Objects.AddPrim(client.Network.CurrentSim, primData, UUID.Zero, rezpos, new Vector3(size), Quaternion.Identity); if (!primDone.WaitOne(10000, false)) throw new Exception("Rez failed, timed out while creating the prim."); @@ -501,7 +492,7 @@ private void button7_Click(object sender, EventArgs e) { distance = 0; } - if (IncludePrim(prim) && (prim.Position != Vector3.Zero) && (distance < (int)this.numRadius.Value)) + if (IncludePrim(prim) && (prim.Position != Vector3.Zero) && (distance < (int)numRadius.Value)) { Prims.Add(prim); if (prim.Properties == null) @@ -534,7 +525,7 @@ private void btn_Save_Click(object sender, EventArgs e) else instance.MainForm.TabConsole.DisplayNotificationInChat(pluginName + ": Failed to save object", ChatBufferTextStyle.Error); - instance.MainForm.TabConsole.DisplayNotificationInChat(pluginName + ":" + ex.ToString(), ChatBufferTextStyle.Error); + instance.MainForm.TabConsole.DisplayNotificationInChat(pluginName + ":" + ex, ChatBufferTextStyle.Error); } } diff --git a/plugins/Radegast.Plugin.Speech/RadSpeech/AreaControl.cs b/plugins/Radegast.Plugin.Speech/RadSpeech/AreaControl.cs index d28b6a0f6..57a7cf1f4 100644 --- a/plugins/Radegast.Plugin.Speech/RadSpeech/AreaControl.cs +++ b/plugins/Radegast.Plugin.Speech/RadSpeech/AreaControl.cs @@ -1,7 +1,23 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using OpenMetaverse; namespace RadegastSpeech @@ -9,8 +25,8 @@ namespace RadegastSpeech internal abstract class AreaControl { protected PluginControl control; - protected GridClient Client { get { return control.instance.Client; } } - protected Talk.Control Talker { get { return control.talker; } } + protected GridClient Client => control.instance.Client; + protected Talk.Control Talker => control.talker; internal AreaControl(PluginControl pc) { diff --git a/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/BlueMenu.cs b/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/BlueMenu.cs index 0478066aa..b751d15c1 100644 --- a/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/BlueMenu.cs +++ b/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/BlueMenu.cs @@ -1,7 +1,24 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + +using System; using Radegast; using System.Windows.Forms; @@ -20,9 +37,9 @@ internal BlueMenu(PluginControl pc, NotificationEventArgs arg) : base(pc) // Watch for being closed by keyboard before we get to talk about it. note.OnNotificationClicked += - new Notification.NotificationClickedCallback(note_OnNotificationClicked); + note_OnNotificationClicked; note.OnNotificationClosed += - new Notification.NotificationCallback(note_OnNotificationClosed); + note_OnNotificationClosed; } internal override void Start() @@ -66,16 +83,16 @@ internal override void Start() void note_OnNotificationClosed(object sender, NotificationEventArgs e) { note.OnNotificationClosed -= - new Notification.NotificationCallback(note_OnNotificationClosed); + note_OnNotificationClosed; note.OnNotificationClicked -= - new Notification.NotificationClickedCallback(note_OnNotificationClicked); + note_OnNotificationClicked; FinishInterruption(); } void note_OnNotificationClicked(object sender, EventArgs e, NotificationEventArgs notice) { Button b = sender as Button; - Talker.SayMore( b.Text, RadegastSpeech.Talk.BeepType.Good); + Talker.SayMore( b.Text, Talk.BeepType.Good); } void ReadOptions() diff --git a/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/Chat.cs b/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/Chat.cs index c92560d90..3db94c3d3 100644 --- a/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/Chat.cs +++ b/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/Chat.cs @@ -1,9 +1,24 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.RegularExpressions; -using Radegast; +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + +using System; using OpenMetaverse; namespace RadegastSpeech.Conversation @@ -24,17 +39,17 @@ internal Chat(PluginControl pc) : base(pc) { // We want to process incoming chat control.instance.Client.Self.ChatFromSimulator += - new EventHandler(OnChat); + OnChat; control.instance.Client.Self.AlertMessage += - new EventHandler(OnAlertMessage); + OnAlertMessage; Radegast.RadegastTab chatTab = control.instance.TabConsole.Tabs["chat"]; Radegast.ChatConsole chatscreen = (Radegast.ChatConsole)chatTab.Control; nearby = chatscreen.lvwObjects; - nearby.SelectedIndexChanged += new EventHandler(nearby_SelectedIndexChanged); + nearby.SelectedIndexChanged += nearby_SelectedIndexChanged; - nearby.GotFocus += new EventHandler(nearby_GotFocus); - chatscreen.ChatInputText.GotFocus += new EventHandler(cbxInput_GotFocus); + nearby.GotFocus += nearby_GotFocus; + chatscreen.ChatInputText.GotFocus += cbxInput_GotFocus; Title = "chat"; @@ -48,9 +63,9 @@ internal Chat(PluginControl pc) : base(pc) public void Dispose() { control.instance.Client.Self.ChatFromSimulator -= - new EventHandler(OnChat); + OnChat; control.instance.Client.Self.AlertMessage -= - new EventHandler(OnAlertMessage); + OnAlertMessage; if (control.instance.TabConsole != null && control.instance.TabConsole.TabExists("chat")) { @@ -58,10 +73,10 @@ public void Dispose() Radegast.ChatConsole chatscreen = (Radegast.ChatConsole)chatTab.Control; nearby = chatscreen.lvwObjects; - nearby.SelectedIndexChanged -= new EventHandler(nearby_SelectedIndexChanged); + nearby.SelectedIndexChanged -= nearby_SelectedIndexChanged; - nearby.GotFocus -= new EventHandler(nearby_GotFocus); - chatscreen.ChatInputText.GotFocus -= new EventHandler(cbxInput_GotFocus); + nearby.GotFocus -= nearby_GotFocus; + chatscreen.ChatInputText.GotFocus -= cbxInput_GotFocus; } nearby = null; diff --git a/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/Closet.cs b/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/Closet.cs index e132d5d22..5b29d9a40 100644 --- a/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/Closet.cs +++ b/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/Closet.cs @@ -1,9 +1,24 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using OpenMetaverse; -using OpenMetaverse.Assets; using Radegast; using System.Windows.Forms; @@ -44,9 +59,9 @@ internal override void Start() invTab = (InventoryConsole)control.instance.TabConsole.Tabs[INVNAME].Control; tree = invTab.invTree; - tree.AfterSelect += new TreeViewEventHandler(OnItemChange); - tree.AfterExpand += new TreeViewEventHandler(tree_AfterExpand); - tree.AfterCollapse += new TreeViewEventHandler(tree_AfterCollapse); + tree.AfterSelect += OnItemChange; + tree.AfterExpand += tree_AfterExpand; + tree.AfterCollapse += tree_AfterCollapse; Talker.SayMore("Inventory"); SayWhere(); @@ -58,9 +73,9 @@ internal override void Stop() Listener.DeactivateGrammar(INVNAME); if (tree == null) return; - tree.AfterSelect -= new TreeViewEventHandler(OnItemChange); - tree.AfterExpand -= new TreeViewEventHandler(tree_AfterExpand); - tree.AfterCollapse -= new TreeViewEventHandler(tree_AfterCollapse); + tree.AfterSelect -= OnItemChange; + tree.AfterExpand -= tree_AfterExpand; + tree.AfterCollapse -= tree_AfterCollapse; } void tree_AfterCollapse(object sender, TreeViewEventArgs e) @@ -83,17 +98,17 @@ internal override bool Hear(string cmd) { if (base.Hear(cmd)) return true; - if (selected is InventoryNotecard && cmd == "read it") + if (selected is InventoryNotecard notecard && cmd == "read it") { control.converse.AddInterruption( - new InvNotecard(control, selected as InventoryNotecard)); + new InvNotecard(control, notecard)); return true; } - if (selected is InventoryLandmark && cmd == "go there") + if (selected is InventoryLandmark landmark && cmd == "go there") { control.converse.AddInterruption( - new InvLandmark( control, selected as InventoryLandmark)); + new InvLandmark( control, landmark)); return true; } @@ -131,7 +146,6 @@ void ListNode() if (!(selected is InventoryFolder)) { Talker.SayMore("Going farther is not yet implemented."); - return; } } } @@ -146,8 +160,8 @@ string DescriptiveName(InventoryBase item) if (item is InventoryNotecard) return name + ", a notecard"; - if (item is InventoryWearable) - return name + ", a " + WearableType(item as InventoryWearable); + if (item is InventoryWearable wearable) + return name + ", a " + WearableType(wearable); if (item is InventoryLandmark) return name + ", a landmark"; @@ -194,6 +208,7 @@ string WearableType(InventoryWearable item) case OpenMetaverse.WearableType.Gloves: return "gloves"; case OpenMetaverse.WearableType.Hair: return "hair"; case OpenMetaverse.WearableType.Shape: return "body shape"; + //case OpenMetaverse.WearableType.Universal: default: return "clothes"; } } diff --git a/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/ConferenceIMSession.cs b/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/ConferenceIMSession.cs index 6c40050f6..fbcb3e9e4 100644 --- a/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/ConferenceIMSession.cs +++ b/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/ConferenceIMSession.cs @@ -1,7 +1,23 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using OpenMetaverse; namespace RadegastSpeech.Conversation diff --git a/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/Control.cs b/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/Control.cs index ad58a8c8a..b5efdf76a 100644 --- a/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/Control.cs +++ b/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/Control.cs @@ -1,18 +1,29 @@ -using System; +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + +using System; using System.Collections.Generic; using System.Linq; -using System.Text; using OpenMetaverse; using Radegast; -using System.Text.RegularExpressions; -using System.Net; using System.Windows.Forms; -#if (COGBOT_LIBOMV || USE_STHREADS) -using ThreadPoolUtil; -using Thread = ThreadPoolUtil.Thread; -using ThreadPool = ThreadPoolUtil.ThreadPool; -using Monitor = ThreadPoolUtil.Monitor; -#endif using System.Threading; namespace RadegastSpeech.Conversation @@ -32,11 +43,11 @@ internal class Control : AreaControl private LinkedList interruptions; // The permanent conversations. - private Conversation.Chat chat; - private Conversation.Closet inventory; - private Conversation.Friends friends; - private Conversation.Voice voice; - private Conversation.Surroundings surroundings; + private Chat chat; + private Closet inventory; + private Friends friends; + private Voice voice; + private Surroundings surroundings; private Mode currentMode; private Mode interrupted; internal string LoginName; @@ -69,47 +80,47 @@ internal override void Start() // Automatically handle notifications (blue dialogs) Notification.OnNotificationDisplayed += - new Notification.NotificationCallback(OnNotificationDisplayed); + OnNotificationDisplayed; // Notification.OnNotificationClosed += // new Notification.NotificationCallback(OnNotificationClosed); // Announce connect and disconnect. control.instance.Netcom.ClientConnected += - new EventHandler(Network_ClientConnected); + Network_ClientConnected; control.instance.Netcom.ClientDisconnected += - new EventHandler(Network_Disconnected); + Network_Disconnected; control.instance.Netcom.ClientLoginStatus += - new EventHandler(netcom_ClientLoginStatus); + netcom_ClientLoginStatus; // Notice arrival in a new sim control.instance.Client.Network.SimChanged += - new EventHandler(Network_SimChanged); + Network_SimChanged; control.instance.Netcom.ClientLoggingIn += - new EventHandler(Netcom_ClientLoggingIn); + Netcom_ClientLoggingIn; // Watch the coming and going of main window tabs. control.instance.TabConsole.OnTabAdded += - new TabsConsole.TabCallback(TabConsole_OnTabAdded); + TabConsole_OnTabAdded; control.instance.TabConsole.OnTabRemoved += - new TabsConsole.TabCallback(TabConsole_OnTabRemoved); + TabConsole_OnTabRemoved; // Notice when the active tab changes on the graphics user interface. control.instance.TabConsole.OnTabSelected += - new TabsConsole.TabCallback(OnTabChange); + OnTabChange; // Handle Instant Messages too control.instance.Client.Self.IM += - new EventHandler(OnInstantMessage); + OnInstantMessage; // Outgoing IMs - control.instance.Netcom.InstantMessageSent += new EventHandler(Netcom_InstantMessageSent); + control.instance.Netcom.InstantMessageSent += Netcom_InstantMessageSent; // Watch for global keys - control.instance.MainForm.KeyUp += new KeyEventHandler(MainForm_KeyUp); + control.instance.MainForm.KeyUp += MainForm_KeyUp; // System messages in chat window - control.instance.TabConsole.OnChatNotification += new TabsConsole.ChatNotificationCallback(TabConsole_OnChatNotification); + control.instance.TabConsole.OnChatNotification += TabConsole_OnChatNotification; control.listener.ActivateGrammar(CONVGRAMMAR); @@ -142,7 +153,7 @@ void MainForm_KeyUp(object sender, KeyEventArgs e) } - void Netcom_ClientLoggingIn(object sender, Radegast.Netcom.OverrideEventArgs e) + void Netcom_ClientLoggingIn(object sender, Radegast.OverrideEventArgs e) { Talker.SayMore("Logging in. Please wait."); } @@ -340,42 +351,42 @@ internal override void Shutdown() // Automatically handle notifications (blue dialogs) Notification.OnNotificationDisplayed -= - new Notification.NotificationCallback(OnNotificationDisplayed); + OnNotificationDisplayed; // Announce connect and disconnect. control.instance.Netcom.ClientConnected -= - new EventHandler(Network_ClientConnected); + Network_ClientConnected; control.instance.Netcom.ClientDisconnected -= - new EventHandler(Network_Disconnected); + Network_Disconnected; control.instance.Netcom.ClientLoginStatus -= - new EventHandler(netcom_ClientLoginStatus); + netcom_ClientLoginStatus; // Notice arrival in a new sim control.instance.Client.Network.SimChanged -= - new EventHandler(Network_SimChanged); + Network_SimChanged; control.instance.Netcom.ClientLoggingIn -= - new EventHandler(Netcom_ClientLoggingIn); + Netcom_ClientLoggingIn; // Watch the coming and going of main window tabs. control.instance.TabConsole.OnTabAdded -= - new TabsConsole.TabCallback(TabConsole_OnTabAdded); + TabConsole_OnTabAdded; control.instance.TabConsole.OnTabRemoved -= - new TabsConsole.TabCallback(TabConsole_OnTabRemoved); + TabConsole_OnTabRemoved; // Notice when the active tab changes on the graphics user interface. control.instance.TabConsole.OnTabSelected -= - new TabsConsole.TabCallback(OnTabChange); + OnTabChange; // Handle Instant Messages too control.instance.Client.Self.IM -= - new EventHandler(OnInstantMessage); + OnInstantMessage; // Outgoing IMs - control.instance.Netcom.InstantMessageSent -= new EventHandler(Netcom_InstantMessageSent); + control.instance.Netcom.InstantMessageSent -= Netcom_InstantMessageSent; // System notifications in chat - control.instance.TabConsole.OnChatNotification -= new TabsConsole.ChatNotificationCallback(TabConsole_OnChatNotification); + control.instance.TabConsole.OnChatNotification -= TabConsole_OnChatNotification; control.listener.DeactivateGrammar(CONVGRAMMAR); @@ -551,8 +562,7 @@ internal void Hear(string message) if (Command(message)) return; // Let the current conversation handle it. - if (currentMode != null) - currentMode.Hear(message); + currentMode?.Hear(message); } internal void SelectConversation(Mode c) @@ -566,8 +576,7 @@ internal void SelectConversation(Mode c) if (currentMode == c) return; // Let the old conversation deactivate any event hooks, grammars, etc. - if (currentMode != null) - currentMode.Stop(); + currentMode?.Stop(); currentMode = c; currentMode.Start(); @@ -657,8 +666,7 @@ internal void AddInterruption(Mode m) internal void ChangeFocus(Mode toThis) { currentMode = toThis; - if (currentMode != null) - currentMode.Start(); + currentMode?.Start(); } @@ -669,7 +677,7 @@ internal void ChangeFocus(Mode toThis) /// void OnNotificationDisplayed(object sender, NotificationEventArgs e) { - AddInterruption(new Conversation.BlueMenu(control, e)); + AddInterruption(new BlueMenu(control, e)); } /// @@ -677,12 +685,11 @@ void OnNotificationDisplayed(object sender, NotificationEventArgs e) /// /// /// - void Netcom_InstantMessageSent(object sender, Radegast.Netcom.InstantMessageSentEventArgs e) + void Netcom_InstantMessageSent(object sender, Radegast.InstantMessageSentEventArgs e) { // Message to an individual - Conversation.IMSession sess = (IMSession)control.converse.GetConversation(control.instance.Names.Get(e.TargetID, true)); - if (sess != null) - sess.OnMessage(Client.Self.AgentID, Client.Self.Name, e.Message); + IMSession sess = (IMSession)control.converse.GetConversation(control.instance.Names.Get(e.TargetID, true)); + sess?.OnMessage(Client.Self.AgentID, Client.Self.Name, e.Message); } @@ -693,10 +700,10 @@ void Netcom_InstantMessageSent(object sender, Radegast.Netcom.InstantMessageSent /// void OnInstantMessage(object sender, InstantMessageEventArgs e) { - WorkPool.QueueUserWorkItem(sync => + ThreadPool.QueueUserWorkItem(sync => { Thread.Sleep(100); // Give tab a chance to show up - Conversation.IMSession sess = null; + IMSession sess = null; string groupName; // All sorts of things come in as a instant messages. For actual messages @@ -751,8 +758,7 @@ void OnInstantMessage(object sender, InstantMessageEventArgs e) sess = (IMSession)control.converse.GetConversation(Utils.BytesToString(e.IM.BinaryBucket)); } - if (sess != null) - sess.OnMessage(e.IM.FromAgentID, e.IM.FromAgentName, e.IM.Message); + sess?.OnMessage(e.IM.FromAgentID, e.IM.FromAgentName, e.IM.Message); break; case InstantMessageDialog.FriendshipOffered: diff --git a/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/Friends.cs b/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/Friends.cs index f6ba1996c..c1cefe9b7 100644 --- a/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/Friends.cs +++ b/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/Friends.cs @@ -1,37 +1,25 @@ -// -// Radegast Metaverse Client Speech Interface -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id: Friends.cs 203 2009-09-16 17:26:02Z mojitotech@gmail.com $ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections.Generic; -using System.Linq; -using System.Text; using Radegast; using OpenMetaverse; @@ -53,9 +41,9 @@ internal Friends(PluginControl pc) friends = frTab.listFriends; control.instance.Client.Friends.FriendOffline += - new EventHandler(Friends_OnFriendOffline); + Friends_OnFriendOffline; control.instance.Client.Friends.FriendOnline += - new EventHandler(Friends_OnFriendOnline); + Friends_OnFriendOnline; } /// @@ -64,7 +52,7 @@ internal Friends(PluginControl pc) internal override void Start() { base.Start(); - friends.SelectedIndexChanged += new EventHandler(friends_ItemSelectionChanged); + friends.SelectedIndexChanged += friends_ItemSelectionChanged; Talker.SayMore("Friends"); } @@ -73,7 +61,7 @@ internal override void Start() /// internal override void Stop() { - friends.SelectedIndexChanged -= new EventHandler(friends_ItemSelectionChanged); + friends.SelectedIndexChanged -= friends_ItemSelectionChanged; base.Stop(); } #endregion diff --git a/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/Friendship.cs b/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/Friendship.cs index 43d6c63c5..b377e099d 100644 --- a/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/Friendship.cs +++ b/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/Friendship.cs @@ -1,7 +1,23 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using OpenMetaverse; namespace RadegastSpeech.Conversation diff --git a/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/GroupIMSession.cs b/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/GroupIMSession.cs index 6bade0c0c..813fec596 100644 --- a/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/GroupIMSession.cs +++ b/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/GroupIMSession.cs @@ -1,7 +1,23 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using OpenMetaverse; namespace RadegastSpeech.Conversation diff --git a/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/IMSession.cs b/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/IMSession.cs index 4cc39a986..ba485423b 100644 --- a/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/IMSession.cs +++ b/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/IMSession.cs @@ -1,9 +1,25 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + +using System; using OpenMetaverse; -using Radegast; namespace RadegastSpeech.Conversation { diff --git a/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/InvLandmark.cs b/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/InvLandmark.cs index b4484a5b4..b045db6f9 100644 --- a/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/InvLandmark.cs +++ b/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/InvLandmark.cs @@ -1,10 +1,24 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using OpenMetaverse.Assets; +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using OpenMetaverse; -using Radegast; namespace RadegastSpeech.Conversation { diff --git a/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/InvNotecard.cs b/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/InvNotecard.cs index 58417fe11..9c541d363 100644 --- a/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/InvNotecard.cs +++ b/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/InvNotecard.cs @@ -1,10 +1,26 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using OpenMetaverse.Assets; using OpenMetaverse; -using Radegast; + namespace RadegastSpeech.Conversation { class InvNotecard : Mode @@ -23,17 +39,53 @@ internal InvNotecard(PluginControl pc, InventoryNotecard a) internal override void Start() { base.Start(); + var transferID = UUID.Random(); Talker.SayMore("Reading " + asset.Name + ". Just a moment."); Client.Assets.RequestInventoryAsset( asset, true, - Assets_OnNotecardReceived); + transferID, + (AssetDownload transfer, Asset asset) => + { + if (transfer.Success && transfer.ID == transferID) + { + AssetNotecard n = (AssetNotecard)asset; + n.Decode(); + AssetNotecard recievedNotecard = n; + + text = string.Empty; + + for (int i = 0; i < n.BodyText.Length; i++) + { + char c = n.BodyText[i]; + + // Special marker for embedded things. + if ((int)c == 0xdbc0) + { + int index = (int)n.BodyText[++i] - 0xdc00; + InventoryItem e = n.EmbeddedItems[index]; + text += " (embedded) "; + } + else + { + text += c; + } + } + + // TODO put in controls to stop, back up etc + StopPosition = 0; + NextSection(); + control.instance.MainForm.KeyDown += + MainForm_KeyPress; + } + else + { + Talker.Say("Failed to download the notecard.", Talk.BeepType.Bad); + } + } + ); } - internal override void Stop() - { - base.Stop(); - } internal override bool Hear(string cmd) { switch (cmd) @@ -51,53 +103,13 @@ internal override bool Hear(string cmd) return true; case "stop": control.instance.MainForm.KeyDown -= - new System.Windows.Forms.KeyEventHandler(MainForm_KeyPress); + MainForm_KeyPress; FinishInterruption(); return true; } return false; } - void Assets_OnNotecardReceived(AssetDownload transfer, Asset asset) - { - - if (transfer.Success) - { - AssetNotecard n = (AssetNotecard)asset; - n.Decode(); - AssetNotecard recievedNotecard = n; - - text = string.Empty; - - for (int i = 0; i < n.BodyText.Length; i++) - { - char c = n.BodyText[i]; - - // Special marker for embedded things. - if ((int)c == 0xdbc0) - { - int index = (int)n.BodyText[++i] - 0xdc00; - InventoryItem e = n.EmbeddedItems[index]; - text += " (embedded) "; - } - else - { - text += c; - } - } - - // TODO put in controls to stop, back up etc - StopPosition = 0; - NextSection(); - control.instance.MainForm.KeyDown += - new System.Windows.Forms.KeyEventHandler(MainForm_KeyPress); - } - else - { - Talker.Say("Failed to download the notecard.", Talk.BeepType.Bad); - } - } - void MainForm_KeyPress(object sender, System.Windows.Forms.KeyEventArgs e) { if (e.KeyCode == System.Windows.Forms.Keys.Space || @@ -119,7 +131,6 @@ void MainForm_KeyPress(object sender, System.Windows.Forms.KeyEventArgs e) { ReadSection(); e.Handled = true; - return; } } diff --git a/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/Max.cs b/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/Max.cs index cb4f0112c..832a12be3 100644 --- a/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/Max.cs +++ b/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/Max.cs @@ -1,7 +1,23 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using OpenMetaverse; namespace RadegastSpeech.Conversation diff --git a/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/Mode.cs b/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/Mode.cs index 35c8cea40..47e34164b 100644 --- a/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/Mode.cs +++ b/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/Mode.cs @@ -1,10 +1,26 @@ -using System; +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Text.RegularExpressions; using OpenMetaverse; -using Radegast; namespace RadegastSpeech.Conversation { @@ -16,11 +32,11 @@ internal abstract class Mode protected string Announcement; protected List altNames; protected bool isMuted = false; - protected GridClient Client { get { return control.instance.Client; }} - protected Talk.Control Talker { get { return control.talker; } } - protected Conversation.Control Converse { get { return control.converse; } } - protected Radegast.TabsConsole TabConsole { get { return control.instance.TabConsole; } } - protected Listen.Control Listener { get { return control.listener; } } + protected GridClient Client => control.instance.Client; + protected Talk.Control Talker => control.talker; + protected Control Converse => control.converse; + protected Radegast.TabsConsole TabConsole => control.instance.TabConsole; + protected Listen.Control Listener => control.listener; private static Regex BadNameChars; private static TalkingContextMenu menu; diff --git a/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/Movement.cs b/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/Movement.cs index c5b93b335..27a8f6491 100644 --- a/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/Movement.cs +++ b/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/Movement.cs @@ -1,7 +1,22 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ namespace RadegastSpeech.Conversation { @@ -11,11 +26,6 @@ internal Movement(PluginControl pc) : base(pc) { } - internal override void Start() - { - base.Start(); - } - internal override bool Hear(string text) { return false; diff --git a/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/SingleIMSession.cs b/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/SingleIMSession.cs index 91761711d..95ce1cce8 100644 --- a/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/SingleIMSession.cs +++ b/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/SingleIMSession.cs @@ -1,7 +1,23 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using OpenMetaverse; namespace RadegastSpeech.Conversation diff --git a/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/Surroundings.cs b/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/Surroundings.cs index 576bf9b05..145521e0e 100644 --- a/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/Surroundings.cs +++ b/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/Surroundings.cs @@ -1,38 +1,24 @@ -// -// Radegast Metaverse Client Speech Interface -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id: Surroundings.cs 203 2009-10-06 17:26:02Z mojitotech@gmail.com $ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows.Forms; using Radegast; using OpenMetaverse; @@ -40,7 +26,7 @@ namespace RadegastSpeech.Conversation { class Surroundings : Mode { - private Radegast.ObjectsConsole obTab; + private ObjectsConsole obTab; public bool Announce { get; set; } private Primitive currentPrim = new Primitive(); diff --git a/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/TalkingContextMenu.cs b/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/TalkingContextMenu.cs index 01af97762..bc285ba80 100644 --- a/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/TalkingContextMenu.cs +++ b/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/TalkingContextMenu.cs @@ -1,8 +1,26 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + +using System; using System.Windows.Forms; +using OpenMetaverse; using Radegast; namespace RadegastSpeech.Conversation @@ -66,7 +84,7 @@ internal bool Hear(string txt) return true; } } - return false; + return false; } internal void SetObjectName(string name) @@ -75,7 +93,7 @@ internal void SetObjectName(string name) private ToolStripMenuItem MakeSpeechAction() { - return new ToolStripMenuItem("Speech...", null, new EventHandler(OnSpeechMenu)); + return new ToolStripMenuItem("Speech...", null, OnSpeechMenu); } /// @@ -92,34 +110,28 @@ private void OnContentMenuOpened(object sender, RadegastContextMenuStrip.Context id = OpenMetaverse.UUID.Zero; // Figure out what this menu applies to. - if (menuStrip.Selection is string) + if (menuStrip.Selection is string selection) { - menuFor = (string)menuStrip.Selection; + menuFor = selection; } - else if (menuStrip.Selection is ListViewItem) + else if (menuStrip.Selection is ListViewItem lv) { - ListViewItem lv = menuStrip.Selection as ListViewItem; menuFor = lv.Text; } - else if (menuStrip.Selection is OpenMetaverse.InventoryItem) + else if (menuStrip.Selection is InventoryItem item) { // Something in Inventory. - menuFor = ((OpenMetaverse.InventoryItem)(menuStrip.Selection)).Name; + menuFor = ((OpenMetaverse.InventoryItem)item).Name; } - else if (menuStrip.Selection is OpenMetaverse.FriendInfo) + else if (menuStrip.Selection is FriendInfo f) { // A Friend. - OpenMetaverse.FriendInfo f = menuStrip.Selection as OpenMetaverse.FriendInfo; menuFor = f.Name; } - else if (menuStrip.Selection is OpenMetaverse.Primitive) + else if (menuStrip.Selection is Primitive p) { // Something in the Objects list. - OpenMetaverse.Primitive p = menuStrip.Selection as OpenMetaverse.Primitive; - if (p.Properties != null) - menuFor = p.Properties.Name; - else - menuFor = "Loading object"; + menuFor = p.Properties != null ? p.Properties.Name : "Loading object"; } // Remove parenthesized distance, etc @@ -140,8 +152,8 @@ private void OnContentMenuOpened(object sender, RadegastContextMenuStrip.Context /// private void OnSpeechMenu( object sender, EventArgs e ) { - System.Windows.Forms.Form va = - new RadegastSpeech.GUI.VoiceAssignment(control, menuFor, id); + Form va = + new GUI.VoiceAssignment(control, menuFor, id); va.Show(); } diff --git a/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/Voice.cs b/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/Voice.cs index 445c98c94..b65cb5cfe 100644 --- a/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/Voice.cs +++ b/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/Voice.cs @@ -1,11 +1,26 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.RegularExpressions; +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + +using System; using Radegast; -using OpenMetaverse; -using OpenMetaverse.Voice; +using LibreMetaverse.Voice; namespace RadegastSpeech.Conversation { @@ -27,9 +42,9 @@ internal Voice(PluginControl pc) internal override void Start() { - vTab.gateway.OnSessionCreate +=new EventHandler(OnSessionCreate); - vTab.gateway.OnSessionRemove += new EventHandler(gateway_OnSessionRemove); - vTab.chkVoiceEnable.CheckStateChanged += new EventHandler(chkVoiceEnable_CheckStateChanged); + vTab.gateway.OnSessionCreate +=OnSessionCreate; + vTab.gateway.OnSessionRemove += gateway_OnSessionRemove; + vTab.chkVoiceEnable.CheckStateChanged += chkVoiceEnable_CheckStateChanged; SayEnabled(); } @@ -37,10 +52,10 @@ internal override void Stop() { if (vTab.gateway != null) { - vTab.gateway.OnSessionCreate -= new EventHandler(OnSessionCreate); - vTab.gateway.OnSessionRemove -= new EventHandler(gateway_OnSessionRemove); + vTab.gateway.OnSessionCreate -= OnSessionCreate; + vTab.gateway.OnSessionRemove -= gateway_OnSessionRemove; } - vTab.chkVoiceEnable.CheckStateChanged -= new EventHandler(chkVoiceEnable_CheckStateChanged); + vTab.chkVoiceEnable.CheckStateChanged -= chkVoiceEnable_CheckStateChanged; } #endregion @@ -63,7 +78,7 @@ void session_OnParticipantAdded(object sender, EventArgs e) { VoiceParticipant p = sender as VoiceParticipant; - string pName = (p.Name == null) ? control.instance.Names.Get(p.ID) : p.Name; + string pName = p.Name ?? control.instance.Names.Get(p.ID); control.talker.SayMore(pName + " is in voice range."); } diff --git a/plugins/Radegast.Plugin.Speech/RadSpeech/Environment/Control.cs b/plugins/Radegast.Plugin.Speech/RadSpeech/Environment/Control.cs index 10be311f7..75b05e607 100644 --- a/plugins/Radegast.Plugin.Speech/RadSpeech/Environment/Control.cs +++ b/plugins/Radegast.Plugin.Speech/RadSpeech/Environment/Control.cs @@ -1,7 +1,22 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ namespace RadegastSpeech.Environment { diff --git a/plugins/Radegast.Plugin.Speech/RadSpeech/Environment/People.cs b/plugins/Radegast.Plugin.Speech/RadSpeech/Environment/People.cs index 6ae0d3226..65f20329e 100644 --- a/plugins/Radegast.Plugin.Speech/RadSpeech/Environment/People.cs +++ b/plugins/Radegast.Plugin.Speech/RadSpeech/Environment/People.cs @@ -1,8 +1,25 @@ -using System; +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + +using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using Radegast; using OpenMetaverse; namespace RadegastSpeech.Environment @@ -13,8 +30,8 @@ namespace RadegastSpeech.Environment class People { private PluginControl control; - private Talk.Control Talker { get { return control.talker; } } - private GridClient Client { get { return control.instance.Client; } } + private Talk.Control Talker => control.talker; + private GridClient Client => control.instance.Client; private Dictionary information; private readonly string[] genders; private Random random; @@ -39,13 +56,13 @@ internal void Start() { // We need appearance info about people Client.Avatars.AvatarAppearance += - new EventHandler(Avatars_OnAvatarAppearance); + Avatars_OnAvatarAppearance; } internal void Shutdown() { Client.Avatars.AvatarAppearance -= - new EventHandler(Avatars_OnAvatarAppearance); + Avatars_OnAvatarAppearance; information.Clear(); } @@ -66,9 +83,11 @@ void Avatars_OnAvatarAppearance( // Create an entry in the avatar information dictionary. if (visualParams.Count > 32) { - AvatarInfo info = new AvatarInfo(); - info.gender = visualParams[31]; - info.height = visualParams[32]; + AvatarInfo info = new AvatarInfo + { + gender = visualParams[31], + height = visualParams[32] + }; // We are only getting 218 parameters. // info.leglen = visualParams[691]; information[e.AvatarID] = info; diff --git a/plugins/Radegast.Plugin.Speech/RadSpeech/GUI/AvatarSpeechAction.cs b/plugins/Radegast.Plugin.Speech/RadSpeech/GUI/AvatarSpeechAction.cs index 93dc223ff..c5d695da3 100644 --- a/plugins/Radegast.Plugin.Speech/RadSpeech/GUI/AvatarSpeechAction.cs +++ b/plugins/Radegast.Plugin.Speech/RadSpeech/GUI/AvatarSpeechAction.cs @@ -1,33 +1,23 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id: -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Windows.Forms; using OpenMetaverse; @@ -64,29 +54,26 @@ public override void OnInvoke(object sender, EventArgs e, object target) // This action applies to avatars, which can come in // various forms. - if (target is FriendInfo) + if (target is FriendInfo f) { - FriendInfo f = target as FriendInfo; name = f.Name; id = f.UUID; } - else if (target is Avatar) + else if (target is Avatar a) { - Avatar a = target as Avatar; name = a.Name; id = a.ID; } - else if (target is ListViewItem) + else if (target is ListViewItem i) { - ListViewItem i = target as ListViewItem; id = (UUID)i.Tag; name = control.instance.Names.Get(id); } else return; - System.Windows.Forms.Form va = - new RadegastSpeech.GUI.VoiceAssignment(control, name, id ); + Form va = + new VoiceAssignment(control, name, id ); va.Show(); } diff --git a/plugins/Radegast.Plugin.Speech/RadSpeech/GUI/NotecardReadAction.cs b/plugins/Radegast.Plugin.Speech/RadSpeech/GUI/NotecardReadAction.cs index 36741eed4..da3d43fe0 100644 --- a/plugins/Radegast.Plugin.Speech/RadSpeech/GUI/NotecardReadAction.cs +++ b/plugins/Radegast.Plugin.Speech/RadSpeech/GUI/NotecardReadAction.cs @@ -1,35 +1,24 @@ -// -// Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id: -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; -using System.Windows.Forms; using OpenMetaverse; using Radegast; @@ -63,13 +52,13 @@ public override void OnInvoke(object sender, EventArgs e, object target) // This action applies to notecards, which can come in // various forms. - if (target is InventoryNotecard) + if (target is InventoryNotecard notecard) { - nc = target as InventoryNotecard; + nc = notecard; } else { - control.talker.SayMore("Can not read this notecard.", RadegastSpeech.Talk.BeepType.Bad); + control.talker.SayMore("Can not read this notecard.", Talk.BeepType.Bad); return; } diff --git a/plugins/Radegast.Plugin.Speech/RadSpeech/GUI/VoiceAssignment.cs b/plugins/Radegast.Plugin.Speech/RadSpeech/GUI/VoiceAssignment.cs index 4187f6596..6ec488525 100644 --- a/plugins/Radegast.Plugin.Speech/RadSpeech/GUI/VoiceAssignment.cs +++ b/plugins/Radegast.Plugin.Speech/RadSpeech/GUI/VoiceAssignment.cs @@ -1,11 +1,25 @@ -using System; +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + +using System; using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Text.RegularExpressions; using System.Windows.Forms; using RadegastSpeech.Talk; using OpenMetaverse; @@ -109,7 +123,7 @@ private void Demonstrate() } sample += "."; - this.BeginInvoke(new MethodInvoker(delegate() + BeginInvoke(new MethodInvoker(delegate() { control.talker.Say(null, sample, diff --git a/plugins/Radegast.Plugin.Speech/RadSpeech/IRadSpeech.cs b/plugins/Radegast.Plugin.Speech/RadSpeech/IRadSpeech.cs index 98e43e251..39b2fd0c1 100644 --- a/plugins/Radegast.Plugin.Speech/RadSpeech/IRadSpeech.cs +++ b/plugins/Radegast.Plugin.Speech/RadSpeech/IRadSpeech.cs @@ -1,7 +1,24 @@ -using System; +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System.Collections.Generic; -using System.Linq; -using System.Text; namespace RadegastSpeech { diff --git a/plugins/Radegast.Plugin.Speech/RadSpeech/Listen/Control.cs b/plugins/Radegast.Plugin.Speech/RadSpeech/Listen/Control.cs index 5ff122039..93be4bc64 100644 --- a/plugins/Radegast.Plugin.Speech/RadSpeech/Listen/Control.cs +++ b/plugins/Radegast.Plugin.Speech/RadSpeech/Listen/Control.cs @@ -1,9 +1,22 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using OpenMetaverse; -using Radegast; +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ namespace RadegastSpeech.Listen { @@ -18,14 +31,12 @@ internal Control(PluginControl pc) internal void CreateGrammar(string name, string[] options) { - if (recog == null) return; - recog.CreateGrammar(name, options); + recog?.CreateGrammar(name, options); } internal override void Start() { // If we have a recognizer, start it. - if (recog != null) - recog.Start(); + recog?.Start(); } internal override void Shutdown() { @@ -35,13 +46,11 @@ internal override void Shutdown() } internal void ActivateGrammar(string name) { - if (recog == null) return; - recog.ActivateGrammar(name); + recog?.ActivateGrammar(name); } internal void DeactivateGrammar(string name) { - if (recog == null) return; - recog.DeactivateGrammar(name); + recog?.DeactivateGrammar(name); } } diff --git a/plugins/Radegast.Plugin.Speech/RadSpeech/Listen/Recognizer.cs b/plugins/Radegast.Plugin.Speech/RadSpeech/Listen/Recognizer.cs index f7dfc447d..6b07adf11 100644 --- a/plugins/Radegast.Plugin.Speech/RadSpeech/Listen/Recognizer.cs +++ b/plugins/Radegast.Plugin.Speech/RadSpeech/Listen/Recognizer.cs @@ -1,7 +1,22 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ namespace RadegastSpeech.Listen { @@ -18,12 +33,12 @@ internal void Start() { if (control.osLayer == null) return; control.osLayer.RecogStart(); - control.osLayer.OnRecognition += new SpeechEventHandler(OnRecognition); + control.osLayer.OnRecognition += OnRecognition; } internal void Stop() { if (control.osLayer == null) return; - control.osLayer.OnRecognition -= new SpeechEventHandler(OnRecognition); + control.osLayer.OnRecognition -= OnRecognition; control.osLayer.RecogStop(); } protected void OnRecognition(string message) @@ -33,18 +48,15 @@ protected void OnRecognition(string message) internal void CreateGrammar(string name, string[] options) { - if (control.osLayer == null) return; - control.osLayer.CreateGrammar(name, options); + control.osLayer?.CreateGrammar(name, options); } internal void ActivateGrammar(string name) { - if (control.osLayer == null) return; - control.osLayer.ActivateGrammar(name); + control.osLayer?.ActivateGrammar(name); } internal void DeactivateGrammar(string name) { - if (control.osLayer == null) return; - control.osLayer.DeactivateGrammar(name); + control.osLayer?.DeactivateGrammar(name); } } } diff --git a/plugins/Radegast.Plugin.Speech/RadSpeech/PluginControl.cs b/plugins/Radegast.Plugin.Speech/RadSpeech/PluginControl.cs index 98c02a5bd..d9b9bb924 100644 --- a/plugins/Radegast.Plugin.Speech/RadSpeech/PluginControl.cs +++ b/plugins/Radegast.Plugin.Speech/RadSpeech/PluginControl.cs @@ -1,37 +1,24 @@ -// -// Radegast Metaverse Client Speech Interface -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id: PluginControl.cs 203 2009-09-07 19:26:02Z mojitotech@gmail.com $ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using System.IO; using System.Reflection; using Radegast; @@ -41,7 +28,7 @@ namespace RadegastSpeech { - [Radegast.Plugin(Name = "Speech", Description = "Adds TTS and STT accesibility capabilities to Radegast", Version = "0.3")] + [Plugin(Name = "Speech", Description = "Adds TTS and STT accesibility capabilities to Radegast", Version = "0.3")] public class PluginControl : IRadegastPlugin { private const string VERSION = "0.3"; @@ -70,11 +57,13 @@ public void StartPlugin(RadegastInstance inst) if (config == null) { - config = new OSDMap(); - config["enabled"] = new OSDBoolean(false); - config["voices"] = new OSDMap(); - config["properties"] = new OSDMap(); - config["substitutions"] = new OSDMap(); + config = new OSDMap + { + ["enabled"] = new OSDBoolean(false), + ["voices"] = new OSDMap(), + ["properties"] = new OSDMap(), + ["substitutions"] = new OSDMap() + }; instance.GlobalSettings["plugin.speech"] = config; } @@ -293,7 +282,6 @@ void MainForm_KeyDown(object sender, KeyEventArgs e) } instance.TabConsole.DisplayNotificationInChat("Voice rate set to " + props["voice_speed"]); - return; } } @@ -337,8 +325,7 @@ private void Initialize() SpeechButton.Checked = false; config["enabled"] = OSD.FromBoolean(false); SaveSpeechSettings(); - System.Windows.Forms.MessageBox.Show("Speech failed initialization: " + e.Message); - return; + MessageBox.Show("Speech failed initialization: " + e.Message); } } @@ -383,10 +370,10 @@ private void StartControls() } catch (Exception e) { - System.Windows.Forms.MessageBox.Show("Speech can not start. See log."); + MessageBox.Show("Speech can not start. See log."); Logger.Log("Speech can not start.", Helpers.LogLevel.Error, e); - System.Console.WriteLine(e.StackTrace); + Console.WriteLine(e.StackTrace); MarkDisabled(); return; } @@ -447,7 +434,7 @@ private void LoadOSLayer() throw new Exception("No startup directory found " + dirName); // The filename depends on the platform. - System.Version version = System.Environment.OSVersion.Version; + Version version = System.Environment.OSVersion.Version; string loadfilename = null; switch (System.Environment.OSVersion.Platform) { @@ -486,7 +473,7 @@ private void LoadOSLayer() try { // This is the one. Instantiate it. - osLayer = (IRadSpeech)ci.Invoke(new object[0]); + osLayer = (IRadSpeech)ci.Invoke(Array.Empty()); return; } catch (Exception ex) diff --git a/plugins/Radegast.Plugin.Speech/RadSpeech/Properties/AssemblyInfo.cs b/plugins/Radegast.Plugin.Speech/RadSpeech/Properties/AssemblyInfo.cs deleted file mode 100644 index 086ed50ce..000000000 --- a/plugins/Radegast.Plugin.Speech/RadSpeech/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("RadegastSpeech")] -[assembly: AssemblyDescription("Speech plugin for Radegast")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("RadegastSpeech")] -[assembly: AssemblyCopyright("Mojito Sorbet 2009")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("0a0e6258-20a9-41a5-8371-a25bf32f6914")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.3.0.0")] -[assembly: AssemblyFileVersion("0.3.0.0")] diff --git a/plugins/Radegast.Plugin.Speech/RadSpeech/Radegast.Plugin.Speech.csproj b/plugins/Radegast.Plugin.Speech/RadSpeech/Radegast.Plugin.Speech.csproj new file mode 100644 index 000000000..cb4317b3a --- /dev/null +++ b/plugins/Radegast.Plugin.Speech/RadSpeech/Radegast.Plugin.Speech.csproj @@ -0,0 +1,124 @@ + + + net48 + true + false + AnyCPU;x64;x86 + + + full + ..\..\bin\$(Configuration)\ + TRACE;DEBUG + + + portable + ..\..\bin\$(Configuration)\ + TRACE + + + ..\..\bin\$(Configuration)\ + TRACE + true + portable + MinimumRecommendedRules.ruleset + + + ..\..\bin\$(Configuration)\ + TRACE + true + portable + MinimumRecommendedRules.ruleset + + + ..\..\bin\$(Configuration)\ + TRACE + true + portable + MinimumRecommendedRules.ruleset + + + ..\..\bin\$(Configuration)\ + + + ..\..\bin\$(Configuration)\ + + + ..\..\bin\$(Configuration)\ + + + ..\..\bin\$(Configuration)\ + + + ..\..\bin\$(Configuration)\ + + + ..\..\bin\$(Configuration)\ + + + + + + + + + + + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + VoiceAssignment.cs + Dependency + + + + VoiceAssignment.cs + DesignerType + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/plugins/Radegast.Plugin.Speech/RadSpeech/Sound/Control.cs b/plugins/Radegast.Plugin.Speech/RadSpeech/Sound/Control.cs index 31906e958..150566b4b 100644 --- a/plugins/Radegast.Plugin.Speech/RadSpeech/Sound/Control.cs +++ b/plugins/Radegast.Plugin.Speech/RadSpeech/Sound/Control.cs @@ -1,8 +1,22 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using OpenMetaverse; +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ namespace RadegastSpeech.Sound { diff --git a/plugins/Radegast.Plugin.Speech/RadSpeech/Sound/FmodSound.cs b/plugins/Radegast.Plugin.Speech/RadSpeech/Sound/FmodSound.cs index 8060c5503..3d93d78b1 100644 --- a/plugins/Radegast.Plugin.Speech/RadSpeech/Sound/FmodSound.cs +++ b/plugins/Radegast.Plugin.Speech/RadSpeech/Sound/FmodSound.cs @@ -1,43 +1,28 @@ -// -// Speech Input and Output for the Radegast Metaverse Client -// Copyright (c) 2009-2014, Radegast Development Team -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the application "Radegast", nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// $Id: FmodSound.cs $ -// +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ // Define the following symbol to use the shared Radegast FMOD instance. #define SHAREDFMOD using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using System.IO; -using OpenMetaverse; using System.Threading; using Radegast.Media; @@ -45,21 +30,20 @@ namespace RadegastSpeech.Sound { class FmodSound : Control { - Radegast.Media.Speech speechPlayer; + Speech speechPlayer; private AutoResetEvent playing; internal FmodSound(PluginControl pc) : base(pc) { playing = new AutoResetEvent(false); - speechPlayer = new Radegast.Media.Speech(); - speechPlayer.OnSpeechDone += new Speech.SpeechDoneCallback(SpeechDoneHandler); + speechPlayer = new Speech(); + speechPlayer.OnSpeechDone += SpeechDoneHandler; } internal override void Stop() { - if (speechPlayer == null) return; - speechPlayer.Stop(); + speechPlayer?.Stop(); } /// diff --git a/plugins/Radegast.Plugin.Speech/RadSpeech/Talk/Control.cs b/plugins/Radegast.Plugin.Speech/RadSpeech/Talk/Control.cs index 21e4ee0a1..940a84977 100644 --- a/plugins/Radegast.Plugin.Speech/RadSpeech/Talk/Control.cs +++ b/plugins/Radegast.Plugin.Speech/RadSpeech/Talk/Control.cs @@ -1,18 +1,29 @@ -using System; +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + +using System; using System.Collections.Generic; -using System.Linq; -using System.Text; using System.IO; using System.Threading; using OpenMetaverse; -using Radegast; - -#if (COGBOT_LIBOMV || USE_STHREADS) -using ThreadPoolUtil; -using Thread = ThreadPoolUtil.Thread; -using ThreadPool = ThreadPoolUtil.ThreadPool; -using Monitor = ThreadPoolUtil.Monitor; -#endif + namespace RadegastSpeech.Talk { @@ -91,9 +102,11 @@ internal override void Start() queue = new Queue(); // Start the background thread that does all the text-to-speech. - speakingThread = new Thread(new ThreadStart(SpeakLoop)); - speakingThread.IsBackground = true; - speakingThread.Name = "SpeakingThread"; + speakingThread = new Thread(SpeakLoop) + { + IsBackground = true, + Name = "SpeakingThread" + }; speakingThread.Start(); } } @@ -415,7 +428,7 @@ private void SpeakLoop() } catch (Exception e) { - System.Console.WriteLine("Synth shutdown " + e.Message); + Console.WriteLine("Synth shutdown " + e.Message); } } #endregion diff --git a/plugins/Radegast.Plugin.Speech/RadSpeech/Talk/Substitutions.cs b/plugins/Radegast.Plugin.Speech/RadSpeech/Talk/Substitutions.cs index 774adf2df..b33c4951c 100644 --- a/plugins/Radegast.Plugin.Speech/RadSpeech/Talk/Substitutions.cs +++ b/plugins/Radegast.Plugin.Speech/RadSpeech/Talk/Substitutions.cs @@ -1,7 +1,24 @@ -using System; +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Text.RegularExpressions; using OpenMetaverse.StructuredData; @@ -38,8 +55,7 @@ public Substitutions( PluginControl pc) Add(@"http(s)*://[a-z0-9\./=%&?+-]+", ", a URL,"); // Load custom substitutions - OSDMap subs = pc.config["substitutions"] as OSDMap; - if (subs != null) + if (pc.config["substitutions"] is OSDMap subs) { foreach (string key in subs.Keys) { diff --git a/plugins/Radegast.Plugin.Speech/RadSpeech/Talk/Synthesizer.cs b/plugins/Radegast.Plugin.Speech/RadSpeech/Talk/Synthesizer.cs index 896f8187e..e55f390a7 100644 --- a/plugins/Radegast.Plugin.Speech/RadSpeech/Talk/Synthesizer.cs +++ b/plugins/Radegast.Plugin.Speech/RadSpeech/Talk/Synthesizer.cs @@ -1,8 +1,24 @@ -using System; +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System.Collections.Generic; -using System.Linq; -using System.Text; -using OpenMetaverse; namespace RadegastSpeech.Talk { @@ -26,9 +42,7 @@ internal Synthesizer(PluginControl pc) "OpenBeep.wav", "CloseBeep.wav"}; - if (control.osLayer == null) return; - - control.osLayer.SpeechStart( + control.osLayer?.SpeechStart( control, BeepNames); } @@ -39,26 +53,22 @@ internal void Start() internal void Stop() { - if (control.osLayer != null) - control.osLayer.SpeechHalt(); + control.osLayer?.SpeechHalt(); } internal Dictionary GetVoices() { - if (control.osLayer == null) return null; - return control.osLayer.GetVoices(); + return control.osLayer?.GetVoices(); } internal void Speak(QueuedSpeech q, string outputfile) { - if (control.osLayer == null) return; - control.osLayer.Speak(q, outputfile); + control.osLayer?.Speak(q, outputfile); } internal void Shutdown() { - if (control.osLayer == null) return; - control.osLayer.SpeechStop(); + control.osLayer?.SpeechStop(); } } diff --git a/plugins/Radegast.Plugin.Speech/RadSpeech/Talk/Voices.cs b/plugins/Radegast.Plugin.Speech/RadSpeech/Talk/Voices.cs index 568480e4f..d6f0bfe3c 100644 --- a/plugins/Radegast.Plugin.Speech/RadSpeech/Talk/Voices.cs +++ b/plugins/Radegast.Plugin.Speech/RadSpeech/Talk/Voices.cs @@ -1,7 +1,25 @@ +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Text.RegularExpressions; using OpenMetaverse; using OpenMetaverse.StructuredData; @@ -143,8 +161,8 @@ private int GetRandom(int max) if (rgen == null) rgen = new Random(); - // This returns a value n such that 0 >= n < max - return rgen.Next(max); + // This returns a value n such that 0 >= n < max + return rgen.Next(max); } internal void RemoveIf(Dictionary d, string key) @@ -248,7 +266,7 @@ internal AssignedVoice PreAssigned( string avName ) // Save all that as one bundle. return GetNamedVoice(vname, vrate, vpitch); - } + } return null; } @@ -399,7 +417,7 @@ internal AssignedVoice(AvailableVoice r, int rate, int pitch) root = r; rateModification = rate; pitchModification = pitch; - this.Male = root.Male; + Male = root.Male; } } } diff --git a/plugins/Radegast.Plugin.Speech/RadSpeechLin/LinSpeech.cs b/plugins/Radegast.Plugin.Speech/RadSpeechLin/LinSpeech.cs index 4e6f34624..dc615b3be 100644 --- a/plugins/Radegast.Plugin.Speech/RadSpeechLin/LinSpeech.cs +++ b/plugins/Radegast.Plugin.Speech/RadSpeechLin/LinSpeech.cs @@ -1,8 +1,24 @@ -using System; +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System.Collections.Generic; -using System.Linq; -using System.Text; -using RadegastSpeech; using RadegastSpeech.Talk; namespace RadegastSpeech @@ -13,11 +29,6 @@ public class LinSpeech : IRadSpeech public event SpeechEventHandler OnRecognition; - public LinSpeech( ) - { - } - - #region Recognition // Speech recognition is not yet available on Linux public void RecogStart() @@ -64,7 +75,7 @@ public Dictionary GetVoices() } public void Speak( - RadegastSpeech.Talk.QueuedSpeech utterance, + QueuedSpeech utterance, string filename) { synth.Speak(utterance, filename); diff --git a/plugins/Radegast.Plugin.Speech/RadSpeechLin/LinSynth.cs b/plugins/Radegast.Plugin.Speech/RadSpeechLin/LinSynth.cs index ef2f653d7..0c15788ec 100644 --- a/plugins/Radegast.Plugin.Speech/RadSpeechLin/LinSynth.cs +++ b/plugins/Radegast.Plugin.Speech/RadSpeechLin/LinSynth.cs @@ -1,15 +1,30 @@ - +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + #define USEFILE using System; using System.Collections.Generic; -using System.Text; -using System.Threading; using System.IO; using System.Diagnostics; using RadegastSpeech.Talk; using System.Text.RegularExpressions; -using OpenMetaverse; -using Radegast; using OpenMetaverse.StructuredData; namespace RadegastSpeech @@ -39,17 +54,17 @@ internal LinSynth( PluginControl pc, string[] beeps) OSDMap speech = pc.config["synthesizer"] as OSDMap; if (speech == null) { - speech = new OSDMap(); - speech["server"] = new OSDString("localhost:1314"); - speech["speed"] = new OSDInteger(0); + speech = new OSDMap + { + ["server"] = new OSDString("localhost:1314"), + ["speed"] = new OSDInteger(0) + }; pc.config["synthesizer"] = speech; pc.SaveSpeechSettings(); } - string server = speech["server"].AsString(); - if (server==null) - server = "localhost:1314"; - string[] parts = server.Split(':'); + string server = speech["server"].AsString() ?? "localhost:1314"; + string[] parts = server.Split(':'); serverhost = parts[0]; if (parts.Length>1) serverport = parts[1]; @@ -176,7 +191,7 @@ internal void Speak(QueuedSpeech utterance, string outputfile) } catch( Exception e ) { - System.Console.WriteLine( "Festival process error " + e.Message ); + Console.WriteLine( "Festival process error " + e.Message ); return; } @@ -209,28 +224,25 @@ internal Dictionary GetVoices() bool skip = false; // Check for additional information about this voice - if (voiceProperties != null) + string propString = voiceProperties?[name].AsString(); + if (propString != null) { - string propString = voiceProperties[name].AsString(); - if (propString != null) - { - // Properties are a series of blank-separated keywords - string[] props = propString.Split(' '); + // Properties are a series of blank-separated keywords + string[] props = propString.Split(' '); - foreach (string key in props) + foreach (string key in props) + { + switch (key) { - switch (key) - { - case "male": - male = true; - break; - case "female": - male = false; - break; - case "ignore": - skip = true; - break; - } + case "male": + male = true; + break; + case "female": + male = false; + break; + case "ignore": + skip = true; + break; } } } diff --git a/plugins/Radegast.Plugin.Speech/RadSpeechLin/Properties/AssemblyInfo.cs b/plugins/Radegast.Plugin.Speech/RadSpeechLin/Properties/AssemblyInfo.cs deleted file mode 100644 index 42e61ab4e..000000000 --- a/plugins/Radegast.Plugin.Speech/RadSpeechLin/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("RadSpeechLin")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Hewlett-Packard Company")] -[assembly: AssemblyProduct("RadSpeechLin")] -[assembly: AssemblyCopyright("Copyright © Hewlett-Packard Company 2009")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("87c17ca6-5ad9-42af-a7c2-4236f0522b2b")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/plugins/Radegast.Plugin.Speech/RadSpeechLin/RadSpeechLin.csproj b/plugins/Radegast.Plugin.Speech/RadSpeechLin/RadSpeechLin.csproj new file mode 100644 index 000000000..aaa41f41f --- /dev/null +++ b/plugins/Radegast.Plugin.Speech/RadSpeechLin/RadSpeechLin.csproj @@ -0,0 +1,86 @@ + + + net48 + false + AnyCPU;x64;x86 + + + full + ..\..\bin\$(Configuration)\ + TRACE;DEBUG + + + portable + ..\..\bin\$(Configuration)\ + TRACE + + + ..\..\bin\$(Configuration)\ + TRACE + true + portable + MinimumRecommendedRules.ruleset + + + ..\..\bin\$(Configuration)\ + TRACE + true + portable + MinimumRecommendedRules.ruleset + + + ..\..\bin\$(Configuration)\ + TRACE + true + portable + MinimumRecommendedRules.ruleset + + + ..\..\bin\$(Configuration)\ + + + ..\..\bin\$(Configuration)\ + + + ..\..\bin\$(Configuration)\ + + + ..\..\bin\$(Configuration)\ + + + ..\..\bin\$(Configuration)\ + + + ..\..\bin\$(Configuration)\ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/plugins/Radegast.Plugin.Speech/RadSpeechMac/MacSpeech.cs b/plugins/Radegast.Plugin.Speech/RadSpeechMac/MacSpeech.cs index 0b9297d0c..03da5af87 100644 --- a/plugins/Radegast.Plugin.Speech/RadSpeechMac/MacSpeech.cs +++ b/plugins/Radegast.Plugin.Speech/RadSpeechMac/MacSpeech.cs @@ -1,10 +1,25 @@ -using System; +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System.Collections.Generic; -using System.Linq; -using System.Text; -using RadegastSpeech; using RadegastSpeech.Talk; -using Radegast; namespace RadegastSpeech { @@ -15,11 +30,6 @@ public class MacSpeech : IRadSpeech #pragma warning disable 67 public event SpeechEventHandler OnRecognition; - public MacSpeech() - { - - } - public void SpeechStart( PluginControl pc, string[] beeps) { synth = new MacSynth( pc, beeps); @@ -43,7 +53,7 @@ public Dictionary GetVoices() } public void Speak( - RadegastSpeech.Talk.QueuedSpeech utterance, + QueuedSpeech utterance, string filename) { synth.Speak(utterance, filename); diff --git a/plugins/Radegast.Plugin.Speech/RadSpeechMac/MacSynth.cs b/plugins/Radegast.Plugin.Speech/RadSpeechMac/MacSynth.cs index 1438ee946..948341d45 100644 --- a/plugins/Radegast.Plugin.Speech/RadSpeechMac/MacSynth.cs +++ b/plugins/Radegast.Plugin.Speech/RadSpeechMac/MacSynth.cs @@ -1,16 +1,31 @@ -// Define CARBON to use the lower level interface +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + +// Define CARBON to use the lower level interface //#define CARBON -using System; using System.Collections.Generic; -using System.Text; using System.Text.RegularExpressions; using System.Threading; using RadegastSpeech.Talk; -using Radegast; -using Monobjc; using Monobjc.Cocoa; -using System.Runtime.InteropServices; using OpenMetaverse.StructuredData; namespace RadegastSpeech @@ -98,27 +113,25 @@ internal Dictionary GetVoices() Dictionary names = new Dictionary(); NSArray insVoices = NSSpeechSynthesizer.AvailableVoices; - foreach (NSString name in insVoices) + foreach (var id in insVoices) { + var name = (NSString) id; bool skip = false; // Check for additional information about this voice - if (voiceProperties != null) + string propString = voiceProperties?[name].AsString(); + if (propString != null) { - string propString = voiceProperties[name].AsString(); - if (propString != null) - { - // Properties are a series of blank-separated keywords - string[] props = propString.Split(' '); + // Properties are a series of blank-separated keywords + string[] props = propString.Split(' '); - foreach (string key in props) + foreach (string key in props) + { + switch (key) { - switch (key) - { - case "ignore": - skip = true; - break; - } + case "ignore": + skip = true; + break; } } } diff --git a/plugins/Radegast.Plugin.Speech/RadSpeechMac/Properties/AssemblyInfo.cs b/plugins/Radegast.Plugin.Speech/RadSpeechMac/Properties/AssemblyInfo.cs deleted file mode 100644 index c0312932b..000000000 --- a/plugins/Radegast.Plugin.Speech/RadSpeechMac/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("RadSpeechMac")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Hewlett-Packard Company")] -[assembly: AssemblyProduct("RadSpeechMac")] -[assembly: AssemblyCopyright("Copyright © Hewlett-Packard Company 2009")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("4e367b93-561a-4547-b959-70bc2b9c1907")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/plugins/Radegast.Plugin.Speech/RadSpeechMac/RadSpeechMac.csproj b/plugins/Radegast.Plugin.Speech/RadSpeechMac/RadSpeechMac.csproj new file mode 100644 index 000000000..fcacd3452 --- /dev/null +++ b/plugins/Radegast.Plugin.Speech/RadSpeechMac/RadSpeechMac.csproj @@ -0,0 +1,94 @@ + + + net48 + false + AnyCPU;x64;x86 + + + full + ..\..\bin\$(Configuration)\ + TRACE;DEBUG + + + pdbonly + ..\..\bin\$(Configuration)\ + TRACE + + + ..\..\bin\$(Configuration)\ + TRACE + true + portable + MinimumRecommendedRules.ruleset + + + ..\..\bin\$(Configuration)\ + TRACE + true + portable + MinimumRecommendedRules.ruleset + + + ..\..\bin\$(Configuration)\ + TRACE + true + portable + MinimumRecommendedRules.ruleset + + + ..\..\bin\$(Configuration)\ + + + ..\..\bin\$(Configuration)\ + + + ..\..\bin\$(Configuration)\ + + + ..\..\bin\$(Configuration)\ + + + ..\..\bin\$(Configuration)\ + + + ..\..\bin\$(Configuration)\ + + + + + + + + + + assemblies\Monobjc.Cocoa.dll + + + assemblies\Monobjc.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/plugins/Radegast.Plugin.Speech/RadSpeechWin/Properties/AssemblyInfo.cs b/plugins/Radegast.Plugin.Speech/RadSpeechWin/Properties/AssemblyInfo.cs deleted file mode 100644 index cfe017f1a..000000000 --- a/plugins/Radegast.Plugin.Speech/RadSpeechWin/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("RadSpeechWin")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Hewlett-Packard Company")] -[assembly: AssemblyProduct("RadSpeechWin")] -[assembly: AssemblyCopyright("Copyright © Hewlett-Packard Company 2009")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("9b3b42ca-3dce-4a0d-b3b1-0d143f690c7a")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.3.0.0")] -[assembly: AssemblyFileVersion("0.3.0.0")] diff --git a/plugins/Radegast.Plugin.Speech/RadSpeechWin/RadSpeechWin.csproj b/plugins/Radegast.Plugin.Speech/RadSpeechWin/RadSpeechWin.csproj new file mode 100644 index 000000000..698918429 --- /dev/null +++ b/plugins/Radegast.Plugin.Speech/RadSpeechWin/RadSpeechWin.csproj @@ -0,0 +1,89 @@ + + + net48 + false + AnyCPU;x64;x86 + + + full + ..\..\bin\$(Configuration)\ + TRACE;DEBUG + + + portable + ..\..\bin\$(Configuration)\ + TRACE + + + ..\..\bin\$(Configuration)\ + TRACE + true + portable + MinimumRecommendedRules.ruleset + + + ..\..\bin\$(Configuration)\ + TRACE + true + portable + MinimumRecommendedRules.ruleset + + + ..\..\bin\$(Configuration)\ + TRACE + true + portable + MinimumRecommendedRules.ruleset + + + ..\..\bin\$(Configuration)\ + + + ..\..\bin\$(Configuration)\ + + + ..\..\bin\$(Configuration)\ + + + ..\..\bin\Release\ + + + ..\..\bin\Release\ + + + ..\..\bin\Release\ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/plugins/Radegast.Plugin.Speech/RadSpeechWin/WinRecog.cs b/plugins/Radegast.Plugin.Speech/RadSpeechWin/WinRecog.cs index 5fd3fc1b3..5c14628c9 100644 --- a/plugins/Radegast.Plugin.Speech/RadSpeechWin/WinRecog.cs +++ b/plugins/Radegast.Plugin.Speech/RadSpeechWin/WinRecog.cs @@ -1,7 +1,25 @@ -using System; +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + +using System; using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Speech.Recognition; using OpenMetaverse; @@ -28,7 +46,6 @@ internal WinRecog( ) rec = null; Logger.Log("Speech recognition disabled, " + e.Message, Helpers.LogLevel.Warning); - return; } } @@ -36,14 +53,14 @@ internal void Start() { if (rec == null) return; rec.Enabled = true; - rec.SpeechRecognized += new EventHandler(onSpeech); + rec.SpeechRecognized += onSpeech; } internal void Stop() { if (rec == null) return; rec.Enabled = false; - rec.SpeechRecognized -= new EventHandler(onSpeech); + rec.SpeechRecognized -= onSpeech; rec.Dispose(); rec = null; } diff --git a/plugins/Radegast.Plugin.Speech/RadSpeechWin/WinSpeech.cs b/plugins/Radegast.Plugin.Speech/RadSpeechWin/WinSpeech.cs index c8ac256fd..c5ce5d9ef 100644 --- a/plugins/Radegast.Plugin.Speech/RadSpeechWin/WinSpeech.cs +++ b/plugins/Radegast.Plugin.Speech/RadSpeechWin/WinSpeech.cs @@ -1,8 +1,25 @@ -using System; +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + +using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using RadegastSpeech; using RadegastSpeech.Talk; namespace RadegastSpeech @@ -17,11 +34,6 @@ public class WinSpeech : IRadSpeech public event SpeechEventHandler OnRecognition; - public WinSpeech() - { - - } - #region Synthesis public void SpeechStart( PluginControl pc, string[] beeps) { @@ -46,8 +58,7 @@ public void SpeechStop() public void SpeechHalt() { - if (synth != null) - synth.Halt(); + synth?.Halt(); } public Dictionary GetVoices() @@ -56,7 +67,7 @@ public Dictionary GetVoices() } public void Speak( - RadegastSpeech.Talk.QueuedSpeech utterance, + QueuedSpeech utterance, string filename) { synth.Speak(utterance, filename); @@ -73,7 +84,7 @@ public void RecogStart() // Hook up event relay recog.OnWinRecognition += - new SpeechEventHandler(recog_OnWinRecognition); + recog_OnWinRecognition; } catch (Exception) { @@ -84,32 +95,27 @@ public void RecogStart() private void recog_OnWinRecognition(string text) { - if (OnRecognition != null) - OnRecognition(text); + OnRecognition?.Invoke(text); } public void RecogStop() { - if (recog != null) - recog.Stop(); + recog?.Stop(); } public void CreateGrammar( string name, string[] alternatives ) { - if (recog != null) - recog.CreateGrammar(name, alternatives); + recog?.CreateGrammar(name, alternatives); } public void ActivateGrammar(string name) { - if (recog != null) - recog.ActivateGrammar(name); + recog?.ActivateGrammar(name); } public void DeactivateGrammar(string name) { - if (recog != null) - recog.DeactivateGrammar(name); + recog?.DeactivateGrammar(name); } #endregion } diff --git a/plugins/Radegast.Plugin.Speech/RadSpeechWin/WinSynth.cs b/plugins/Radegast.Plugin.Speech/RadSpeechWin/WinSynth.cs index 608e2146a..19813184d 100644 --- a/plugins/Radegast.Plugin.Speech/RadSpeechWin/WinSynth.cs +++ b/plugins/Radegast.Plugin.Speech/RadSpeechWin/WinSynth.cs @@ -1,16 +1,32 @@ - +/** + * Radegast Metaverse Client + * Copyright(c) 2009-2014, Radegast Development Team + * Copyright(c) 2016-2020, Sjofn, LLC + * All rights reserved. + * + * Radegast is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program.If not, see. + */ + using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Speech; using System.IO; using System.Speech.Synthesis; using System.Speech.AudioFormat; using RadegastSpeech.Talk; using OpenMetaverse; using OpenMetaverse.StructuredData; -using Radegast; namespace RadegastSpeech { @@ -22,23 +38,19 @@ class WinSynth private PromptBuilder pb; private PromptStyle mainStyle; private FileStream mstream; - private PromptVolume promptVol = PromptVolume.Loud; private string[] BeepNames; private OSDMap voiceProperties; PromptRate voiceRate { get { - if (voiceProperties != null) + string voiceSpeed = voiceProperties?["voice_speed"]; + if (!string.IsNullOrEmpty(voiceSpeed)) { - string voiceSpeed = voiceProperties["voice_speed"]; - if (!string.IsNullOrEmpty(voiceSpeed)) + switch (voiceSpeed) { - switch (voiceSpeed) - { - case "fast": return PromptRate.Fast; - case "slow": return PromptRate.Slow; - } + case "fast": return PromptRate.Fast; + case "slow": return PromptRate.Slow; } } return PromptRate.Medium; @@ -114,16 +126,10 @@ private void StartSpeech(AssignedVoice vb, string outputfile) System.Collections.ObjectModel.ReadOnlyCollection formats = wv.winVoice.VoiceInfo.SupportedAudioFormats; - format = formats.FirstOrDefault(); - - if (format == null) - { - // The voice did not tell us its parameters, so we pick some. - format = new SpeechAudioFormatInfo( - 16000, // Samples per second - AudioBitsPerSample.Sixteen, - AudioChannel.Mono); - } + format = formats.FirstOrDefault() ?? new SpeechAudioFormatInfo( + 16000, // Samples per second + AudioBitsPerSample.Sixteen, + AudioChannel.Mono); // First set up to synthesize the message into a WAV file. mstream = new FileStream(outputfile, FileMode.Create, FileAccess.Write); @@ -175,10 +181,12 @@ private void SaySegment(QueuedSpeech utterance) /// private void SayPrompt(string text) { - PromptStyle intro = new PromptStyle(); - intro.Rate = voiceRate; - //intro.Volume = promptVol - 1; - intro.Emphasis = PromptEmphasis.Moderate; + PromptStyle intro = new PromptStyle + { + Rate = voiceRate, + //Volume = promptVol - 1; + Emphasis = PromptEmphasis.Moderate + }; pb.StartStyle(intro); pb.StartSentence(); pb.AppendText(text + ":"); @@ -235,22 +243,19 @@ System.Collections.ObjectModel.ReadOnlyCollection installed bool skip = false; // Check for additional information about this voice - if (voiceProperties != null) + string propString = voiceProperties?[v.VoiceInfo.Name].AsString(); + if (propString != null) { - string propString = voiceProperties[v.VoiceInfo.Name].AsString(); - if (propString != null) - { - // Properties are a series of blank-separated keywords - string[] props = propString.Split(' '); + // Properties are a series of blank-separated keywords + string[] props = propString.Split(' '); - foreach (string key in props) + foreach (string key in props) + { + switch (key) { - switch (key) - { - case "ignore": - skip = true; - break; - } + case "ignore": + skip = true; + break; } } } diff --git a/premake5.lua b/premake5.lua deleted file mode 100644 index bcc18492a..000000000 --- a/premake5.lua +++ /dev/null @@ -1,451 +0,0 @@ -solution "Radegast" - configurations { "Debug", "Release" } - platforms { "x86" } - dotnetframework "4.5" - language "C#" - warnings "Extra" - disablewarnings {"1591", "1574", "0419", "0618", "0414", "0169"} - buildoptions { "/checked-", "/nostdlib-"} - targetdir "bin" - implibdir "bin" - - configuration "Debug" - defines { "TRACE", "DEBUG", "SMARTHREADPOOL_REF" } - flags { "Symbols" } - optimize "Off" - clr "Unsafe" - - configuration "Release" - defines { "TRACE", "SMARTHREADPOOL_REF" } - optimize "Full" - clr "Unsafe" - - configuration "**.config" - buildaction "Copy" - configuration "**.so" - buildaction "Copy" - configuration "**.xml" - buildaction "Copy" - configuration "**.txt" - buildaction "Copy" - configuration "**.png" - buildaction "Copy" - configuration "**.wav" - buildaction "Copy" - - project "OpenMetaverseTypes" - kind("SharedLib") - location(path.join("libopenmetaverse", "OpenMetaverseTypes")) - namespace("OpenMetaverse") - files { - path.join("%{prj.location}", "**.cs") - } - excludes { - path.join("%{prj.location}", "obj", "**") - } - links { - "System", - "System.Core", - "System.Xml", - } - - project "OpenMetaverse.StructuredData" - kind("SharedLib") - location(path.join("libopenmetaverse", "OpenMetaverse.StructuredData")) - namespace("OpenMetaverse.StructuredData") - files { - path.join("%{prj.location}", "**.cs") - } - excludes { - path.join("%{prj.location}", "obj", "**") - } - dependson { - "OpenMetaverseTypes", - } - links { - "System", - "System.Xml", - "OpenMetaverseTypes", - } - - project "OpenMetaverse" - kind("SharedLib") - location(path.join("libopenmetaverse", "OpenMetaverse")) - namespace("OpenMetaverse") - files { - path.join("%{prj.location}", "**.cs") - } - excludes { - path.join("%{prj.location}", "obj", "**") - } - dependson { - "OpenMetaverseTypes", - "OpenMetaverse.StructuredData", - } - links { - "System", - "System.Core", - "System.Xml", - "System.Data", - "System.Drawing", - "OpenMetaverseTypes", - "OpenMetaverse.StructuredData", - path.join("libopenmetaverse", "bin", "log4net"), - path.join("libopenmetaverse", "bin", "SmartThreadPool"), - path.join("libopenmetaverse", "bin", "XMLRPC"), - path.join("libopenmetaverse", "bin", "zlib.net"), - } - - project "OpenMetaverse.Rendering.Meshmerizer" - kind("SharedLib") - location(path.join("libopenmetaverse", "OpenMetaverse.Rendering.Meshmerizer")) - namespace("OpenMetaverse.Rendering") - files { - path.join("%{prj.location}", "**.cs") - } - excludes { - path.join("%{prj.location}", "obj", "**") - } - dependson { - "OpenMetaverse", - "OpenMetaverseTypes", - } - links { - "System", - "System.Xml", - "System.Data", - "System.Drawing", - "OpenMetaverse", - "OpenMetaverseTypes", - path.join("libopenmetaverse", "bin", "PrimMesher"), - } - - project "Radegast" - kind("WindowedApp") - location("Radegast") - icon(path.join("%{prj.location}", "radegast.ico")) - files { - path.join("%{prj.location}", "Properties", "**.cs"), - path.join("%{prj.location}", "**.cs"), - path.join("%{prj.location}", "**.resx"), - path.join("%{prj.location}", "openjpeg-dotnet*"), - path.join("%{prj.location}", "*.config"), - path.join("%{prj.location}", "*.so"), - path.join("%{prj.location}", "*.dylib"), - path.join("%{prj.location}", "fmodex.*"), - path.join("%{prj.location}", "*.xml"), - path.join("%{prj.location}", "*.txt"), - path.join("%{prj.location}", "*.png"), - path.join("%{prj.location}", "radegast.nsi"), - path.join("%{prj.location}", "openmetaverse_data", "**"), - path.join("%{prj.location}", "character", "**"), - path.join("%{prj.location}", "shader_data", "**") - } - excludes { - path.join("%{prj.location}", "AssemblyInfo.cs"), - path.join("%{prj.location}", "openmetaverse_data", ".svn", "**"), - path.join("%{prj.location}", "obj", "**") - } - dependson { - "OpenMetaverse", - "OpenMetaverseTypes", - "OpenMetaverse.StructuredData", - "OpenMetaverse.Rendering.Meshmerizer" - } - links { - "System", - "System.Core", - "System.Data", - "System.Drawing", - "System.Web", - "System.Web.Extensions", - "System.Windows.Forms", - "System.Xml", - "OpenMetaverse", - "OpenMetaverseTypes", - "OpenMetaverse.StructuredData", - "OpenMetaverse.Rendering.Meshmerizer", - path.join("%{prj.location}", "assemblies", "fmodex-dotnet"), - path.join("%{prj.location}", "assemblies", "OpenTK"), - path.join("%{prj.location}", "assemblies", "OpenTK.GLControl"), - path.join("%{prj.location}", "assemblies", "Tools"), - path.join("%{prj.location}", "assemblies", "log4net"), - path.join("%{prj.location}", "assemblies", "CommandLine"), - path.join("%{prj.location}", "assemblies", "XMLRPC"), - } - configuration "**/**.dylib" - buildaction "Copy" - configuration "**/fmodex.*" - buildaction "Copy" - configuration "**/openjpeg-dotnet*" - buildaction "Copy" - configuration "**/radegast.nsi" - buildaction "Copy" - configuration "**/openmetaverse_data/**" - buildaction "Copy" - configuration "**/character/**" - buildaction "Copy" - configuration "**/shader_data/**" - buildaction "Copy" - - project "Radegast.Plugin.Alice" - kind("SharedLib") - location(path.join("plugins", "Radegast.Plugin.Alice")) - files { - path.join("%{prj.location}", "**.cs"), - path.join("%{prj.location}", "Properties", "**.cs"), - path.join("%{prj.location}", "aiml", "**"), - path.join("%{prj.location}", "aiml_config", "**") - } - excludes { - path.join("%{prj.location}", "AssemblyInfo.cs"), - path.join("%{prj.location}", "obj", "**") - } - dependson { - "Radegast", - "OpenMetaverse", - "OpenMetaverseTypes", - "OpenMetaverse.StructuredData", - "Radegast.Plugin.Speech" - } - links { - "System", - "System.Core", - "System.Xml", - "System.Data", - "System.Drawing", - "System.Xml.Linq", - "System.Windows.Forms", - "OpenMetaverse", - "OpenMetaverseTypes", - "OpenMetaverse.StructuredData", - "Radegast.exe", - path.join("%{prj.location}", "assemblies", "AIMLbot"), - } - configuration "**/aiml/**" - buildaction "Copy" - configuration "**/aiml_config/**" - buildaction "Copy" - - project "Radegast.Plugin.SimpleBuilder" - kind("SharedLib") - location(path.join("plugins", "Radegast.Plugin.SimpleBuilder")) - files { - path.join("%{prj.location}", "**.cs"), - path.join("%{prj.location}", "Properties", "**.cs") - } - excludes { - path.join("%{prj.location}", "AssemblyInfo.cs"), - path.join("%{prj.location}", "obj", "**") - } - dependson{ - "Radegast", - "OpenMetaverse", - "OpenMetaverseTypes", - "OpenMetaverse.StructuredData" - } - links { - "System", - "System.Core", - "System.Xml", - "System.Data", - "System.Drawing", - "System.Windows.Forms", - "OpenMetaverse", - "OpenMetaverseTypes", - "OpenMetaverse.StructuredData", - "Radegast", - } - - project "Radegast.Plugin.IRC" - kind("SharedLib") - location(path.join("plugins", "Radegast.Plugin.IRC")) - files { - path.join("%{prj.location}", "**.cs"), - path.join("%{prj.location}", "Properties", "**.cs") - } - excludes { - path.join("%{prj.location}", "AssemblyInfo.cs"), - path.join("%{prj.location}", "obj", "**") - } - dependson{ - "Radegast", - "OpenMetaverse", - "OpenMetaverseTypes", - "OpenMetaverse.StructuredData" - } - links { - "System", - "System.Core", - "System.Xml", - "System.Data", - "System.Drawing", - "System.Windows.Forms", - "System.Xml.Linq", - "System.Data.DataSetExtensions", - "OpenMetaverse", - "OpenMetaverseTypes", - "OpenMetaverse.StructuredData", - "Radegast", - path.join("%{prj.location}", "assemblies", "Meebey.SmartIrc4net") - } - ---[[ - project "Radegast.Plugin.EVOVend" - kind("SharedLib") - location(path.join("plugins", "Radegast.Plugin.EVOVend")) - files { - path.join("%{prj.location}", "**.cs"), - path.join("%{prj.location}", "Properties", "**.cs") - } - excludes { - path.join("%{prj.location}", "AssemblyInfo.cs"), - path.join("%{prj.location}", "obj", "**") - } - dependson{ - "Radegast", - "OpenMetaverse", - "OpenMetaverseTypes", - "OpenMetaverse.StructuredData" - } - links { - "System", - "System.Core", - "System.Xml", - "System.Data", - "System.Drawing", - "System.Windows.Forms", - "OpenMetaverse", - "OpenMetaverseTypes", - "OpenMetaverse.StructuredData", - "Radegast", - } ---]] - - project "Radegast.Plugin.Speech" - kind("SharedLib") - location(path.join("plugins", "Radegast.Plugin.Speech", "RadSpeech")) - files { - path.join("%{prj.location}", "**.cs"), - path.join("%{prj.location}", "**.wav"), - path.join("%{prj.location}", "**.resx"), - } - excludes { - path.join("%{prj.location}", "obj", "**") - } - dependson{ - "Radegast", - "OpenMetaverse", - "OpenMetaverseTypes", - "OpenMetaverse.StructuredData" - } - links { - "System", - "System.Core", - "System.Drawing", - "System.Windows.Forms", - "System.Xml.Linq", - "System.Data.DataSetExtensions", - "System.Data", - "System.Xml", - "OpenMetaverse", - "OpenMetaverseTypes", - "OpenMetaverse.StructuredData", - "Radegast.exe", - "fmodex-dotnet.dll", - } - - project "RadSpeechLin" - kind("SharedLib") - location(path.join("plugins", "Radegast.Plugin.Speech", "RadSpeechLin")) - files { - path.join("%{prj.location}", "**.cs"), - } - excludes { - path.join("%{prj.location}", "obj", "**") - } - dependson { - "Radegast", - "OpenMetaverse", - "OpenMetaverseTypes", - "OpenMetaverse.StructuredData", - "Radegast.Plugin.Speech" - } - links { - "System", - "System.Core", - "System.Xml.Linq", - "System.Data.DataSetExtensions", - "System.Data", - "System.Xml", - "OpenMetaverse", - "OpenMetaverseTypes", - "OpenMetaverse.StructuredData", - "Radegast.exe", - "Radegast.Plugin.Speech", - } - - if os.is("windows") then - project "RadSpeechWin" - kind("SharedLib") - location(path.join("plugins", "Radegast.Plugin.Speech", "RadSpeechWin")) - files { - path.join("%{prj.location}", "**.cs"), - } - excludes { - path.join("%{prj.location}", "obj", "**") - } - dependson { - "Radegast", - "OpenMetaverse", - "OpenMetaverseTypes", - "OpenMetaverse.StructuredData", - "Radegast.Plugin.Speech" - } - links { - "System", - "System.Core", - "System.Speech", - "System.Xml.Linq", - "System.Data.DataSetExtensions", - "System.Data", - "System.Xml", - "OpenMetaverse", - "OpenMetaverseTypes", - "OpenMetaverse.StructuredData", - "Radegast.exe", - "Radegast.Plugin.Speech", - } - end - - project "RadSpeechMac" - kind("SharedLib") - location(path.join("plugins", "Radegast.Plugin.Speech", "RadSpeechMac")) - files { - path.join("%{prj.location}", "**.cs"), - } - excludes { - path.join("%{prj.location}", "obj", "**") - } - dependson { - "Radegast", - "OpenMetaverse", - "OpenMetaverseTypes", - "OpenMetaverse.StructuredData", - "Radegast.Plugin.Speech" - } - links { - "System", - "System.Core", - "System.Xml.Linq", - "System.Data.DataSetExtensions", - "System.Data", - "System.Xml", - "OpenMetaverse", - "OpenMetaverseTypes", - "OpenMetaverse.StructuredData", - "Radegast.exe", - "Radegast.Plugin.Speech", - path.join("%{prj.location}", "assemblies", "Monobjc.Cocoa"), - path.join("%{prj.location}", "assemblies", "Monobjc"), - } diff --git a/runprebuild.sh b/runprebuild.sh deleted file mode 100755 index 99af8f1ea..000000000 --- a/runprebuild.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash - -cd `dirname "$0"` -mkdir bin 2>/dev/null - -if [ "$(uname -s)" == "Darwin" ]; then - ./build/macosx/premake5 --os=macosx vs2010 -else - ./build/linux/premake5 --os=linux vs2010 -fi - -if [ x$1 == xbuild ]; then - xbuild /p:Configuration=Release Radegast.sln - RES=$? - echo Build Exit Code: $RES - - if [ x$RES != x0 ]; then - exit $RES - fi - - if [ x$2 == xdist ]; then - tar czvf radegast-latest.tgz bin - fi - - exit $RES -else - echo "Now run:" - echo - echo "xbuild Radegast.sln" -fi diff --git a/runprebuild2010.bat b/runprebuild2010.bat deleted file mode 100644 index 99a248a09..000000000 --- a/runprebuild2010.bat +++ /dev/null @@ -1,81 +0,0 @@ -@echo off -:: -:: Prebuild generator for the Radegast -:: -:: Command Line Options: -:: (none) - create solution/project files and create compile.bat file to build solution -:: msbuild - Create project files, compile solution -:: msbuild runtests - create project files, compile solution, run unit tests -:: msbuild docs - create project files, compile solution, build API documentation -:: msbuild docs dist - Create project files, compile solution, run unit tests, build api documentation, create binary zip -:: - and exe installer -:: -:: nant - Create project files, run nant to compile solution -:: nant runtests - Create project files, run nant to compile solution, run unit tests -:: - -echo ########################################## -echo creating prebuild files for: vs2010 -echo Parameters: %1 %2 -echo ########################################## - -if not exist bin mkdir bin - -:: run prebuild to generate solution/project files from prebuild.xml configuration file -Build\Windows\Premake5.exe vs2010 - -:: build compile.bat file based on command line parameters -echo @echo off > compile.bat -if(.%1)==(.) echo %SystemRoot%\Microsoft.NET\Framework\v4.0.30319\msbuild Radegast.sln >> compile.bat - -if(.%1)==(.msbuild) echo echo ==== COMPILE BEGIN ==== >> compile.bat -if(.%1)==(.msbuild) echo %SystemRoot%\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /p:Configuration=Release Radegast.sln >> compile.bat -if(.%1)==(.msbuild) echo IF ERRORLEVEL 1 GOTO FAIL >> compile.bat - -if(.%1)==(.nant) echo nant >> compile.bat -if(.%1)==(.nant) echo IF ERRORLEVEL 1 GOTO FAIL >> compile.bat - -if(.%3)==(.docs) echo echo ==== GENERATE DOCUMENTATION BEGIN ==== >> compile.bat -if(.%2)==(.docs) echo %SystemRoot%\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /p:Configuration=Release docs\Radegast.shfbproj >> compile.bat -if(.%2)==(.docs) echo IF ERRORLEVEL 1 GOTO FAIL >> compile.bat -if(.%2)==(.docs) echo 7z.exe a -tzip docs\documentation.zip docs\trunk >> compile.bat -if(.%2)==(.docs) echo IF ERRORLEVEL 1 GOTO FAIL >> compile.bat - -if(.%2)==(.runtests) echo echo ==== UNIT TESTS BEGIN ==== >> compile.bat -if(.%2)==(.runtests) echo nunit-console bin\Radegast.Tests.dll /exclude:Network /nodots /labels /xml:testresults.xml >> compile.bat - -if(.%2)==(.runtests) echo IF ERRORLEVEL 1 GOTO FAIL >> compile.bat - -if not (.%2)==(.dist) goto NODIST -echo echo ==== GENERATE DISTRIBUTION BEGIN ==== >> compile.bat -copy Radegast\radegast.nsi bin -echo del /q Radegast-*-installer.exe >> compile.bat -echo del /q radegast-latest.zip >> compile.bat - -if not exist "%PROGRAMFILES%\NSIS\Unicode\makensis.exe" goto NOUNINSIS -echo "%PROGRAMFILES%\NSIS\Unicode\makensis.exe" bin\radegast.nsi >> compile.bat -goto NONSIS -:NOUNINSIS - -if not exist "%PROGRAMFILES%\NSIS\makensis.exe" goto NONSIS -echo "%PROGRAMFILES%\NSIS\makensis.exe" bin\radegast.nsi >> compile.bat -:NONSIS - -echo cd bin >> compile.bat -echo 7z.exe a -r -tzip ..\radegast-latest.zip *.* >> compile.bat -echo cd .. >> compile.bat - -:NODIST - -echo :SUCCESS >> compile.bat -echo echo Build Successful! >> compile.bat -echo exit /B 0 >> compile.bat -echo :FAIL >> compile.bat -echo echo Build Failed, check log for reason >> compile.bat -echo exit /B 1 >> compile.bat - -:: perform the appropriate action -if(.%1)==(.msbuild) compile.bat -if(.%1)==(.nant) compile.bat -if(.%1)==(.dist) compile.bat - diff --git a/runprebuild2012.bat b/runprebuild2012.bat deleted file mode 100644 index 5e24576ab..000000000 --- a/runprebuild2012.bat +++ /dev/null @@ -1,81 +0,0 @@ -@echo off -:: -:: Prebuild generator for the Radegast -:: -:: Command Line Options: -:: (none) - create solution/project files and create compile.bat file to build solution -:: msbuild - Create project files, compile solution -:: msbuild runtests - create project files, compile solution, run unit tests -:: msbuild docs - create project files, compile solution, build API documentation -:: msbuild docs dist - Create project files, compile solution, run unit tests, build api documentation, create binary zip -:: - and exe installer -:: -:: nant - Create project files, run nant to compile solution -:: nant runtests - Create project files, run nant to compile solution, run unit tests -:: - -echo ########################################## -echo creating prebuild files for: vs2012 -echo Parameters: %1 %2 -echo ########################################## - -if not exist bin mkdir bin - -:: run prebuild to generate solution/project files from prebuild.xml configuration file -Build\Windows\Premake5.exe vs2012 - -:: build compile.bat file based on command line parameters -echo @echo off > compile.bat -if(.%1)==(.) echo %SystemRoot%\Microsoft.NET\Framework\v4.0.30319\msbuild Radegast.sln >> compile.bat - -if(.%1)==(.msbuild) echo echo ==== COMPILE BEGIN ==== >> compile.bat -if(.%1)==(.msbuild) echo %SystemRoot%\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /p:Configuration=Release Radegast.sln >> compile.bat -if(.%1)==(.msbuild) echo IF ERRORLEVEL 1 GOTO FAIL >> compile.bat - -if(.%1)==(.nant) echo nant >> compile.bat -if(.%1)==(.nant) echo IF ERRORLEVEL 1 GOTO FAIL >> compile.bat - -if(.%3)==(.docs) echo echo ==== GENERATE DOCUMENTATION BEGIN ==== >> compile.bat -if(.%2)==(.docs) echo %SystemRoot%\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /p:Configuration=Release docs\Radegast.shfbproj >> compile.bat -if(.%2)==(.docs) echo IF ERRORLEVEL 1 GOTO FAIL >> compile.bat -if(.%2)==(.docs) echo 7z.exe a -tzip docs\documentation.zip docs\trunk >> compile.bat -if(.%2)==(.docs) echo IF ERRORLEVEL 1 GOTO FAIL >> compile.bat - -if(.%2)==(.runtests) echo echo ==== UNIT TESTS BEGIN ==== >> compile.bat -if(.%2)==(.runtests) echo nunit-console bin\Radegast.Tests.dll /exclude:Network /nodots /labels /xml:testresults.xml >> compile.bat - -if(.%2)==(.runtests) echo IF ERRORLEVEL 1 GOTO FAIL >> compile.bat - -if not (.%2)==(.dist) goto NODIST -echo echo ==== GENERATE DISTRIBUTION BEGIN ==== >> compile.bat -copy Radegast\radegast.nsi bin -echo del /q Radegast-*-installer.exe >> compile.bat -echo del /q radegast-latest.zip >> compile.bat - -if not exist "%PROGRAMFILES%\NSIS\Unicode\makensis.exe" goto NOUNINSIS -echo "%PROGRAMFILES%\NSIS\Unicode\makensis.exe" bin\radegast.nsi >> compile.bat -goto NONSIS -:NOUNINSIS - -if not exist "%PROGRAMFILES%\NSIS\makensis.exe" goto NONSIS -echo "%PROGRAMFILES%\NSIS\makensis.exe" bin\radegast.nsi >> compile.bat -:NONSIS - -echo cd bin >> compile.bat -echo 7z.exe a -r -tzip ..\radegast-latest.zip *.* >> compile.bat -echo cd .. >> compile.bat - -:NODIST - -echo :SUCCESS >> compile.bat -echo echo Build Successful! >> compile.bat -echo exit /B 0 >> compile.bat -echo :FAIL >> compile.bat -echo echo Build Failed, check log for reason >> compile.bat -echo exit /B 1 >> compile.bat - -:: perform the appropriate action -if(.%1)==(.msbuild) compile.bat -if(.%1)==(.nant) compile.bat -if(.%1)==(.dist) compile.bat - diff --git a/runprebuild2013.bat b/runprebuild2013.bat deleted file mode 100644 index 6b71ea026..000000000 --- a/runprebuild2013.bat +++ /dev/null @@ -1,81 +0,0 @@ -@echo off -:: -:: Prebuild generator for the Radegast -:: -:: Command Line Options: -:: (none) - create solution/project files and create compile.bat file to build solution -:: msbuild - Create project files, compile solution -:: msbuild runtests - create project files, compile solution, run unit tests -:: msbuild docs - create project files, compile solution, build API documentation -:: msbuild docs dist - Create project files, compile solution, run unit tests, build api documentation, create binary zip -:: - and exe installer -:: -:: nant - Create project files, run nant to compile solution -:: nant runtests - Create project files, run nant to compile solution, run unit tests -:: - -echo ########################################## -echo creating prebuild files for: vs2013 -echo Parameters: %1 %2 -echo ########################################## - -if not exist bin mkdir bin - -:: run prebuild to generate solution/project files from prebuild.xml configuration file -Build\Windows\Premake5.exe vs2013 - -:: build compile.bat file based on command line parameters -echo @echo off > compile.bat -if(.%1)==(.) echo %SystemRoot%\Microsoft.NET\Framework\v4.0.30319\msbuild Radegast.sln >> compile.bat - -if(.%1)==(.msbuild) echo echo ==== COMPILE BEGIN ==== >> compile.bat -if(.%1)==(.msbuild) echo %SystemRoot%\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /p:Configuration=Release Radegast.sln >> compile.bat -if(.%1)==(.msbuild) echo IF ERRORLEVEL 1 GOTO FAIL >> compile.bat - -if(.%1)==(.nant) echo nant >> compile.bat -if(.%1)==(.nant) echo IF ERRORLEVEL 1 GOTO FAIL >> compile.bat - -if(.%3)==(.docs) echo echo ==== GENERATE DOCUMENTATION BEGIN ==== >> compile.bat -if(.%2)==(.docs) echo %SystemRoot%\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /p:Configuration=Release docs\Radegast.shfbproj >> compile.bat -if(.%2)==(.docs) echo IF ERRORLEVEL 1 GOTO FAIL >> compile.bat -if(.%2)==(.docs) echo 7z.exe a -tzip docs\documentation.zip docs\trunk >> compile.bat -if(.%2)==(.docs) echo IF ERRORLEVEL 1 GOTO FAIL >> compile.bat - -if(.%2)==(.runtests) echo echo ==== UNIT TESTS BEGIN ==== >> compile.bat -if(.%2)==(.runtests) echo nunit-console bin\Radegast.Tests.dll /exclude:Network /nodots /labels /xml:testresults.xml >> compile.bat - -if(.%2)==(.runtests) echo IF ERRORLEVEL 1 GOTO FAIL >> compile.bat - -if not (.%2)==(.dist) goto NODIST -echo echo ==== GENERATE DISTRIBUTION BEGIN ==== >> compile.bat -copy Radegast\radegast.nsi bin -echo del /q Radegast-*-installer.exe >> compile.bat -echo del /q radegast-latest.zip >> compile.bat - -if not exist "%PROGRAMFILES%\NSIS\Unicode\makensis.exe" goto NOUNINSIS -echo "%PROGRAMFILES%\NSIS\Unicode\makensis.exe" bin\radegast.nsi >> compile.bat -goto NONSIS -:NOUNINSIS - -if not exist "%PROGRAMFILES%\NSIS\makensis.exe" goto NONSIS -echo "%PROGRAMFILES%\NSIS\makensis.exe" bin\radegast.nsi >> compile.bat -:NONSIS - -echo cd bin >> compile.bat -echo 7z.exe a -r -tzip ..\radegast-latest.zip *.* >> compile.bat -echo cd .. >> compile.bat - -:NODIST - -echo :SUCCESS >> compile.bat -echo echo Build Successful! >> compile.bat -echo exit /B 0 >> compile.bat -echo :FAIL >> compile.bat -echo echo Build Failed, check log for reason >> compile.bat -echo exit /B 1 >> compile.bat - -:: perform the appropriate action -if(.%1)==(.msbuild) compile.bat -if(.%1)==(.nant) compile.bat -if(.%1)==(.dist) compile.bat - diff --git a/runprebuild2015.bat b/runprebuild2015.bat deleted file mode 100644 index ba39e560a..000000000 --- a/runprebuild2015.bat +++ /dev/null @@ -1,81 +0,0 @@ -@echo off -:: -:: Prebuild generator for the Radegast -:: -:: Command Line Options: -:: (none) - create solution/project files and create compile.bat file to build solution -:: msbuild - Create project files, compile solution -:: msbuild runtests - create project files, compile solution, run unit tests -:: msbuild docs - create project files, compile solution, build API documentation -:: msbuild docs dist - Create project files, compile solution, run unit tests, build api documentation, create binary zip -:: - and exe installer -:: -:: nant - Create project files, run nant to compile solution -:: nant runtests - Create project files, run nant to compile solution, run unit tests -:: - -echo ########################################## -echo creating prebuild files for: vs2015 -echo Parameters: %1 %2 -echo ########################################## - -if not exist bin mkdir bin - -:: run prebuild to generate solution/project files from prebuild.xml configuration file -Build\Windows\Premake5.exe vs2015 - -:: build compile.bat file based on command line parameters -echo @echo off > compile.bat -if(.%1)==(.) echo %SystemRoot%\Microsoft.NET\Framework\v4.0.30319\msbuild Radegast.sln >> compile.bat - -if(.%1)==(.msbuild) echo echo ==== COMPILE BEGIN ==== >> compile.bat -if(.%1)==(.msbuild) echo %SystemRoot%\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /p:Configuration=Release Radegast.sln >> compile.bat -if(.%1)==(.msbuild) echo IF ERRORLEVEL 1 GOTO FAIL >> compile.bat - -if(.%1)==(.nant) echo nant >> compile.bat -if(.%1)==(.nant) echo IF ERRORLEVEL 1 GOTO FAIL >> compile.bat - -if(.%3)==(.docs) echo echo ==== GENERATE DOCUMENTATION BEGIN ==== >> compile.bat -if(.%2)==(.docs) echo %SystemRoot%\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /p:Configuration=Release docs\Radegast.shfbproj >> compile.bat -if(.%2)==(.docs) echo IF ERRORLEVEL 1 GOTO FAIL >> compile.bat -if(.%2)==(.docs) echo 7z.exe a -tzip docs\documentation.zip docs\trunk >> compile.bat -if(.%2)==(.docs) echo IF ERRORLEVEL 1 GOTO FAIL >> compile.bat - -if(.%2)==(.runtests) echo echo ==== UNIT TESTS BEGIN ==== >> compile.bat -if(.%2)==(.runtests) echo nunit-console bin\Radegast.Tests.dll /exclude:Network /nodots /labels /xml:testresults.xml >> compile.bat - -if(.%2)==(.runtests) echo IF ERRORLEVEL 1 GOTO FAIL >> compile.bat - -if not (.%2)==(.dist) goto NODIST -echo echo ==== GENERATE DISTRIBUTION BEGIN ==== >> compile.bat -copy Radegast\radegast.nsi bin -echo del /q Radegast-*-installer.exe >> compile.bat -echo del /q radegast-latest.zip >> compile.bat - -if not exist "%PROGRAMFILES%\NSIS\Unicode\makensis.exe" goto NOUNINSIS -echo "%PROGRAMFILES%\NSIS\Unicode\makensis.exe" bin\radegast.nsi >> compile.bat -goto NONSIS -:NOUNINSIS - -if not exist "%PROGRAMFILES%\NSIS\makensis.exe" goto NONSIS -echo "%PROGRAMFILES%\NSIS\makensis.exe" bin\radegast.nsi >> compile.bat -:NONSIS - -echo cd bin >> compile.bat -echo 7z.exe a -r -tzip ..\radegast-latest.zip *.* >> compile.bat -echo cd .. >> compile.bat - -:NODIST - -echo :SUCCESS >> compile.bat -echo echo Build Successful! >> compile.bat -echo exit /B 0 >> compile.bat -echo :FAIL >> compile.bat -echo echo Build Failed, check log for reason >> compile.bat -echo exit /B 1 >> compile.bat - -:: perform the appropriate action -if(.%1)==(.msbuild) compile.bat -if(.%1)==(.nant) compile.bat -if(.%1)==(.dist) compile.bat - diff --git a/util/InstallRemotePfx.ps1 b/util/InstallRemotePfx.ps1 new file mode 100644 index 000000000..82f7e32e8 --- /dev/null +++ b/util/InstallRemotePfx.ps1 @@ -0,0 +1,28 @@ +<# + # Copyright (c) 2020, Sjofn LLC. All rights reserved. + # + # Permission to use, copy, modify, and/or distribute this script for any + # purpose without fee is hereby granted. + # + # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + #> + +param([String]$PfxDownloadUrl, [String]$PfxDownloadUser, [String]$PfxDownloadPasswd, [String]$PfxPasswd) +Write-Output "Downloading signing certificate..." + +$secure_pwd = ConvertTo-SecureString -String $PfxDownloadPasswd -AsPlainText -Force +$credential = New-Object System.Management.Automation.PSCredential ($PfxDownloadUser, $secure_pwd) + +Invoke-WebRequest -Uri $PfxDownloadUrl -Credential $credential -OutFile "tmp.pfx" + +Write-Output "Importing signing certificate..." +$secure_pwd = ConvertTo-SecureString -String $PfxPasswd -AsPlainText -Force +Import-PfxCertificate -FilePath "tmp.pfx" -CertStoreLocation cert://LocalMachine/My -Password $secure_pwd + +Remove-Item "tmp.pfx"