├── .gitignore ├── CoherentUI └── Copyright.txt ├── Prebuilt ├── Bin32 │ ├── CryGame.dll │ └── Plugins │ │ ├── CoherentUI │ │ └── Plugin_CoherentUI.dll │ │ ├── D3D │ │ └── Plugin_D3D.dll │ │ └── Plugin_Manager.dll └── Bin64 │ ├── CryGame.dll │ └── Plugins │ ├── CoherentUI │ └── Plugin_CoherentUI.dll │ ├── D3D │ └── Plugin_D3D.dll │ └── Plugin_Manager.dll ├── README.md ├── authors.txt ├── changelog.md ├── inc ├── IPluginCoherentUI.h └── rapidjson │ ├── _license.txt │ ├── _readme.txt │ ├── document.h │ ├── filestream.h │ ├── internal │ ├── pow10.h │ ├── stack.h │ └── strfunc.h │ ├── prettywriter.h │ ├── rapidjson.h │ ├── reader.h │ ├── stringbuffer.h │ └── writer.h ├── license.txt ├── project ├── CoherentUI.vcxproj ├── CoherentUI.vcxproj.filters ├── Plugin_CoherentUI.sln ├── resource.h └── version.rc ├── samples ├── Code │ ├── GameSDK │ │ └── GameDll │ │ │ ├── Game.cpp │ │ │ ├── Game.h │ │ │ ├── GameDllSDK.vcxproj │ │ │ ├── GameStartup.cpp │ │ │ └── GameStartup.h │ └── Solutions │ │ └── CryEngine_GameCodeOnly_CoherentUI.sln ├── GameSDK │ ├── Levels │ │ └── Singleplayer │ │ │ └── ForestCOUI │ │ │ ├── CoUIFlowGraph.xml │ │ │ ├── ForestCOUI.bak2 │ │ │ ├── ForestCOUI.cry │ │ │ ├── Layers │ │ │ ├── AB1.lyr │ │ │ ├── AB1 │ │ │ │ ├── AB1_Art.lyr │ │ │ │ ├── AB1_Art │ │ │ │ │ ├── AB1_Lighting.lyr │ │ │ │ │ └── AB1_Lighting │ │ │ │ │ │ └── AB1_Ropes.lyr │ │ │ │ ├── AB1_High_Spec.lyr │ │ │ │ ├── AB1_Logic.lyr │ │ │ │ └── AB1_Navigation.lyr │ │ │ ├── AB2.lyr │ │ │ ├── AB2 │ │ │ │ ├── AB2_Art.lyr │ │ │ │ ├── AB2_Lighting.lyr │ │ │ │ ├── AB2_Logic.lyr │ │ │ │ └── AB2_Navigation.lyr │ │ │ ├── AB3.lyr │ │ │ ├── AB3 │ │ │ │ ├── AB3_Art.lyr │ │ │ │ ├── AB3_Art │ │ │ │ │ ├── AB3_Lighting.lyr │ │ │ │ │ └── AB3_Lighting │ │ │ │ │ │ └── AB3_Ropes.lyr │ │ │ │ ├── AB3_Logic.lyr │ │ │ │ └── AB3_Navigation.lyr │ │ │ ├── AB4.lyr │ │ │ ├── AB4 │ │ │ │ ├── AB4_Art.lyr │ │ │ │ ├── AB4_Art │ │ │ │ │ ├── AB4_Lighting.lyr │ │ │ │ │ └── AB4_Lighting │ │ │ │ │ │ └── AB4_Ropes.lyr │ │ │ │ ├── AB4_Logic.lyr │ │ │ │ └── AB4_Navigation.lyr │ │ │ ├── Boundary_Collision.lyr │ │ │ ├── Music.lyr │ │ │ ├── Night_lightsetup.lyr │ │ │ ├── NonStreamed.lyr │ │ │ ├── Particles.lyr │ │ │ └── Sound.lyr │ │ │ ├── LevelData │ │ │ ├── Environment.xml │ │ │ ├── GameTokens.xml │ │ │ ├── Heightmap.dat │ │ │ ├── TerrainTexture.xml │ │ │ ├── TimeOfDay.xml │ │ │ └── VegetationMap.dat │ │ │ ├── filelist.xml │ │ │ ├── level.pak │ │ │ ├── tags.txt │ │ │ └── terraintexture.pak │ ├── Libs │ │ └── UI │ │ │ ├── css │ │ │ ├── coherent.css │ │ │ ├── compass.css │ │ │ ├── fonts.css │ │ │ ├── map.css │ │ │ ├── openlayers_default_style.css │ │ │ └── tips.css │ │ │ ├── fonts │ │ │ └── Audiowide.woff │ │ │ ├── hud.html │ │ │ ├── img │ │ │ ├── Coherent UI - icon.png │ │ │ ├── Forest.jpg │ │ │ ├── digits.png │ │ │ ├── gadget_center.png │ │ │ ├── gadget_inner.png │ │ │ ├── gadget_outer.png │ │ │ ├── icon.png │ │ │ └── scope.png │ │ │ └── js │ │ │ ├── OpenLayers │ │ │ ├── OpenLayers.js │ │ │ ├── img │ │ │ │ ├── layer-switcher-maximize.png │ │ │ │ ├── layer-switcher-minimize.png │ │ │ │ ├── marker.png │ │ │ │ └── marker_default.png │ │ │ └── theme │ │ │ │ └── default │ │ │ │ └── style.css │ │ │ ├── backbone │ │ │ └── backbone-min.js │ │ │ ├── coherent.js │ │ │ ├── compass.js │ │ │ ├── jquery.sparkline.min.js │ │ │ ├── jquery │ │ │ └── jquery-1.7.2.min.js │ │ │ ├── map.js │ │ │ ├── oscilloscope.js │ │ │ ├── player.js │ │ │ ├── tips.js │ │ │ └── underscore │ │ │ └── underscore-min.js │ └── Objects │ │ ├── curve.cgf │ │ ├── jointedBreakable_example.cgf │ │ ├── placeholder_1024_576.mtl │ │ ├── placeholder_1024_768.mtl │ │ ├── placeholder_nomips_argb_1024_576_dxt1.dds │ │ ├── placeholder_nomips_argb_1024_768_dxt1.dds │ │ ├── placeholder_nomips_argb_1280_720_dxt1.dds │ │ └── placeholder_nomips_argb_1280_960_dxt1.dds └── curve.obj ├── src ├── CPluginCoherentUI.cpp ├── CPluginCoherentUI.h ├── CPluginCoherentUIModule.cpp ├── CoherentGeometry.cpp ├── CoherentGeometry.h ├── CoherentHUDViewListener.cpp ├── CoherentHUDViewListener.h ├── CoherentInputEventListener.cpp ├── CoherentInputEventListener.h ├── CoherentPlayerEventListener.cpp ├── CoherentPlayerEventListener.h ├── CoherentSystemEventListener.cpp ├── CoherentSystemEventListener.h ├── CoherentUISystem.cpp ├── CoherentUISystem.h ├── CoherentViewListener.cpp ├── CoherentViewListener.h ├── Flownodes │ ├── CFlowCUIHandleEvent.cpp │ ├── CFlowCUIOutputEntityNode.cpp │ ├── CFlowCUIOutputHUD.cpp │ ├── CFlowCUISendTokens.cpp │ ├── CFlowCUISetInput.cpp │ ├── CFlowCUITriggerEvent.cpp │ └── CFlowCUITriggerEventFloat.cpp ├── FullscreenTriangleDrawer.cpp ├── FullscreenTriangleDrawer.h ├── PakFileHandler.cpp ├── PakFileHandler.h ├── StdAfx.cpp ├── StdAfx.h └── ViewConfig.h └── tools ├── CoherentUI_Installer.nsi ├── _astyle.exe ├── _stylehelper.bat ├── build.bat ├── build_installer.bat ├── codestyle.astylerc └── stylecode.bat /.gitignore: -------------------------------------------------------------------------------- 1 | ################# 2 | # CoherentUI SDK Redist 3 | ################# 4 | 5 | CoherentUI/* 6 | !CoherentUI/*.txt 7 | 8 | ################# 9 | ## Eclipse 10 | ################# 11 | 12 | *.pydevproject 13 | .project 14 | .metadata 15 | bin/ 16 | tmp/ 17 | *.tmp 18 | *.bak 19 | *.swp 20 | *~.nib 21 | local.properties 22 | .classpath 23 | .settings/ 24 | .loadpath 25 | 26 | # External tool builders 27 | .externalToolBuilders/ 28 | 29 | # Locally stored "Eclipse launch configurations" 30 | *.launch 31 | 32 | # CDT-specific 33 | .cproject 34 | 35 | # PDT-specific 36 | .buildpath 37 | 38 | 39 | ################# 40 | ## Visual Studio 41 | ################# 42 | 43 | ## Ignore Visual Studio temporary files, build results, and 44 | ## files generated by popular Visual Studio add-ons. 45 | 46 | # User-specific files 47 | *.suo 48 | *.user 49 | *.sln.docstates 50 | 51 | # Build results 52 | [Dd]ebug/ 53 | [Rr]elease/ 54 | *_i.c 55 | *_p.c 56 | *.ilk 57 | *.meta 58 | *.pch 59 | *.pdb 60 | *.pgc 61 | *.pgd 62 | *.rsp 63 | *.sbr 64 | *.tlb 65 | *.tli 66 | *.tlh 67 | *.tmp 68 | *.vspscc 69 | .builds 70 | *.dotCover 71 | 72 | ## TODO: If you have NuGet Package Restore enabled, uncomment this 73 | #packages/ 74 | 75 | # Visual C++ cache files 76 | ipch/ 77 | *.aps 78 | *.ncb 79 | *.opensdf 80 | *.sdf 81 | 82 | # Visual Studio profiler 83 | *.psess 84 | *.vsp 85 | 86 | # ReSharper is a .NET coding add-in 87 | _ReSharper* 88 | 89 | # Installshield output folder 90 | [Ee]xpress 91 | 92 | # DocProject is a documentation generator add-in 93 | DocProject/buildhelp/ 94 | DocProject/Help/*.HxT 95 | DocProject/Help/*.HxC 96 | DocProject/Help/*.hhc 97 | DocProject/Help/*.hhk 98 | DocProject/Help/*.hhp 99 | DocProject/Help/Html2 100 | DocProject/Help/html 101 | 102 | # Click-Once directory 103 | publish 104 | 105 | # Others 106 | [Bb]in 107 | sql 108 | TestResults 109 | *.Cache 110 | ClientBin 111 | stylecop.* 112 | ~$* 113 | *.dbmdl 114 | Generated_Code #added for RIA/Silverlight projects 115 | 116 | # Backup & report files from converting an old project file to a newer 117 | # Visual Studio version. Backup files are not needed, because we have git ;-) 118 | _UpgradeReport_Files/ 119 | Backup*/ 120 | UpgradeLog*.XML 121 | 122 | 123 | 124 | ############ 125 | ## Windows 126 | ############ 127 | 128 | # Windows image file caches 129 | Thumbs.db 130 | 131 | # Folder config file 132 | Desktop.ini 133 | 134 | 135 | ############# 136 | ## Python 137 | ############# 138 | 139 | *.py[co] 140 | 141 | # Packages 142 | *.egg 143 | *.egg-info 144 | dist 145 | build 146 | eggs 147 | parts 148 | bin 149 | var 150 | sdist 151 | develop-eggs 152 | .installed.cfg 153 | 154 | # Installer logs 155 | pip-log.txt 156 | 157 | # Unit test / coverage reports 158 | .coverage 159 | .tox 160 | 161 | #Translations 162 | *.mo 163 | 164 | #Mr Developer 165 | .mr.developer.cfg 166 | 167 | # Mac crap 168 | .DS_Store 169 | -------------------------------------------------------------------------------- /CoherentUI/Copyright.txt: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Coherent UI, modern user interface library for 3 | games. Release 1.8.0. Build 1.8.0.0 for $LICENSEE$. 4 | 5 | Copyright (c) 2012 Coherent Labs Limited and/or its licensors. All 6 | rights reserved in all media. 7 | 8 | The coded instructions, statements, computer programs, and/or related 9 | material (collectively the "Data") in these files contain confidential 10 | and unpublished information proprietary Coherent Labs and/or its 11 | licensors, which is protected by United States of America federal 12 | copyright law and by international treaties. 13 | 14 | This software or source code is supplied under the terms of a license 15 | agreement and nondisclosure agreement with Coherent Labs Limited and may 16 | not be copied, disclosed, or exploited except in accordance with the 17 | terms of that agreement. The Data may not be disclosed or distributed to 18 | third parties, in whole or in part, without the prior written consent of 19 | Coherent Labs Limited. 20 | 21 | COHERENT LABS MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS 22 | SOURCE CODE FOR ANY PURPOSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT 23 | HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 24 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 25 | MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE 26 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER, ITS AFFILIATES, 27 | PARENT COMPANIES, LICENSORS, SUPPLIERS, OR CONTRIBUTORS BE LIABLE FOR 28 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 33 | ANY WAY OUT OF THE USE OR PERFORMANCE OF THIS SOFTWARE OR SOURCE CODE, 34 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | -------------------------------------------------------------------------------- /Prebuilt/Bin32/CryGame.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLabs/CoherentUI_CryEngine3/44b30e41e37a92ee16edbc6b738f996cfb3bd67e/Prebuilt/Bin32/CryGame.dll -------------------------------------------------------------------------------- /Prebuilt/Bin32/Plugins/CoherentUI/Plugin_CoherentUI.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLabs/CoherentUI_CryEngine3/44b30e41e37a92ee16edbc6b738f996cfb3bd67e/Prebuilt/Bin32/Plugins/CoherentUI/Plugin_CoherentUI.dll -------------------------------------------------------------------------------- /Prebuilt/Bin32/Plugins/D3D/Plugin_D3D.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLabs/CoherentUI_CryEngine3/44b30e41e37a92ee16edbc6b738f996cfb3bd67e/Prebuilt/Bin32/Plugins/D3D/Plugin_D3D.dll -------------------------------------------------------------------------------- /Prebuilt/Bin32/Plugins/Plugin_Manager.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLabs/CoherentUI_CryEngine3/44b30e41e37a92ee16edbc6b738f996cfb3bd67e/Prebuilt/Bin32/Plugins/Plugin_Manager.dll -------------------------------------------------------------------------------- /Prebuilt/Bin64/CryGame.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLabs/CoherentUI_CryEngine3/44b30e41e37a92ee16edbc6b738f996cfb3bd67e/Prebuilt/Bin64/CryGame.dll -------------------------------------------------------------------------------- /Prebuilt/Bin64/Plugins/CoherentUI/Plugin_CoherentUI.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLabs/CoherentUI_CryEngine3/44b30e41e37a92ee16edbc6b738f996cfb3bd67e/Prebuilt/Bin64/Plugins/CoherentUI/Plugin_CoherentUI.dll -------------------------------------------------------------------------------- /Prebuilt/Bin64/Plugins/D3D/Plugin_D3D.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLabs/CoherentUI_CryEngine3/44b30e41e37a92ee16edbc6b738f996cfb3bd67e/Prebuilt/Bin64/Plugins/D3D/Plugin_D3D.dll -------------------------------------------------------------------------------- /Prebuilt/Bin64/Plugins/Plugin_Manager.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLabs/CoherentUI_CryEngine3/44b30e41e37a92ee16edbc6b738f996cfb3bd67e/Prebuilt/Bin64/Plugins/Plugin_Manager.dll -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | CoherentUI Plugin for CryEngine SDK 2 | ===================================== 3 | 4 | Coherent UI for CryEngine 3.5.7 Free SDK 5 | 6 | Visit [our blog](http://blog.coherent-labs.com/2013/01/coherent-ui-in-cryengine-3-redux.html) for a review of the plugin and code walkthrough. 7 | 8 | NOTE: build instructions in the blog post may be outdated, we changed the directory structure; Use the build instructions in this file. 9 | 10 | Installation, Integration & Usage 11 | ========================== 12 | [Setup and build of the plugin](https://github.com/CoherentLabs/CoherentUI_CryEngine3/wiki/Installation-of-Coherent-UI-Plugin) 13 | 14 | [Integrating with the GameSDK](https://github.com/CoherentLabs/CoherentUI_CryEngine3/wiki/Integrating-the-plugin-with-the-GameSDK) 15 | 16 | [Using the Coherent UI Plugin, Materials, Flownodes](https://github.com/CoherentLabs/CoherentUI_CryEngine3/wiki/Using-the-Coherent-UI-plugin) 17 | -------------------------------------------------------------------------------- /authors.txt: -------------------------------------------------------------------------------- 1 | Nick - Coherent Labs (http://coherent-labs.com/) 2 | Hendrik Polczynski - PakFileHandler, simplifications 3 | Ingo Herwig - Flownodes -------------------------------------------------------------------------------- /changelog.md: -------------------------------------------------------------------------------- 1 | CoherentUI Plugin 1.0.0.0 (2013) 2 | --------------------------- 3 | Initial Stable Release for CryEngine (32/64 bit) 4 | -------------------------------------------------------------------------------- /inc/IPluginCoherentUI.h: -------------------------------------------------------------------------------- 1 | /* CoherentUI_Plugin - for licensing and copyright see license.txt */ 2 | 3 | #include 4 | 5 | #pragma once 6 | 7 | struct IPlayerEventListener; 8 | 9 | /** 10 | * @brief CoherentUI Plugin Namespace 11 | */ 12 | namespace CoherentUIPlugin 13 | { 14 | /** 15 | * @brief plugin CoherentUI concrete interface 16 | */ 17 | struct IPluginCoherentUI 18 | { 19 | /** 20 | * @brief Get Plugin base interface 21 | */ 22 | virtual PluginManager::IPluginBase* GetBase() = 0; 23 | 24 | virtual bool InitializeSystem() = 0; 25 | virtual void ShutdownSystem() = 0; 26 | virtual IPlayerEventListener* GetPlayerEventListener() const = 0; 27 | }; 28 | }; -------------------------------------------------------------------------------- /inc/rapidjson/_license.txt: -------------------------------------------------------------------------------- 1 | Copyright (C) 2011 Milo Yip 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. -------------------------------------------------------------------------------- /inc/rapidjson/_readme.txt: -------------------------------------------------------------------------------- 1 | rapidjson v0.11 2 | 3 | Copyright (c) 2011 Milo Yip (miloyip@gmail.com) 4 | 5 | http://code.google.com/p/rapidjson/ 6 | 7 | 16 Nov 2012 8 | 9 | 1. Introduction 10 | Rapidjson is a JSON parser and generator for C++. It was inspired by rapidxml http://rapidxml.sourceforge.net/ 11 | Rapidjson is small but complete. It supports both SAX and DOM style API. The SAX parser is only a half thousand lines of code. 12 | Rapidjson is fast. Its performance can be comparable to strlen(). It also optionally supports SSE2/SSE4.1 for acceleration. 13 | Rapidjson is self-contained. It does not depend on external libraries such as BOOST. It even does not depend on STL. 14 | Rapidjson is memory friendly. Each JSON value costs exactly 16/20 bytes for 32/64-bit machines (excluding text string). By default it uses a fast memory allocator, and the parser allocates memory compactly during parsing. 15 | 16 | For the full features please refer to the user guide. 17 | 18 | JSON(JavaScript Object Notation) is a light-weight data exchange format. 19 | More information about JSON can be obtained at 20 | http://json.org/ 21 | http://www.ietf.org/rfc/rfc4627.txt 22 | 23 | 2. Installation 24 | 25 | Rapidjson is a header-only C++ library. Just copy the rapidjson/include/rapidjson folder to system or project's include path. 26 | 27 | To build the tests and examples, 28 | 1. obtain premake4 http://industriousone.com/premake/download 29 | 2. Copy premake4 executable to rapidjson/build 30 | 3. Run rapidjson/build/premake.bat on Windows, rapidjson/build/premake on Linux or other platforms 31 | 4. On Windows, build the solution at rapidjson/build/vs2008/ or /vs2010/ 32 | 5. On other platforms, run GNU make at rapidjson/build/gmake/ (e.g., make -f test.make config=release32, make -f example.make config=debug32) 33 | 6. On success, the executable are generated at rapidjson/bin 34 | -------------------------------------------------------------------------------- /inc/rapidjson/filestream.h: -------------------------------------------------------------------------------- 1 | #ifndef RAPIDJSON_FILESTREAM_H_ 2 | #define RAPIDJSON_FILESTREAM_H_ 3 | 4 | #include 5 | 6 | namespace rapidjson { 7 | 8 | //! Wrapper of C file stream for input or output. 9 | /*! 10 | This simple wrapper does not check the validity of the stream. 11 | \implements Stream 12 | */ 13 | class FileStream { 14 | public: 15 | typedef char Ch; //!< Character type. Only support char. 16 | 17 | FileStream(FILE* fp) : fp_(fp), count_(0) { Read(); } 18 | char Peek() const { return current_; } 19 | char Take() { char c = current_; Read(); return c; } 20 | size_t Tell() const { return count_; } 21 | void Put(char c) { fputc(c, fp_); } 22 | 23 | // Not implemented 24 | char* PutBegin() { return 0; } 25 | size_t PutEnd(char*) { return 0; } 26 | 27 | private: 28 | void Read() { 29 | RAPIDJSON_ASSERT(fp_ != 0); 30 | int c = fgetc(fp_); 31 | if (c != EOF) { 32 | current_ = (char)c; 33 | count_++; 34 | } 35 | else 36 | current_ = '\0'; 37 | } 38 | 39 | FILE* fp_; 40 | char current_; 41 | size_t count_; 42 | }; 43 | 44 | } // namespace rapidjson 45 | 46 | #endif // RAPIDJSON_FILESTREAM_H_ 47 | -------------------------------------------------------------------------------- /inc/rapidjson/internal/pow10.h: -------------------------------------------------------------------------------- 1 | #ifndef RAPIDJSON_POW10_ 2 | #define RAPIDJSON_POW10_ 3 | 4 | namespace rapidjson { 5 | namespace internal { 6 | 7 | //! Computes integer powers of 10 in double (10.0^n). 8 | /*! This function uses lookup table for fast and accurate results. 9 | \param n positive/negative exponent. Must <= 308. 10 | \return 10.0^n 11 | */ 12 | inline double Pow10(int n) { 13 | static const double e[] = { // 1e-308...1e308: 617 * 8 bytes = 4936 bytes 14 | 1e-308,1e-307,1e-306,1e-305,1e-304,1e-303,1e-302,1e-301,1e-300, 15 | 1e-299,1e-298,1e-297,1e-296,1e-295,1e-294,1e-293,1e-292,1e-291,1e-290,1e-289,1e-288,1e-287,1e-286,1e-285,1e-284,1e-283,1e-282,1e-281,1e-280, 16 | 1e-279,1e-278,1e-277,1e-276,1e-275,1e-274,1e-273,1e-272,1e-271,1e-270,1e-269,1e-268,1e-267,1e-266,1e-265,1e-264,1e-263,1e-262,1e-261,1e-260, 17 | 1e-259,1e-258,1e-257,1e-256,1e-255,1e-254,1e-253,1e-252,1e-251,1e-250,1e-249,1e-248,1e-247,1e-246,1e-245,1e-244,1e-243,1e-242,1e-241,1e-240, 18 | 1e-239,1e-238,1e-237,1e-236,1e-235,1e-234,1e-233,1e-232,1e-231,1e-230,1e-229,1e-228,1e-227,1e-226,1e-225,1e-224,1e-223,1e-222,1e-221,1e-220, 19 | 1e-219,1e-218,1e-217,1e-216,1e-215,1e-214,1e-213,1e-212,1e-211,1e-210,1e-209,1e-208,1e-207,1e-206,1e-205,1e-204,1e-203,1e-202,1e-201,1e-200, 20 | 1e-199,1e-198,1e-197,1e-196,1e-195,1e-194,1e-193,1e-192,1e-191,1e-190,1e-189,1e-188,1e-187,1e-186,1e-185,1e-184,1e-183,1e-182,1e-181,1e-180, 21 | 1e-179,1e-178,1e-177,1e-176,1e-175,1e-174,1e-173,1e-172,1e-171,1e-170,1e-169,1e-168,1e-167,1e-166,1e-165,1e-164,1e-163,1e-162,1e-161,1e-160, 22 | 1e-159,1e-158,1e-157,1e-156,1e-155,1e-154,1e-153,1e-152,1e-151,1e-150,1e-149,1e-148,1e-147,1e-146,1e-145,1e-144,1e-143,1e-142,1e-141,1e-140, 23 | 1e-139,1e-138,1e-137,1e-136,1e-135,1e-134,1e-133,1e-132,1e-131,1e-130,1e-129,1e-128,1e-127,1e-126,1e-125,1e-124,1e-123,1e-122,1e-121,1e-120, 24 | 1e-119,1e-118,1e-117,1e-116,1e-115,1e-114,1e-113,1e-112,1e-111,1e-110,1e-109,1e-108,1e-107,1e-106,1e-105,1e-104,1e-103,1e-102,1e-101,1e-100, 25 | 1e-99, 1e-98, 1e-97, 1e-96, 1e-95, 1e-94, 1e-93, 1e-92, 1e-91, 1e-90, 1e-89, 1e-88, 1e-87, 1e-86, 1e-85, 1e-84, 1e-83, 1e-82, 1e-81, 1e-80, 26 | 1e-79, 1e-78, 1e-77, 1e-76, 1e-75, 1e-74, 1e-73, 1e-72, 1e-71, 1e-70, 1e-69, 1e-68, 1e-67, 1e-66, 1e-65, 1e-64, 1e-63, 1e-62, 1e-61, 1e-60, 27 | 1e-59, 1e-58, 1e-57, 1e-56, 1e-55, 1e-54, 1e-53, 1e-52, 1e-51, 1e-50, 1e-49, 1e-48, 1e-47, 1e-46, 1e-45, 1e-44, 1e-43, 1e-42, 1e-41, 1e-40, 28 | 1e-39, 1e-38, 1e-37, 1e-36, 1e-35, 1e-34, 1e-33, 1e-32, 1e-31, 1e-30, 1e-29, 1e-28, 1e-27, 1e-26, 1e-25, 1e-24, 1e-23, 1e-22, 1e-21, 1e-20, 29 | 1e-19, 1e-18, 1e-17, 1e-16, 1e-15, 1e-14, 1e-13, 1e-12, 1e-11, 1e-10, 1e-9, 1e-8, 1e-7, 1e-6, 1e-5, 1e-4, 1e-3, 1e-2, 1e-1, 1e+0, 30 | 1e+1, 1e+2, 1e+3, 1e+4, 1e+5, 1e+6, 1e+7, 1e+8, 1e+9, 1e+10, 1e+11, 1e+12, 1e+13, 1e+14, 1e+15, 1e+16, 1e+17, 1e+18, 1e+19, 1e+20, 31 | 1e+21, 1e+22, 1e+23, 1e+24, 1e+25, 1e+26, 1e+27, 1e+28, 1e+29, 1e+30, 1e+31, 1e+32, 1e+33, 1e+34, 1e+35, 1e+36, 1e+37, 1e+38, 1e+39, 1e+40, 32 | 1e+41, 1e+42, 1e+43, 1e+44, 1e+45, 1e+46, 1e+47, 1e+48, 1e+49, 1e+50, 1e+51, 1e+52, 1e+53, 1e+54, 1e+55, 1e+56, 1e+57, 1e+58, 1e+59, 1e+60, 33 | 1e+61, 1e+62, 1e+63, 1e+64, 1e+65, 1e+66, 1e+67, 1e+68, 1e+69, 1e+70, 1e+71, 1e+72, 1e+73, 1e+74, 1e+75, 1e+76, 1e+77, 1e+78, 1e+79, 1e+80, 34 | 1e+81, 1e+82, 1e+83, 1e+84, 1e+85, 1e+86, 1e+87, 1e+88, 1e+89, 1e+90, 1e+91, 1e+92, 1e+93, 1e+94, 1e+95, 1e+96, 1e+97, 1e+98, 1e+99, 1e+100, 35 | 1e+101,1e+102,1e+103,1e+104,1e+105,1e+106,1e+107,1e+108,1e+109,1e+110,1e+111,1e+112,1e+113,1e+114,1e+115,1e+116,1e+117,1e+118,1e+119,1e+120, 36 | 1e+121,1e+122,1e+123,1e+124,1e+125,1e+126,1e+127,1e+128,1e+129,1e+130,1e+131,1e+132,1e+133,1e+134,1e+135,1e+136,1e+137,1e+138,1e+139,1e+140, 37 | 1e+141,1e+142,1e+143,1e+144,1e+145,1e+146,1e+147,1e+148,1e+149,1e+150,1e+151,1e+152,1e+153,1e+154,1e+155,1e+156,1e+157,1e+158,1e+159,1e+160, 38 | 1e+161,1e+162,1e+163,1e+164,1e+165,1e+166,1e+167,1e+168,1e+169,1e+170,1e+171,1e+172,1e+173,1e+174,1e+175,1e+176,1e+177,1e+178,1e+179,1e+180, 39 | 1e+181,1e+182,1e+183,1e+184,1e+185,1e+186,1e+187,1e+188,1e+189,1e+190,1e+191,1e+192,1e+193,1e+194,1e+195,1e+196,1e+197,1e+198,1e+199,1e+200, 40 | 1e+201,1e+202,1e+203,1e+204,1e+205,1e+206,1e+207,1e+208,1e+209,1e+210,1e+211,1e+212,1e+213,1e+214,1e+215,1e+216,1e+217,1e+218,1e+219,1e+220, 41 | 1e+221,1e+222,1e+223,1e+224,1e+225,1e+226,1e+227,1e+228,1e+229,1e+230,1e+231,1e+232,1e+233,1e+234,1e+235,1e+236,1e+237,1e+238,1e+239,1e+240, 42 | 1e+241,1e+242,1e+243,1e+244,1e+245,1e+246,1e+247,1e+248,1e+249,1e+250,1e+251,1e+252,1e+253,1e+254,1e+255,1e+256,1e+257,1e+258,1e+259,1e+260, 43 | 1e+261,1e+262,1e+263,1e+264,1e+265,1e+266,1e+267,1e+268,1e+269,1e+270,1e+271,1e+272,1e+273,1e+274,1e+275,1e+276,1e+277,1e+278,1e+279,1e+280, 44 | 1e+281,1e+282,1e+283,1e+284,1e+285,1e+286,1e+287,1e+288,1e+289,1e+290,1e+291,1e+292,1e+293,1e+294,1e+295,1e+296,1e+297,1e+298,1e+299,1e+300, 45 | 1e+301,1e+302,1e+303,1e+304,1e+305,1e+306,1e+307,1e+308 46 | }; 47 | RAPIDJSON_ASSERT(n <= 308); 48 | return n < -308 ? 0.0 : e[n + 308]; 49 | } 50 | 51 | } // namespace internal 52 | } // namespace rapidjson 53 | 54 | #endif // RAPIDJSON_POW10_ 55 | -------------------------------------------------------------------------------- /inc/rapidjson/internal/stack.h: -------------------------------------------------------------------------------- 1 | #ifndef RAPIDJSON_INTERNAL_STACK_H_ 2 | #define RAPIDJSON_INTERNAL_STACK_H_ 3 | 4 | namespace rapidjson { 5 | namespace internal { 6 | 7 | /////////////////////////////////////////////////////////////////////////////// 8 | // Stack 9 | 10 | //! A type-unsafe stack for storing different types of data. 11 | /*! \tparam Allocator Allocator for allocating stack memory. 12 | */ 13 | template 14 | class Stack { 15 | public: 16 | Stack(Allocator* allocator, size_t stack_capacity) : allocator_(allocator), own_allocator_(0), stack_(0), stack_top_(0), stack_end_(0), stack_capacity_(stack_capacity) { 17 | RAPIDJSON_ASSERT(stack_capacity_ > 0); 18 | if (!allocator_) 19 | own_allocator_ = allocator_ = new Allocator(); 20 | stack_top_ = stack_ = (char*)allocator_->Malloc(stack_capacity_); 21 | stack_end_ = stack_ + stack_capacity_; 22 | } 23 | 24 | ~Stack() { 25 | Allocator::Free(stack_); 26 | delete own_allocator_; // Only delete if it is owned by the stack 27 | } 28 | 29 | void Clear() { /*stack_top_ = 0;*/ stack_top_ = stack_; } 30 | 31 | template 32 | T* Push(size_t count = 1) { 33 | // Expand the stack if needed 34 | if (stack_top_ + sizeof(T) * count >= stack_end_) { 35 | size_t new_capacity = stack_capacity_ * 2; 36 | size_t size = GetSize(); 37 | size_t new_size = GetSize() + sizeof(T) * count; 38 | if (new_capacity < new_size) 39 | new_capacity = new_size; 40 | stack_ = (char*)allocator_->Realloc(stack_, stack_capacity_, new_capacity); 41 | stack_capacity_ = new_capacity; 42 | stack_top_ = stack_ + size; 43 | stack_end_ = stack_ + stack_capacity_; 44 | } 45 | T* ret = (T*)stack_top_; 46 | stack_top_ += sizeof(T) * count; 47 | return ret; 48 | } 49 | 50 | template 51 | T* Pop(size_t count) { 52 | RAPIDJSON_ASSERT(GetSize() >= count * sizeof(T)); 53 | stack_top_ -= count * sizeof(T); 54 | return (T*)stack_top_; 55 | } 56 | 57 | template 58 | T* Top() { 59 | RAPIDJSON_ASSERT(GetSize() >= sizeof(T)); 60 | return (T*)(stack_top_ - sizeof(T)); 61 | } 62 | 63 | template 64 | T* Bottom() { return (T*)stack_; } 65 | 66 | Allocator& GetAllocator() { return *allocator_; } 67 | size_t GetSize() const { return stack_top_ - stack_; } 68 | size_t GetCapacity() const { return stack_capacity_; } 69 | 70 | private: 71 | Allocator* allocator_; 72 | Allocator* own_allocator_; 73 | char *stack_; 74 | char *stack_top_; 75 | char *stack_end_; 76 | size_t stack_capacity_; 77 | }; 78 | 79 | } // namespace internal 80 | } // namespace rapidjson 81 | 82 | #endif // RAPIDJSON_STACK_H_ 83 | -------------------------------------------------------------------------------- /inc/rapidjson/internal/strfunc.h: -------------------------------------------------------------------------------- 1 | #ifndef RAPIDJSON_INTERNAL_STRFUNC_H_ 2 | #define RAPIDJSON_INTERNAL_STRFUNC_H_ 3 | 4 | namespace rapidjson { 5 | namespace internal { 6 | 7 | //! Custom strlen() which works on different character types. 8 | /*! \tparam Ch Character type (e.g. char, wchar_t, short) 9 | \param s Null-terminated input string. 10 | \return Number of characters in the string. 11 | \note This has the same semantics as strlen(), the return value is not number of Unicode codepoints. 12 | */ 13 | template 14 | inline SizeType StrLen(const Ch* s) { 15 | const Ch* p = s; 16 | while (*p != '\0') 17 | ++p; 18 | return SizeType(p - s); 19 | } 20 | 21 | } // namespace internal 22 | } // namespace rapidjson 23 | 24 | #endif // RAPIDJSON_INTERNAL_STRFUNC_H_ 25 | -------------------------------------------------------------------------------- /inc/rapidjson/prettywriter.h: -------------------------------------------------------------------------------- 1 | #ifndef RAPIDJSON_PRETTYWRITER_H_ 2 | #define RAPIDJSON_PRETTYWRITER_H_ 3 | 4 | #include "writer.h" 5 | 6 | namespace rapidjson { 7 | 8 | //! Writer with indentation and spacing. 9 | /*! 10 | \tparam Stream Type of ouptut stream. 11 | \tparam Encoding Encoding of both source strings and output. 12 | \tparam Allocator Type of allocator for allocating memory of stack. 13 | */ 14 | template, typename Allocator = MemoryPoolAllocator<> > 15 | class PrettyWriter : public Writer { 16 | public: 17 | typedef Writer Base; 18 | typedef typename Base::Ch Ch; 19 | 20 | //! Constructor 21 | /*! \param stream Output stream. 22 | \param allocator User supplied allocator. If it is null, it will create a private one. 23 | \param levelDepth Initial capacity of 24 | */ 25 | PrettyWriter(Stream& stream, Allocator* allocator = 0, size_t levelDepth = Base::kDefaultLevelDepth) : 26 | Base(stream, allocator, levelDepth), indentChar_(' '), indentCharCount_(4) {} 27 | 28 | //! Set custom indentation. 29 | /*! \param indentChar Character for indentation. Must be whitespace character (' ', '\t', '\n', '\r'). 30 | \param indentCharCount Number of indent characters for each indentation level. 31 | \note The default indentation is 4 spaces. 32 | */ 33 | PrettyWriter& SetIndent(Ch indentChar, unsigned indentCharCount) { 34 | RAPIDJSON_ASSERT(indentChar == ' ' || indentChar == '\t' || indentChar == '\n' || indentChar == '\r'); 35 | indentChar_ = indentChar; 36 | indentCharCount_ = indentCharCount; 37 | return *this; 38 | } 39 | 40 | //@name Implementation of Handler. 41 | //@{ 42 | 43 | PrettyWriter& Null() { PrettyPrefix(kNullType); Base::WriteNull(); return *this; } 44 | PrettyWriter& Bool(bool b) { PrettyPrefix(b ? kTrueType : kFalseType); Base::WriteBool(b); return *this; } 45 | PrettyWriter& Int(int i) { PrettyPrefix(kNumberType); Base::WriteInt(i); return *this; } 46 | PrettyWriter& Uint(unsigned u) { PrettyPrefix(kNumberType); Base::WriteUint(u); return *this; } 47 | PrettyWriter& Int64(int64_t i64) { PrettyPrefix(kNumberType); Base::WriteInt64(i64); return *this; } 48 | PrettyWriter& Uint64(uint64_t u64) { PrettyPrefix(kNumberType); Base::WriteUint64(u64); return *this; } 49 | PrettyWriter& Double(double d) { PrettyPrefix(kNumberType); Base::WriteDouble(d); return *this; } 50 | 51 | PrettyWriter& String(const Ch* str, SizeType length, bool copy = false) { 52 | (void)copy; 53 | PrettyPrefix(kStringType); 54 | Base::WriteString(str, length); 55 | return *this; 56 | } 57 | 58 | PrettyWriter& StartObject() { 59 | PrettyPrefix(kObjectType); 60 | new (Base::level_stack_.template Push()) typename Base::Level(false); 61 | Base::WriteStartObject(); 62 | return *this; 63 | } 64 | 65 | PrettyWriter& EndObject(SizeType memberCount = 0) { 66 | (void)memberCount; 67 | RAPIDJSON_ASSERT(Base::level_stack_.GetSize() >= sizeof(typename Base::Level)); 68 | RAPIDJSON_ASSERT(!Base::level_stack_.template Top()->inArray); 69 | bool empty = Base::level_stack_.template Pop(1)->valueCount == 0; 70 | 71 | if (!empty) { 72 | Base::stream_.Put('\n'); 73 | WriteIndent(); 74 | } 75 | Base::WriteEndObject(); 76 | return *this; 77 | } 78 | 79 | PrettyWriter& StartArray() { 80 | PrettyPrefix(kArrayType); 81 | new (Base::level_stack_.template Push()) typename Base::Level(true); 82 | Base::WriteStartArray(); 83 | return *this; 84 | } 85 | 86 | PrettyWriter& EndArray(SizeType memberCount = 0) { 87 | (void)memberCount; 88 | RAPIDJSON_ASSERT(Base::level_stack_.GetSize() >= sizeof(typename Base::Level)); 89 | RAPIDJSON_ASSERT(Base::level_stack_.template Top()->inArray); 90 | bool empty = Base::level_stack_.template Pop(1)->valueCount == 0; 91 | 92 | if (!empty) { 93 | Base::stream_.Put('\n'); 94 | WriteIndent(); 95 | } 96 | Base::WriteEndArray(); 97 | return *this; 98 | } 99 | 100 | //@} 101 | 102 | //! Simpler but slower overload. 103 | PrettyWriter& String(const Ch* str) { return String(str, internal::StrLen(str)); } 104 | 105 | protected: 106 | void PrettyPrefix(Type type) { 107 | (void)type; 108 | if (Base::level_stack_.GetSize() != 0) { // this value is not at root 109 | typename Base::Level* level = Base::level_stack_.template Top(); 110 | 111 | if (level->inArray) { 112 | if (level->valueCount > 0) { 113 | Base::stream_.Put(','); // add comma if it is not the first element in array 114 | Base::stream_.Put('\n'); 115 | } 116 | else 117 | Base::stream_.Put('\n'); 118 | WriteIndent(); 119 | } 120 | else { // in object 121 | if (level->valueCount > 0) { 122 | if (level->valueCount % 2 == 0) { 123 | Base::stream_.Put(','); 124 | Base::stream_.Put('\n'); 125 | } 126 | else { 127 | Base::stream_.Put(':'); 128 | Base::stream_.Put(' '); 129 | } 130 | } 131 | else 132 | Base::stream_.Put('\n'); 133 | 134 | if (level->valueCount % 2 == 0) 135 | WriteIndent(); 136 | } 137 | if (!level->inArray && level->valueCount % 2 == 0) 138 | RAPIDJSON_ASSERT(type == kStringType); // if it's in object, then even number should be a name 139 | level->valueCount++; 140 | } 141 | else 142 | RAPIDJSON_ASSERT(type == kObjectType || type == kArrayType); 143 | } 144 | 145 | void WriteIndent() { 146 | size_t count = (Base::level_stack_.GetSize() / sizeof(typename Base::Level)) * indentCharCount_; 147 | PutN(Base::stream_, indentChar_, count); 148 | } 149 | 150 | Ch indentChar_; 151 | unsigned indentCharCount_; 152 | }; 153 | 154 | } // namespace rapidjson 155 | 156 | #endif // RAPIDJSON_RAPIDJSON_H_ 157 | -------------------------------------------------------------------------------- /inc/rapidjson/stringbuffer.h: -------------------------------------------------------------------------------- 1 | #ifndef RAPIDJSON_STRINGBUFFER_H_ 2 | #define RAPIDJSON_STRINGBUFFER_H_ 3 | 4 | #include "rapidjson.h" 5 | #include "internal/stack.h" 6 | 7 | namespace rapidjson { 8 | 9 | //! Represents an in-memory output stream. 10 | /*! 11 | \tparam Encoding Encoding of the stream. 12 | \tparam Allocator type for allocating memory buffer. 13 | \implements Stream 14 | */ 15 | template 16 | struct GenericStringBuffer { 17 | typedef typename Encoding::Ch Ch; 18 | 19 | GenericStringBuffer(Allocator* allocator = 0, size_t capacity = kDefaultCapacity) : stack_(allocator, capacity) {} 20 | 21 | void Put(Ch c) { *stack_.template Push() = c; } 22 | 23 | void Clear() { stack_.Clear(); } 24 | 25 | const char* GetString() const { 26 | // Push and pop a null terminator. This is safe. 27 | *stack_.template Push() = '\0'; 28 | stack_.template Pop(1); 29 | 30 | return stack_.template Bottom(); 31 | } 32 | 33 | size_t Size() const { return stack_.GetSize(); } 34 | 35 | static const size_t kDefaultCapacity = 256; 36 | mutable internal::Stack stack_; 37 | }; 38 | 39 | typedef GenericStringBuffer > StringBuffer; 40 | 41 | //! Implement specialized version of PutN() with memset() for better performance. 42 | template<> 43 | inline void PutN(GenericStringBuffer >& stream, char c, size_t n) { 44 | memset(stream.stack_.Push(n), c, n * sizeof(c)); 45 | } 46 | 47 | } // namespace rapidjson 48 | 49 | #endif // RAPIDJSON_STRINGBUFFER_H_ 50 | -------------------------------------------------------------------------------- /inc/rapidjson/writer.h: -------------------------------------------------------------------------------- 1 | #ifndef RAPIDJSON_WRITER_H_ 2 | #define RAPIDJSON_WRITER_H_ 3 | 4 | #include "rapidjson.h" 5 | #include "internal/stack.h" 6 | #include "internal/strfunc.h" 7 | #include // snprintf() or _sprintf_s() 8 | #include // placement new 9 | 10 | #ifdef _MSC_VER 11 | #pragma warning(push) 12 | #pragma warning(disable : 4127) // conditional expression is constant 13 | #endif 14 | 15 | namespace rapidjson { 16 | 17 | //! JSON writer 18 | /*! Writer implements the concept Handler. 19 | It generates JSON text by events to an output stream. 20 | 21 | User may programmatically calls the functions of a writer to generate JSON text. 22 | 23 | On the other side, a writer can also be passed to objects that generates events, 24 | 25 | for example Reader::Parse() and Document::Accept(). 26 | 27 | \tparam Stream Type of ouptut stream. 28 | \tparam Encoding Encoding of both source strings and output. 29 | \implements Handler 30 | */ 31 | template, typename Allocator = MemoryPoolAllocator<> > 32 | class Writer { 33 | public: 34 | typedef typename Encoding::Ch Ch; 35 | 36 | Writer(Stream& stream, Allocator* allocator = 0, size_t levelDepth = kDefaultLevelDepth) : 37 | stream_(stream), level_stack_(allocator, levelDepth * sizeof(Level)) {} 38 | 39 | //@name Implementation of Handler 40 | //@{ 41 | Writer& Null() { Prefix(kNullType); WriteNull(); return *this; } 42 | Writer& Bool(bool b) { Prefix(b ? kTrueType : kFalseType); WriteBool(b); return *this; } 43 | Writer& Int(int i) { Prefix(kNumberType); WriteInt(i); return *this; } 44 | Writer& Uint(unsigned u) { Prefix(kNumberType); WriteUint(u); return *this; } 45 | Writer& Int64(int64_t i64) { Prefix(kNumberType); WriteInt64(i64); return *this; } 46 | Writer& Uint64(uint64_t u64) { Prefix(kNumberType); WriteUint64(u64); return *this; } 47 | Writer& Double(double d) { Prefix(kNumberType); WriteDouble(d); return *this; } 48 | 49 | Writer& String(const Ch* str, SizeType length, bool copy = false) { 50 | (void)copy; 51 | Prefix(kStringType); 52 | WriteString(str, length); 53 | return *this; 54 | } 55 | 56 | Writer& StartObject() { 57 | Prefix(kObjectType); 58 | new (level_stack_.template Push()) Level(false); 59 | WriteStartObject(); 60 | return *this; 61 | } 62 | 63 | Writer& EndObject(SizeType memberCount = 0) { 64 | (void)memberCount; 65 | RAPIDJSON_ASSERT(level_stack_.GetSize() >= sizeof(Level)); 66 | RAPIDJSON_ASSERT(!level_stack_.template Top()->inArray); 67 | level_stack_.template Pop(1); 68 | WriteEndObject(); 69 | return *this; 70 | } 71 | 72 | Writer& StartArray() { 73 | Prefix(kArrayType); 74 | new (level_stack_.template Push()) Level(true); 75 | WriteStartArray(); 76 | return *this; 77 | } 78 | 79 | Writer& EndArray(SizeType elementCount = 0) { 80 | (void)elementCount; 81 | RAPIDJSON_ASSERT(level_stack_.GetSize() >= sizeof(Level)); 82 | RAPIDJSON_ASSERT(level_stack_.template Top()->inArray); 83 | level_stack_.template Pop(1); 84 | WriteEndArray(); 85 | return *this; 86 | } 87 | //@} 88 | 89 | //! Simpler but slower overload. 90 | Writer& String(const Ch* str) { return String(str, internal::StrLen(str)); } 91 | 92 | protected: 93 | //! Information for each nested level 94 | struct Level { 95 | Level(bool inArray_) : inArray(inArray_), valueCount(0) {} 96 | bool inArray; //!< true if in array, otherwise in object 97 | size_t valueCount; //!< number of values in this level 98 | }; 99 | 100 | static const size_t kDefaultLevelDepth = 32; 101 | 102 | void WriteNull() { 103 | stream_.Put('n'); stream_.Put('u'); stream_.Put('l'); stream_.Put('l'); 104 | } 105 | 106 | void WriteBool(bool b) { 107 | if (b) { 108 | stream_.Put('t'); stream_.Put('r'); stream_.Put('u'); stream_.Put('e'); 109 | } 110 | else { 111 | stream_.Put('f'); stream_.Put('a'); stream_.Put('l'); stream_.Put('s'); stream_.Put('e'); 112 | } 113 | } 114 | 115 | void WriteInt(int i) { 116 | if (i < 0) { 117 | stream_.Put('-'); 118 | i = -i; 119 | } 120 | WriteUint((unsigned)i); 121 | } 122 | 123 | void WriteUint(unsigned u) { 124 | char buffer[10]; 125 | char *p = buffer; 126 | do { 127 | *p++ = (u % 10) + '0'; 128 | u /= 10; 129 | } while (u > 0); 130 | 131 | do { 132 | --p; 133 | stream_.Put(*p); 134 | } while (p != buffer); 135 | } 136 | 137 | void WriteInt64(int64_t i64) { 138 | if (i64 < 0) { 139 | stream_.Put('-'); 140 | i64 = -i64; 141 | } 142 | WriteUint64((uint64_t)i64); 143 | } 144 | 145 | void WriteUint64(uint64_t u64) { 146 | char buffer[20]; 147 | char *p = buffer; 148 | do { 149 | *p++ = char(u64 % 10) + '0'; 150 | u64 /= 10; 151 | } while (u64 > 0); 152 | 153 | do { 154 | --p; 155 | stream_.Put(*p); 156 | } while (p != buffer); 157 | } 158 | 159 | //! \todo Optimization with custom double-to-string converter. 160 | void WriteDouble(double d) { 161 | char buffer[100]; 162 | #if _MSC_VER 163 | int ret = sprintf_s(buffer, sizeof(buffer), "%g", d); 164 | #else 165 | int ret = snprintf(buffer, sizeof(buffer), "%g", d); 166 | #endif 167 | RAPIDJSON_ASSERT(ret >= 1); 168 | for (int i = 0; i < ret; i++) 169 | stream_.Put(buffer[i]); 170 | } 171 | 172 | void WriteString(const Ch* str, SizeType length) { 173 | static const char hexDigits[] = "0123456789ABCDEF"; 174 | static const char escape[256] = { 175 | #define Z16 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 176 | //0 1 2 3 4 5 6 7 8 9 A B C D E F 177 | 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'b', 't', 'n', 'u', 'f', 'r', 'u', 'u', // 00 178 | 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', // 10 179 | 0, 0, '"', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 20 180 | Z16, Z16, // 30~4F 181 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,'\\', 0, 0, 0, // 50 182 | Z16, Z16, Z16, Z16, Z16, Z16, Z16, Z16, Z16, Z16 // 60~FF 183 | #undef Z16 184 | }; 185 | 186 | stream_.Put('\"'); 187 | for (const Ch* p = str; p != str + length; ++p) { 188 | if ((sizeof(Ch) == 1 || *p < 256) && escape[(unsigned char)*p]) { 189 | stream_.Put('\\'); 190 | stream_.Put(escape[(unsigned char)*p]); 191 | if (escape[(unsigned char)*p] == 'u') { 192 | stream_.Put('0'); 193 | stream_.Put('0'); 194 | stream_.Put(hexDigits[(*p) >> 4]); 195 | stream_.Put(hexDigits[(*p) & 0xF]); 196 | } 197 | } 198 | else 199 | stream_.Put(*p); 200 | } 201 | stream_.Put('\"'); 202 | } 203 | 204 | void WriteStartObject() { stream_.Put('{'); } 205 | void WriteEndObject() { stream_.Put('}'); } 206 | void WriteStartArray() { stream_.Put('['); } 207 | void WriteEndArray() { stream_.Put(']'); } 208 | 209 | void Prefix(Type type) { 210 | (void)type; 211 | if (level_stack_.GetSize() != 0) { // this value is not at root 212 | Level* level = level_stack_.template Top(); 213 | if (level->valueCount > 0) { 214 | if (level->inArray) 215 | stream_.Put(','); // add comma if it is not the first element in array 216 | else // in object 217 | stream_.Put((level->valueCount % 2 == 0) ? ',' : ':'); 218 | } 219 | if (!level->inArray && level->valueCount % 2 == 0) 220 | RAPIDJSON_ASSERT(type == kStringType); // if it's in object, then even number should be a name 221 | level->valueCount++; 222 | } 223 | else 224 | RAPIDJSON_ASSERT(type == kObjectType || type == kArrayType); 225 | } 226 | 227 | Stream& stream_; 228 | internal::Stack level_stack_; 229 | 230 | private: 231 | // Prohibit assignment for VC C4512 warning 232 | Writer& operator=(const Writer& w); 233 | }; 234 | 235 | } // namespace rapidjson 236 | 237 | #ifdef _MSC_VER 238 | #pragma warning(pop) 239 | #endif 240 | 241 | #endif // RAPIDJSON_RAPIDJSON_H_ 242 | -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- 1 | CoherentUI Plugin 2 | ==================== 3 | Copyright (c) 2013, The authors of the CoherentUI Plugin project 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 2. Redistributions in binary form must reproduce the above copyright notice, 12 | this list of conditions and the following disclaimer in the documentation 13 | and/or other materials provided with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 19 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | [This is the BSD 2-Clause License, http://opensource.org/licenses/BSD-2-Clause] 27 | -------------------------------------------------------------------------------- /project/CoherentUI.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | {06585823-906f-421a-a5f5-b4798fc376d0} 18 | 19 | 20 | {8c6e54d8-5411-45bd-a464-ee3776b8c2ed} 21 | exe;bat;astylerc 22 | 23 | 24 | {ab84a8ee-b9fe-433b-8593-88e77eb903a8} 25 | nsi;nsh 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | Tools 35 | 36 | 37 | Tools 38 | 39 | 40 | Tools 41 | 42 | 43 | Tools 44 | 45 | 46 | Tools 47 | 48 | 49 | Installer 50 | 51 | 52 | Installer 53 | 54 | 55 | 56 | 57 | Source Files 58 | 59 | 60 | Source Files 61 | 62 | 63 | Source Files 64 | 65 | 66 | Source Files 67 | 68 | 69 | Source Files 70 | 71 | 72 | Source Files 73 | 74 | 75 | Source Files 76 | 77 | 78 | Source Files 79 | 80 | 81 | Source Files 82 | 83 | 84 | Source Files 85 | 86 | 87 | Source Files 88 | 89 | 90 | Source Files 91 | 92 | 93 | Flownodes 94 | 95 | 96 | Flownodes 97 | 98 | 99 | Flownodes 100 | 101 | 102 | Flownodes 103 | 104 | 105 | Flownodes 106 | 107 | 108 | Flownodes 109 | 110 | 111 | Flownodes 112 | 113 | 114 | 115 | 116 | Header Files 117 | 118 | 119 | Resource Files 120 | 121 | 122 | Header Files 123 | 124 | 125 | Header Files 126 | 127 | 128 | Header Files 129 | 130 | 131 | Header Files 132 | 133 | 134 | Header Files 135 | 136 | 137 | Header Files 138 | 139 | 140 | Header Files 141 | 142 | 143 | Header Files 144 | 145 | 146 | Header Files 147 | 148 | 149 | Header Files 150 | 151 | 152 | Header Files 153 | 154 | 155 | Header Files 156 | 157 | 158 | 159 | 160 | Resource Files 161 | 162 | 163 | -------------------------------------------------------------------------------- /project/Plugin_CoherentUI.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CoherentUI", "CoherentUI.vcxproj", "{611E60F1-B300-47F1-9E33-591B5BAD59ED}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Debug|x64 = Debug|x64 10 | Release|Win32 = Release|Win32 11 | Release|x64 = Release|x64 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {611E60F1-B300-47F1-9E33-591B5BAD59ED}.Debug|Win32.ActiveCfg = Debug|Win32 15 | {611E60F1-B300-47F1-9E33-591B5BAD59ED}.Debug|Win32.Build.0 = Debug|Win32 16 | {611E60F1-B300-47F1-9E33-591B5BAD59ED}.Debug|x64.ActiveCfg = Debug|x64 17 | {611E60F1-B300-47F1-9E33-591B5BAD59ED}.Debug|x64.Build.0 = Debug|x64 18 | {611E60F1-B300-47F1-9E33-591B5BAD59ED}.Release|Win32.ActiveCfg = Release|Win32 19 | {611E60F1-B300-47F1-9E33-591B5BAD59ED}.Release|Win32.Build.0 = Release|Win32 20 | {611E60F1-B300-47F1-9E33-591B5BAD59ED}.Release|x64.ActiveCfg = Release|x64 21 | {611E60F1-B300-47F1-9E33-591B5BAD59ED}.Release|x64.Build.0 = Release|x64 22 | EndGlobalSection 23 | GlobalSection(SolutionProperties) = preSolution 24 | HideSolutionNode = FALSE 25 | EndGlobalSection 26 | EndGlobal 27 | -------------------------------------------------------------------------------- /project/resource.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLabs/CoherentUI_CryEngine3/44b30e41e37a92ee16edbc6b738f996cfb3bd67e/project/resource.h -------------------------------------------------------------------------------- /project/version.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLabs/CoherentUI_CryEngine3/44b30e41e37a92ee16edbc6b738f996cfb3bd67e/project/version.rc -------------------------------------------------------------------------------- /samples/Code/GameSDK/GameDll/GameStartup.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLabs/CoherentUI_CryEngine3/44b30e41e37a92ee16edbc6b738f996cfb3bd67e/samples/Code/GameSDK/GameDll/GameStartup.h -------------------------------------------------------------------------------- /samples/GameSDK/Levels/Singleplayer/ForestCOUI/CoUIFlowGraph.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /samples/GameSDK/Levels/Singleplayer/ForestCOUI/ForestCOUI.bak2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLabs/CoherentUI_CryEngine3/44b30e41e37a92ee16edbc6b738f996cfb3bd67e/samples/GameSDK/Levels/Singleplayer/ForestCOUI/ForestCOUI.bak2 -------------------------------------------------------------------------------- /samples/GameSDK/Levels/Singleplayer/ForestCOUI/ForestCOUI.cry: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLabs/CoherentUI_CryEngine3/44b30e41e37a92ee16edbc6b738f996cfb3bd67e/samples/GameSDK/Levels/Singleplayer/ForestCOUI/ForestCOUI.cry -------------------------------------------------------------------------------- /samples/GameSDK/Levels/Singleplayer/ForestCOUI/Layers/AB1.lyr: -------------------------------------------------------------------------------- 1 | 2 | 52 | 53 | -------------------------------------------------------------------------------- /samples/GameSDK/Levels/Singleplayer/ForestCOUI/Layers/AB1/AB1_Art/AB1_Lighting/AB1_Ropes.lyr: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | -------------------------------------------------------------------------------- /samples/GameSDK/Levels/Singleplayer/ForestCOUI/Layers/AB1/AB1_Logic.lyr: -------------------------------------------------------------------------------- 1 | 2 | 54 | 55 | -------------------------------------------------------------------------------- /samples/GameSDK/Levels/Singleplayer/ForestCOUI/Layers/AB2.lyr: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | -------------------------------------------------------------------------------- /samples/GameSDK/Levels/Singleplayer/ForestCOUI/Layers/AB2/AB2_Logic.lyr: -------------------------------------------------------------------------------- 1 | 2 | 64 | 65 | -------------------------------------------------------------------------------- /samples/GameSDK/Levels/Singleplayer/ForestCOUI/Layers/AB3.lyr: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | -------------------------------------------------------------------------------- /samples/GameSDK/Levels/Singleplayer/ForestCOUI/Layers/AB3/AB3_Art/AB3_Lighting/AB3_Ropes.lyr: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | -------------------------------------------------------------------------------- /samples/GameSDK/Levels/Singleplayer/ForestCOUI/Layers/AB3/AB3_Logic.lyr: -------------------------------------------------------------------------------- 1 | 2 | 35 | 36 | -------------------------------------------------------------------------------- /samples/GameSDK/Levels/Singleplayer/ForestCOUI/Layers/AB4.lyr: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | -------------------------------------------------------------------------------- /samples/GameSDK/Levels/Singleplayer/ForestCOUI/Layers/AB4/AB4_Logic.lyr: -------------------------------------------------------------------------------- 1 | 2 | 87 | 88 | -------------------------------------------------------------------------------- /samples/GameSDK/Levels/Singleplayer/ForestCOUI/LevelData/Environment.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /samples/GameSDK/Levels/Singleplayer/ForestCOUI/LevelData/GameTokens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /samples/GameSDK/Levels/Singleplayer/ForestCOUI/LevelData/Heightmap.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLabs/CoherentUI_CryEngine3/44b30e41e37a92ee16edbc6b738f996cfb3bd67e/samples/GameSDK/Levels/Singleplayer/ForestCOUI/LevelData/Heightmap.dat -------------------------------------------------------------------------------- /samples/GameSDK/Levels/Singleplayer/ForestCOUI/LevelData/TerrainTexture.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /samples/GameSDK/Levels/Singleplayer/ForestCOUI/LevelData/VegetationMap.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLabs/CoherentUI_CryEngine3/44b30e41e37a92ee16edbc6b738f996cfb3bd67e/samples/GameSDK/Levels/Singleplayer/ForestCOUI/LevelData/VegetationMap.dat -------------------------------------------------------------------------------- /samples/GameSDK/Levels/Singleplayer/ForestCOUI/filelist.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /samples/GameSDK/Levels/Singleplayer/ForestCOUI/level.pak: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLabs/CoherentUI_CryEngine3/44b30e41e37a92ee16edbc6b738f996cfb3bd67e/samples/GameSDK/Levels/Singleplayer/ForestCOUI/level.pak -------------------------------------------------------------------------------- /samples/GameSDK/Levels/Singleplayer/ForestCOUI/tags.txt: -------------------------------------------------------------------------------- 1 | 0.000000,0.000000,0.000000,0.000000,0.000000,0.000000 2 | 0.000000,0.000000,0.000000,0.000000,0.000000,0.000000 3 | 0.000000,0.000000,0.000000,0.000000,0.000000,0.000000 4 | 0.000000,0.000000,0.000000,0.000000,0.000000,0.000000 5 | 0.000000,0.000000,0.000000,0.000000,0.000000,0.000000 6 | 0.000000,0.000000,0.000000,0.000000,0.000000,0.000000 7 | 0.000000,0.000000,0.000000,0.000000,0.000000,0.000000 8 | 0.000000,0.000000,0.000000,0.000000,0.000000,0.000000 9 | 0.000000,0.000000,0.000000,0.000000,0.000000,0.000000 10 | 0.000000,0.000000,0.000000,0.000000,0.000000,0.000000 11 | 0.000000,0.000000,0.000000,0.000000,0.000000,0.000000 12 | 0.000000,0.000000,0.000000,0.000000,0.000000,0.000000 13 | -------------------------------------------------------------------------------- /samples/GameSDK/Levels/Singleplayer/ForestCOUI/terraintexture.pak: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLabs/CoherentUI_CryEngine3/44b30e41e37a92ee16edbc6b738f996cfb3bd67e/samples/GameSDK/Levels/Singleplayer/ForestCOUI/terraintexture.pak -------------------------------------------------------------------------------- /samples/GameSDK/Libs/UI/css/coherent.css: -------------------------------------------------------------------------------- 1 | body 2 | { 3 | overflow: hidden; 4 | padding: 0; 5 | margin: 0; 6 | font-family: 'Audiowide', cursive; 7 | -webkit-perspective: preserve-3d; 8 | } 9 | 10 | div 11 | { 12 | -webkit-user-select: none; 13 | } 14 | 15 | .HealthBar 16 | { 17 | opacity: 0.6; 18 | } 19 | 20 | .HealthBarTick 21 | { 22 | margin: 2px; 23 | width: 12px; 24 | height: 25px; 25 | float: left; 26 | background-color: rgba(128, 128, 128, 0.3); 27 | -webkit-box-shadow: inset 2px 2px 3px red; 28 | } 29 | 30 | .Filled.HealthBarTick 31 | { 32 | background-color: #829F06; 33 | -webkit-box-shadow: inset 2px 2px 3px #ffec13; 34 | } 35 | 36 | 37 | div.Digit 38 | { 39 | overflow: hidden; 40 | height: 40px; 41 | width: 22px; 42 | float: right; 43 | padding: 2px; 44 | } 45 | 46 | div.Digit > img 47 | { 48 | height: 100%; 49 | } 50 | 51 | div.Clear 52 | { 53 | clear: both; 54 | } 55 | 56 | #hud 57 | { 58 | position: absolute; 59 | width: 100%; 60 | height: 100%; 61 | -webkit-transform-style: preserve-3d; 62 | } 63 | 64 | #Interaction 65 | { 66 | display: none; 67 | position: absolute; 68 | top: 645px; 69 | left: 500px; 70 | color: #ffec13; 71 | text-shadow: 0px 0px 2px #000, 0px 0px 2px #000; 72 | } 73 | 74 | .WidgetMockup 75 | { 76 | border: 2px solid orange; 77 | background-color: #ffec13; 78 | opacity: 0.5; 79 | } 80 | 81 | @-webkit-keyframes compassForward 82 | { 83 | 0% 84 | { 85 | -webkit-transform: perspective(500) rotateX(-25deg) translateZ(20px); 86 | } 87 | 50% 88 | { 89 | -webkit-transform: perspective(500) rotateX(-15deg) translateZ(30px) translateY(10px); 90 | } 91 | 100% 92 | { 93 | -webkit-transform: perspective(500) rotateX(-25deg) translateZ(20px); 94 | } 95 | } 96 | 97 | @-webkit-keyframes compassBackward 98 | { 99 | 0% 100 | { 101 | -webkit-transform: perspective(500) rotateX(-25deg) translateZ(20px); 102 | } 103 | 50% 104 | { 105 | -webkit-transform: perspective(500) rotateX(-28deg) translateZ(20px) translateY(5px); 106 | } 107 | 100% 108 | { 109 | -webkit-transform: perspective(500) rotateX(-25deg) translateZ(20px); 110 | } 111 | } 112 | 113 | #compass 114 | { 115 | position: absolute; 116 | top: 10px; 117 | width: 400px; 118 | left: -webkit-calc(50% - 200px); 119 | height: 80px; 120 | color: #ffec13; 121 | -webkit-transform: perspective(500) rotateX(-25deg) translateZ(20px); 122 | } 123 | 124 | #compass.Forward 125 | { 126 | -webkit-animation: compassForward 1s infinite; 127 | } 128 | 129 | #compass.Backward 130 | { 131 | -webkit-animation: compassBackward 1s infinite; 132 | } 133 | 134 | #noisyGadget 135 | { 136 | position: absolute; 137 | top: 20px; 138 | right: 20px; 139 | width: 200px; 140 | height: 200px; 141 | float: left; 142 | -webkit-transform: perspective(500) rotateX(-20deg) rotateY(-20deg); 143 | } 144 | 145 | @-webkit-keyframes noisyForward 146 | { 147 | 0% 148 | { 149 | -webkit-transform: perspective(500) rotateX(-20deg) rotateY(-20deg); 150 | } 151 | 50% 152 | { 153 | -webkit-transform: perspective(500) rotateX(-15deg) rotateY(-15deg) translateX(10px) translateY(10px); 154 | } 155 | 100% 156 | { 157 | -webkit-transform: perspective(500) rotateX(-20deg) rotateY(-20deg); 158 | } 159 | } 160 | 161 | @-webkit-keyframes noisyBackward 162 | { 163 | 0% 164 | { 165 | -webkit-transform: perspective(500) rotateX(-20deg) rotateY(-20deg); 166 | } 167 | 50% 168 | { 169 | -webkit-transform: perspective(500) rotateX(-25deg) rotateY(-25deg) translateX(10px) translateY(20px); 170 | } 171 | 100% 172 | { 173 | -webkit-transform: perspective(500) rotateX(-20deg) rotateY(-20deg); 174 | } 175 | } 176 | 177 | #noisyGadget.Forward 178 | { 179 | -webkit-animation: noisyForward 1s infinite; 180 | } 181 | 182 | #noisyGadget.Backward 183 | { 184 | -webkit-animation: noisyBackward 1s infinite; 185 | } 186 | 187 | #oscilloscopeHolder 188 | { 189 | position: absolute; 190 | left: 30px; 191 | bottom: 30px; 192 | width: 150px; 193 | height: 80px; 194 | background-image: url('../img/scope.png'); 195 | -webkit-transform: perspective(500) rotateX(20deg) rotateY(20deg); 196 | opacity: 0.8; 197 | } 198 | 199 | #oscilloscope 200 | { 201 | padding: 3px; 202 | } 203 | 204 | 205 | @-webkit-keyframes oscilloscopeForward 206 | { 207 | 0% 208 | { 209 | -webkit-transform: perspective(500) rotateX(20deg) rotateY(20deg); 210 | } 211 | 50% 212 | { 213 | -webkit-transform: perspective(500) rotateX(15deg) rotateY(15deg) translateX(10px) translateY(20px); 214 | } 215 | 100% 216 | { 217 | -webkit-transform: perspective(500) rotateX(20deg) rotateY(20deg); 218 | } 219 | } 220 | 221 | @-webkit-keyframes oscilloscopeBackward 222 | { 223 | 0% 224 | { 225 | -webkit-transform: perspective(500) rotateX(20deg) rotateY(20deg); 226 | } 227 | 50% 228 | { 229 | -webkit-transform: perspective(500) rotateX(25deg) rotateY(25deg) translateX(10px) translateY(20px); 230 | } 231 | 100% 232 | { 233 | -webkit-transform: perspective(500) rotateX(20deg) rotateY(20deg); 234 | } 235 | } 236 | 237 | 238 | #oscilloscopeHolder.Forward 239 | { 240 | -webkit-animation: oscilloscopeForward 1s infinite; 241 | } 242 | 243 | #oscilloscopeHolder.Backward 244 | { 245 | -webkit-animation: oscilloscopeBackward 1s infinite; 246 | } 247 | 248 | @-webkit-keyframes playerStatsForward 249 | { 250 | 0% 251 | { 252 | -webkit-transform: perspective(500) rotateX(20deg) rotateY(-20deg); 253 | } 254 | 50% 255 | { 256 | -webkit-transform: perspective(500) rotateX(15deg) rotateY(-15deg) translateX(10px) translateY(20px); 257 | } 258 | 100% 259 | { 260 | -webkit-transform: perspective(500) rotateX(20deg) rotateY(-20deg); 261 | } 262 | } 263 | 264 | @-webkit-keyframes playerStatsBackward 265 | { 266 | 0% 267 | { 268 | -webkit-transform: perspective(500) rotateX(20deg) rotateY(-20deg); 269 | } 270 | 50% 271 | { 272 | -webkit-transform: perspective(500) rotateX(25deg) rotateY(-25deg) translateX(10px) translateY(20px); 273 | } 274 | 100% 275 | { 276 | -webkit-transform: perspective(500) rotateX(20deg) rotateY(-20deg); 277 | } 278 | } 279 | 280 | #playerStats 281 | { 282 | position: absolute; 283 | bottom: 30px; 284 | right: 50px; 285 | width: 160px; 286 | height: 100px; 287 | float: right; 288 | text-align: center; 289 | -webkit-transform: perspective(500) rotateX(20deg) rotateY(-20deg); 290 | } 291 | 292 | #playerStats.Forward 293 | { 294 | -webkit-animation: playerStatsForward 1s infinite; 295 | } 296 | 297 | #playerStats.Backward 298 | { 299 | -webkit-animation: playerStatsBackward 1s infinite; 300 | } 301 | 302 | @-webkit-keyframes turning_cw 303 | { 304 | 0% 305 | { 306 | -webkit-transform: rotate(0deg); 307 | } 308 | 100% 309 | { 310 | -webkit-transform: rotate(360deg); 311 | } 312 | } 313 | 314 | @-webkit-keyframes turning_acw 315 | { 316 | 0% 317 | { 318 | -webkit-transform: rotate(360deg); 319 | } 320 | 100% 321 | { 322 | -webkit-transform: rotate(0deg); 323 | } 324 | } 325 | 326 | div.OuterCircle 327 | { 328 | text-align: center; 329 | width: 100%; 330 | height: 100%; 331 | position: relative; 332 | opacity: 0.5; 333 | background-image: url('../img/gadget_outer.png'); 334 | -webkit-animation: turning_cw 5s infinite; 335 | } 336 | 337 | 338 | div.InnerCircle 339 | { 340 | position:absolute; 341 | width: 100%; 342 | height: 100%; 343 | background-image: url('../img/gadget_inner.png'); 344 | -webkit-transform: rotate(360deg); 345 | -webkit-animation: turning_acw 4s infinite; 346 | } 347 | 348 | div.CenterCircle 349 | { 350 | position: absolute; 351 | width: 100%; 352 | height: 100%; 353 | background-image: url('../img/gadget_center.png'); 354 | -webkit-transform: rotate(360deg); 355 | -webkit-animation: turning_cw 5s infinite; 356 | } 357 | 358 | div.GadgetContent 359 | { 360 | position:absolute; 361 | top: 0px; 362 | left: 0px; 363 | width: 100%; 364 | height: 100%; 365 | background: rgba(0, 0, 0, 0); 366 | text-align: center; 367 | line-height: 200px; 368 | font-size: 32px; 369 | color: #ffec13; 370 | text-shadow: 0 4px 4px #fcac6a; 371 | font-weight: bold; 372 | } 373 | 374 | div.GadgetContent > img 375 | { 376 | padding: 70px; 377 | width: 60px; 378 | height: 60px; 379 | } 380 | -------------------------------------------------------------------------------- /samples/GameSDK/Libs/UI/css/compass.css: -------------------------------------------------------------------------------- 1 | #stage { 2 | width: 400px; 3 | height: 300px; 4 | /* 5 | 6 | Setting the perspective of the contents of the stage 7 | but not the stage itself 8 | 9 | */ 10 | -webkit-perspective: 800; 11 | } 12 | 13 | .ring { 14 | margin: 0 auto; 15 | height: 110px; 16 | width: 400px; 17 | -webkit-transform-style: preserve-3d; 18 | } 19 | 20 | .poster { 21 | position: absolute; 22 | left: 150px; 23 | width: 100px; 24 | height: 100px; 25 | opacity: 0.7; 26 | } 27 | 28 | .poster > p { 29 | font-size: 20px; 30 | text-align: center; 31 | margin-top: 5px; 32 | } 33 | 34 | #compassImage { 35 | width: 100%; 36 | height: 110px; 37 | -webkit-transform-style: preserve-3d; 38 | /* 39 | overflow: hidden; 40 | */ 41 | } 42 | -------------------------------------------------------------------------------- /samples/GameSDK/Libs/UI/css/fonts.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: 'Audiowide'; 3 | font-style: normal; 4 | font-weight: 400; 5 | src: local('Audiowide'), local('Audiowide-Regular'), url('../fonts/Audiowide.woff') format('woff'); 6 | } -------------------------------------------------------------------------------- /samples/GameSDK/Libs/UI/css/map.css: -------------------------------------------------------------------------------- 1 | 2 | .olControlAttribution { 3 | bottom: 5px; 4 | } 5 | 6 | .smallmap { 7 | width: 386px; 8 | height: 256px; 9 | } 10 | 11 | #map { 12 | position: absolute; 13 | top: 120px; 14 | left: 60px; 15 | 16 | -webkit-transform: perspective(500) rotateX(-20deg) rotateY(20deg); 17 | } 18 | -------------------------------------------------------------------------------- /samples/GameSDK/Libs/UI/css/tips.css: -------------------------------------------------------------------------------- 1 | li.tip 2 | { 3 | list-style-type: none; 4 | width: 36px; 5 | height: 36px; 6 | border: 2px solid #fcac6a; 7 | border-radius: 22px; 8 | padding: 2px; 9 | margin: 4px; 10 | -webkit-transition: width 2s ease-in-out; 11 | display: none; 12 | overflow: hidden; 13 | background-color: rgba(255, 235, 19, 0.2); 14 | } 15 | 16 | li.rollIn 17 | { 18 | width: 250px; 19 | } 20 | 21 | li.rollOut 22 | { 23 | width: 36px; 24 | } 25 | 26 | div.tipIcon 27 | { 28 | background-image: url('../img/icon.png'); 29 | background-repeat: no-repeat; 30 | background-size: cover; 31 | width: 34px; 32 | height: 34px; 33 | float: right; 34 | } 35 | 36 | .rollIn > div.tipIcon 37 | { 38 | -webkit-animation: turning_cw 1.25s infinite linear; 39 | } 40 | 41 | .rollOut > div.tipIcon 42 | { 43 | -webkit-animation: turning_acw 1.25s infinite linear; 44 | } 45 | 46 | div.tipText 47 | { 48 | width: 100%; 49 | height: 32px; 50 | padding-top: 6px; 51 | padding-left: 6px; 52 | display: none; 53 | color: white; 54 | } 55 | 56 | #tipBox 57 | { 58 | position: relative; 59 | top: 20px; 60 | left: -5px; 61 | } 62 | -------------------------------------------------------------------------------- /samples/GameSDK/Libs/UI/fonts/Audiowide.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLabs/CoherentUI_CryEngine3/44b30e41e37a92ee16edbc6b738f996cfb3bd67e/samples/GameSDK/Libs/UI/fonts/Audiowide.woff -------------------------------------------------------------------------------- /samples/GameSDK/Libs/UI/hud.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Coherent UI Demo 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 |
18 |
    19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 | 30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
Press (Esc) to exit interaction mode
50 |
51 |
52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 148 | 154 | 164 | 165 | 166 | -------------------------------------------------------------------------------- /samples/GameSDK/Libs/UI/img/Coherent UI - icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLabs/CoherentUI_CryEngine3/44b30e41e37a92ee16edbc6b738f996cfb3bd67e/samples/GameSDK/Libs/UI/img/Coherent UI - icon.png -------------------------------------------------------------------------------- /samples/GameSDK/Libs/UI/img/Forest.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLabs/CoherentUI_CryEngine3/44b30e41e37a92ee16edbc6b738f996cfb3bd67e/samples/GameSDK/Libs/UI/img/Forest.jpg -------------------------------------------------------------------------------- /samples/GameSDK/Libs/UI/img/digits.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLabs/CoherentUI_CryEngine3/44b30e41e37a92ee16edbc6b738f996cfb3bd67e/samples/GameSDK/Libs/UI/img/digits.png -------------------------------------------------------------------------------- /samples/GameSDK/Libs/UI/img/gadget_center.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLabs/CoherentUI_CryEngine3/44b30e41e37a92ee16edbc6b738f996cfb3bd67e/samples/GameSDK/Libs/UI/img/gadget_center.png -------------------------------------------------------------------------------- /samples/GameSDK/Libs/UI/img/gadget_inner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLabs/CoherentUI_CryEngine3/44b30e41e37a92ee16edbc6b738f996cfb3bd67e/samples/GameSDK/Libs/UI/img/gadget_inner.png -------------------------------------------------------------------------------- /samples/GameSDK/Libs/UI/img/gadget_outer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLabs/CoherentUI_CryEngine3/44b30e41e37a92ee16edbc6b738f996cfb3bd67e/samples/GameSDK/Libs/UI/img/gadget_outer.png -------------------------------------------------------------------------------- /samples/GameSDK/Libs/UI/img/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLabs/CoherentUI_CryEngine3/44b30e41e37a92ee16edbc6b738f996cfb3bd67e/samples/GameSDK/Libs/UI/img/icon.png -------------------------------------------------------------------------------- /samples/GameSDK/Libs/UI/img/scope.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLabs/CoherentUI_CryEngine3/44b30e41e37a92ee16edbc6b738f996cfb3bd67e/samples/GameSDK/Libs/UI/img/scope.png -------------------------------------------------------------------------------- /samples/GameSDK/Libs/UI/js/OpenLayers/img/layer-switcher-maximize.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLabs/CoherentUI_CryEngine3/44b30e41e37a92ee16edbc6b738f996cfb3bd67e/samples/GameSDK/Libs/UI/js/OpenLayers/img/layer-switcher-maximize.png -------------------------------------------------------------------------------- /samples/GameSDK/Libs/UI/js/OpenLayers/img/layer-switcher-minimize.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLabs/CoherentUI_CryEngine3/44b30e41e37a92ee16edbc6b738f996cfb3bd67e/samples/GameSDK/Libs/UI/js/OpenLayers/img/layer-switcher-minimize.png -------------------------------------------------------------------------------- /samples/GameSDK/Libs/UI/js/OpenLayers/img/marker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLabs/CoherentUI_CryEngine3/44b30e41e37a92ee16edbc6b738f996cfb3bd67e/samples/GameSDK/Libs/UI/js/OpenLayers/img/marker.png -------------------------------------------------------------------------------- /samples/GameSDK/Libs/UI/js/OpenLayers/img/marker_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLabs/CoherentUI_CryEngine3/44b30e41e37a92ee16edbc6b738f996cfb3bd67e/samples/GameSDK/Libs/UI/js/OpenLayers/img/marker_default.png -------------------------------------------------------------------------------- /samples/GameSDK/Libs/UI/js/compass.js: -------------------------------------------------------------------------------- 1 | (function (window) { 2 | 'use strict;' 3 | 4 | const POSTERS_PER_ROW = 16; 5 | const RING_RADIUS = 100; 6 | 7 | var lables = ['N', '◇', 'NE', '◇', 'E', '◇', 'SE', '◇', 'S', '◇', 'SW', '◇', 'W', '◇', 'NW', '◇'] 8 | 9 | function setup_posters (row) 10 | { 11 | var posterAngle = 360 / lables.length; 12 | for (var i = 0; i < lables.length; i ++) { 13 | var poster = window.document.createElement('div'); 14 | poster.className = 'poster'; 15 | // compute and assign the transform for this poster 16 | var transform = 'rotateY(' + (posterAngle * i) + 'deg) translateZ(' + RING_RADIUS + 'px)'; 17 | poster.style.webkitTransform = transform; 18 | // setup the number to show inside the poster 19 | var content = poster.appendChild(window.document.createElement('p')); 20 | content.innerHTML = lables[i]; 21 | // add the poster to the row 22 | row.appendChild(poster); 23 | } 24 | } 25 | 26 | function init () 27 | { 28 | setup_posters(window.document.getElementById('compassImage')); 29 | rotate(0); 30 | } 31 | 32 | // call init once the window.document is fully loaded 33 | window.addEventListener('load', init, false); 34 | 35 | function normalizeAngle(a) { 36 | var t = a + 360; 37 | return t - Math.floor(t / 360) * 360; 38 | } 39 | 40 | 41 | function rotate(rotation) { 42 | var x = window.document.getElementById('compassImage'); 43 | 44 | rotation = normalizeAngle(rotation); 45 | x.style.webkitTransform = 'rotateY(' + (-rotation) + 'deg)'; 46 | 47 | var c = x.children; 48 | var n = c.length; 49 | var angle = 360 / n; 50 | var n1 = normalizeAngle(rotation + 90); 51 | var n2 = normalizeAngle(rotation + 270); 52 | var nl = n1; 53 | var nr = n2; 54 | var invert = 0; 55 | 56 | if (nl > nr) { 57 | invert = 180; 58 | nl = n2; 59 | nr = n1; 60 | } 61 | 62 | for (var i = 0; i < n; ++i) { 63 | var a = normalizeAngle(i * angle + invert); 64 | if (a >= nl && a <= nr) { 65 | c[i].style.display = 'none'; 66 | } 67 | else 68 | { 69 | c[i].style.display = 'block'; 70 | } 71 | } 72 | } 73 | 74 | window.Compass = { SetRotation: rotate }; 75 | }(window)); -------------------------------------------------------------------------------- /samples/GameSDK/Libs/UI/js/map.js: -------------------------------------------------------------------------------- 1 | (function (window, engine, $) { 2 | 'use strict'; 3 | 4 | var map; 5 | var myMarker; 6 | 7 | function InitializeMap() 8 | { 9 | map = new OpenLayers.Map('map'); 10 | 11 | // 12 | // Coordinate systems relative to Forest.jpg 13 | // 14 | // OpenLayers CryEngine 15 | // 16 | // ^ +Y ^ -X 17 | // | | 18 | // -X | +X -Y | +Y 19 | // <-----+-----> <-----+-----> 20 | // | | 21 | // | | 22 | // v -Y v +X 23 | // 24 | 25 | var graphic = new OpenLayers.Layer.Image( 26 | 'Forest', 27 | 'img/Forest.jpg', 28 | new OpenLayers.Bounds(6, -1240, 1024, -200), 29 | new OpenLayers.Size(2048, 2048), 30 | {numZoomLevels: 4} 31 | ); 32 | 33 | graphic.events.on({ 34 | loadstart: function() { 35 | OpenLayers.Console.log("loadstart"); 36 | }, 37 | loadend: function() { 38 | OpenLayers.Console.log("loadend"); 39 | } 40 | }); 41 | 42 | map.addLayer(graphic); 43 | map.addControl(new OpenLayers.Control.LayerSwitcher()); 44 | map.zoomToMaxExtent(); 45 | 46 | var markers = new OpenLayers.Layer.Markers( "Markers" ); 47 | map.addLayer(markers); 48 | 49 | // Some decent default coordinates around the spawn location 50 | var markerDefaultCoordinates = new OpenLayers.LonLat(350,-850); 51 | myMarker = new OpenLayers.Marker(markerDefaultCoordinates); 52 | map.setCenter(markerDefaultCoordinates); 53 | markers.addMarker(myMarker); 54 | 55 | // Bind engine methods 56 | engine.on('SetPlayerPositionOnMap', function (x, y) { 57 | MoveMarker(y, -x); 58 | }); 59 | 60 | engine.on('SetPlayerRotationOnMap', function (deg) { 61 | SetMarkerRotation(deg); 62 | }); 63 | 64 | engine.on('ShowMap', function (show) { 65 | ShowMap(show); 66 | }); 67 | } 68 | 69 | function MoveMarker(lon, lat){ 70 | var newPx = map.getLayerPxFromViewPortPx( 71 | map.getPixelFromLonLat( 72 | new OpenLayers.LonLat(lon, lat) 73 | .transform(map.displayProjection, map.projection) 74 | ) 75 | ); 76 | myMarker.moveTo(newPx); 77 | 78 | // Ensure the marker is visible after the move 79 | var vpExtents = map.getExtent(); 80 | if ( 81 | vpExtents.left > myMarker.lonlat.lon || 82 | vpExtents.right < myMarker.lonlat.lon || 83 | vpExtents.bottom > myMarker.lonlat.lat || 84 | vpExtents.top < myMarker.lonlat.lat 85 | ) 86 | { 87 | map.setCenter(myMarker.lonlat); 88 | } 89 | } 90 | 91 | function SetMarkerRotation(deg) 92 | { 93 | myMarker.icon.imageDiv.style.webkitTransform = "rotate(" + deg + "deg)"; 94 | } 95 | 96 | function ShowMap(show) 97 | { 98 | $("#map").css("display", show ? "block" : "none"); 99 | } 100 | 101 | InitializeMap(); 102 | ShowMap(false); 103 | 104 | })(window, engine, $); -------------------------------------------------------------------------------- /samples/GameSDK/Libs/UI/js/oscilloscope.js: -------------------------------------------------------------------------------- 1 | (function ($, window, engine) { 2 | 'use strict'; 3 | 4 | var sparkData = [], 5 | sparkIndex = 0, 6 | sparkMult = 3, 7 | sparkChange = 50; 8 | 9 | function GenerateSparklineData(samples, remove) { 10 | if (remove !== null) { 11 | sparkData.splice(0, remove); 12 | } 13 | for (var s = sparkData.length; s < samples; ++s) { 14 | sparkData.push(Math.sin(sparkIndex++ * sparkMult) * 16); 15 | if (sparkIndex == sparkChange) { 16 | sparkMult = 3 + Math.random() * (sparkMult < 3? 0.5 : -0.5); 17 | sparkChange += Math.floor(4 * sparkMult * s / 16); 18 | } 19 | } 20 | return sparkData; 21 | } 22 | 23 | function Sparkles(samples, remove) 24 | { 25 | $('#oscilloscope').sparkline(GenerateSparklineData(samples, remove), { 26 | type: 'line', 27 | lineColor: '#82DF06', 28 | fillColor: false, 29 | spotColor: false, 30 | minSpotColor: false, 31 | maxSpotColor: false, 32 | chartRangeMin: -18, 33 | chartRangeMax: 18, 34 | height: '100%', 35 | width: '96%', 36 | disableInteraction: true 37 | }); 38 | } 39 | 40 | function SparkAnimate() { 41 | Sparkles(100, 1); 42 | } 43 | 44 | engine.on('Ready', function () { 45 | Sparkles(100); 46 | window.setInterval(SparkAnimate, 100); 47 | }); 48 | })($, window, engine); -------------------------------------------------------------------------------- /samples/GameSDK/Libs/UI/js/player.js: -------------------------------------------------------------------------------- 1 | (function (window, _, engine, $) { 2 | 'use strict'; 3 | 4 | function CreateHealthBar(id, ticks) { 5 | var t = _.template($('#healthBarTemplate').html()); 6 | return $(t({id: id, ticks: ticks})); 7 | } 8 | 9 | function SetHealthBar(value) { 10 | var ticks = $('#healthBarTicks > div.HealthBarTick'), 11 | length = ticks.length, 12 | limit = Math.round(value * length / 100), 13 | i; 14 | 15 | for (i = 0; i < limit; ++i) { 16 | $(ticks[i]).addClass('Filled'); 17 | } 18 | for (i = limit; i < length; ++i) { 19 | $(ticks[i]).removeClass('Filled'); 20 | } 21 | } 22 | 23 | function SetHealthDigits(value) { 24 | var healthDigits = $('#health > div > img'), 25 | digits = healthDigits.length; 26 | 27 | for (var i = 0; i < digits; ++i) { 28 | var digit = value % 10; 29 | $(healthDigits[i]).css('margin-left', -1 + -24 * digit); 30 | value = (value - digit) / 10; 31 | } 32 | } 33 | 34 | function SetHealth(value) { 35 | var health = (value > 0) ? (value < 100 ? value : 99) : 0; 36 | Player.health = health; 37 | SetHealthBar(health); 38 | SetHealthDigits(health); 39 | } 40 | 41 | engine.on('OnPlayerHealthChanged', SetHealth); 42 | 43 | engine.on('Ready', function () { 44 | $('#healthBar').html(CreateHealthBar('healthBarTicks', 10)); 45 | SetHealth(99); 46 | }); 47 | 48 | window.Player = { health : 99 }; 49 | })(window, _, engine, $); -------------------------------------------------------------------------------- /samples/GameSDK/Libs/UI/js/tips.js: -------------------------------------------------------------------------------- 1 | (function (window, engine, $, _) { 2 | 'use strict'; 3 | 4 | var tips = ['Go Go Go!', 'HTML5', 'CSS3', 'JavaScript'], 5 | fadingTime = 500, // ms 6 | rollInTime = 3000, // ms 7 | displayTime = 2000, // ms 8 | tipTemplate; 9 | 10 | function GetRollerOut(item) { 11 | return function () { 12 | window.setTimeout(function () { 13 | $(item.children()[1]).fadeOut(fadingTime, function () { 14 | item.addClass('rollOut'); 15 | 16 | window.setTimeout(function () { 17 | item.fadeOut(fadingTime, function () { item.detach(); }); 18 | }, rollInTime + 2 * fadingTime); 19 | }); 20 | }, displayTime); 21 | }; 22 | } 23 | 24 | function GetRollerIn(item) { 25 | return function () { 26 | item.addClass('rollIn'); 27 | 28 | window.setTimeout(function () { 29 | $(item.children()[1]).fadeIn(fadingTime, GetRollerOut(item)); 30 | }, rollInTime); 31 | }; 32 | } 33 | 34 | function ShowTip(tip) { 35 | var item = $(tipTemplate({text: tip})), 36 | box = $('#tipBox'); 37 | 38 | item.fadeIn(fadingTime, GetRollerIn(item)); 39 | box.append(item); 40 | } 41 | 42 | function ShowRandomTip() { 43 | var index = Math.floor(Math.random() * tips.length); 44 | ShowTip(tips[index]); 45 | window.setTimeout(ShowRandomTip, 16000 + Math.random() * 4000); 46 | } 47 | 48 | engine.on('Ready', function () { 49 | tipTemplate = _.template($('#tipTemplate').html()); 50 | }); 51 | engine.on('Ready', ShowRandomTip); 52 | 53 | })(window, engine, $, _); -------------------------------------------------------------------------------- /samples/GameSDK/Objects/curve.cgf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLabs/CoherentUI_CryEngine3/44b30e41e37a92ee16edbc6b738f996cfb3bd67e/samples/GameSDK/Objects/curve.cgf -------------------------------------------------------------------------------- /samples/GameSDK/Objects/jointedBreakable_example.cgf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLabs/CoherentUI_CryEngine3/44b30e41e37a92ee16edbc6b738f996cfb3bd67e/samples/GameSDK/Objects/jointedBreakable_example.cgf -------------------------------------------------------------------------------- /samples/GameSDK/Objects/placeholder_1024_576.mtl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /samples/GameSDK/Objects/placeholder_1024_768.mtl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /samples/GameSDK/Objects/placeholder_nomips_argb_1024_576_dxt1.dds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLabs/CoherentUI_CryEngine3/44b30e41e37a92ee16edbc6b738f996cfb3bd67e/samples/GameSDK/Objects/placeholder_nomips_argb_1024_576_dxt1.dds -------------------------------------------------------------------------------- /samples/GameSDK/Objects/placeholder_nomips_argb_1024_768_dxt1.dds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLabs/CoherentUI_CryEngine3/44b30e41e37a92ee16edbc6b738f996cfb3bd67e/samples/GameSDK/Objects/placeholder_nomips_argb_1024_768_dxt1.dds -------------------------------------------------------------------------------- /samples/GameSDK/Objects/placeholder_nomips_argb_1280_720_dxt1.dds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLabs/CoherentUI_CryEngine3/44b30e41e37a92ee16edbc6b738f996cfb3bd67e/samples/GameSDK/Objects/placeholder_nomips_argb_1280_720_dxt1.dds -------------------------------------------------------------------------------- /samples/GameSDK/Objects/placeholder_nomips_argb_1280_960_dxt1.dds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLabs/CoherentUI_CryEngine3/44b30e41e37a92ee16edbc6b738f996cfb3bd67e/samples/GameSDK/Objects/placeholder_nomips_argb_1280_960_dxt1.dds -------------------------------------------------------------------------------- /samples/curve.obj: -------------------------------------------------------------------------------- 1 | # 3ds Max Wavefront OBJ Exporter v0.97b - (c)2007 guruware 2 | # File Created: 20.10.2012 22:27:58 3 | 4 | # 5 | # object Box001 6 | # 7 | 8 | v -0.0150 -1.4200 0.2526 9 | v -0.1904 -1.1044 0.2375 10 | v -0.1604 -1.1044 0.2375 11 | v 0.0150 -1.4200 0.2526 12 | v -0.3313 -0.7889 0.1982 13 | v -0.3013 -0.7889 0.1982 14 | v -0.4315 -0.4733 0.1436 15 | v -0.4015 -0.4733 0.1436 16 | v -0.4846 -0.1578 0.0828 17 | v -0.4546 -0.1578 0.0828 18 | v -0.4844 0.1578 0.0247 19 | v -0.4544 0.1578 0.0247 20 | v -0.4246 0.4733 -0.0216 21 | v -0.3946 0.4733 -0.0216 22 | v -0.2990 0.7889 -0.0472 23 | v -0.2690 0.7889 -0.0472 24 | v -0.1012 1.1044 -0.0430 25 | v -0.0712 1.1044 -0.0430 26 | v 0.1750 1.4200 0.0000 27 | v 0.2050 1.4200 0.0000 28 | v -0.0150 -1.4200 1.8526 29 | v 0.0150 -1.4200 1.8526 30 | v -0.1378 -1.1044 1.8375 31 | v -0.1678 -1.1044 1.8375 32 | v -0.2618 -0.7889 1.7982 33 | v -0.2918 -0.7889 1.7982 34 | v -0.3506 -0.4733 1.7436 35 | v -0.3806 -0.4733 1.7436 36 | v -0.3981 -0.1578 1.6828 37 | v -0.4281 -0.1578 1.6828 38 | v -0.3979 0.1578 1.6247 39 | v -0.4279 0.1578 1.6247 40 | v -0.3438 0.4733 1.5784 41 | v -0.3738 0.4733 1.5784 42 | v -0.2294 0.7889 1.5528 43 | v -0.2594 0.7889 1.5528 44 | v -0.0486 1.1044 1.5570 45 | v -0.0786 1.1044 1.5570 46 | v 0.2050 1.4200 1.6000 47 | v 0.1750 1.4200 1.6000 48 | # 40 vertices 49 | 50 | vt 1.0000 0.0000 0.0000 51 | vt 1.0000 0.1111 0.0000 52 | vt 0.0000 0.1111 0.0000 53 | vt 0.0000 0.0000 0.0000 54 | vt 1.0000 0.2222 0.0000 55 | vt 0.0000 0.2222 0.0000 56 | vt 1.0000 0.3333 0.0000 57 | vt 0.0000 0.3333 0.0000 58 | vt 1.0000 0.4444 0.0000 59 | vt 0.0000 0.4444 0.0000 60 | vt 1.0000 0.5556 0.0000 61 | vt 0.0000 0.5556 0.0000 62 | vt 1.0000 0.6667 0.0000 63 | vt 0.0000 0.6667 0.0000 64 | vt 1.0000 0.7778 0.0000 65 | vt 0.0000 0.7778 0.0000 66 | vt 1.0000 0.8889 0.0000 67 | vt 0.0000 0.8889 0.0000 68 | vt 1.0000 1.0000 0.0000 69 | vt 0.0000 1.0000 0.0000 70 | vt 0.1111 0.0000 0.0000 71 | vt 0.1111 1.0000 0.0000 72 | vt 0.2222 0.0000 0.0000 73 | vt 0.2222 1.0000 0.0000 74 | vt 0.3333 0.0000 0.0000 75 | vt 0.3333 1.0000 0.0000 76 | vt 0.4444 0.0000 0.0000 77 | vt 0.4444 1.0000 0.0000 78 | vt 0.5556 0.0000 0.0000 79 | vt 0.5556 1.0000 0.0000 80 | vt 0.6667 0.0000 0.0000 81 | vt 0.6667 1.0000 0.0000 82 | vt 0.7778 0.0000 0.0000 83 | vt 0.7778 1.0000 0.0000 84 | vt 0.8889 0.0000 0.0000 85 | vt 0.8889 1.0000 0.0000 86 | # 36 texture coords 87 | 88 | g Box001 89 | f 1/1 2/2 3/3 90 | f 3/3 4/4 1/1 91 | f 2/2 5/5 6/6 92 | f 6/6 3/3 2/2 93 | f 5/5 7/7 8/8 94 | f 8/8 6/6 5/5 95 | f 7/7 9/9 10/10 96 | f 10/10 8/8 7/7 97 | f 9/9 11/11 12/12 98 | f 12/12 10/10 9/9 99 | f 11/11 13/13 14/14 100 | f 14/14 12/12 11/11 101 | f 13/13 15/15 16/16 102 | f 16/16 14/14 13/13 103 | f 15/15 17/17 18/18 104 | f 18/18 16/16 15/15 105 | f 17/17 19/19 20/20 106 | f 20/20 18/18 17/17 107 | f 21/4 22/1 23/2 108 | f 23/2 24/3 21/4 109 | f 24/3 23/2 25/5 110 | f 25/5 26/6 24/3 111 | f 26/6 25/5 27/7 112 | f 27/7 28/8 26/6 113 | f 28/8 27/7 29/9 114 | f 29/9 30/10 28/8 115 | f 30/10 29/9 31/11 116 | f 31/11 32/12 30/10 117 | f 32/12 31/11 33/13 118 | f 33/13 34/14 32/12 119 | f 34/14 33/13 35/15 120 | f 35/15 36/16 34/14 121 | f 36/16 35/15 37/17 122 | f 37/17 38/18 36/16 123 | f 38/18 37/17 39/19 124 | f 39/19 40/20 38/18 125 | f 1/4 4/1 22/19 126 | f 22/19 21/20 1/4 127 | f 4/4 3/21 23/22 128 | f 23/22 22/20 4/4 129 | f 3/21 6/23 25/24 130 | f 25/24 23/22 3/21 131 | f 6/23 8/25 27/26 132 | f 27/26 25/24 6/23 133 | f 8/25 10/27 29/28 134 | f 29/28 27/26 8/25 135 | f 10/27 12/29 31/30 136 | f 31/30 29/28 10/27 137 | f 12/29 14/31 33/32 138 | f 33/32 31/30 12/29 139 | f 14/31 16/33 35/34 140 | f 35/34 33/32 14/31 141 | f 16/33 18/35 37/36 142 | f 37/36 35/34 16/33 143 | f 18/35 20/1 39/19 144 | f 39/19 37/36 18/35 145 | f 20/4 19/1 40/19 146 | f 40/19 39/20 20/4 147 | f 19/4 17/21 38/22 148 | f 38/22 40/20 19/4 149 | f 17/21 15/23 36/24 150 | f 36/24 38/22 17/21 151 | f 15/23 13/25 34/26 152 | f 34/26 36/24 15/23 153 | f 13/25 11/27 32/28 154 | f 32/28 34/26 13/25 155 | f 11/27 9/29 30/30 156 | f 30/30 32/28 11/27 157 | f 9/29 7/31 28/32 158 | f 28/32 30/30 9/29 159 | f 7/31 5/33 26/34 160 | f 26/34 28/32 7/31 161 | f 5/33 2/35 24/36 162 | f 24/36 26/34 5/33 163 | f 2/35 1/1 21/19 164 | f 21/19 24/36 2/35 165 | # 76 faces 166 | 167 | -------------------------------------------------------------------------------- /src/CPluginCoherentUI.cpp: -------------------------------------------------------------------------------- 1 | /* CoherentUI_Plugin - for licensing and copyright see license.txt */ 2 | 3 | #include 4 | #include 5 | #include "CoherentUISystem.h" 6 | 7 | namespace CoherentUIPlugin 8 | { 9 | CPluginCoherentUI* gPlugin = NULL; 10 | D3DPlugin::IPluginD3D* gD3DSystem = NULL; 11 | void* gD3DDevice = NULL; 12 | 13 | CPluginCoherentUI::CPluginCoherentUI() 14 | { 15 | gPlugin = this; 16 | } 17 | 18 | CPluginCoherentUI::~CPluginCoherentUI() 19 | { 20 | Release( true ); 21 | 22 | gPlugin = NULL; 23 | } 24 | 25 | bool CPluginCoherentUI::Release( bool bForce ) 26 | { 27 | bool bRet = true; 28 | bool bWasInitialized = m_bIsFullyInitialized; // Will be reset by base class so backup 29 | 30 | if ( !m_bCanUnload ) 31 | { 32 | // Note: Type Unregistration will be automatically done by the Base class (Through RegisterTypes) 33 | // Should be called while Game is still active otherwise there might be leaks/problems 34 | bRet = CPluginBase::Release( bForce ); 35 | 36 | if ( bRet ) 37 | { 38 | ShutdownSystem(); 39 | 40 | if ( gD3DSystem ) 41 | { 42 | PluginManager::safeReleasePlugin( "D3D", gD3DSystem ); 43 | } 44 | 45 | // Cleanup like this always (since the class is static its cleaned up when the dll is unloaded) 46 | gPluginManager->UnloadPlugin( GetName() ); 47 | 48 | // Allow Plugin Manager garbage collector to unload this plugin 49 | AllowDllUnload(); 50 | } 51 | } 52 | 53 | return bRet; 54 | }; 55 | 56 | bool CPluginCoherentUI::Init( SSystemGlobalEnvironment& env, SSystemInitParams& startupParams, IPluginBase* pPluginManager, const char* sPluginDirectory ) 57 | { 58 | gPluginManager = ( PluginManager::IPluginManager* )pPluginManager->GetConcreteInterface( NULL ); 59 | CPluginBase::Init( env, startupParams, pPluginManager, sPluginDirectory ); 60 | 61 | if ( gEnv && gEnv->pSystem && !gEnv->pSystem->IsQuitting() ) 62 | { 63 | gCoherentUISystem = new CCoherentUISystem(); 64 | } 65 | 66 | return true; 67 | } 68 | 69 | bool CPluginCoherentUI::RegisterTypes( int nFactoryType, bool bUnregister ) 70 | { 71 | // Note: Autoregister Flownodes will be automatically registered by the Base class 72 | bool bRet = CPluginBase::RegisterTypes( nFactoryType, bUnregister ); 73 | 74 | using namespace PluginManager; 75 | eFactoryType enFactoryType = eFactoryType( nFactoryType ); 76 | 77 | if ( bRet ) 78 | { 79 | if ( gEnv && gEnv->pSystem && !gEnv->pSystem->IsQuitting() ) 80 | { 81 | // CVars 82 | if ( gEnv->pConsole && ( enFactoryType == FT_All || enFactoryType == FT_CVar ) ) 83 | { 84 | if ( !bUnregister ) 85 | { 86 | // TODO: Register CVars here if you have some 87 | // ... 88 | } 89 | 90 | else 91 | { 92 | // TODO: Unregister CVars here if you have some 93 | // ... 94 | } 95 | } 96 | 97 | // CVars Commands 98 | if ( gEnv->pConsole && ( enFactoryType == FT_All || enFactoryType == FT_CVarCommand ) ) 99 | { 100 | if ( !bUnregister ) 101 | { 102 | // TODO: Register CVar Commands here if you have some 103 | // ... 104 | } 105 | 106 | else 107 | { 108 | // TODO: Unregister CVar Commands here if you have some 109 | // ... 110 | } 111 | } 112 | 113 | // Game Objects 114 | if ( gEnv->pGame && gEnv->pGame->GetIGameFramework() && ( enFactoryType == FT_All || enFactoryType == FT_GameObjectExtension ) ) 115 | { 116 | if ( !bUnregister ) 117 | { 118 | // TODO: Register Game Object Extensions here if you have some 119 | // ... 120 | } 121 | } 122 | } 123 | } 124 | 125 | return bRet; 126 | } 127 | 128 | const char* CPluginCoherentUI::ListCVars() const 129 | { 130 | return "..."; // TODO: Enter CVARs/Commands here if you have some 131 | } 132 | 133 | const char* CPluginCoherentUI::GetStatus() const 134 | { 135 | return "OK"; 136 | } 137 | 138 | bool CPluginCoherentUI::CheckDependencies() const 139 | { 140 | bool bRet = CPluginBase::CheckDependencies(); 141 | 142 | if ( bRet ) 143 | { 144 | bRet = PluginManager::safeGetPluginConcreteInterface( "D3D" ); 145 | } 146 | 147 | return bRet; 148 | } 149 | 150 | bool CPluginCoherentUI::InitDependencies() 151 | { 152 | if ( gEnv && gEnv->pSystem && !gEnv->pSystem->IsQuitting() && gCoherentUISystem ) 153 | { 154 | gD3DSystem = PluginManager::safeUsePluginConcreteInterface( "D3D" ); 155 | 156 | if ( gD3DSystem ) 157 | { 158 | gD3DDevice = gD3DSystem->GetDevice(); 159 | gD3DSystem->RegisterListener( gCoherentUISystem ); 160 | } 161 | } 162 | 163 | return CPluginBase::InitDependencies(); 164 | } 165 | 166 | bool CPluginCoherentUI::InitializeSystem() 167 | { 168 | if ( gCoherentUISystem ) 169 | { 170 | return gCoherentUISystem->InitializeCoherentUI(); 171 | } 172 | 173 | else 174 | { 175 | if ( gEnv && gEnv->pSystem && !gEnv->pSystem->IsQuitting() ) 176 | { 177 | gCoherentUISystem = new CCoherentUISystem(); 178 | 179 | if ( gD3DSystem ) 180 | { 181 | gD3DSystem->RegisterListener( gCoherentUISystem ); 182 | } 183 | 184 | return true; 185 | } 186 | } 187 | 188 | return false; 189 | } 190 | 191 | void CPluginCoherentUI::ShutdownSystem() 192 | { 193 | if ( gCoherentUISystem ) 194 | { 195 | if ( gD3DSystem ) 196 | { 197 | gD3DSystem->UnregisterListener( gCoherentUISystem ); 198 | } 199 | 200 | delete gCoherentUISystem; 201 | gCoherentUISystem = NULL; 202 | } 203 | } 204 | 205 | IPlayerEventListener* CPluginCoherentUI::GetPlayerEventListener() const 206 | { 207 | if ( gCoherentUISystem ) 208 | { 209 | return gCoherentUISystem->GetPlayerEventListener(); 210 | } 211 | 212 | return NULL; 213 | } 214 | } -------------------------------------------------------------------------------- /src/CPluginCoherentUI.h: -------------------------------------------------------------------------------- 1 | /* CoherentUI_Plugin - for licensing and copyright see license.txt */ 2 | 3 | #pragma once 4 | 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | #define PLUGIN_NAME "CoherentUI" 15 | #define PLUGIN_CONSOLE_PREFIX "[" PLUGIN_NAME " " PLUGIN_TEXT "] " //!< Prefix for Logentries by this plugin 16 | 17 | namespace CoherentUIPlugin 18 | { 19 | /** 20 | * @brief Provides information and manages the resources of this plugin. 21 | */ 22 | class CPluginCoherentUI : 23 | public PluginManager::CPluginBase, 24 | public IPluginCoherentUI 25 | { 26 | public: 27 | CPluginCoherentUI(); 28 | ~CPluginCoherentUI(); 29 | 30 | // IPluginBase 31 | bool Release( bool bForce = false ); 32 | 33 | int GetInitializationMode() const 34 | { 35 | return int( PluginManager::IM_Default ); 36 | }; 37 | 38 | bool Init( SSystemGlobalEnvironment& env, SSystemInitParams& startupParams, IPluginBase* pPluginManager, const char* sPluginDirectory ); 39 | 40 | bool RegisterTypes( int nFactoryType, bool bUnregister ); 41 | 42 | const char* GetVersion() const 43 | { 44 | return "1.0.0.0"; 45 | }; 46 | 47 | const char* GetName() const 48 | { 49 | return PLUGIN_NAME; 50 | }; 51 | 52 | const char* GetCategory() const 53 | { 54 | return "Framework"; 55 | }; 56 | 57 | const char* ListAuthors() const 58 | { 59 | return "Coherent Labs"; 60 | }; 61 | 62 | const char* ListCVars() const; 63 | 64 | const char* GetStatus() const; 65 | 66 | const char* GetCurrentConcreteInterfaceVersion() const 67 | { 68 | return "1.0"; 69 | }; 70 | 71 | void* GetConcreteInterface( const char* sInterfaceVersion ) 72 | { 73 | return static_cast < IPluginCoherentUI* > ( this ); 74 | }; 75 | 76 | bool CheckDependencies() const; 77 | bool InitDependencies(); 78 | 79 | // IPluginCoherentUI 80 | PluginManager::IPluginBase* GetBase() 81 | { 82 | return static_cast( this ); 83 | }; 84 | 85 | virtual bool InitializeSystem(); 86 | virtual void ShutdownSystem(); 87 | virtual IPlayerEventListener* GetPlayerEventListener() const; 88 | }; 89 | 90 | extern CPluginCoherentUI* gPlugin; 91 | extern D3DPlugin::IPluginD3D* gD3DSystem; 92 | extern void* gD3DDevice; 93 | } 94 | 95 | /** 96 | * @brief This function is required to use the Autoregister Flownode without modification. 97 | * Include the file "CPluginCoherentUI.h" in front of flownode. 98 | */ 99 | inline void GameWarning( const char* sFormat, ... ) PRINTF_PARAMS( 1, 2 ); 100 | inline void GameWarning( const char* sFormat, ... ) 101 | { 102 | va_list ArgList; 103 | va_start( ArgList, sFormat ); 104 | CoherentUIPlugin::gPlugin->LogV( ILog::eWarningAlways, sFormat, ArgList ); 105 | va_end( ArgList ); 106 | }; 107 | -------------------------------------------------------------------------------- /src/CPluginCoherentUIModule.cpp: -------------------------------------------------------------------------------- 1 | /* CoherentUI_Plugin - for licensing and copyright see license.txt */ 2 | 3 | #include 4 | #include 5 | #include "CPluginCoherentUI.h" 6 | #include 7 | #include 8 | 9 | extern "C" 10 | { 11 | DLL_EXPORT PluginManager::IPluginBase* GetPluginInterface( const char* sInterfaceVersion ) 12 | { 13 | // This function should not create a new interface class each call. 14 | static CoherentUIPlugin::CPluginCoherentUI modulePlugin; 15 | CoherentUIPlugin::gPlugin = &modulePlugin; 16 | return modulePlugin.GetBase(); 17 | } 18 | } 19 | 20 | PluginManager::IPluginManager* gPluginManager = NULL; //!< pointer to plugin manager 21 | 22 | // Needed for module specific flow node 23 | CG2AutoRegFlowNodeBase* CG2AutoRegFlowNodeBase::m_pFirst = 0; //!< pointer to first flownode inside this plugin 24 | CG2AutoRegFlowNodeBase* CG2AutoRegFlowNodeBase::m_pLast = 0; //!< pointer to last flownode inside this plugin 25 | 26 | #define WIN32_LEAN_AND_MEAN 27 | #include 28 | 29 | /** 30 | * @brief DLL Entry point. 31 | * Has no function(yet?) in this plugin system. 32 | */ 33 | BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) 34 | { 35 | switch ( ul_reason_for_call ) 36 | { 37 | case DLL_PROCESS_ATTACH: 38 | break; 39 | 40 | case DLL_THREAD_ATTACH: 41 | break; 42 | 43 | case DLL_THREAD_DETACH: 44 | break; 45 | 46 | case DLL_PROCESS_DETACH: 47 | break; 48 | } 49 | 50 | return TRUE; 51 | } -------------------------------------------------------------------------------- /src/CoherentGeometry.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "CoherentGeometry.h" 3 | 4 | namespace CoherentUIPlugin 5 | { 6 | 7 | bool CCoherentGeometry::LoadFromObj( const char* objFile ) 8 | { 9 | // Very, very primitive .obj parser 10 | // 1. Parse the positions ('v' lines) 11 | // 2. Parse the texcoords ('vt' lines) 12 | // 3. Parse faces ('f' lines); these must be declared after the positions and texcoords; 13 | // For each face construct a vertex 14 | 15 | std::vector positions; 16 | std::vector texCoords; 17 | 18 | FILE* fin = fopen( objFile, "r" ); 19 | 20 | if ( !fin ) 21 | { 22 | return false; 23 | } 24 | 25 | const int MAX_LINE_LEN = 1024; 26 | char line[MAX_LINE_LEN]; 27 | 28 | while ( fgets( line, MAX_LINE_LEN, fin ) ) 29 | { 30 | float x, y, z; 31 | 32 | if ( line[0] == '#' ) 33 | { 34 | continue; 35 | } 36 | 37 | else if ( line[0] == 'v' && line[1] == ' ' ) 38 | { 39 | // Position 40 | sscanf( line, "v %f %f %f", &x, &y, &z ); 41 | positions.push_back( x ); 42 | positions.push_back( y ); 43 | positions.push_back( z ); 44 | } 45 | 46 | else if ( line[0] == 'v' && line[1] == 't' ) 47 | { 48 | // Texcoord 49 | sscanf( line, "vt %f %f", &x, &y ); 50 | texCoords.push_back( x ); 51 | texCoords.push_back( y ); 52 | } 53 | 54 | else if ( line[0] == 'f' ) 55 | { 56 | // Face 57 | int p[3]; 58 | int t[3]; 59 | sscanf( line, "f %d/%d %d/%d %d/%d", &p[0], &t[0], &p[1], &t[1], &p[2], &t[2] ); 60 | 61 | for ( int i = 0; i < 3; ++i ) 62 | { 63 | if (p[i] < 0) 64 | { 65 | p[i] += positions.size() / 3 + 1; 66 | } 67 | if (t[i] < 0) 68 | { 69 | t[i] += texCoords.size() / 2 + 1; 70 | } 71 | 72 | float* posstart = &positions[( p[i] - 1 ) * 3]; 73 | float* texstart = &texCoords[( t[i] - 1 ) * 2]; 74 | 75 | m_Vertices.push_back( Vec3( posstart[0], posstart[1], posstart[2] ) ); 76 | m_TexCoords.push_back( Vec2( texstart[0], texstart[1] ) ); 77 | } 78 | } 79 | } 80 | 81 | fclose( fin ); 82 | 83 | return true; 84 | } 85 | 86 | bool CCoherentGeometry::IntersectWithRay( const Vec3& rayOriginModelSpace, const Vec3& rayDirectionModelSpace, float& outDist, float& outU, float& outV ) 87 | { 88 | static const int NO_HIT = -1; 89 | int hitFaceIndex = NO_HIT; // Actually index of the hit face's first vertex index in the indices array, but never mind 90 | float minDist = std::numeric_limits::max(); 91 | float texU = 0; 92 | float texV = 0; 93 | 94 | for ( size_t i = 0; i < m_Vertices.size(); i += 3 ) 95 | { 96 | float t, u, v; 97 | const Vec3& v0 = m_Vertices[i]; 98 | const Vec3& v1 = m_Vertices[i + 1]; 99 | const Vec3& v2 = m_Vertices[i + 2]; 100 | 101 | if ( IntersectRayTriangle( rayOriginModelSpace, rayDirectionModelSpace, v0, v1, v2, t, u, v ) ) 102 | { 103 | if ( t < minDist ) 104 | { 105 | minDist = t; 106 | // Temporarily save barycentric coordinates here 107 | texU = u; 108 | texV = v; 109 | 110 | hitFaceIndex = i; 111 | } 112 | } 113 | } 114 | 115 | if ( hitFaceIndex != NO_HIT ) 116 | { 117 | // Compute texture coordinates from barycentric coordinates 118 | Vec2 texCoords = 119 | ( 1 - texU - texV ) * m_TexCoords[hitFaceIndex] + 120 | texU * m_TexCoords[hitFaceIndex + 1] + 121 | texV * m_TexCoords[hitFaceIndex + 2]; 122 | 123 | outU = texCoords.x; 124 | outV = 1.0f - texCoords.y; 125 | outDist = minDist; 126 | 127 | return true; 128 | } 129 | 130 | return false; 131 | } 132 | 133 | bool CCoherentGeometry::IntersectRayTriangle( 134 | const Vec3& rayOrigin, const Vec3& rayDirection, 135 | const Vec3& v0, const Vec3& v1, const Vec3& v2, 136 | float& t, float& u, float& v ) 137 | { 138 | // Moller-Trumbore ray-triangle intersection 139 | Vec3 e1 = v1 - v0; 140 | Vec3 e2 = v2 - v0; 141 | 142 | Vec3 pvec = rayDirection.cross( e2 ); 143 | 144 | float det = e1.dot( pvec ); 145 | 146 | static const float DET_EPSILON = 0.001f; 147 | 148 | // With culling 149 | if ( det < DET_EPSILON ) 150 | { 151 | return false; 152 | } 153 | 154 | Vec3 tvec = rayOrigin - v0; 155 | u = tvec.dot( pvec ); 156 | 157 | if ( u < 0 || u > det ) 158 | { 159 | return false; 160 | } 161 | 162 | Vec3 qvec = tvec.cross( e1 ); 163 | 164 | v = rayDirection.dot( qvec ); 165 | 166 | if ( v < 0 || u + v > det ) 167 | { 168 | return false; 169 | } 170 | 171 | float detRcp = 1.0f / det; 172 | t = e2.dot( qvec ) * detRcp; 173 | u *= detRcp; 174 | v *= detRcp; 175 | 176 | return true; 177 | } 178 | 179 | } -------------------------------------------------------------------------------- /src/CoherentGeometry.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace CoherentUIPlugin 5 | { 6 | 7 | class CCoherentGeometry 8 | { 9 | public: 10 | bool LoadFromObj( const char* objFile ); 11 | bool IntersectWithRay( const Vec3& rayOriginModelSpace, const Vec3& rayDirectionModelSpace, float& outDist, float& outU, float& outV ); 12 | 13 | private: 14 | static bool IntersectRayTriangle( 15 | const Vec3& rayOrigin, const Vec3& rayDirection, 16 | const Vec3& v0, const Vec3& v1, const Vec3& v2, 17 | float& t, float& u, float& v ); 18 | 19 | private: 20 | struct Vertex 21 | { 22 | float X; 23 | float Y; 24 | float Z; 25 | 26 | float U; 27 | float V; 28 | }; 29 | 30 | std::vector m_Vertices; 31 | std::vector m_TexCoords; 32 | }; 33 | 34 | } 35 | 36 | -------------------------------------------------------------------------------- /src/CoherentHUDViewListener.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "CoherentHUDViewListener.h" 3 | 4 | #include 5 | 6 | namespace CoherentUIPlugin 7 | { 8 | 9 | bool CCoherentHUDViewListener::RaycastGeometry( const Vec3& origin, const Vec3& dir, float& outDist, int& outViewX, int& outViewY ) 10 | { 11 | if ( !m_pView ) 12 | { 13 | return false; 14 | } 15 | 16 | // Get the mouse position and check if it's over a solid pixel, 17 | // ignoring the input ray. 18 | POINT cursorPos; 19 | ::GetCursorPos( &cursorPos ); 20 | ::ScreenToClient( HWND( gEnv->pRenderer->GetCurrentContextHWND() ), 21 | &cursorPos ); 22 | 23 | // When using shared textures you should issue the query at the beginning 24 | // of the frame and fetch as late as possible for optimal performance. 25 | // Since the current state of the plugin supports only shared memory transport, 26 | // issuing a query and immediately fetching causes no performance penalty. 27 | m_pView->IssueMouseOnUIQuery( 28 | cursorPos.x / ( float )m_pView->GetWidth(), 29 | cursorPos.y / ( float )m_pView->GetHeight() 30 | ); 31 | m_pView->FetchMouseOnUIQuery(); 32 | 33 | if ( m_pView->IsMouseOnView() ) 34 | { 35 | outDist = 0; 36 | outViewX = cursorPos.x; 37 | outViewY = cursorPos.y; 38 | 39 | return true; 40 | } 41 | 42 | return false; 43 | } 44 | 45 | bool CCoherentHUDViewListener::ShouldSwapRedAndBlueChannels() const 46 | { 47 | // The red and blue channels are swapped in the shader for DX11, 48 | // no need to do it in RAM (see FullscreenTriangleDrawer). 49 | // For DX9, there is no need either, so just return false. 50 | return false; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/CoherentHUDViewListener.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CoherentViewListener.h" 4 | 5 | namespace CoherentUIPlugin 6 | { 7 | class CCoherentHUDViewListener : public CCoherentViewListener 8 | { 9 | virtual bool RaycastGeometry( const Vec3& origin, const Vec3& dir, float& outDist, int& outViewX, int& outViewY ) COHERENT_OVERRIDE; 10 | virtual bool ShouldSwapRedAndBlueChannels() const COHERENT_OVERRIDE; 11 | }; 12 | } 13 | -------------------------------------------------------------------------------- /src/CoherentInputEventListener.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace Coherent 6 | { 7 | namespace UI 8 | { 9 | struct KeyEventData; 10 | struct MouseEventData; 11 | } 12 | } 13 | 14 | namespace CoherentUIPlugin 15 | { 16 | 17 | class CCoherentViewListener; 18 | 19 | class CCoherentInputEventListener : public IInputEventListener 20 | { 21 | public: 22 | CCoherentInputEventListener(); 23 | 24 | int GetMouseX() const 25 | { 26 | return m_MouseX; 27 | } 28 | 29 | int GetMouseY() const 30 | { 31 | return m_MouseY; 32 | } 33 | 34 | bool IsPlayerInputEnabled() const 35 | { 36 | return m_PlayerInputEnabled; 37 | } 38 | 39 | bool ShouldDrawCoherentUI() const 40 | { 41 | return m_DrawCoherentUI; 42 | } 43 | 44 | bool ShouldDrawCursor() const 45 | { 46 | return m_DrawCursor; 47 | } 48 | 49 | virtual int GetPriority() const COHERENT_OVERRIDE; 50 | 51 | virtual bool OnInputEvent( const SInputEvent& event ) COHERENT_OVERRIDE; 52 | 53 | virtual bool OnInputEventUI( const SInputEvent& event ) COHERENT_OVERRIDE; 54 | 55 | virtual void SetPlayerInput( bool enabled ); 56 | 57 | private: 58 | bool ToKeyEventData( const SInputEvent& event, Coherent::UI::KeyEventData& keyData ); 59 | 60 | bool ToMouseEvent( const SInputEvent& event, Coherent::UI::MouseEventData& mouseData ); 61 | 62 | bool TraceMouse( int& outX, int& outY, CCoherentViewListener*& pViewListener ); 63 | 64 | private: 65 | CCoherentViewListener* m_pLastFocusedViewListener; // The last View listener that the user moused over 66 | int m_MouseX; 67 | int m_MouseY; 68 | bool m_PlayerInputEnabled; 69 | bool m_DrawCoherentUI; 70 | bool m_DrawCursor; 71 | }; 72 | 73 | } -------------------------------------------------------------------------------- /src/CoherentPlayerEventListener.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "CoherentPlayerEventListener.h" 3 | 4 | #include "CoherentViewListener.h" 5 | #include 6 | #include 7 | 8 | namespace CoherentUIPlugin 9 | { 10 | 11 | CCoherentPlayerEventListener::CCoherentPlayerEventListener() 12 | { 13 | } 14 | 15 | void CCoherentPlayerEventListener::AddViewListener( CCoherentViewListener* pViewListener ) 16 | { 17 | m_ViewEventListeners.push_back( pViewListener ); 18 | } 19 | 20 | void CCoherentPlayerEventListener::RemoveViewListener( CCoherentViewListener* pViewListener ) 21 | { 22 | std::vector::iterator it = std::find( m_ViewEventListeners.begin(), 23 | m_ViewEventListeners.end(), pViewListener ); 24 | m_ViewEventListeners.erase( it ); 25 | } 26 | 27 | void CCoherentPlayerEventListener::OnHealthChanged( IActor* pActor, float fHealth ) 28 | { 29 | for ( size_t i = 0, count = m_ViewEventListeners.size(); i < count; ++i ) 30 | { 31 | CCoherentViewListener* pViewListener = m_ViewEventListeners[i]; 32 | 33 | if ( pViewListener->GetView() != nullptr ) 34 | { 35 | pViewListener->GetView()->TriggerEvent( "OnPlayerHealthChanged", cry_floorf(fHealth / pActor->GetMaxHealth() * 100.0f) ); 36 | } 37 | } 38 | } 39 | 40 | } -------------------------------------------------------------------------------- /src/CoherentPlayerEventListener.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct IActor; 4 | 5 | #include 6 | 7 | namespace CoherentUIPlugin 8 | { 9 | 10 | class CCoherentViewListener; 11 | 12 | class CCoherentPlayerEventListener : public IPlayerEventListener 13 | { 14 | public: 15 | CCoherentPlayerEventListener(); 16 | void AddViewListener( CCoherentViewListener* pViewListener ); 17 | void RemoveViewListener( CCoherentViewListener* pViewListener ); 18 | 19 | virtual void OnHealthChanged( IActor* pActor, float fHealth ) COHERENT_OVERRIDE; 20 | 21 | private: 22 | std::vector m_ViewEventListeners; 23 | }; 24 | 25 | } -------------------------------------------------------------------------------- /src/CoherentSystemEventListener.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "CoherentSystemEventListener.h" 3 | #include "CoherentUISystem.h" 4 | 5 | namespace CoherentUIPlugin 6 | { 7 | 8 | CCoherentSystemEventListener::CCoherentSystemEventListener( CCoherentUISystem* pUISystem ) 9 | : m_IsReady( false ) 10 | , m_pUISystem( pUISystem ) 11 | {} 12 | 13 | void CCoherentSystemEventListener::SystemReady() 14 | { 15 | m_IsReady = true; 16 | m_pUISystem->OnSystemReady(); 17 | } 18 | 19 | void CCoherentSystemEventListener::OnError( const Coherent::UI::SystemError& error ) 20 | { 21 | m_pUISystem->OnError( error ); 22 | } 23 | } -------------------------------------------------------------------------------- /src/CoherentSystemEventListener.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace CoherentUIPlugin 6 | { 7 | class CCoherentUISystem; 8 | 9 | class CCoherentSystemEventListener : public Coherent::UI::EventListener 10 | { 11 | public: 12 | CCoherentSystemEventListener( CCoherentUISystem* pUISystem ); 13 | 14 | virtual void SystemReady() COHERENT_OVERRIDE; 15 | virtual void OnError( const Coherent::UI::SystemError& error ); 16 | 17 | bool IsReady() const 18 | { 19 | return m_IsReady; 20 | } 21 | 22 | private: 23 | bool m_IsReady; 24 | CCoherentUISystem* m_pUISystem; 25 | }; 26 | 27 | } -------------------------------------------------------------------------------- /src/CoherentUISystem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | 11 | namespace Coherent 12 | { 13 | namespace UI 14 | { 15 | class UISystem; 16 | class SurfaceResponse; 17 | struct ViewInfo; 18 | } 19 | } 20 | 21 | struct IDirect3DTexture9; 22 | struct ID3D11Texture2D; 23 | struct IPlayerEventListener; 24 | struct ViewConfig; 25 | 26 | namespace CoherentUIPlugin 27 | { 28 | class CCoherentInputEventListener; 29 | class CCoherentPlayerEventListener; 30 | class CCoherentSystemEventListener; 31 | class CCoherentViewListener; 32 | class CFullscreenTriangleDrawer; 33 | struct ViewConfig; 34 | 35 | class CCoherentUISystem : 36 | public D3DPlugin::ID3DEventListener, 37 | public IGameFrameworkListener 38 | { 39 | public: 40 | CCoherentUISystem( void ); 41 | ~CCoherentUISystem( void ); 42 | 43 | bool InitializeCoherentUI(); 44 | bool IsReady(); 45 | 46 | CCoherentViewListener* CreateView( ViewConfig* pConfig ); 47 | void DeleteView( CCoherentViewListener* pViewListener ); 48 | CCoherentViewListener* CreateHUDView( std::wstring path ); 49 | void DeleteHUDView(); 50 | CCoherentViewListener* CCoherentUISystem::GetViewListener( int id ); 51 | 52 | void QueueCreateSurface( int width, int height, Coherent::UI::SurfaceResponse* pResponse ); 53 | void ReleaseSurface( Coherent::UI::CoherentHandle surface ); 54 | void* GetNativeTextureFromSharedHandle( Coherent::UI::CoherentHandle surface ); 55 | 56 | IPlayerEventListener* GetPlayerEventListener() const; 57 | bool RaycastClosestViewListenersGeometry( const Vec3& origin, const Vec3& dir, int& outX, int& outY, CCoherentViewListener*& ppViewListener ); 58 | 59 | void SetCUIInput( bool enabled ); 60 | 61 | // Coherent::UI::EventListener methods 62 | virtual void OnSystemReady(); 63 | virtual void OnError( const Coherent::UI::SystemError& error ); 64 | 65 | // ID3DListener methods 66 | virtual void OnPrePresent() COHERENT_OVERRIDE; 67 | virtual void OnPostPresent() COHERENT_OVERRIDE {} 68 | virtual void OnPreReset() COHERENT_OVERRIDE; 69 | virtual void OnPostReset() COHERENT_OVERRIDE; 70 | virtual void OnPostBeginScene() COHERENT_OVERRIDE; 71 | 72 | // IGameFrameworkListener methods 73 | virtual void OnPostUpdate( float fDeltaTime ) COHERENT_OVERRIDE; 74 | virtual void OnPreRender() COHERENT_OVERRIDE {} 75 | virtual void OnSaveGame( ISaveGame* pSaveGame ) COHERENT_OVERRIDE {} 76 | virtual void OnLoadGame( ILoadGame* pLoadGame ) COHERENT_OVERRIDE {} 77 | virtual void OnLevelEnd( const char* nextLevel ) COHERENT_OVERRIDE {} 78 | virtual void OnActionEvent( const SActionEvent& event ) COHERENT_OVERRIDE; 79 | 80 | private: 81 | struct CreateSurfaceTask 82 | { 83 | int Width; 84 | int Height; 85 | Coherent::UI::SurfaceResponse* Response; 86 | }; 87 | 88 | // Shared textures specific structure 89 | struct TexturePair 90 | { 91 | union DirectXTexture 92 | { 93 | IDirect3DTexture9* pTexDX9; 94 | ID3D11Texture2D* pTexDX11; 95 | void* pTexPtr; 96 | } NativeTexture; 97 | int CryTextureID; 98 | }; 99 | 100 | private: 101 | void UpdateHUD(); 102 | 103 | void SetTexturesForListeners(); 104 | void ChangeEntityDiffuseTextureForMaterial( CCoherentViewListener* pViewListener, const char* entityName, const char* materialName ); 105 | 106 | void ExecutePendingCreateSurfaceTasks(); 107 | Coherent::UI::CoherentHandle CreateSharedTextureDX9( const CreateSurfaceTask& task, TexturePair* outTexturePair ); 108 | Coherent::UI::CoherentHandle CreateSharedTextureDX11( const CreateSurfaceTask& task, TexturePair* outTexturePair ); 109 | 110 | private: 111 | boost::scoped_ptr m_SystemEventsListener; 112 | boost::scoped_ptr m_InputEventsListener; 113 | boost::scoped_ptr m_PlayerEventListener; 114 | 115 | boost::scoped_ptr m_HudViewListener; 116 | 117 | typedef std::map View; 118 | View m_Views; 119 | 120 | Coherent::UI::UISystem* m_pUISystem; 121 | 122 | std::vector m_PendingCreateSurfaceTasks; 123 | CryCriticalSection m_PendingCreateSurfaceTasksLock; 124 | 125 | boost::scoped_ptr m_FullscreenDrawer; 126 | 127 | // Shared texture specific member variable 128 | typedef std::map HandleToSurfaceMap; 129 | HandleToSurfaceMap m_Surfaces; 130 | CryCriticalSection m_SurfacesCollectionLock; 131 | 132 | // CryPak File Handler 133 | PakFileHandler m_PakFileHandler; 134 | }; 135 | 136 | } 137 | 138 | extern CoherentUIPlugin::CCoherentUISystem* gCoherentUISystem; //!< Global internal Coherent UI System Pointer 139 | -------------------------------------------------------------------------------- /src/CoherentViewListener.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace Coherent 7 | { 8 | namespace UI 9 | { 10 | class View; 11 | class SurfaceResponse; 12 | } 13 | } 14 | 15 | struct ID3D11ShaderResourceView; 16 | 17 | namespace CoherentUIPlugin 18 | { 19 | class CCoherentGeometry; 20 | 21 | class CCoherentViewListener : public Coherent::UI::ViewListener 22 | { 23 | public: 24 | CCoherentViewListener( void* pDirectXTexture = NULL ); // IDirect3D9Texture* or ID3D11Texture2D* 25 | virtual ~CCoherentViewListener(); 26 | 27 | void SetTexture( void* pTexture, int cryTexID ); 28 | void* GetTexture() const; 29 | void ReleaseTexture(); 30 | 31 | bool IsReadyForBindings() const; 32 | Coherent::UI::View* GetView() const; 33 | 34 | virtual void OnError( const Coherent::UI::ViewError& error ) COHERENT_OVERRIDE; 35 | virtual void OnViewCreated( Coherent::UI::View* pView ) COHERENT_OVERRIDE; 36 | virtual void OnReadyForBindings( int frameId, const wchar_t* path, bool isMainFrame ) COHERENT_OVERRIDE; 37 | virtual void OnDraw( Coherent::UI::CoherentHandle handle, bool sharedMem, int width, int height ) COHERENT_OVERRIDE; 38 | virtual void CreateSurface( bool sharedMemory, unsigned width, unsigned height, Coherent::UI::SurfaceResponse* pResponse ) COHERENT_OVERRIDE; 39 | virtual void DestroySurface( Coherent::UI::CoherentHandle surface, bool ) COHERENT_OVERRIDE; 40 | 41 | virtual bool RaycastGeometry( const Vec3& origin, const Vec3& dir, float& outDist, int& outViewX, int& outViewY ); 42 | 43 | virtual bool ShouldSwapRedAndBlueChannels() const; 44 | 45 | void SetCollisionMesh( const char* objFileName ); 46 | bool HasCollisionMesh() const; 47 | void SetEngineObjectAndMaterialNames( const char* engineObjectName, const char* materialToOverrideName ); 48 | const char* GetEngineObjectName() const; 49 | const char* GetOverriddenMaterialName() const; 50 | 51 | private: 52 | void DrawFrameDX9SharedMemory( Coherent::UI::CoherentHandle data, int width, int height ); 53 | void DrawFrameDX9SharedTexture( Coherent::UI::CoherentHandle data, int width, int height ); 54 | void DrawFrameDX11SharedMemory( Coherent::UI::CoherentHandle data, int width, int height ); 55 | void DrawFrameDX11SharedTexture( Coherent::UI::CoherentHandle data, int width, int height ); 56 | 57 | void CreateShaderResourceViewForDX11Texture(); 58 | 59 | protected: 60 | void* m_pTexture; // IDirect3D9Texture* or ID3D11Texture2D* 61 | ID3D11ShaderResourceView* m_pTextureSRV; // Shader resource view for DX11 texture 62 | int m_CryTextureID; // Used for removal from the CryEngine renderer when the listener is destroyed 63 | 64 | bool m_ReadyForBindings; 65 | Coherent::UI::View* m_pView; 66 | 67 | boost::scoped_ptr m_Geometry; 68 | string m_EngineObjectName; 69 | string m_MaterialToOverrideName; 70 | }; 71 | 72 | } 73 | -------------------------------------------------------------------------------- /src/Flownodes/CFlowCUIHandleEvent.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include "CoherentViewListener.h" 8 | #include "CoherentUISystem.h" 9 | 10 | namespace CoherentUIPlugin 11 | { 12 | struct Event 13 | { 14 | std::string strArg; 15 | bool boolArg; 16 | }; 17 | 18 | class CFlowCUIHandleEvent : public CFlowBaseNode 19 | { 20 | private: 21 | 22 | enum EInputPorts 23 | { 24 | EIP_ACTIVATE = 0, 25 | EIP_VIEWID, 26 | EIP_EVENT, 27 | }; 28 | 29 | enum EOutputPorts 30 | { 31 | EIP_ARG1 = 0, 32 | EIP_ARG2 33 | }; 34 | 35 | int m_iViewId; 36 | bool m_bHandlerRegistered; 37 | bool m_bReceivedEvent; 38 | Event m_event; 39 | 40 | public: 41 | CFlowCUIHandleEvent( SActivationInfo* pActInfo ) 42 | { 43 | m_iViewId = 0; 44 | m_bHandlerRegistered = false; 45 | m_bReceivedEvent = false; 46 | } 47 | 48 | virtual ~CFlowCUIHandleEvent() 49 | { 50 | } 51 | 52 | virtual IFlowNodePtr Clone( SActivationInfo* pActInfo ) 53 | { 54 | return new CFlowCUIHandleEvent( pActInfo ); 55 | } 56 | 57 | virtual void GetMemoryUsage( ICrySizer* s ) const 58 | { 59 | s->Add( *this ); 60 | } 61 | 62 | void Serialize( SActivationInfo* pActInfo, TSerialize ser ) 63 | { 64 | } 65 | 66 | virtual void GetConfiguration( SFlowNodeConfig& config ) 67 | { 68 | static const SInputPortConfig inputs[] = 69 | { 70 | InputPortConfig_Void( "Activate", _HELP( "Activate View" ) ), 71 | InputPortConfig( "ViewID", 0, _HELP( "View ID" ) ), 72 | InputPortConfig( "Event", "", _HELP( "Event Name" ) ), 73 | InputPortConfig_AnyType( NULL ), 74 | }; 75 | 76 | static const SOutputPortConfig outputs[] = 77 | { 78 | OutputPortConfig( "Arg1", _HELP( "String argument (optional)" ), "sArg" ), 79 | OutputPortConfig( "Arg2", _HELP( "Boolean argument (optional)" ), "bArg" ), 80 | OutputPortConfig_AnyType( NULL ), 81 | }; 82 | 83 | config.pInputPorts = inputs; 84 | config.pOutputPorts = outputs; 85 | config.sDescription = _HELP( PLUGIN_CONSOLE_PREFIX "CoherentUI event handler" ); 86 | 87 | //config.nFlags |= EFLN_TARGET_ENTITY; 88 | config.SetCategory( EFLN_APPROVED ); 89 | } 90 | 91 | virtual void ProcessEvent( EFlowEvent evt, SActivationInfo* pActInfo ) 92 | { 93 | switch ( evt ) 94 | { 95 | case eFE_Suspend: 96 | pActInfo->pGraph->SetRegularlyUpdated( pActInfo->myID, false ); 97 | break; 98 | 99 | case eFE_Resume: 100 | pActInfo->pGraph->SetRegularlyUpdated( pActInfo->myID, true ); 101 | break; 102 | 103 | case eFE_Initialize: 104 | break; 105 | 106 | case eFE_Activate: 107 | { 108 | if ( IsPortActive( pActInfo, EIP_ACTIVATE ) ) { 109 | m_iViewId = GetPortInt( pActInfo, EIP_VIEWID ); 110 | m_bHandlerRegistered = false; 111 | pActInfo->pGraph->SetRegularlyUpdated( pActInfo->myID, true ); 112 | } 113 | } 114 | break; 115 | 116 | case eFE_Update: 117 | if ( !m_bHandlerRegistered ) 118 | { 119 | CCoherentViewListener* pViewListener = gCoherentUISystem->GetViewListener( m_iViewId ); 120 | if ( pViewListener && pViewListener->IsReadyForBindings() ) 121 | { 122 | Coherent::UI::View* pView = pViewListener->GetView(); 123 | if ( pView ) 124 | { 125 | std::string sEvent = GetPortString( pActInfo, EIP_EVENT ); 126 | pView->RegisterForEvent( sEvent.c_str(), Coherent::UI::MakeHandler(this, &CFlowCUIHandleEvent::HandleEvent)); 127 | m_bHandlerRegistered = true; 128 | } 129 | } 130 | } 131 | if ( m_bReceivedEvent ) 132 | { 133 | m_bReceivedEvent = false; 134 | string strArg = m_event.strArg.c_str(); 135 | ActivateOutput( pActInfo, EIP_ARG1, strArg ); 136 | ActivateOutput( pActInfo, EIP_ARG2, m_event.boolArg ); 137 | } 138 | break; 139 | } 140 | } 141 | 142 | void HandleEvent( Event& e ) 143 | { 144 | m_event = e; 145 | m_bReceivedEvent = true; 146 | } 147 | }; 148 | } 149 | 150 | // Expose the Options structure to JavaScript 151 | void CoherentBind(Coherent::UI::Binder* binder, CoherentUIPlugin::Event* e) 152 | { 153 | // Specify the exposed name of the type 154 | if(auto type = binder->RegisterType("Event", e)) 155 | { 156 | // expose normal data properties 157 | type.Property("strArg", &CoherentUIPlugin::Event::strArg); 158 | type.Property("boolArg", &CoherentUIPlugin::Event::boolArg); 159 | } 160 | } 161 | 162 | REGISTER_FLOW_NODE_EX( "CoherentUI_Plugin:HandleEvent", CoherentUIPlugin::CFlowCUIHandleEvent, CFlowCUIHandleEvent ); -------------------------------------------------------------------------------- /src/Flownodes/CFlowCUIOutputEntityNode.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "CoherentViewListener.h" 6 | #include "CoherentUISystem.h" 7 | #include "ViewConfig.h" 8 | 9 | namespace CoherentUIPlugin 10 | { 11 | class CFlowCUIOutputEntityNode : public CFlowBaseNode 12 | { 13 | private: 14 | CCoherentViewListener* m_pViewListener; 15 | IEntity* m_pEntity; 16 | ViewConfig* m_pViewConfig; 17 | bool m_bViewNeedsUpdate; 18 | 19 | enum EInputPorts 20 | { 21 | EIP_ACTIVATE = 0, 22 | EIP_URL, 23 | EIP_WIDTH, 24 | EIP_HEIGHT, 25 | EIP_TRANSPARENT, 26 | EIP_CLICKABLE, 27 | EIP_MESH, 28 | EIP_SHARED_MEMORY, 29 | }; 30 | 31 | enum EOutputPorts 32 | { 33 | EOP_VIEWID = 0 34 | }; 35 | 36 | #define INITIALIZE_OUTPUTS(x) \ 37 | ActivateOutput(x, EOP_VIEWID, -1); 38 | 39 | public: 40 | CFlowCUIOutputEntityNode( SActivationInfo* pActInfo ) 41 | { 42 | m_pViewListener = NULL; 43 | m_pEntity = NULL; 44 | m_pViewConfig = new ViewConfig(); 45 | m_bViewNeedsUpdate = false; 46 | } 47 | 48 | virtual ~CFlowCUIOutputEntityNode() 49 | { 50 | if ( m_pViewListener ) 51 | { 52 | gCoherentUISystem->DeleteView( m_pViewListener ); 53 | } 54 | if ( m_pViewConfig ) 55 | { 56 | delete m_pViewConfig; 57 | } 58 | } 59 | 60 | virtual IFlowNodePtr Clone( SActivationInfo* pActInfo ) 61 | { 62 | return new CFlowCUIOutputEntityNode( pActInfo ); 63 | } 64 | 65 | virtual void GetMemoryUsage( ICrySizer* s ) const 66 | { 67 | s->Add( *this ); 68 | } 69 | 70 | void Serialize( SActivationInfo* pActInfo, TSerialize ser ) 71 | { 72 | } 73 | 74 | virtual void GetConfiguration( SFlowNodeConfig& config ) 75 | { 76 | static const SInputPortConfig inputs[] = 77 | { 78 | InputPortConfig_Void( "Activate", _HELP( "Activate View" ) ), 79 | InputPortConfig( "Url", "", _HELP( "Initial URL" ) ), 80 | InputPortConfig( "Width", 0, _HELP( "Width" ) ), 81 | InputPortConfig( "Height", 0, _HELP( "Height" ) ), 82 | InputPortConfig( "Transparent", false, _HELP( "Is Transparent" ) ), 83 | InputPortConfig( "Clickable", true, _HELP( "Is Clickable" ) ), 84 | InputPortConfig( "Mesh", "", _HELP( "Collision Mesh" ) ), 85 | InputPortConfig( "SharedMemory", true, _HELP( "Uses Shared Memory" ) ), 86 | InputPortConfig_AnyType( NULL ), 87 | }; 88 | 89 | static const SOutputPortConfig outputs[] = 90 | { 91 | OutputPortConfig( "ViewID", _HELP( "ID for Further Use" ), "nViewID" ), 92 | OutputPortConfig_AnyType( NULL ), 93 | }; 94 | 95 | config.pInputPorts = inputs; 96 | config.pOutputPorts = outputs; 97 | config.sDescription = _HELP( PLUGIN_CONSOLE_PREFIX "CoherentUI on entity" ); 98 | 99 | config.nFlags |= EFLN_TARGET_ENTITY; 100 | config.SetCategory( EFLN_APPROVED ); 101 | } 102 | 103 | virtual void ProcessEvent( EFlowEvent evt, SActivationInfo* pActInfo ) 104 | { 105 | switch ( evt ) 106 | { 107 | case eFE_Suspend: 108 | break; 109 | 110 | case eFE_Resume: 111 | break; 112 | 113 | case eFE_Initialize: 114 | INITIALIZE_OUTPUTS( pActInfo ); 115 | break; 116 | 117 | case eFE_SetEntityId: 118 | m_pEntity = pActInfo->pEntity; 119 | break; 120 | 121 | case eFE_Activate: 122 | if ( IsPortActive( pActInfo, EIP_ACTIVATE ) && m_pEntity ) 123 | { 124 | // get the view definition 125 | std::string sUrl = GetPortString( pActInfo, EIP_URL ); 126 | std::wstring sUrlW( sUrl.length(), L' ' ); 127 | sUrlW.assign( sUrl.begin(), sUrl.end() ); 128 | 129 | Coherent::UI::ViewInfo info; 130 | info.Width = GetPortInt( pActInfo, EIP_WIDTH ); 131 | info.Height = GetPortInt( pActInfo, EIP_HEIGHT ); 132 | info.IsTransparent = GetPortBool( pActInfo, EIP_TRANSPARENT ); 133 | info.UsesSharedMemory = GetPortBool( pActInfo, EIP_SHARED_MEMORY ); 134 | info.SupportClickThrough = GetPortBool( pActInfo, EIP_CLICKABLE ); 135 | 136 | m_pViewConfig->ViewInfo = info; 137 | m_pViewConfig->Url = sUrlW; 138 | m_pViewConfig->Entity = m_pEntity; 139 | m_pViewConfig->CollisionMesh = GetPortString( pActInfo, EIP_MESH ); 140 | 141 | // indicate that we have to create/update the view later 142 | m_bViewNeedsUpdate = true; 143 | pActInfo->pGraph->SetRegularlyUpdated( pActInfo->myID, true ); 144 | } 145 | 146 | break; 147 | 148 | case eFE_Update: 149 | // make sure the view is created/updated, after the system is ready 150 | if ( m_bViewNeedsUpdate && gCoherentUISystem->IsReady() ) 151 | { 152 | if ( m_pViewListener ) 153 | { 154 | gCoherentUISystem->DeleteView( m_pViewListener ); 155 | } 156 | m_pViewListener = gCoherentUISystem->CreateView( m_pViewConfig ); 157 | m_bViewNeedsUpdate = false; 158 | } 159 | 160 | // set the view id output after the view is available 161 | if ( m_pViewListener ) 162 | { 163 | Coherent::UI::View* view = m_pViewListener->GetView(); 164 | if ( view ) 165 | { 166 | ActivateOutput( pActInfo, EOP_VIEWID, view->GetId() ); 167 | // updates are not necessary until next initialization 168 | pActInfo->pGraph->SetRegularlyUpdated( pActInfo->myID, false ); 169 | } 170 | } 171 | break; 172 | } 173 | } 174 | }; 175 | } 176 | 177 | REGISTER_FLOW_NODE_EX( "CoherentUI_Plugin:OutputEntity", CoherentUIPlugin::CFlowCUIOutputEntityNode, CFlowCUIOutputEntityNode ); -------------------------------------------------------------------------------- /src/Flownodes/CFlowCUIOutputHUD.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "CoherentViewListener.h" 6 | #include "CoherentUISystem.h" 7 | #include "ViewConfig.h" 8 | 9 | namespace CoherentUIPlugin 10 | { 11 | class CFlowCUIOutputHUD : public CFlowBaseNode 12 | { 13 | private: 14 | CCoherentViewListener* m_pViewListener; 15 | std::wstring m_sPathW; 16 | bool m_bViewNeedsUpdate; 17 | 18 | enum EInputPorts 19 | { 20 | EIP_ACTIVATE = 0, 21 | EIP_PATH, 22 | }; 23 | 24 | enum EOutputPorts 25 | { 26 | EOP_VIEWID = 0 27 | }; 28 | 29 | #define INITIALIZE_OUTPUTS(x) \ 30 | ActivateOutput(x, EOP_VIEWID, -1); 31 | 32 | public: 33 | CFlowCUIOutputHUD( SActivationInfo* pActInfo ) 34 | { 35 | m_pViewListener = NULL; 36 | m_bViewNeedsUpdate = false; 37 | } 38 | 39 | virtual ~CFlowCUIOutputHUD() 40 | { 41 | if ( m_pViewListener ) 42 | { 43 | gCoherentUISystem->DeleteHUDView(); 44 | } 45 | } 46 | 47 | virtual IFlowNodePtr Clone( SActivationInfo* pActInfo ) 48 | { 49 | return new CFlowCUIOutputHUD( pActInfo ); 50 | } 51 | 52 | virtual void GetMemoryUsage( ICrySizer* s ) const 53 | { 54 | s->Add( *this ); 55 | } 56 | 57 | void Serialize( SActivationInfo* pActInfo, TSerialize ser ) 58 | { 59 | } 60 | 61 | virtual void GetConfiguration( SFlowNodeConfig& config ) 62 | { 63 | static const SInputPortConfig inputs[] = 64 | { 65 | InputPortConfig_Void( "Activate", _HELP( "Activate View" ) ), 66 | InputPortConfig( "Path", "", _HELP( "Initial URL" ) ), 67 | InputPortConfig_AnyType( NULL ), 68 | }; 69 | 70 | static const SOutputPortConfig outputs[] = 71 | { 72 | OutputPortConfig( "ViewID", _HELP( "ID for Further Use" ), "nViewID" ), 73 | OutputPortConfig_AnyType( NULL ), 74 | }; 75 | 76 | config.pInputPorts = inputs; 77 | config.pOutputPorts = outputs; 78 | config.sDescription = _HELP( PLUGIN_CONSOLE_PREFIX "CoherentUI HUD" ); 79 | 80 | //config.nFlags |= EFLN_TARGET_ENTITY; 81 | config.SetCategory( EFLN_APPROVED ); 82 | } 83 | 84 | virtual void ProcessEvent( EFlowEvent evt, SActivationInfo* pActInfo ) 85 | { 86 | switch ( evt ) 87 | { 88 | case eFE_Suspend: 89 | break; 90 | 91 | case eFE_Resume: 92 | break; 93 | 94 | case eFE_Initialize: 95 | INITIALIZE_OUTPUTS( pActInfo ); 96 | break; 97 | 98 | case eFE_Activate: 99 | { 100 | if ( IsPortActive( pActInfo, EIP_ACTIVATE ) ) 101 | { 102 | // get the view definition 103 | std::string sPath = GetPortString( pActInfo, EIP_PATH ); 104 | m_sPathW.assign( sPath.begin(), sPath.end() ); 105 | 106 | // indicate that we have to create/update the view later 107 | m_bViewNeedsUpdate = true; 108 | pActInfo->pGraph->SetRegularlyUpdated( pActInfo->myID, true ); 109 | } 110 | } 111 | break; 112 | 113 | case eFE_Update: 114 | // make sure the view is created, after the system is ready 115 | if ( m_bViewNeedsUpdate && gCoherentUISystem->IsReady() ) 116 | { 117 | if ( m_pViewListener ) 118 | { 119 | // update only 120 | Coherent::UI::View* view = m_pViewListener->GetView(); 121 | view->Load( m_sPathW.c_str() ); 122 | view->Reload( true ); 123 | } 124 | else 125 | { 126 | // create 127 | m_pViewListener = gCoherentUISystem->CreateHUDView( m_sPathW ); 128 | } 129 | m_bViewNeedsUpdate = false; 130 | } 131 | 132 | // set the view id output after the view is available 133 | if ( m_pViewListener ) 134 | { 135 | Coherent::UI::View* view = m_pViewListener->GetView(); 136 | if ( view ) 137 | { 138 | ActivateOutput( pActInfo, EOP_VIEWID, view->GetId() ); 139 | // updates are not necessary until next initialization 140 | pActInfo->pGraph->SetRegularlyUpdated( pActInfo->myID, false ); 141 | } 142 | } 143 | break; 144 | } 145 | } 146 | }; 147 | } 148 | 149 | REGISTER_FLOW_NODE_EX( "CoherentUI_Plugin:OutputHUD", CoherentUIPlugin::CFlowCUIOutputHUD, CFlowCUIOutputHUD ); -------------------------------------------------------------------------------- /src/Flownodes/CFlowCUISendTokens.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "CoherentViewListener.h" 7 | #include "CoherentUISystem.h" 8 | 9 | #include "rapidjson/writer.h" 10 | #include "rapidjson/stringbuffer.h" 11 | 12 | using namespace rapidjson; 13 | 14 | namespace CoherentUIPlugin 15 | { 16 | class CFlowCUISendTokens : public CFlowBaseNode 17 | { 18 | private: 19 | 20 | enum EInputPorts 21 | { 22 | EIP_ACTIVATE = 0, 23 | EIP_VIEWID, 24 | EIP_EVENT, 25 | }; 26 | 27 | public: 28 | CFlowCUISendTokens( SActivationInfo* pActInfo ) 29 | { 30 | } 31 | 32 | virtual ~CFlowCUISendTokens() 33 | { 34 | } 35 | 36 | virtual IFlowNodePtr Clone( SActivationInfo* pActInfo ) 37 | { 38 | return new CFlowCUISendTokens( pActInfo ); 39 | } 40 | 41 | virtual void GetMemoryUsage( ICrySizer* s ) const 42 | { 43 | s->Add( *this ); 44 | } 45 | 46 | void Serialize( SActivationInfo* pActInfo, TSerialize ser ) 47 | { 48 | } 49 | 50 | virtual void GetConfiguration( SFlowNodeConfig& config ) 51 | { 52 | static const SInputPortConfig inputs[] = 53 | { 54 | InputPortConfig_Void( "Activate", _HELP( "Activate View" ) ), 55 | InputPortConfig( "ViewID", 0, _HELP( "View ID" ) ), 56 | InputPortConfig( "Event", "GameTokens", NULL, _HELP( "Event Name" ), NULL ), 57 | InputPortConfig_AnyType( NULL ), 58 | }; 59 | 60 | config.pInputPorts = inputs; 61 | config.pOutputPorts = NULL;//output 62 | config.sDescription = _HELP( PLUGIN_CONSOLE_PREFIX "CoherentUI event trigger sending game tokens" ); 63 | 64 | //config.nFlags |= EFLN_TARGET_ENTITY; 65 | config.SetCategory( EFLN_APPROVED ); 66 | } 67 | 68 | virtual void ProcessEvent( EFlowEvent evt, SActivationInfo* pActInfo ) 69 | { 70 | switch ( evt ) 71 | { 72 | case eFE_Suspend: 73 | break; 74 | 75 | case eFE_Resume: 76 | break; 77 | 78 | case eFE_Initialize: 79 | break; 80 | 81 | case eFE_Activate: 82 | { 83 | if ( IsPortActive( pActInfo, EIP_ACTIVATE ) ) { 84 | int viewId = GetPortInt( pActInfo, EIP_VIEWID ); 85 | CCoherentViewListener* pViewListener = gCoherentUISystem->GetViewListener( viewId ); 86 | if ( pViewListener ) 87 | { 88 | Coherent::UI::View* pView = pViewListener->GetView(); 89 | if ( pView ) 90 | { 91 | StringBuffer buffer; 92 | Writer writer(buffer); 93 | writer.StartObject(); 94 | 95 | IGameTokenSystem *pGameTokenSystem = gEnv->pGame->GetIGameFramework()->GetIGameTokenSystem(); 96 | if(pGameTokenSystem) 97 | { 98 | IGameTokenIt* pIt = pGameTokenSystem->GetGameTokenIterator(); 99 | while(IGameToken *pGameToken=pIt->Next()) 100 | { 101 | writer.String(pGameToken->GetName()); 102 | writer.String(pGameToken->GetValueAsString()); 103 | } 104 | } 105 | writer.EndObject(); 106 | 107 | std::string sEvent = GetPortString( pActInfo, EIP_EVENT ); 108 | pView->TriggerEvent( sEvent.c_str(), buffer.GetString() ); 109 | } 110 | } 111 | } 112 | } 113 | break; 114 | 115 | case eFE_Update: 116 | break; 117 | } 118 | } 119 | }; 120 | } 121 | 122 | REGISTER_FLOW_NODE_EX( "CoherentUI_Plugin:SendTokens", CoherentUIPlugin::CFlowCUISendTokens, CFlowCUISendTokens ); -------------------------------------------------------------------------------- /src/Flownodes/CFlowCUISetInput.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "CoherentUISystem.h" 5 | 6 | namespace CoherentUIPlugin 7 | { 8 | class CFlowCUISetInput : public CFlowBaseNode 9 | { 10 | private: 11 | 12 | enum EInputPorts 13 | { 14 | EIP_ACTIVATE = 0, 15 | EIP_ENABLED, 16 | }; 17 | 18 | public: 19 | CFlowCUISetInput( SActivationInfo* pActInfo ) 20 | { 21 | } 22 | 23 | virtual ~CFlowCUISetInput() 24 | { 25 | } 26 | 27 | virtual IFlowNodePtr Clone( SActivationInfo* pActInfo ) 28 | { 29 | return new CFlowCUISetInput( pActInfo ); 30 | } 31 | 32 | virtual void GetMemoryUsage( ICrySizer* s ) const 33 | { 34 | s->Add( *this ); 35 | } 36 | 37 | void Serialize( SActivationInfo* pActInfo, TSerialize ser ) 38 | { 39 | } 40 | 41 | virtual void GetConfiguration( SFlowNodeConfig& config ) 42 | { 43 | static const SInputPortConfig inputs[] = 44 | { 45 | InputPortConfig_Void( "Activate", _HELP( "Activate Input" ) ), 46 | InputPortConfig( "Enabled", _HELP( "Is Enabled" ) ), 47 | InputPortConfig_AnyType( NULL ), 48 | }; 49 | 50 | config.pInputPorts = inputs; 51 | config.pOutputPorts = NULL;//output 52 | config.sDescription = _HELP( PLUGIN_CONSOLE_PREFIX "CoherentUI enable input" ); 53 | 54 | //config.nFlags |= EFLN_TARGET_ENTITY; 55 | config.SetCategory( EFLN_APPROVED ); 56 | } 57 | 58 | virtual void ProcessEvent( EFlowEvent evt, SActivationInfo* pActInfo ) 59 | { 60 | switch ( evt ) 61 | { 62 | case eFE_Suspend: 63 | break; 64 | 65 | case eFE_Resume: 66 | break; 67 | 68 | case eFE_Initialize: 69 | break; 70 | 71 | case eFE_Activate: 72 | { 73 | if ( IsPortActive( pActInfo, EIP_ACTIVATE ) ) { 74 | if ( gCoherentUISystem->IsReady() ) 75 | { 76 | bool enabled = GetPortBool( pActInfo, EIP_ENABLED ); 77 | gCoherentUISystem->SetCUIInput( enabled ); 78 | } 79 | } 80 | } 81 | break; 82 | 83 | case eFE_Update: 84 | break; 85 | } 86 | } 87 | }; 88 | } 89 | 90 | REGISTER_FLOW_NODE_EX( "CoherentUI_Plugin:SetInput", CoherentUIPlugin::CFlowCUISetInput, CFlowCUISetInput ); -------------------------------------------------------------------------------- /src/Flownodes/CFlowCUITriggerEvent.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "CoherentViewListener.h" 6 | #include "CoherentUISystem.h" 7 | 8 | namespace CoherentUIPlugin 9 | { 10 | class CFlowCUITriggerEvent : public CFlowBaseNode 11 | { 12 | private: 13 | 14 | enum EInputPorts 15 | { 16 | EIP_ACTIVATE = 0, 17 | EIP_VIEWID, 18 | EIP_EVENT, 19 | EIP_ARG1, 20 | }; 21 | 22 | public: 23 | CFlowCUITriggerEvent( SActivationInfo* pActInfo ) 24 | { 25 | } 26 | 27 | virtual ~CFlowCUITriggerEvent() 28 | { 29 | } 30 | 31 | virtual IFlowNodePtr Clone( SActivationInfo* pActInfo ) 32 | { 33 | return new CFlowCUITriggerEvent( pActInfo ); 34 | } 35 | 36 | virtual void GetMemoryUsage( ICrySizer* s ) const 37 | { 38 | s->Add( *this ); 39 | } 40 | 41 | void Serialize( SActivationInfo* pActInfo, TSerialize ser ) 42 | { 43 | } 44 | 45 | virtual void GetConfiguration( SFlowNodeConfig& config ) 46 | { 47 | static const SInputPortConfig inputs[] = 48 | { 49 | InputPortConfig_Void( "Activate", _HELP( "Activate View" ) ), 50 | InputPortConfig( "ViewID", 0, _HELP( "View ID" ) ), 51 | InputPortConfig( "Event", "", _HELP( "Event Name" ) ), 52 | InputPortConfig( "Arg1", _HELP( "Argument 1 (optional: boolean)" ) ), 53 | InputPortConfig_AnyType( NULL ), 54 | }; 55 | 56 | config.pInputPorts = inputs; 57 | config.pOutputPorts = NULL;//output 58 | config.sDescription = _HELP( PLUGIN_CONSOLE_PREFIX "CoherentUI event trigger (1 argument)" ); 59 | 60 | //config.nFlags |= EFLN_TARGET_ENTITY; 61 | config.SetCategory( EFLN_APPROVED ); 62 | } 63 | 64 | virtual void ProcessEvent( EFlowEvent evt, SActivationInfo* pActInfo ) 65 | { 66 | switch ( evt ) 67 | { 68 | case eFE_Suspend: 69 | break; 70 | 71 | case eFE_Resume: 72 | break; 73 | 74 | case eFE_Initialize: 75 | break; 76 | 77 | case eFE_Activate: 78 | { 79 | if ( IsPortActive( pActInfo, EIP_ACTIVATE ) ) { 80 | int viewId = GetPortInt( pActInfo, EIP_VIEWID ); 81 | CCoherentViewListener* pViewListener = gCoherentUISystem->GetViewListener( viewId ); 82 | if ( pViewListener && pViewListener->IsReadyForBindings() ) 83 | { 84 | Coherent::UI::View* pView = pViewListener->GetView(); 85 | if ( pView ) 86 | { 87 | std::string sEvent = GetPortString( pActInfo, EIP_EVENT ); 88 | bool bArg1 = GetPortBool( pActInfo, EIP_ARG1 ); 89 | pView->TriggerEvent(sEvent.c_str(), bArg1); 90 | } 91 | } 92 | } 93 | } 94 | break; 95 | 96 | case eFE_Update: 97 | break; 98 | } 99 | } 100 | }; 101 | } 102 | 103 | REGISTER_FLOW_NODE_EX( "CoherentUI_Plugin:TriggerEvent", CoherentUIPlugin::CFlowCUITriggerEvent, CFlowCUITriggerEvent ); -------------------------------------------------------------------------------- /src/Flownodes/CFlowCUITriggerEventFloat.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "CoherentViewListener.h" 6 | #include "CoherentUISystem.h" 7 | 8 | namespace CoherentUIPlugin 9 | { 10 | class CFlowCUITriggerEventFloat : public CFlowBaseNode 11 | { 12 | private: 13 | 14 | enum EInputPorts 15 | { 16 | EIP_ACTIVATE = 0, 17 | EIP_VIEWID, 18 | EIP_EVENT, 19 | EIP_ARG1, 20 | EIP_ARG2, 21 | EIP_ARG3, 22 | EIP_ARG4, 23 | }; 24 | 25 | public: 26 | CFlowCUITriggerEventFloat( SActivationInfo* pActInfo ) 27 | { 28 | } 29 | 30 | virtual ~CFlowCUITriggerEventFloat() 31 | { 32 | } 33 | 34 | virtual IFlowNodePtr Clone( SActivationInfo* pActInfo ) 35 | { 36 | return new CFlowCUITriggerEventFloat( pActInfo ); 37 | } 38 | 39 | virtual void GetMemoryUsage( ICrySizer* s ) const 40 | { 41 | s->Add( *this ); 42 | } 43 | 44 | void Serialize( SActivationInfo* pActInfo, TSerialize ser ) 45 | { 46 | } 47 | 48 | virtual void GetConfiguration( SFlowNodeConfig& config ) 49 | { 50 | static const SInputPortConfig inputs[] = 51 | { 52 | InputPortConfig_Void( "Activate", _HELP( "Activate View" ) ), 53 | InputPortConfig( "ViewID", 0, _HELP( "View ID" ) ), 54 | InputPortConfig( "Event", "", _HELP( "Event Name" ) ), 55 | InputPortConfig( "Arg1", _HELP( "Argument 1 (optional: float)" ) ), 56 | InputPortConfig( "Arg2", _HELP( "Argument 2 (optional: float)" ) ), 57 | InputPortConfig( "Arg3", _HELP( "Argument 3 (optional: float)" ) ), 58 | InputPortConfig( "Arg4", _HELP( "Argument 4 (optional: float)" ) ), 59 | InputPortConfig_AnyType( NULL ), 60 | }; 61 | 62 | config.pInputPorts = inputs; 63 | config.pOutputPorts = NULL;//output 64 | config.sDescription = _HELP( PLUGIN_CONSOLE_PREFIX "CoherentUI event trigger (4 arguments)" ); 65 | 66 | //config.nFlags |= EFLN_TARGET_ENTITY; 67 | config.SetCategory( EFLN_APPROVED ); 68 | } 69 | 70 | virtual void ProcessEvent( EFlowEvent evt, SActivationInfo* pActInfo ) 71 | { 72 | switch ( evt ) 73 | { 74 | case eFE_Suspend: 75 | break; 76 | 77 | case eFE_Resume: 78 | break; 79 | 80 | case eFE_Initialize: 81 | break; 82 | 83 | case eFE_Activate: 84 | { 85 | if ( IsPortActive( pActInfo, EIP_ACTIVATE ) ) { 86 | int viewId = GetPortInt( pActInfo, EIP_VIEWID ); 87 | CCoherentViewListener* pViewListener = gCoherentUISystem->GetViewListener( viewId ); 88 | if ( pViewListener && pViewListener->IsReadyForBindings() ) 89 | { 90 | Coherent::UI::View* pView = pViewListener->GetView(); 91 | if ( pView ) 92 | { 93 | std::string sEvent = GetPortString( pActInfo, EIP_EVENT ); 94 | float fArg1 = GetPortFloat( pActInfo, EIP_ARG1 ); 95 | float fArg2 = GetPortFloat( pActInfo, EIP_ARG2 ); 96 | float fArg3 = GetPortFloat( pActInfo, EIP_ARG3 ); 97 | float fArg4 = GetPortFloat( pActInfo, EIP_ARG4 ); 98 | 99 | pView->TriggerEvent(sEvent.c_str(), 100 | GetPortFloat( pActInfo, EIP_ARG1 ), 101 | GetPortFloat( pActInfo, EIP_ARG2 ), 102 | GetPortFloat( pActInfo, EIP_ARG3 ), 103 | GetPortFloat( pActInfo, EIP_ARG4 ) 104 | ); 105 | } 106 | } 107 | } 108 | } 109 | break; 110 | 111 | case eFE_Update: 112 | break; 113 | } 114 | } 115 | }; 116 | } 117 | 118 | REGISTER_FLOW_NODE_EX( "CoherentUI_Plugin:TriggerEventFloat", CoherentUIPlugin::CFlowCUITriggerEventFloat, CFlowCUITriggerEventFloat ); -------------------------------------------------------------------------------- /src/FullscreenTriangleDrawer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | namespace Coherent 5 | { 6 | namespace UI 7 | { 8 | class View; 9 | class SurfaceResponse; 10 | } 11 | } 12 | 13 | struct IDirect3DTexture9; 14 | struct IDirect3DVertexDeclaration9; 15 | struct IDirect3DVertexBuffer9; 16 | struct IDirect3DVertexShader9; 17 | struct IDirect3DPixelShader9; 18 | struct IDirect3DStateBlock9; 19 | struct ID3D11ShaderResourceView; 20 | struct ID3D11VertexShader; 21 | struct ID3D11PixelShader; 22 | struct ID3D11BlendState; 23 | 24 | namespace CoherentUIPlugin 25 | { 26 | 27 | class CFullscreenTriangleDrawer 28 | { 29 | public: 30 | CFullscreenTriangleDrawer(); 31 | ~CFullscreenTriangleDrawer(); 32 | 33 | void Draw( void* pTexture ); 34 | 35 | private: 36 | void CreateDX9Resources(); 37 | void CreateDX11Resources(); 38 | 39 | void DrawDX9( IDirect3DTexture9* pTexture ); 40 | void DrawDX11( ID3D11ShaderResourceView* pTexture ); 41 | 42 | private: 43 | // DX9 44 | IDirect3DVertexDeclaration9* m_pVertexDeclaration; 45 | IDirect3DVertexBuffer9* m_pVertexBuffer; 46 | IDirect3DVertexShader9* m_pVertexShader9; 47 | IDirect3DPixelShader9* m_pPixelShader9; 48 | IDirect3DStateBlock9* m_pStateBlock; 49 | 50 | // DX11 51 | ID3D11VertexShader* m_pVertexShader11; 52 | ID3D11PixelShader* m_pPixelShader11; 53 | ID3D11BlendState* m_pBlendState11; 54 | }; 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/PakFileHandler.cpp: -------------------------------------------------------------------------------- 1 | /* CoherentUI_Plugin - for licensing and copyright see license.txt */ 2 | 3 | 4 | #include "StdAfx.h" 5 | #include "PakFileHandler.h" 6 | 7 | #include 8 | #include 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | namespace CoherentUIPlugin 15 | { 16 | PakFileHandler::PakFileHandler() 17 | { 18 | } 19 | 20 | void PakFileHandler::ReadFile( const wchar_t* sURL, Coherent::UI::ResourceResponse* pResponse ) 21 | { 22 | if ( !sURL ) 23 | { 24 | return; 25 | } 26 | 27 | FILE* fHandle = NULL; 28 | 29 | // Use only the netloc of the url for resouce name, ignoring the scheme, any queries and fragment parts 30 | Coherent::UI::URLComponent sPathURL; 31 | 32 | if ( ( !CoherentGetURLParser().Parse( sURL, nullptr, &sPathURL, nullptr, nullptr ) && sPathURL.Start ) ) 33 | { 34 | gPlugin->LogWarning( "ReadFile() Couldn't parse URL:", PluginManager::UCS22UTF8( wstring( sURL ) ).c_str() ); 35 | pResponse->SignalFailure(); 36 | return; 37 | } 38 | 39 | // CryPak uses UTF-8 40 | wstring sPathW( sPathURL.Start, sPathURL.Start + sPathURL.Length ); 41 | string sPath = PluginManager::UCS22UTF8( sPathW ); 42 | 43 | // Open File 44 | if ( ( fHandle = gEnv->pCryPak->FOpen( sPath, "rb" ) ) == NULL ) 45 | { 46 | gPlugin->LogWarning( "ReadFile(%s) Unable to find specified path in pak", sPath.c_str() ); 47 | pResponse->SignalFailure(); 48 | goto End; 49 | } 50 | 51 | size_t nSize = gEnv->pCryPak->FGetSize( fHandle ); 52 | 53 | if ( !nSize ) 54 | { 55 | gPlugin->LogWarning( "ReadFile(%s) File is empty", sPath.c_str() ); 56 | pResponse->SignalFailure( ); 57 | goto End; 58 | } 59 | 60 | void* pBuffer = pResponse->GetBuffer( nSize ); 61 | 62 | if ( !pBuffer ) 63 | { 64 | gPlugin->LogError( "ReadFile(%s) Unable to obtain buffer for this resource (%d bytes)", sPath.c_str(), int( nSize ) ); 65 | pResponse->SignalFailure( ); 66 | goto End; 67 | } 68 | 69 | if ( nSize != gEnv->pCryPak->FReadRawAll( pBuffer, nSize, fHandle ) ) 70 | { 71 | gPlugin->LogError( "ReadFile(%s) Unable to read all data (%d bytes)", sPath.c_str(), int( nSize ) ); 72 | pResponse->SignalFailure( ); 73 | goto End; 74 | } 75 | 76 | pResponse->SignalSuccess( ); 77 | 78 | End: 79 | 80 | if ( fHandle ) 81 | { 82 | gEnv->pCryPak->FClose( fHandle ); 83 | } 84 | } 85 | 86 | void PakFileHandler::WriteFile( const wchar_t* sURL, Coherent::UI::ResourceData* pResource ) 87 | { 88 | pResource->SignalFailure(); 89 | } 90 | }; -------------------------------------------------------------------------------- /src/PakFileHandler.h: -------------------------------------------------------------------------------- 1 | /* CoherentUI_Plugin - for licensing and copyright see license.txt */ 2 | 3 | #pragma once 4 | 5 | #include 6 | #include 7 | 8 | namespace CoherentUIPlugin 9 | { 10 | /** 11 | * @brief Override File Operations for CryEngine to support pak files 12 | */ 13 | class PakFileHandler : 14 | public Coherent::UI::FileHandler 15 | { 16 | public: 17 | PakFileHandler(); 18 | virtual void ReadFile( const wchar_t* sURL, Coherent::UI::ResourceResponse* pResponse ); 19 | virtual void WriteFile( const wchar_t* sURL, Coherent::UI::ResourceData* pResource ); 20 | 21 | private: 22 | }; 23 | } -------------------------------------------------------------------------------- /src/StdAfx.cpp: -------------------------------------------------------------------------------- 1 | /* CoherentUI_Plugin - for licensing and copyright see license.txt */ 2 | 3 | #include "StdAfx.h" 4 | -------------------------------------------------------------------------------- /src/StdAfx.h: -------------------------------------------------------------------------------- 1 | /* CoherentUI_Plugin - for licensing and copyright see license.txt */ 2 | 3 | #pragma once 4 | 5 | #if defined(XENON) || defined(PS3) 6 | #define MAX_PLAYER_LIMIT 12 7 | #else 8 | #define MAX_PLAYER_LIMIT 16 9 | #endif 10 | 11 | // Insert your headers here 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #ifndef _FORCEDLL 32 | #define _FORCEDLL 33 | #endif 34 | 35 | #ifndef CoherentUIPLUGIN_EXPORTS 36 | #define CoherentUIPLUGIN_EXPORTS 37 | #endif 38 | 39 | #pragma warning(disable: 4018) // conditional expression is constant 40 | 41 | //{{AFX_INSERT_LOCATION}} 42 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line. 43 | 44 | #define NOMINMAX 45 | #define WIN32_LEAN_AND_MEAN 46 | #include 47 | 48 | #include 49 | #include 50 | 51 | #include 52 | -------------------------------------------------------------------------------- /src/ViewConfig.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | namespace CoherentUIPlugin 5 | { 6 | 7 | struct ViewConfig 8 | { 9 | /// The view parameters 10 | /// 11 | Coherent::UI::ViewInfo ViewInfo; 12 | 13 | /// The initial url 14 | /// 15 | std::wstring Url; 16 | 17 | /// The entity to map the view on 18 | /// 19 | IEntity* Entity; 20 | 21 | /// The name of the material to map the view on 22 | /// (if defined, it Entity will be ignored) 23 | /// 24 | std::string MaterialName; 25 | 26 | /// The name of the collision mesh object if used 27 | /// 28 | std::string CollisionMesh; 29 | }; 30 | 31 | } 32 | -------------------------------------------------------------------------------- /tools/CoherentUI_Installer.nsi: -------------------------------------------------------------------------------- 1 | ; CoherentUI Plugin Installer 2 | 3 | !include "MUI2.nsh" 4 | !include "Sections.nsh" 5 | 6 | ################################## 7 | XPStyle on 8 | 9 | !define VERSION "1.0.0.0" 10 | Name "CoherentUI Plugin ${VERSION} for CryEngine" 11 | 12 | ; The file to write 13 | OutFile "Plugin_CoherentUI_${VERSION}.exe" 14 | 15 | ; Default Installdir 16 | InstallDir "C:\CryENGINE_PC\" 17 | 18 | ; Request application privileges for Windows Vista/7 19 | RequestExecutionLevel user 20 | 21 | !define FILES_ROOT ".." 22 | 23 | ; MUI Settings 24 | !define MUI_ABORTWARNING 25 | 26 | !define MUI_ICON "${FILES_ROOT}\..\Plugin_SDK\images\logos\PluginWizard.ico" 27 | !define MUI_UNICON "${FILES_ROOT}\..\Plugin_SDK\images\logos\PluginWizard.ico" 28 | 29 | ;!define MUI_HEADERIMAGE 30 | ;!define MUI_HEADERIMAGE_BITMAP "" 31 | ;!define MUI_HEADERIMAGE_BITMAP_NOSTRETCH 32 | 33 | ################################### 34 | 35 | ; License page 36 | !insertmacro MUI_PAGE_LICENSE "${FILES_ROOT}\license.txt" 37 | 38 | ; Components page 39 | !insertmacro MUI_PAGE_COMPONENTS 40 | 41 | ; Directory page 42 | !define MUI_DIRECTORYPAGE_VARIABLE $INSTDIR 43 | !define MUI_PAGE_CUSTOMFUNCTION_LEAVE "IsValidCEInstallation" 44 | !insertmacro MUI_PAGE_DIRECTORY 45 | 46 | ; Install files page 47 | !insertmacro MUI_PAGE_INSTFILES 48 | 49 | ################################### 50 | 51 | ; Sections 52 | Section "CoherentUI" SEC_PLUGIN 53 | SectionIn RO 54 | 55 | SetOutPath "$INSTDIR\Bin32\Plugins\CoherentUI" 56 | ;File "${FILES_ROOT}\..\..\Bin32\Plugins\CoherentUI\Plugin_CoherentUI.dll" 57 | File "${FILES_ROOT}\..\..\Bin32\Plugins\CoherentUI\*.dll" 58 | 59 | SetOutPath "$INSTDIR\Bin64\Plugins\CoherentUI" 60 | ;File "${FILES_ROOT}\..\..\Bin64\Plugins\CoherentUI\Plugin_CoherentUI.dll" 61 | File "${FILES_ROOT}\..\..\Bin64\Plugins\CoherentUI\*.dll" 62 | 63 | ; Standard Code directory also used in git repo 64 | SetOutPath "$INSTDIR\Code\Plugin_CoherentUI" 65 | File /nonfatal "${FILES_ROOT}\*.txt" 66 | File /nonfatal "${FILES_ROOT}\*.md" 67 | File /nonfatal "${FILES_ROOT}\*.markdown" 68 | 69 | Call ShowChangelog 70 | SectionEnd 71 | 72 | Section "Interface Headers" SEC_INTERFACE 73 | SetOutPath "$INSTDIR\Code\Plugin_CoherentUI\inc" 74 | File /r "${FILES_ROOT}\inc\" 75 | SectionEnd 76 | 77 | #################################### 78 | 79 | ; Section descriptions 80 | !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN 81 | !insertmacro MUI_DESCRIPTION_TEXT ${SEC_PLUGIN} "Redistributables loaded by the plugin manager." 82 | !insertmacro MUI_DESCRIPTION_TEXT ${SEC_INTERFACE} "Interfaces required to use the plugin from C++." 83 | !insertmacro MUI_FUNCTION_DESCRIPTION_END 84 | 85 | 86 | !insertmacro MUI_LANGUAGE "English" 87 | 88 | ; Set Fileinfos 89 | VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "CoherentUI Plugin" 90 | VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "Copyright (c) 2013, The authors of the CoherentUI Plugin project" 91 | VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "CoherentUI Plugin for CryEngine" 92 | VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "${VERSION}" 93 | VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductVersion" "${VERSION}" 94 | VIProductVersion "${VERSION}" 95 | 96 | #################################### 97 | 98 | ; Show changelog 99 | Function "ShowChangelog" 100 | Exec 'notepad "$INSTDIR\Code\Plugin_CoherentUI\changelog.md"' 101 | FunctionEnd 102 | 103 | ; Custom functions 104 | Function "IsValidCEInstallation" 105 | IfFileExists "$INSTDIR\Bin32\Plugins\Plugin_Manager.dll" cont 106 | MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION|MB_TOPMOST|MB_SETFOREGROUND \ 107 | "The path is not a CryEngine installation or the Plugin SDK is not installed:$\n\ 108 | $INSTDIR $\n$\n\ 109 | The Plugin will NOT work,$\ncontinue anyways?" \ 110 | IDOK cont1 111 | Abort 112 | cont: 113 | cont1: 114 | FunctionEnd 115 | -------------------------------------------------------------------------------- /tools/_astyle.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLabs/CoherentUI_CryEngine3/44b30e41e37a92ee16edbc6b738f996cfb3bd67e/tools/_astyle.exe -------------------------------------------------------------------------------- /tools/_stylehelper.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | IF (%1)==() GOTO error 4 | dir /b /ad %1 >nul 2>nul && GOTO indentDir 5 | IF NOT EXIST %1 GOTO error 6 | goto indentFile 7 | 8 | :indentDir 9 | set searchdir=%1 10 | 11 | IF (%2)==() GOTO assignDefaultSuffix 12 | set filesuffix=%2 13 | 14 | GOTO run 15 | 16 | :assignDefaultSuffix 17 | ::echo !!!!DEFAULT SUFFIX!!! 18 | set filesuffix=* 19 | 20 | :run 21 | FOR /F "tokens=*" %%G IN ('DIR /B /S %searchdir%\*.%filesuffix%') DO ( 22 | echo Indenting file "%%G" 23 | "_astyle.exe" "%%G" --options="codestyle.astylerc" 24 | ) 25 | GOTO ende 26 | 27 | :indentFile 28 | echo Indenting one file %1 29 | "_astyle.exe" "%1" --options="codestyle.astylerc" 30 | 31 | 32 | GOTO ende 33 | 34 | :error 35 | echo . 36 | echo ERROR: As parameter given directory or file does not exist! 37 | echo Syntax is: call_Artistic_Style.bat dirname filesuffix 38 | echo Syntax is: call_Artistic_Style.bat filename 39 | echo Example: call_Artistic_Style.bat temp cpp 40 | echo . 41 | 42 | :ende 43 | -------------------------------------------------------------------------------- /tools/build.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | :: Set project relevant settings 4 | set VCPROJECT="..\project\CoherentUI.vcxproj" 5 | set VCTOOLS="%VS100COMNTOOLS%..\..\VC\vcvarsall.bat" 6 | 7 | IF EXIST %VCTOOLS% ( 8 | :: Compile x86 9 | call %VCTOOLS% x86 10 | 11 | MSBuild %VCPROJECT% /t:Rebuild /p:Configuration=Release 12 | IF ERRORLEVEL 1 GOTO COMPILERROR 13 | 14 | 15 | :: Compile x64 16 | call %VCTOOLS% x64 17 | 18 | MSBuild %VCPROJECT% /t:Rebuild /p:Configuration=Release 19 | IF ERRORLEVEL 1 GOTO COMPILERROR 20 | ) 21 | 22 | :: End 23 | GOTO ENDOK 24 | 25 | :COMPILERROR 26 | 27 | ::Trigger a Syntax error 28 | --ERROR_DETECTED-- 29 | 30 | :ENDOK 31 | -------------------------------------------------------------------------------- /tools/build_installer.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | :: Detection code from https://github.com/SublimeText/NSIS 4 | 5 | set nsis_compiler= 6 | 7 | if defined NSIS_HOME ( 8 | if exist "%NSIS_HOME%\makensis.exe" ( 9 | set "nsis_compiler=%NSIS_HOME%" 10 | ) 11 | ) 12 | 13 | if %PROCESSOR_ARCHITECTURE%==x86 ( 14 | Set RegQry=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\NSIS 15 | ) else ( 16 | Set RegQry=HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\NSIS 17 | ) 18 | 19 | if not defined nsis_compiler ( 20 | for /F "tokens=2*" %%a in ('reg query %RegQry% /v InstallLocation ^|findstr InstallLocation') do set nsis_compiler=%%b 21 | ) 22 | 23 | if not defined nsis_compiler ( 24 | for %%X in (makensis.exe) do (set nsis_compiler=%%~dp$PATH:X) 25 | ) 26 | 27 | if defined nsis_compiler ( 28 | "%nsis_compiler%\makensis.exe" "CoherentUI_Installer.nsi" 29 | ) else ( 30 | echo "Error, build system cannot find NSIS! Please reinstall it, add makensis.exe to your PATH, or define the NSIS_HOME environment variable." 31 | ) 32 | -------------------------------------------------------------------------------- /tools/codestyle.astylerc: -------------------------------------------------------------------------------- 1 | --style=bsd 2 | --indent-switches 3 | --indent-cases 4 | --indent-namespaces 5 | --indent-classes 6 | --indent-preprocessor 7 | --indent-col1-comments 8 | --max-instatement-indent=40 9 | --break-blocks=all 10 | --pad-oper 11 | --pad-header 12 | --pad-paren-in 13 | --add-brackets 14 | --align-pointer=type 15 | --align-reference=type 16 | --indent=spaces=4 17 | --convert-tabs 18 | --lineend=windows 19 | --mode=c 20 | --suffix=none 21 | -------------------------------------------------------------------------------- /tools/stylecode.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | cmd /C "_stylehelper.bat ..\src cpp" 2>NUL 4 | cmd /C "_stylehelper.bat ..\src h" 2>NUL 5 | cmd /C "_stylehelper.bat ..\src hpp" 2>NUL 6 | cmd /C "_stylehelper.bat ..\src c" 2>NUL 7 | cmd /C "_stylehelper.bat ..\src cc" 2>NUL 8 | cmd /C "_stylehelper.bat ..\src inc" 2>NUL 9 | 10 | cmd /C "_stylehelper.bat ..\inc cpp" 2>NUL 11 | cmd /C "_stylehelper.bat ..\inc h" 2>NUL 12 | cmd /C "_stylehelper.bat ..\inc hpp" 2>NUL 13 | cmd /C "_stylehelper.bat ..\inc c" 2>NUL 14 | cmd /C "_stylehelper.bat ..\inc cc" 2>NUL 15 | cmd /C "_stylehelper.bat ..\inc inc" 2>NUL 16 | 17 | pause --------------------------------------------------------------------------------