diff --git a/.gitignore b/.gitignore index 259148f..4a53f58 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,397 @@ *.exe *.out *.app + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.tlog +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio 6 auto-generated project file (contains which files were open etc.) +*.vbp + +# Visual Studio 6 workspace and project file (working project files containing files to include in project) +*.dsw +*.dsp + +# Visual Studio 6 technical files +*.ncb +*.aps + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# Visual Studio History (VSHistory) files +.vshistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +# VS Code files for those working on multiple tools +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +# Windows Installer files from build outputs +*.cab +*.msi +*.msix +*.msm +*.msp + +# JetBrains Rider +*.sln.iml \ No newline at end of file diff --git a/LevelEditor.rc b/LevelEditor.rc index ab74102..c25d139 100644 --- a/LevelEditor.rc +++ b/LevelEditor.rc @@ -52,7 +52,7 @@ END // Icon with lowest ID value placed first to ensure application icon // remains consistent on all systems. -MAINICON ICON "F:\Personal\NewEra\LevelEditor\LevelEditor.ico" +MAINICON ICON "LevelEditor.ico" #endif // ������� (������) resources ///////////////////////////////////////////////////////////////////////////// diff --git a/LevelEditor.vcxproj b/LevelEditor.vcxproj index ca0ab62..dee7501 100644 --- a/LevelEditor.vcxproj +++ b/LevelEditor.vcxproj @@ -186,7 +186,7 @@ Console true extlibs\lib\$(PlatformTarget);%(AdditionalLibraryDirectories) - sfml-network-s-d.lib;ws2_32.lib;sfml-audio-s-d.lib;ogg.lib;vorbis.lib;vorbisfile.lib;vorbisenc.lib;flac.lib;openal32.lib;sfml-graphics-s-d.lib;freetype.lib;sfml-window-s-d.lib;gdi32.lib;opengl32.lib;sfml-system-s-d.lib;winmm.lib;kernel32.lib;user32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + ws2_32.lib;sfml-audio-s-d.lib;ogg.lib;vorbis.lib;vorbisfile.lib;vorbisenc.lib;flac.lib;openal32.lib;sfml-graphics-s-d.lib;freetype.lib;sfml-window-s-d.lib;gdi32.lib;opengl32.lib;sfml-system-s-d.lib;winmm.lib;kernel32.lib;user32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) copy /Y "$(SolutionDir)extlibs\bin\$(PlatformTarget)\openal32.dll" "$(TargetDir)openal32.dll" @@ -209,7 +209,7 @@ copy /Y "$(SolutionDir)data" "$(TargetDir)Data\" Console true extlibs\lib\$(PlatformTarget) - sfml-network-d.lib;sfml-audio-d.lib;openal32.lib;sfml-graphics-d.lib;sfml-window-d.lib;sfml-system-d.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib + sfml-audio-d.lib;openal32.lib;sfml-graphics-d.lib;sfml-window-d.lib;sfml-system-d.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib @@ -242,7 +242,7 @@ xcopy /Y "$(SolutionDir)data" "$(TargetDir)Data\" true true extlibs\lib\$(PlatformTarget);%(AdditionalLibraryDirectories) - sfml-network-s.lib;ws2_32.lib;sfml-audio-s.lib;ogg.lib;vorbis.lib;vorbisfile.lib;vorbisenc.lib;flac.lib;openal32.lib;sfml-graphics-s.lib;freetype.lib;sfml-window-s.lib;gdi32.lib;opengl32.lib;sfml-system-s.lib;winmm.lib;kernel32.lib;user32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + ws2_32.lib;sfml-audio-s.lib;ogg.lib;vorbis.lib;vorbisfile.lib;vorbisenc.lib;flac.lib;openal32.lib;sfml-graphics-s.lib;freetype.lib;sfml-window-s.lib;gdi32.lib;opengl32.lib;sfml-system-s.lib;winmm.lib;kernel32.lib;user32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) copy /Y "$(SolutionDir)extlibs\bin\$(PlatformTarget)\openal32.dll" "$(TargetDir)openal32.dll" @@ -269,7 +269,7 @@ copy /Y "$(SolutionDir)resources" "$(TargetDir)resources\" true true extlibs\lib\$(PlatformTarget) - sfml-network.lib;sfml-audio.lib;openal32.lib;sfml-graphics.lib;sfml-window.lib;sfml-system.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + sfml-audio.lib;openal32.lib;sfml-graphics.lib;sfml-window.lib;sfml-system.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) copy /Y "$(SolutionDir)extlibs\bin\$(PlatformTarget)\sfml-audio-2.dll" "$(TargetDir)sfml-audio-2.dll" @@ -296,7 +296,7 @@ copy /Y "$(SolutionDir)resources" "$(TargetDir)resources\" Console true extlibs\lib\$(PlatformTarget);%(AdditionalLibraryDirectories) - sfml-network-s-d.lib;ws2_32.lib;sfml-audio-s-d.lib;ogg.lib;vorbis.lib;vorbisfile.lib;vorbisenc.lib;flac.lib;openal32.lib;sfml-graphics-s-d.lib;freetype.lib;sfml-window-s-d.lib;gdi32.lib;opengl32.lib;sfml-system-s-d.lib;winmm.lib;kernel32.lib;user32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + ws2_32.lib;sfml-audio-s-d.lib;ogg.lib;vorbis.lib;vorbisfile.lib;vorbisenc.lib;flac.lib;openal32.lib;sfml-graphics-s-d.lib;freetype.lib;sfml-window-s-d.lib;gdi32.lib;opengl32.lib;sfml-system-s-d.lib;winmm.lib;kernel32.lib;user32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) copy /Y "$(SolutionDir)extlibs\bin\$(PlatformTarget)\openal32.dll" "$(TargetDir)openal32.dll" @@ -319,7 +319,7 @@ copy /Y "$(SolutionDir)data" "$(TargetDir)Data\" Console true extlibs\lib\$(PlatformTarget) - sfml-network-d.lib;sfml-audio-d.lib;openal32.lib;sfml-graphics-d.lib;sfml-window-d.lib;sfml-system-d.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib + sfml-audio-d.lib;openal32.lib;sfml-graphics-d.lib;sfml-window-d.lib;sfml-system-d.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib xcopy /Y "$(SolutionDir)extlibs\bin\$(PlatformTarget)\sfml-audio-d-2.dll" "$(TargetDir)sfml-audio-d-2.dll" @@ -350,7 +350,7 @@ xcopy /Y "$(SolutionDir)data" "$(TargetDir)Data\" true true extlibs\lib\$(PlatformTarget);%(AdditionalLibraryDirectories) - sfml-network-s.lib;ws2_32.lib;sfml-audio-s.lib;ogg.lib;vorbis.lib;vorbisfile.lib;vorbisenc.lib;flac.lib;openal32.lib;sfml-graphics-s.lib;freetype.lib;sfml-window-s.lib;gdi32.lib;opengl32.lib;sfml-system-s.lib;winmm.lib;kernel32.lib;user32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + ws2_32.lib;sfml-audio-s.lib;ogg.lib;vorbis.lib;vorbisfile.lib;vorbisenc.lib;flac.lib;openal32.lib;sfml-graphics-s.lib;freetype.lib;sfml-window-s.lib;gdi32.lib;opengl32.lib;sfml-system-s.lib;winmm.lib;kernel32.lib;user32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) xcopy /Y "$(SolutionDir)extlibs\bin\$(PlatformTarget)\openal32.dll" "$(TargetDir)openal32.dll" @@ -376,7 +376,7 @@ xcopy /Y "$(SolutionDir)data" "$(TargetDir)Data\" true true extlibs\lib\$(PlatformTarget) - sfml-network.lib;sfml-audio.lib;openal32.lib;sfml-graphics.lib;sfml-window.lib;sfml-system.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + sfml-audio.lib;openal32.lib;sfml-graphics.lib;sfml-window.lib;sfml-system.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) xcopy /Y "$(SolutionDir)extlibs\bin\$(PlatformTarget)\sfml-audio-2.dll" "$(TargetDir)sfml-audio-2.dll" @@ -655,8 +655,6 @@ xcopy /Y "$(SolutionDir)data" "$(TargetDir)Data\" - - diff --git a/LevelEditor.vcxproj.filters b/LevelEditor.vcxproj.filters index 8101ddf..9097764 100644 --- a/LevelEditor.vcxproj.filters +++ b/LevelEditor.vcxproj.filters @@ -810,8 +810,6 @@ - - \ No newline at end of file diff --git a/data/Plugins/Settings.json b/data/Plugins/Settings.json index 528e419..6308d2f 100644 --- a/data/Plugins/Settings.json +++ b/data/Plugins/Settings.json @@ -6,8 +6,8 @@ "language": "English", "theme": "New", "layout": "Standard", - "musicVolume": 49.3007, - "soundVolume": 50, + "musicVolume": 8.69131, + "soundVolume": 8.54146, "usePrettyPrinting": true, "useTabs": true, "defaultFileLocation": "Saved" diff --git a/source/utility/dispatchers.hpp b/source/utility/dispatchers.hpp index 65ee65c..ab56bad 100644 --- a/source/utility/dispatchers.hpp +++ b/source/utility/dispatchers.hpp @@ -23,6 +23,77 @@ #include #include +const minijson::dispatcher vector2f_dispatcher +{ + minijson::handlers::handler("x", [](sf::Vector2f& vector, minijson::value v) { v.to(vector.x); }), + minijson::handlers::handler("y", [](sf::Vector2f& vector, minijson::value v) { v.to(vector.y); }), + minijson::handlers::ignore_any_handler {} +}; + +const minijson::dispatcher vector2u_dispatcher +{ + minijson::handlers::handler("x", [](sf::Vector2u& vector, minijson::value v) { v.to(vector.x); }), + minijson::handlers::handler("y", [](sf::Vector2u& vector, minijson::value v) { v.to(vector.y); }), + minijson::handlers::ignore_any_handler {} +}; + +const minijson::dispatcher intrect_dispatcher +{ + minijson::handlers::handler("left", [](sf::IntRect& rect, minijson::value v) { v.to(rect.left); }), + minijson::handlers::handler("top", [](sf::IntRect& rect, minijson::value v) { v.to(rect.top); }), + minijson::handlers::handler("width", [](sf::IntRect& rect, minijson::value v) { v.to(rect.width); }), + minijson::handlers::handler("height", [](sf::IntRect& rect, minijson::value v) { v.to(rect.height); }), + minijson::handlers::ignore_any_handler {} +}; + +const minijson::dispatcher color_dispatcher +{ + minijson::handlers::handler("r", [](sf::Color& color, minijson::value v) { v.to(color.r); }), + minijson::handlers::handler("g", [](sf::Color& color, minijson::value v) { v.to(color.g); }), + minijson::handlers::handler("b", [](sf::Color& color, minijson::value v) { v.to(color.b); }), + minijson::handlers::optional_handler("a", [](sf::Color& color, minijson::value v) { v.to(color.a); }), + minijson::handlers::ignore_any_handler {} +}; + +const minijson::dispatcher background_movement_dispatcher +{ + minijson::handlers::handler("enabled", [](bool& enabled, sf::Vector2f&, sf::Vector2f&, sf::Vector2f&, minijson::value v) { v.to(enabled); }), + minijson::handlers::optional_handler("min", [](bool&, sf::Vector2f& min, sf::Vector2f&, sf::Vector2f&, minijson::value, auto& context) { vector2f_dispatcher.run(context, min); }), + minijson::handlers::optional_handler("max", [](bool&, sf::Vector2f&, sf::Vector2f& max, sf::Vector2f&, minijson::value, auto& context) { vector2f_dispatcher.run(context, max); }), + minijson::handlers::optional_handler("step", [](bool&, sf::Vector2f&, sf::Vector2f&, sf::Vector2f& step, minijson::value, auto& context) { vector2f_dispatcher.run(context, step); }), + minijson::handlers::ignore_any_handler {} +}; + +const minijson::dispatcher vertex_dispatcher +{ + minijson::handlers::handler("x", [](sf::Vector2f& position, int&, minijson::value v) { v.to(position.x); }), + minijson::handlers::handler("y", [](sf::Vector2f& position, int&, minijson::value v) { v.to(position.y); }), + minijson::handlers::handler("scale", [](sf::Vector2f&, int& scale, minijson::value v) { v.to(scale); }), + minijson::handlers::ignore_any_handler {} +}; + +const minijson::dispatcher action_dispatcher +{ + minijson::handlers::handler("actionType", [](sf::String& action_type, std::vector&, minijson::value v) { action_type = v.raw().data(); }), + + minijson::handlers::handler( + "arguments", + [](sf::String&, std::vector& arguments, minijson::value, auto& context) + { + std::vector array_elements = std::vector(); + minijson::parse_array(context, [&](minijson::value v) + { + array_elements.push_back(toWide(v.raw())); + } + ); + + arguments = array_elements; + } + ), + + minijson::handlers::ignore_any_handler {} +}; + const minijson::dispatcher settings_dispatcher { minijson::handlers::handler("windowSize", [](ApplicationSettings& settings, minijson::value v) { v.to(settings.window_size); }), @@ -77,7 +148,7 @@ const minijson::dispatcher theme_dispatcher v.to(theme.toggle_animations); } ), - + minijson::handlers::handler( "shaders", [](EditorTheme& theme, minijson::value, auto& context) @@ -160,10 +231,10 @@ const minijson::dispatcher theme_dispatcher ); } ), - + minijson::handlers::handler( "textThemes", - [](EditorTheme& theme, minijson::value, auto& context) + [](EditorTheme& theme, minijson::value, auto& context) { parse_object(context, [&](std::string_view name, minijson::value, auto& inner_context) { @@ -174,7 +245,7 @@ const minijson::dispatcher theme_dispatcher ); } ), - + minijson::handlers::handler( "inputControlThemes", [](EditorTheme& theme, minijson::value, auto& context) @@ -229,11 +300,11 @@ const minijson::dispatcher control_theme_dispatcher const minijson::dispatcher text_theme_dispatcher { minijson::handlers::handler( - "horizontalAlignment", + "horizontalAlignment", [](EditorTheme&, TextTheme& textTheme, minijson::value v) { static std::unordered_map const table - = { + = { { "Center", TextTheme::TextHorizontalAlignment::Center }, { "Left", TextTheme::TextHorizontalAlignment::Left }, { "Right", TextTheme::TextHorizontalAlignment::Right } @@ -249,7 +320,7 @@ const minijson::dispatcher text_theme_dispatcher [](EditorTheme&, TextTheme& textTheme, minijson::value v) { static std::unordered_map const table - = { + = { { "Center", TextTheme::TextVerticalAlignment::Center }, { "Top", TextTheme::TextVerticalAlignment::Top }, { "Bottom", TextTheme::TextVerticalAlignment::Bottom } @@ -260,29 +331,20 @@ const minijson::dispatcher text_theme_dispatcher } ), - minijson::handlers::handler("font", [](EditorTheme& theme, TextTheme& textTheme, minijson::value v) { textTheme.font = theme.fonts[toWide(v.raw())]; }), - minijson::handlers::handler("fillDefaultColor", [](EditorTheme&, TextTheme& textTheme, minijson::value v, auto& ctx) { color_dispatcher.run(ctx, textTheme.fill_default_color); }), - minijson::handlers::handler("fillHoveringColor", [](EditorTheme&, TextTheme& textTheme, minijson::value v, auto& ctx) { color_dispatcher.run(ctx, textTheme.fill_hovering_color); }), - minijson::handlers::handler("fillHoldingColor", [](EditorTheme&, TextTheme& textTheme, minijson::value v, auto& ctx) { color_dispatcher.run(ctx, textTheme.fill_holding_color); }), - minijson::handlers::handler("fillDisabledColor", [](EditorTheme&, TextTheme& textTheme, minijson::value v, auto& ctx) { color_dispatcher.run(ctx, textTheme.fill_disabled_color); }), - minijson::handlers::handler("outlineDefaultColor", [](EditorTheme&, TextTheme& textTheme, minijson::value v, auto& ctx) { color_dispatcher.run(ctx, textTheme.outline_default_color); }), - minijson::handlers::handler("outlineHoveringColor", [](EditorTheme&, TextTheme& textTheme, minijson::value v, auto& ctx) { color_dispatcher.run(ctx, textTheme.outline_hovering_color); }), - minijson::handlers::handler("outlineHoldingColor", [](EditorTheme&, TextTheme& textTheme, minijson::value v, auto& ctx) { color_dispatcher.run(ctx, textTheme.outline_holding_color); }), - minijson::handlers::handler("outlineDisabledColor", [](EditorTheme&, TextTheme& textTheme, minijson::value v, auto& ctx) { color_dispatcher.run(ctx, textTheme.outline_disabled_color); }), - minijson::handlers::handler("characterSize", [](EditorTheme&, TextTheme& textTheme, minijson::value v) { v.to(textTheme.character_size); }), - minijson::handlers::handler("letterSpacing", [](EditorTheme&, TextTheme& textTheme, minijson::value v) { v.to(textTheme.letter_spacing); }), - minijson::handlers::handler("lineSpacing", [](EditorTheme&, TextTheme& textTheme, minijson::value v) { v.to(textTheme.line_spacing); }), - minijson::handlers::handler("outlineThickness", [](EditorTheme&, TextTheme& textTheme, minijson::value v) { v.to(textTheme.outline_thickness); }), - minijson::handlers::handler("style", [](EditorTheme&, TextTheme& textTheme, minijson::value v) { v.to(textTheme.style); }), - minijson::handlers::ignore_any_handler {} -}; - -const minijson::dispatcher color_dispatcher -{ - minijson::handlers::handler("r", [](sf::Color& color, minijson::value v) { v.to(color.r); }), - minijson::handlers::handler("g", [](sf::Color& color, minijson::value v) { v.to(color.g); }), - minijson::handlers::handler("b", [](sf::Color& color, minijson::value v) { v.to(color.b); }), - minijson::handlers::optional_handler("a", [](sf::Color& color, minijson::value v) { v.to(color.a); }), + minijson::handlers::handler("font", [](EditorTheme& theme, TextTheme& textTheme, minijson::value v) { textTheme.font = theme.fonts[toWide(v.raw())]; }), + minijson::handlers::handler("fillDefaultColor", [](EditorTheme&, TextTheme& textTheme, minijson::value v, auto& ctx) { color_dispatcher.run(ctx, textTheme.fill_default_color); }), + minijson::handlers::handler("fillHoveringColor", [](EditorTheme&, TextTheme& textTheme, minijson::value v, auto& ctx) { color_dispatcher.run(ctx, textTheme.fill_hovering_color); }), + minijson::handlers::handler("fillHoldingColor", [](EditorTheme&, TextTheme& textTheme, minijson::value v, auto& ctx) { color_dispatcher.run(ctx, textTheme.fill_holding_color); }), + minijson::handlers::handler("fillDisabledColor", [](EditorTheme&, TextTheme& textTheme, minijson::value v, auto& ctx) { color_dispatcher.run(ctx, textTheme.fill_disabled_color); }), + minijson::handlers::handler("outlineDefaultColor", [](EditorTheme&, TextTheme& textTheme, minijson::value v, auto& ctx) { color_dispatcher.run(ctx, textTheme.outline_default_color); }), + minijson::handlers::handler("outlineHoveringColor", [](EditorTheme&, TextTheme& textTheme, minijson::value v, auto& ctx) { color_dispatcher.run(ctx, textTheme.outline_hovering_color); }), + minijson::handlers::handler("outlineHoldingColor", [](EditorTheme&, TextTheme& textTheme, minijson::value v, auto& ctx) { color_dispatcher.run(ctx, textTheme.outline_holding_color); }), + minijson::handlers::handler("outlineDisabledColor", [](EditorTheme&, TextTheme& textTheme, minijson::value v, auto& ctx) { color_dispatcher.run(ctx, textTheme.outline_disabled_color); }), + minijson::handlers::handler("characterSize", [](EditorTheme&, TextTheme& textTheme, minijson::value v) { v.to(textTheme.character_size); }), + minijson::handlers::handler("letterSpacing", [](EditorTheme&, TextTheme& textTheme, minijson::value v) { v.to(textTheme.letter_spacing); }), + minijson::handlers::handler("lineSpacing", [](EditorTheme&, TextTheme& textTheme, minijson::value v) { v.to(textTheme.line_spacing); }), + minijson::handlers::handler("outlineThickness", [](EditorTheme&, TextTheme& textTheme, minijson::value v) { v.to(textTheme.outline_thickness); }), + minijson::handlers::handler("style", [](EditorTheme&, TextTheme& textTheme, minijson::value v) { v.to(textTheme.style); }), minijson::handlers::ignore_any_handler {} }; @@ -311,12 +373,12 @@ inline void setCursor(sf::Cursor* cursor, minijson::value v) const minijson::dispatcher input_control_theme_dispatcher { - minijson::handlers::handler("mouseCursorDefault", [](EditorTheme&, InputControlTheme& input_control_theme, minijson::value v) { setCursor(input_control_theme.mouse_cursor_default, v); }), - minijson::handlers::handler("mouseCursorText", [](EditorTheme&, InputControlTheme& input_control_theme, minijson::value v) { setCursor(input_control_theme.mouse_cursor_text, v); }), - minijson::handlers::handler("cursorWidth", [](EditorTheme&, InputControlTheme& input_control_theme, minijson::value v) { v.to(input_control_theme.cursor_width); }), - minijson::handlers::handler("cursorColor", [](EditorTheme&, InputControlTheme& input_control_theme, minijson::value, auto& ctx) { color_dispatcher.run(ctx, input_control_theme.cursor_color); }), - minijson::handlers::handler("selectionColor", [](EditorTheme&, InputControlTheme& input_control_theme, minijson::value, auto& ctx) { color_dispatcher.run(ctx, input_control_theme.selection_color); }), - minijson::handlers::optional_handler("inputSound", [](EditorTheme& theme, InputControlTheme& input_control_theme, minijson::value v) { input_control_theme.input_sound = toWide(v.raw()); }), + minijson::handlers::handler("mouseCursorDefault", [](EditorTheme&, InputControlTheme& input_control_theme, minijson::value v) { setCursor(input_control_theme.mouse_cursor_default, v); }), + minijson::handlers::handler("mouseCursorText", [](EditorTheme&, InputControlTheme& input_control_theme, minijson::value v) { setCursor(input_control_theme.mouse_cursor_text, v); }), + minijson::handlers::handler("cursorWidth", [](EditorTheme&, InputControlTheme& input_control_theme, minijson::value v) { v.to(input_control_theme.cursor_width); }), + minijson::handlers::handler("cursorColor", [](EditorTheme&, InputControlTheme& input_control_theme, minijson::value, auto& ctx) { color_dispatcher.run(ctx, input_control_theme.cursor_color); }), + minijson::handlers::handler("selectionColor", [](EditorTheme&, InputControlTheme& input_control_theme, minijson::value, auto& ctx) { color_dispatcher.run(ctx, input_control_theme.selection_color); }), + minijson::handlers::optional_handler("inputSound", [](EditorTheme& theme, InputControlTheme& input_control_theme, minijson::value v) { input_control_theme.input_sound = toWide(v.raw()); }), minijson::handlers::ignore_any_handler {} }; @@ -359,7 +421,7 @@ const minijson::dispatcher layout_dispatcher const minijson::dispatcher scene_dispatcher { minijson::handlers::handler( - "background", + "background", [](Application&, SoundHandler&, ApplicationSettings&, EditorTheme& theme, sf::RenderWindow& window, sf::Vector2u, Scene& scene, std::map*, minijson::value v) { sf::String key = toWide(v.raw()); @@ -398,7 +460,7 @@ const minijson::dispatcher scene_dispatcher parse_object(context, [&](std::string_view name, minijson::value, auto& inner_context) { sf::String key = toWide(name); - ControlConstructor constructor = ControlConstructor + ControlConstructor constructor = ControlConstructor { .window = &window, .intended_resolution = intended_resolution, @@ -419,60 +481,51 @@ const minijson::dispatcher scene_dispatcher minijson::handlers::ignore_any_handler {} }; -const minijson::dispatcher background_movement_dispatcher -{ - minijson::handlers::handler("enabled", [](bool& enabled, sf::Vector2f&, sf::Vector2f&, sf::Vector2f&, minijson::value v) { v.to(enabled); }), - minijson::handlers::optional_handler("min", [](bool&, sf::Vector2f& min, sf::Vector2f&, sf::Vector2f&, minijson::value, auto& context) { vector2f_dispatcher.run(context, min); }), - minijson::handlers::optional_handler("max", [](bool&, sf::Vector2f&, sf::Vector2f& max, sf::Vector2f&, minijson::value, auto& context) { vector2f_dispatcher.run(context, max); }), - minijson::handlers::optional_handler("step", [](bool&, sf::Vector2f&, sf::Vector2f&, sf::Vector2f& step, minijson::value, auto& context) { vector2f_dispatcher.run(context, step); }), - minijson::handlers::ignore_any_handler {} -}; - const minijson::dispatcher control_dispatcher { - minijson::handlers::handler("controlType", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value v) { constructor.control_type = v.raw().data(); }), - minijson::handlers::handler("theme", [](Application&, EditorTheme& theme, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value v) { constructor.theme = &theme.control_themes[toWide(v.raw())]; }), - minijson::handlers::handler("position", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value, auto& context) { vector2f_dispatcher.run(context, constructor.position); }), - minijson::handlers::handler("size", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value, auto& context) { vector2f_dispatcher.run(context, constructor.size); }), - minijson::handlers::optional_handler("visible", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value v) { v.to(constructor.visible); }), - minijson::handlers::optional_handler("enabled", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value v) { v.to(constructor.enabled); }), - minijson::handlers::optional_handler("bgRect", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value, auto& context) { intrect_dispatcher.run(context, constructor.bg_rect); }), - minijson::handlers::optional_handler("bgActiveRect", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value, auto& context) { intrect_dispatcher.run(context, constructor.bg_active_rect); }), - minijson::handlers::optional_handler("textTheme", [](Application&, EditorTheme& theme, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value v) { constructor.text_theme = &theme.text_themes[toWide(v.raw())]; }), - minijson::handlers::optional_handler("inputControlTheme", [](Application&, EditorTheme& theme, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value v) { constructor.input_control_theme = &theme.input_control_themes[toWide(v.raw())]; }), - minijson::handlers::optional_handler("checked", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value v) { v.to(constructor.checked); }), - minijson::handlers::optional_handler("text", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value v) { constructor.text = v.raw().data(); }), - minijson::handlers::optional_handler("buttonSize", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value, auto& context) { vector2f_dispatcher.run(context, constructor.button_size); }), - minijson::handlers::optional_handler("firstButtonBgRect", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value, auto& context) { intrect_dispatcher.run(context, constructor.first_button_bg_rect); }), - minijson::handlers::optional_handler("firstButtonBgFocusedRect", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value, auto& context) { intrect_dispatcher.run(context, constructor.first_button_bg_focused_rect); }), - minijson::handlers::optional_handler("secondButtonBgRect", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value, auto& context) { intrect_dispatcher.run(context, constructor.second_button_bg_rect); }), - minijson::handlers::optional_handler("secondButtonBgFocusedRect", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value, auto& context) { intrect_dispatcher.run(context, constructor.second_button_bg_focused_rect); }), - minijson::handlers::optional_handler("min", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value v) { v.to(constructor.min); }), - minijson::handlers::optional_handler("max", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value v) { v.to(constructor.max); }), - minijson::handlers::optional_handler("step", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value v) { v.to(constructor.step); }), - minijson::handlers::optional_handler("value", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value v) { v.to(constructor.value); }), - minijson::handlers::optional_handler("buttonOffset", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value v) { v.to(constructor.button_offset); }), - minijson::handlers::optional_handler("index", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value v) { v.to(constructor.index); }), - minijson::handlers::optional_handler("scrollTime", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value v) { v.to(constructor.scroll_time); }), - minijson::handlers::optional_handler("thumbSize", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value, auto& context) { vector2f_dispatcher.run(context, constructor.thumb_size); }), - minijson::handlers::optional_handler("thumbRect", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map* ,ControlConstructor& constructor, minijson::value, auto& context) { intrect_dispatcher.run(context, constructor.thumb_rect); }), - minijson::handlers::optional_handler("vertical", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value v) { v.to(constructor.vertical); }), - minijson::handlers::optional_handler("scrollMultiplier", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value v) { v.to(constructor.scroll_multiplier); }), - minijson::handlers::optional_handler("createButtonPosition", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value, auto& context) { vector2f_dispatcher.run(context, constructor.create_button_position); }), - minijson::handlers::optional_handler("createButtonSize", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value, auto& context) { vector2f_dispatcher.run(context, constructor.create_button_size); }), - minijson::handlers::optional_handler("createButtonBgRect", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value, auto& context) { intrect_dispatcher.run(context, constructor.create_button_bg); }), - minijson::handlers::optional_handler("createButtonBgFocusedRect", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value, auto& context) { intrect_dispatcher.run(context, constructor.create_button_bg_focused); }), - minijson::handlers::optional_handler("createButtonText", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value v) { constructor.create_button_text = v.raw().data(); }), - minijson::handlers::optional_handler("sliderPosition", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value, auto& context) { vector2f_dispatcher.run(context, constructor.slider_position); }), - minijson::handlers::optional_handler("sliderSize", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value, auto& context) { vector2f_dispatcher.run(context, constructor.slider_size); }), - minijson::handlers::optional_handler("sliderBgRect", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value, auto& context) { intrect_dispatcher.run(context, constructor.slider_bg); }), - minijson::handlers::optional_handler("sliderBgFocusedRect", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value, auto& context) { intrect_dispatcher.run(context, constructor.slider_bg_focused); }), - minijson::handlers::optional_handler("sliderThumbSize", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value, auto& context) { vector2f_dispatcher.run(context, constructor.slider_thumb_size); }), - minijson::handlers::optional_handler("sliderThumb", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value, auto& context) { intrect_dispatcher.run(context, constructor.slider_thumb); }), - minijson::handlers::optional_handler("rowOffset", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value v) { v.to(constructor.row_offset); }), - minijson::handlers::optional_handler("rotationAngle", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value v) { v.to(constructor.rotation_angle); }), - minijson::handlers::optional_handler("minYPosition", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value v) { v.to(constructor.min_y_position); }), - + minijson::handlers::handler("controlType", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value v) { constructor.control_type = v.raw().data(); }), + minijson::handlers::handler("theme", [](Application&, EditorTheme& theme, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value v) { constructor.theme = &theme.control_themes[toWide(v.raw())]; }), + minijson::handlers::handler("position", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value, auto& context) { vector2f_dispatcher.run(context, constructor.position); }), + minijson::handlers::handler("size", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value, auto& context) { vector2f_dispatcher.run(context, constructor.size); }), + minijson::handlers::optional_handler("visible", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value v) { v.to(constructor.visible); }), + minijson::handlers::optional_handler("enabled", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value v) { v.to(constructor.enabled); }), + minijson::handlers::optional_handler("bgRect", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value, auto& context) { intrect_dispatcher.run(context, constructor.bg_rect); }), + minijson::handlers::optional_handler("bgActiveRect", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value, auto& context) { intrect_dispatcher.run(context, constructor.bg_active_rect); }), + minijson::handlers::optional_handler("textTheme", [](Application&, EditorTheme& theme, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value v) { constructor.text_theme = &theme.text_themes[toWide(v.raw())]; }), + minijson::handlers::optional_handler("inputControlTheme", [](Application&, EditorTheme& theme, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value v) { constructor.input_control_theme = &theme.input_control_themes[toWide(v.raw())]; }), + minijson::handlers::optional_handler("checked", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value v) { v.to(constructor.checked); }), + minijson::handlers::optional_handler("text", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value v) { constructor.text = v.raw().data(); }), + minijson::handlers::optional_handler("buttonSize", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value, auto& context) { vector2f_dispatcher.run(context, constructor.button_size); }), + minijson::handlers::optional_handler("firstButtonBgRect", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value, auto& context) { intrect_dispatcher.run(context, constructor.first_button_bg_rect); }), + minijson::handlers::optional_handler("firstButtonBgFocusedRect", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value, auto& context) { intrect_dispatcher.run(context, constructor.first_button_bg_focused_rect); }), + minijson::handlers::optional_handler("secondButtonBgRect", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value, auto& context) { intrect_dispatcher.run(context, constructor.second_button_bg_rect); }), + minijson::handlers::optional_handler("secondButtonBgFocusedRect", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value, auto& context) { intrect_dispatcher.run(context, constructor.second_button_bg_focused_rect); }), + minijson::handlers::optional_handler("min", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value v) { v.to(constructor.min); }), + minijson::handlers::optional_handler("max", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value v) { v.to(constructor.max); }), + minijson::handlers::optional_handler("step", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value v) { v.to(constructor.step); }), + minijson::handlers::optional_handler("value", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value v) { v.to(constructor.value); }), + minijson::handlers::optional_handler("buttonOffset", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value v) { v.to(constructor.button_offset); }), + minijson::handlers::optional_handler("index", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value v) { v.to(constructor.index); }), + minijson::handlers::optional_handler("scrollTime", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value v) { v.to(constructor.scroll_time); }), + minijson::handlers::optional_handler("thumbSize", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value, auto& context) { vector2f_dispatcher.run(context, constructor.thumb_size); }), + minijson::handlers::optional_handler("thumbRect", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map* ,ControlConstructor& constructor, minijson::value, auto& context) { intrect_dispatcher.run(context, constructor.thumb_rect); }), + minijson::handlers::optional_handler("vertical", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value v) { v.to(constructor.vertical); }), + minijson::handlers::optional_handler("scrollMultiplier", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value v) { v.to(constructor.scroll_multiplier); }), + minijson::handlers::optional_handler("createButtonPosition", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value, auto& context) { vector2f_dispatcher.run(context, constructor.create_button_position); }), + minijson::handlers::optional_handler("createButtonSize", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value, auto& context) { vector2f_dispatcher.run(context, constructor.create_button_size); }), + minijson::handlers::optional_handler("createButtonBgRect", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value, auto& context) { intrect_dispatcher.run(context, constructor.create_button_bg); }), + minijson::handlers::optional_handler("createButtonBgFocusedRect", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value, auto& context) { intrect_dispatcher.run(context, constructor.create_button_bg_focused); }), + minijson::handlers::optional_handler("createButtonText", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value v) { constructor.create_button_text = v.raw().data(); }), + minijson::handlers::optional_handler("sliderPosition", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value, auto& context) { vector2f_dispatcher.run(context, constructor.slider_position); }), + minijson::handlers::optional_handler("sliderSize", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value, auto& context) { vector2f_dispatcher.run(context, constructor.slider_size); }), + minijson::handlers::optional_handler("sliderBgRect", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value, auto& context) { intrect_dispatcher.run(context, constructor.slider_bg); }), + minijson::handlers::optional_handler("sliderBgFocusedRect", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value, auto& context) { intrect_dispatcher.run(context, constructor.slider_bg_focused); }), + minijson::handlers::optional_handler("sliderThumbSize", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value, auto& context) { vector2f_dispatcher.run(context, constructor.slider_thumb_size); }), + minijson::handlers::optional_handler("sliderThumb", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value, auto& context) { intrect_dispatcher.run(context, constructor.slider_thumb); }), + minijson::handlers::optional_handler("rowOffset", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value v) { v.to(constructor.row_offset); }), + minijson::handlers::optional_handler("rotationAngle", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value v) { v.to(constructor.rotation_angle); }), + minijson::handlers::optional_handler("minYPosition", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value v) { v.to(constructor.min_y_position); }), + minijson::handlers::optional_handler( "rowConstructors", [](Application& application, EditorTheme& theme, sf::RenderWindow& window, Scene& scene, std::map* strings, ControlConstructor& constructor, minijson::value, auto& context) @@ -480,7 +533,7 @@ const minijson::dispatcher control_dispatcher std::vector array_elements = std::vector(); minijson::parse_array(context, [&](minijson::value, auto& context) { - ControlConstructor constructor = ControlConstructor { .window = &window, .strings = strings }; + ControlConstructor constructor = ControlConstructor {.window = &window, .strings = strings }; control_dispatcher.run(context, application, theme, window, scene, strings, constructor); array_elements.push_back(constructor); } @@ -499,7 +552,7 @@ const minijson::dispatcher control_dispatcher control_dispatcher.run(context, application, theme, window, scene, strings, *constructor.row_erase_button); } ), - + minijson::handlers::optional_handler( "items", [](Application&, EditorTheme&, sf::RenderWindow&, Scene&, std::map*, ControlConstructor& constructor, minijson::value, auto& context) @@ -519,7 +572,7 @@ const minijson::dispatcher control_dispatcher minijson::handlers::optional_handler( "action", [](Application& application, EditorTheme&, sf::RenderWindow&, Scene& scene, std::map*, ControlConstructor& constructor, minijson::value, auto& context) - { + { sf::String action_type; std::vector arguments; action_dispatcher.run(context, action_type, arguments); @@ -542,14 +595,14 @@ const minijson::dispatcher control_dispatcher { application.loadSettings(arguments); } - else + else { auto it = std::find(arguments.begin(), arguments.end(), "update_window"); if (it != arguments.end()) { application.updateIfDirty(); } - + it = std::find(arguments.begin(), arguments.end(), "open_level"); if (it != arguments.end()) { @@ -686,7 +739,7 @@ const minijson::dispatcher control_dispatcher control->setEnabled(!enabled); }; constructor.action_numeric = [&application, arguments](long double v) { application.getControl(arguments[0])->setEnabled(v > 1); }; - constructor.action_boolean = [&application, arguments](bool v) + constructor.action_boolean = [&application, arguments](bool v) { for (std::string argument : arguments) { @@ -725,57 +778,4 @@ const minijson::dispatcher control_dispatcher minijson::handlers::ignore_any_handler {} }; -const minijson::dispatcher vector2f_dispatcher -{ - minijson::handlers::handler("x", [](sf::Vector2f& vector, minijson::value v) { v.to(vector.x); }), - minijson::handlers::handler("y", [](sf::Vector2f& vector, minijson::value v) { v.to(vector.y); }), - minijson::handlers::ignore_any_handler {} -}; - -const minijson::dispatcher vector2u_dispatcher -{ - minijson::handlers::handler("x", [](sf::Vector2u& vector, minijson::value v) { v.to(vector.x); }), - minijson::handlers::handler("y", [](sf::Vector2u& vector, minijson::value v) { v.to(vector.y); }), - minijson::handlers::ignore_any_handler {} -}; - -const minijson::dispatcher intrect_dispatcher -{ - minijson::handlers::handler("left", [](sf::IntRect& rect, minijson::value v) { v.to(rect.left); }), - minijson::handlers::handler("top", [](sf::IntRect& rect, minijson::value v) { v.to(rect.top); }), - minijson::handlers::handler("width", [](sf::IntRect& rect, minijson::value v) { v.to(rect.width); }), - minijson::handlers::handler("height", [](sf::IntRect& rect, minijson::value v) { v.to(rect.height); }), - minijson::handlers::ignore_any_handler {} -}; - -const minijson::dispatcher vertex_dispatcher -{ - minijson::handlers::handler("x", [](sf::Vector2f& position, int&, minijson::value v) { v.to(position.x); }), - minijson::handlers::handler("y", [](sf::Vector2f& position, int&, minijson::value v) { v.to(position.y); }), - minijson::handlers::handler("scale", [](sf::Vector2f&, int& scale, minijson::value v) { v.to(scale); }), - minijson::handlers::ignore_any_handler {} -}; - -const minijson::dispatcher action_dispatcher -{ - minijson::handlers::handler("actionType", [](sf::String& action_type, std::vector&, minijson::value v) { action_type = v.raw().data(); }), - - minijson::handlers::handler( - "arguments", - [](sf::String&, std::vector& arguments, minijson::value, auto& context) - { - std::vector array_elements = std::vector(); - minijson::parse_array(context, [&](minijson::value v) - { - array_elements.push_back(toWide(v.raw())); - } - ); - - arguments = array_elements; - } - ), - - minijson::handlers::ignore_any_handler {} -}; - #endif \ No newline at end of file