├── code ├── source │ ├── visual │ │ ├── mesh.cpp │ │ ├── mesh.hpp │ │ ├── shadertech_particle.cpp │ │ ├── shadertech_particle.hpp │ │ ├── subcache_mesh.cpp │ │ ├── shadertech_shadowcaster.hpp │ │ ├── entitylogic_particlesource.cpp │ │ ├── subcache_mesh.hpp │ │ ├── font_mgr.hpp │ │ ├── entitylogic.cpp │ │ ├── shadertech_shadowmap.hpp │ │ ├── shader_mgr.hpp │ │ ├── bitmap.hpp │ │ ├── entity_def.cpp │ │ ├── vertexattribute.hpp │ │ ├── particle_mgr.hpp │ │ ├── armatureattachment_def.hpp │ │ ├── armatureattachment_def.cpp │ │ ├── camera_mgr.hpp │ │ ├── visual_mgr.hpp │ │ └── shadertech_generic.hpp │ ├── mod │ │ ├── mod.cpp │ │ ├── mod.hpp │ │ ├── node_player_mgr.cpp │ │ └── node_player_mgr.hpp │ ├── global │ │ ├── env.cpp │ │ ├── file_impl.cpp │ │ ├── exception.hpp │ │ ├── file_impl_archive.hpp │ │ ├── cvar.cpp │ │ ├── global.hpp │ │ ├── eventqueue.hpp │ │ ├── memory.cpp │ │ ├── file_stream.hpp │ │ ├── memory.hpp │ │ ├── eventqueue.cpp │ │ ├── eventreceiver.cpp │ │ ├── eventreceiver.hpp │ │ ├── file_impl.hpp │ │ └── file_mgr.hpp │ ├── util │ │ ├── string.hpp │ │ ├── util.hpp │ │ ├── uniform_uv.cpp │ │ ├── deque.hpp │ │ ├── queue.hpp │ │ ├── stack.hpp │ │ ├── preproc_join.hpp │ │ ├── dyn_bitarray.hpp │ │ ├── hashset.hpp │ │ ├── printf_format.hpp │ │ ├── angle.hpp │ │ ├── objectnodetraits.hpp │ │ ├── fh_types.def │ │ ├── typestringtraits.hpp │ │ ├── misc.hpp │ │ ├── rawarchive.tpp │ │ ├── math_constants.hpp │ │ ├── referencecountable.cpp │ │ ├── fh_save.hpp │ │ ├── class_preproc.hpp │ │ ├── thread.hpp │ │ ├── set.hpp │ │ ├── mem_chunk.cpp │ │ ├── mutex.hpp │ │ ├── scopefinalizer.hpp │ │ ├── base_cb_listener.hpp │ │ ├── uniform_uv.hpp │ │ ├── bool_wrap.hpp │ │ ├── mem_pool_linear.hpp │ │ ├── graph.hpp │ │ ├── exception.hpp │ │ ├── referencecountable.hpp │ │ ├── rawarchive.hpp │ │ ├── mem_pool.cpp │ │ ├── poolview.hpp │ │ ├── exception.cpp │ │ ├── crashhandler.hpp │ │ ├── mem_chunk.hpp │ │ ├── parallel_queue.hpp │ │ ├── pair.hpp │ │ ├── key.hpp │ │ ├── mem_pool.hpp │ │ └── bit.hpp │ ├── game │ │ ├── propertygrid.cpp │ │ ├── editor │ │ │ ├── editorcomponent.cpp │ │ │ ├── editorextension_mgr.cpp │ │ │ ├── editor.cpp │ │ │ ├── editor.hpp │ │ │ ├── components │ │ │ │ ├── ec_performance.hpp │ │ │ │ ├── ec_console.cpp │ │ │ │ ├── ec_console.hpp │ │ │ │ ├── ec_nodes.hpp │ │ │ │ └── ec_we_tools.hpp │ │ │ ├── editorextension.hpp │ │ │ ├── extensions │ │ │ │ └── ee_blender.hpp │ │ │ ├── editorextension_mgr.hpp │ │ │ └── editorview.hpp │ │ ├── ingamelogic.hpp │ │ ├── worldaudio_env.hpp │ │ ├── worldentity_pack.cpp │ │ ├── basegamelogic.hpp │ │ ├── physics.hpp │ │ ├── worldquery.hpp │ │ ├── world_gen │ │ │ ├── worker.cpp │ │ │ ├── workerlocation.hpp │ │ │ └── worker.hpp │ │ ├── worldentity_table.cpp │ │ ├── worldentity_pack.hpp │ │ ├── worldentity_table.hpp │ │ ├── worldchunktask.hpp │ │ ├── basegamelogic.cpp │ │ ├── physics.cpp │ │ ├── worldentity_set.cpp │ │ ├── worldcontactlistener.hpp │ │ └── worldaudio_env.cpp │ ├── physics │ │ ├── jointtypes.def │ │ ├── object_rigid.hpp │ │ ├── box2d.hpp │ │ ├── joints.hpp │ │ ├── b2_fixtureuserdata.hpp │ │ ├── friction.hpp │ │ ├── ghostlydynamics.hpp │ │ ├── joint_friction.hpp │ │ ├── jointtype.hpp │ │ ├── joint_rope.hpp │ │ ├── jointtype.cpp │ │ ├── joint_weld.hpp │ │ ├── joint_target.hpp │ │ ├── chunk_util.hpp │ │ ├── potentialfield.hpp │ │ ├── fixture.cpp │ │ ├── joint_friction.cpp │ │ ├── joint_distance.hpp │ │ ├── entityjoint_def.hpp │ │ ├── material.cpp │ │ ├── b2_joint.hpp │ │ └── joint_rope.cpp │ ├── nodes │ │ ├── compositionnode_ui.cpp │ │ ├── baseslot.cpp │ │ ├── native_instances │ │ │ ├── batchpriorities.hpp │ │ │ ├── nodeinstance_error.hpp │ │ │ ├── nodeinstance_add_real.hpp │ │ │ ├── nodeinstance_pow_real.hpp │ │ │ ├── nodeinstance_worldclock.hpp │ │ │ ├── nodeinstance_multiply_real.hpp │ │ │ ├── nodeinstance_guiinput.cpp │ │ │ ├── nodeinstance_add_real.cpp │ │ │ ├── nodeinstance_guiinput.hpp │ │ │ ├── nodeinstance_logicor.hpp │ │ │ ├── nodeinstance_lerp_vec2.hpp │ │ │ ├── nodeinstance_multiply_real.cpp │ │ │ ├── nodeinstance_pow_real.cpp │ │ │ ├── nodeinstance_delayedtrigger.hpp │ │ │ ├── nodeinstance_triggertosignal.hpp │ │ │ ├── nodeinstance_exp_release_real.hpp │ │ │ ├── nodeinstance_lerp_pose.hpp │ │ │ └── nodeinstance_worldclock.cpp │ │ ├── baseoutputslot.cpp │ │ ├── signaltypes.def │ │ ├── baseslot.hpp │ │ ├── compositionnode_ui.hpp │ │ ├── nodeevent_mgr.cpp │ │ ├── subsignaltypes.def │ │ ├── nodeevent_mgr.hpp │ │ ├── nodeeventreceiverproxy.hpp │ │ ├── signaltype.hpp │ │ ├── nodeeventreceiverproxy_we.cpp │ │ ├── nodeeventreceiverproxy_we.hpp │ │ ├── nodeeventtype.cpp │ │ ├── baseinputslot.cpp │ │ ├── signaltypetraits.tpp │ │ ├── compositionnodeslothandle.cpp │ │ ├── signalargument.cpp │ │ ├── compositionnodeslottemplategrouphandle.cpp │ │ └── updateline.hpp │ ├── net │ │ ├── exception.cpp │ │ ├── exception.hpp │ │ ├── net.hpp │ │ └── protocol_msg │ │ │ └── msg.tpp │ ├── gui │ │ ├── element_tab.hpp │ │ ├── element_attributefield.cpp │ │ ├── element_worldinterface.cpp │ │ ├── element_worldinterface.hpp │ │ ├── element_panel.cpp │ │ ├── attributefieldelementfactory.hpp │ │ ├── callback.tpp │ │ ├── element_attributefield_vector4.hpp │ │ ├── element_panel.hpp │ │ ├── element_attributefield_baseshape.hpp │ │ ├── element_attributefield_string.hpp │ │ ├── element_attributefield_boolean.hpp │ │ ├── element_attributefield_path.hpp │ │ ├── element_attributefield_scalar.hpp │ │ ├── element_attributefield_resourcepair.hpp │ │ ├── element_attributefield_resource.hpp │ │ ├── element_attributefield_vector2.hpp │ │ ├── element_layout_radial.hpp │ │ ├── element_attributefield_boolean.cpp │ │ ├── elementvisualentity_custom.cpp │ │ ├── element_attributefield_signalargument.hpp │ │ ├── element_2dcontroller.hpp │ │ ├── gui_mgr.hpp │ │ └── element_attributefield_string.cpp │ ├── animation │ │ ├── joint.cpp │ │ ├── joint.hpp │ │ ├── joint_def.hpp │ │ ├── joint_def.cpp │ │ └── clipchannel.hpp │ ├── app.hpp │ ├── audio │ │ ├── audiostream.cpp │ │ ├── audiodevice.cpp │ │ ├── audiodevice.hpp │ │ ├── audiostream.hpp │ │ ├── audioreceiverhandle.hpp │ │ ├── audiostream_raw.hpp │ │ ├── audioreceiver.hpp │ │ ├── audiodevice_dummy.hpp │ │ ├── audiostream_raw.cpp │ │ ├── soundinstancehandle.hpp │ │ └── audiosourcehandle.hpp │ ├── debug │ │ ├── log.cpp │ │ └── log.hpp │ ├── resources │ │ ├── exception.cpp │ │ ├── resource_id.cpp │ │ ├── exception.hpp │ │ ├── attribute.cpp │ │ ├── attributeparseinfo.hpp │ │ └── attribute_def.tpp │ ├── ui │ │ ├── nodes │ │ │ ├── signalvalue_ui_factory.hpp │ │ │ ├── signalvalue_ui_factory.cpp │ │ │ └── basesignalvalue_ui.hpp │ │ ├── game │ │ │ ├── editor │ │ │ │ ├── common.hpp │ │ │ │ ├── editorcomponent_ui_factory.hpp │ │ │ │ ├── editorcomponent_ui.cpp │ │ │ │ ├── editor_ui.hpp │ │ │ │ └── editorcomponent_ui_factory.cpp │ │ │ ├── inventory_ui.hpp │ │ │ ├── inventory_gui.hpp │ │ │ └── ingame_ui.hpp │ │ └── hid │ │ │ ├── control.cpp │ │ │ ├── controls │ │ │ └── control_text.hpp │ │ │ ├── action.hpp │ │ │ └── baseactionlistener.cpp │ ├── hardware │ │ ├── dll.hpp │ │ ├── hid_devicefactory.hpp │ │ ├── memory.hpp │ │ ├── hid_devicefactory.cpp │ │ └── hid_device_gamepad.hpp │ ├── main.cpp │ ├── collision │ │ ├── ray.hpp │ │ └── box2d.hpp │ └── build.cpp ├── deps │ └── common │ │ ├── glfw-3.0.3 │ │ ├── src │ │ │ └── config.h │ │ └── COPYING.txt │ │ ├── libvorbis-1.3.4 │ │ ├── AUTHORS │ │ ├── include │ │ │ ├── Makefile.am │ │ │ └── vorbis │ │ │ │ └── Makefile.am │ │ └── lib │ │ │ ├── books │ │ │ ├── floor │ │ │ │ └── Makefile.am │ │ │ ├── Makefile.am │ │ │ ├── uncoupled │ │ │ │ └── Makefile.am │ │ │ └── coupled │ │ │ │ └── Makefile.am │ │ │ └── modes │ │ │ └── Makefile.am │ │ ├── freetype-2.5.3 │ │ ├── docs │ │ │ └── FTL.TXT │ │ └── src │ │ │ ├── autofit │ │ │ └── afangles.h │ │ │ └── gzip │ │ │ └── infcodes.h │ │ ├── libogg-1.3.2 │ │ ├── include │ │ │ ├── Makefile.am │ │ │ └── ogg │ │ │ │ ├── Makefile.am │ │ │ │ └── config_types.h.in │ │ ├── AUTHORS │ │ └── src │ │ │ └── Makefile.am │ │ ├── clipper-4.8.0 │ │ └── clipper │ │ │ ├── clipper.cpp │ │ │ └── clipper.hpp │ │ ├── portaudio-19 │ │ └── src │ │ │ ├── common │ │ │ └── pa_debugprint.c │ │ │ └── hostapi │ │ │ └── wasapi │ │ │ └── mingw-include │ │ │ ├── ksguid.h │ │ │ └── propkeydef.h │ │ ├── utfcpp-2.3.2 │ │ └── doc │ │ │ └── ReleaseNotes │ │ └── zlib-1.2.8 │ │ ├── inffast.h │ │ └── gzclose.c ├── clbs │ └── build_dev.bat └── tools │ └── editor_extensions │ └── blender │ └── editor_extension.blend ├── .gitignore └── .gitmodules /code/source/visual/mesh.cpp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /code/deps/common/glfw-3.0.3/src/config.h: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /code/clbs/build_dev.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | clbs dev -j4 3 | pause>nul -------------------------------------------------------------------------------- /code/source/mod/mod.cpp: -------------------------------------------------------------------------------- 1 | #include "global/module_util.hpp" 2 | 3 | DECLARE_MOD(mod); 4 | DEFINE_MOD(mod); 5 | -------------------------------------------------------------------------------- /code/source/mod/mod.hpp: -------------------------------------------------------------------------------- 1 | #error Documentation only 2 | 3 | /// This directory contains game-specific features 4 | -------------------------------------------------------------------------------- /code/deps/common/libvorbis-1.3.4/AUTHORS: -------------------------------------------------------------------------------- 1 | Monty 2 | 3 | and the rest of the Xiph.org Foundation. 4 | -------------------------------------------------------------------------------- /code/deps/common/freetype-2.5.3/docs/FTL.TXT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crafn/clover/HEAD/code/deps/common/freetype-2.5.3/docs/FTL.TXT -------------------------------------------------------------------------------- /code/deps/common/libogg-1.3.2/include/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | SUBDIRS = ogg 4 | -------------------------------------------------------------------------------- /code/deps/common/libvorbis-1.3.4/include/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | SUBDIRS = vorbis 4 | -------------------------------------------------------------------------------- /code/deps/common/clipper-4.8.0/clipper/clipper.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crafn/clover/HEAD/code/deps/common/clipper-4.8.0/clipper/clipper.cpp -------------------------------------------------------------------------------- /code/deps/common/clipper-4.8.0/clipper/clipper.hpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crafn/clover/HEAD/code/deps/common/clipper-4.8.0/clipper/clipper.hpp -------------------------------------------------------------------------------- /code/deps/common/libvorbis-1.3.4/lib/books/floor/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | EXTRA_DIST = floor_books.h 4 | -------------------------------------------------------------------------------- /code/deps/common/libvorbis-1.3.4/lib/books/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | SUBDIRS = coupled uncoupled floor 4 | -------------------------------------------------------------------------------- /code/deps/common/portaudio-19/src/common/pa_debugprint.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crafn/clover/HEAD/code/deps/common/portaudio-19/src/common/pa_debugprint.c -------------------------------------------------------------------------------- /code/source/global/env.cpp: -------------------------------------------------------------------------------- 1 | #include "env.hpp" 2 | 3 | namespace clover { 4 | namespace global { 5 | 6 | Env g_env; 7 | 8 | } // global 9 | } // clover 10 | -------------------------------------------------------------------------------- /code/source/util/string.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_UTIL_STRING_HPP 2 | #define CLOVER_UTIL_STRING_HPP 3 | 4 | #include "str8.hpp" 5 | 6 | #endif // CLOVER_UTIL_STRING_HPP 7 | -------------------------------------------------------------------------------- /code/tools/editor_extensions/blender/editor_extension.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crafn/clover/HEAD/code/tools/editor_extensions/blender/editor_extension.blend -------------------------------------------------------------------------------- /code/deps/common/libvorbis-1.3.4/lib/books/uncoupled/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | EXTRA_DIST = res_books_uncoupled.h 4 | -------------------------------------------------------------------------------- /code/deps/common/libvorbis-1.3.4/lib/books/coupled/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | EXTRA_DIST = res_books_stereo.h res_books_51.h 4 | -------------------------------------------------------------------------------- /code/source/util/util.hpp: -------------------------------------------------------------------------------- 1 | #error Documentation only 2 | 3 | /// 'util' namespace (and directory) should only contain utilities which 4 | /// can be extracted from the project cleanly to a separate library 5 | -------------------------------------------------------------------------------- /code/source/visual/mesh.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_VISUAL_MESH_HPP 2 | #define CLOVER_VISUAL_MESH_HPP 3 | 4 | #include "visual/subcache_mesh.hpp" 5 | #include "visual/mesh_impl.hpp" 6 | 7 | #endif // CLOVER_VISUAL_MESH_HPP -------------------------------------------------------------------------------- /code/deps/common/freetype-2.5.3/src/autofit/afangles.h: -------------------------------------------------------------------------------- 1 | /* 2 | * afangles.h 3 | * 4 | * This is a dummy file, used to please the build system. It is never 5 | * included by the auto-fitter sources. 6 | * 7 | */ 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | Temp and build files 2 | *.swp 3 | *.swo 4 | *~ 5 | *.cache 6 | code/clbs/lib 7 | code/clbs/obj 8 | builds 9 | *.fuse_hidden* 10 | resources 11 | backup 12 | resources.zip 13 | *.blend1 14 | *.blend2 15 | -------------------------------------------------------------------------------- /code/source/game/propertygrid.cpp: -------------------------------------------------------------------------------- 1 | #include "physics/grid.hpp" 2 | #include "propertygrid.hpp" 3 | 4 | namespace clover { 5 | namespace game { 6 | 7 | void PropertyGrid::update() 8 | { 9 | } 10 | 11 | } // game 12 | } // clover 13 | -------------------------------------------------------------------------------- /code/deps/common/libvorbis-1.3.4/include/vorbis/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | vorbisincludedir = $(includedir)/vorbis 4 | 5 | vorbisinclude_HEADERS = codec.h vorbisfile.h vorbisenc.h 6 | 7 | 8 | -------------------------------------------------------------------------------- /code/deps/common/libogg-1.3.2/include/ogg/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | oggincludedir = $(includedir)/ogg 4 | 5 | ogginclude_HEADERS = ogg.h os_types.h 6 | nodist_ogginclude_HEADERS = config_types.h 7 | -------------------------------------------------------------------------------- /code/source/physics/jointtypes.def: -------------------------------------------------------------------------------- 1 | JOINT_TYPE(None) 2 | JOINT_TYPE(Distance) 3 | JOINT_TYPE(Friction) 4 | JOINT_TYPE(HardWeld) 5 | JOINT_TYPE(Prismatic) 6 | JOINT_TYPE(Revolute) 7 | JOINT_TYPE(Rope) 8 | JOINT_TYPE(Weld) 9 | JOINT_TYPE(Wheel) 10 | -------------------------------------------------------------------------------- /code/deps/common/libogg-1.3.2/AUTHORS: -------------------------------------------------------------------------------- 1 | Monty 2 | Greg Maxwell 3 | Ralph Giles 4 | Cristian Adam 5 | Tim Terriberry 6 | 7 | and the rest of the Xiph.Org Foundation. 8 | -------------------------------------------------------------------------------- /code/source/nodes/compositionnode_ui.cpp: -------------------------------------------------------------------------------- 1 | #include "compositionnode_ui.hpp" 2 | 3 | namespace clover { 4 | namespace nodes { 5 | 6 | CompositionNodeUi::CompositionNodeUi(CompositionNodeType& type_) 7 | : type(&type_){ 8 | } 9 | 10 | } // nodes 11 | } // clover -------------------------------------------------------------------------------- /code/source/physics/object_rigid.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_PHYSICS_OBJECT_RIGID_HPP 2 | #define CLOVER_PHYSICS_OBJECT_RIGID_HPP 3 | 4 | #include "build.hpp" 5 | #include "object_rigid_impl.hpp" 6 | #include "fixture_rigid.hpp" 7 | 8 | #endif // CLOVER_PHYSICS_OBJECT_RIGID_HPP -------------------------------------------------------------------------------- /code/source/global/file_impl.cpp: -------------------------------------------------------------------------------- 1 | #include "file_impl.hpp" 2 | 3 | namespace clover { 4 | namespace global { 5 | 6 | FileImpl::FileImpl(const util::Str8& name, bool readOnly) 7 | : name(name), read_only(readOnly) 8 | {} 9 | 10 | FileImpl::~FileImpl() 11 | { 12 | } 13 | 14 | } // global 15 | } // clover -------------------------------------------------------------------------------- /code/source/net/exception.cpp: -------------------------------------------------------------------------------- 1 | #include "exception.hpp" 2 | 3 | namespace clover { 4 | namespace net { 5 | 6 | NetException::NetException(const char* str, ...){ 7 | va_list args; 8 | va_start(args, str); 9 | global::Exception::constructor(str, args); 10 | va_end(args); 11 | } 12 | 13 | } // net 14 | } // clover -------------------------------------------------------------------------------- /code/source/gui/element_tab.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_GUI_TAB_HPP 2 | #define CLOVER_GUI_TAB_HPP 3 | 4 | #include "build.hpp" 5 | #include "element_panel.hpp" 6 | 7 | namespace clover { 8 | namespace gui { 9 | 10 | typedef gui::PanelElement TabElement; 11 | 12 | } // gui 13 | } // clover 14 | 15 | #endif // CLOVER_GUI_TAB_HPP -------------------------------------------------------------------------------- /code/source/nodes/baseslot.cpp: -------------------------------------------------------------------------------- 1 | #include "baseslot.hpp" 2 | 3 | namespace clover { 4 | namespace nodes { 5 | 6 | BaseSlot::BaseSlot(SignalType t) 7 | : type(t){ 8 | } 9 | 10 | BaseSlot::~BaseSlot(){ 11 | } 12 | 13 | SignalType BaseSlot::getType() const { 14 | return type; 15 | } 16 | 17 | } // nodes 18 | } // clover -------------------------------------------------------------------------------- /code/source/util/uniform_uv.cpp: -------------------------------------------------------------------------------- 1 | #include "uniform_uv.hpp" 2 | #include "debug/print.hpp" 3 | 4 | namespace clover { 5 | namespace util { 6 | 7 | util::Vec2f UniformUv::getUv(util::Vec2f pos) const { 8 | // @todo Rotation 9 | return (pos - uv.translation)*uv.scale.inversed(); 10 | } 11 | 12 | } // utils 13 | } // clover -------------------------------------------------------------------------------- /code/source/game/editor/editorcomponent.cpp: -------------------------------------------------------------------------------- 1 | #include "editorcomponent.hpp" 2 | #include "global/event.hpp" 3 | 4 | namespace clover { 5 | namespace game { namespace editor { 6 | 7 | EditorComponent::EditorComponent(){ 8 | } 9 | 10 | EditorComponent::~EditorComponent(){ 11 | } 12 | 13 | }} // game::editor 14 | } // clover -------------------------------------------------------------------------------- /code/source/util/deque.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_UTIL_DEQUE_HPP 2 | #define CLOVER_UTIL_DEQUE_HPP 3 | 4 | #include "build.hpp" 5 | 6 | #include 7 | 8 | namespace clover { 9 | namespace util { 10 | 11 | template 12 | using Deque = std::deque; 13 | 14 | } // util 15 | } // clover 16 | 17 | #endif // CLOVER_UTIL_DEQUE_HPP -------------------------------------------------------------------------------- /code/source/util/queue.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_UTIL_QUEUE_HPP 2 | #define CLOVER_UTIL_QUEUE_HPP 3 | 4 | #include "build.hpp" 5 | 6 | #include 7 | 8 | namespace clover { 9 | namespace util { 10 | 11 | template 12 | using Queue = std::queue; 13 | 14 | } // util 15 | } // clover 16 | 17 | #endif // CLOVER_UTIL_QUEUE_HPP -------------------------------------------------------------------------------- /code/source/util/stack.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_UTIL_STACK_HPP 2 | #define CLOVER_UTIL_STACK_HPP 3 | 4 | #include "build.hpp" 5 | 6 | #include 7 | 8 | namespace clover { 9 | namespace util { 10 | 11 | template 12 | using Stack= std::stack; 13 | 14 | } // util 15 | } // clover 16 | 17 | #endif // CLOVER_UTIL_STACK_HPP -------------------------------------------------------------------------------- /code/source/util/preproc_join.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_UTIL_PREPROC_JOIN_HPP 2 | #define CLOVER_UTIL_PREPROC_JOIN_HPP 3 | 4 | #define JOIN_INDIRECTION(x, y) x##y 5 | /// Joins two things by expanding macros first 6 | /// e.g. JOIN(test, __LINE__) == test6 7 | #define JOIN(x, y) JOIN_INDIRECTION(x, y) 8 | 9 | #endif // CLOVER_UTIL_PREPROC_JOIN_HPP 10 | -------------------------------------------------------------------------------- /code/source/global/exception.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_GLOBAL_EXCEPTION_HPP 2 | #define CLOVER_GLOBAL_EXCEPTION_HPP 3 | 4 | #include "build.hpp" 5 | #include "util/exception.hpp" 6 | 7 | namespace clover { 8 | namespace global { 9 | 10 | using util::Exception; 11 | 12 | } // global 13 | } // clover 14 | 15 | #endif // CLOVER_GLOBAL_EXCEPTION_HPP 16 | -------------------------------------------------------------------------------- /code/source/animation/joint.cpp: -------------------------------------------------------------------------------- 1 | #include "joint.hpp" 2 | 3 | namespace clover { 4 | namespace animation { 5 | 6 | Joint::Joint(const util::Str8& name_, const JointPose& bind_pose_, JointId id_, JointId super_id_) 7 | : bindPose(bind_pose_) 8 | , name(name_) 9 | , id(id_) 10 | , superId(super_id_){ 11 | } 12 | 13 | } // animation 14 | } // clover -------------------------------------------------------------------------------- /code/source/util/dyn_bitarray.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_UTIL_DYN_BITARRAY_HPP 2 | #define CLOVER_UTIL_DYN_BITARRAY_HPP 3 | 4 | #include "build.hpp" 5 | 6 | #include 7 | 8 | namespace clover { 9 | namespace util { 10 | 11 | using DynBitArray= std::vector; 12 | 13 | } // util 14 | } // clover 15 | 16 | #endif // CLOVER_UTIL_DYN_BITARRAY_HPP 17 | -------------------------------------------------------------------------------- /code/source/app.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_APP_HPP 2 | #define CLOVER_APP_HPP 3 | 4 | #include "build.hpp" 5 | #include "util/string.hpp" 6 | 7 | namespace clover { 8 | 9 | class App { 10 | public: 11 | App(const util::Str8& executablePath); 12 | ~App(); 13 | void run(); 14 | 15 | private: 16 | }; 17 | 18 | } // clover 19 | 20 | #endif // CLOVER_APP_HPP 21 | -------------------------------------------------------------------------------- /code/source/audio/audiostream.cpp: -------------------------------------------------------------------------------- 1 | #include "audiostream.hpp" 2 | #include "util/ensure.hpp" 3 | 4 | namespace clover { 5 | namespace audio { 6 | 7 | AudioStream::AudioStream() 8 | : eos(false){ 9 | } 10 | 11 | AudioStream::~AudioStream(){ 12 | } 13 | 14 | bool AudioStream::hasEnded() const { 15 | return eos; 16 | } 17 | 18 | } // audio 19 | } // clover -------------------------------------------------------------------------------- /code/source/util/hashset.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_UTIL_HASHSET_HPP 2 | #define CLOVER_UTIL_HASHSET_HPP 3 | 4 | #include "build.hpp" 5 | 6 | #include 7 | 8 | namespace clover { 9 | namespace util { 10 | 11 | template 12 | using HashSet= std::unordered_set; 13 | 14 | } // util 15 | } // clover 16 | 17 | #endif // CLOVER_UTIL_HASHSET_HPP -------------------------------------------------------------------------------- /code/source/nodes/native_instances/batchpriorities.hpp: -------------------------------------------------------------------------------- 1 | #ifndef NODES_NATIVE_INSTANCES_BATCHPRIORITIES_HPP 2 | #define NODES_NATIVE_INSTANCES_BATCHPRIORITIES_HPP 3 | 4 | const int nodeBatchPriority_physicsEntity= 10; 5 | const int nodeBatchPriority_physicsObject= 10; 6 | const int nodeBatchPriority_visualEntity= 0; 7 | 8 | #endif // NODES_NATIVE_INSTANCES_BATCHPRIORITIES_HPP 9 | -------------------------------------------------------------------------------- /code/source/physics/box2d.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_PHYSICS_BOX2D_HPP 2 | #define CLOVER_PHYSICS_BOX2D_HPP 3 | 4 | #include "build.hpp" 5 | #include "collision/box2d.hpp" 6 | 7 | namespace clover { 8 | namespace physics { 9 | 10 | using collision::toB2; 11 | using collision::fromB2; 12 | 13 | } // physics 14 | } // clover 15 | 16 | #endif // CLOVER_PHYSICS_BOX2D_HPP 17 | -------------------------------------------------------------------------------- /code/source/util/printf_format.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_UTIL_PRINTF_FORMAT_HPP 2 | #define CLOVER_UTIL_PRINTF_FORMAT_HPP 3 | 4 | #ifdef __GNUC__ 5 | #define PRINTF_FORMAT(stringIndex, firstToCheck) \ 6 | __attribute__ ((format (printf, (stringIndex), (firstToCheck)))) 7 | #else 8 | #define PRINTF_FORMAT(a, b) 9 | #endif 10 | 11 | #endif // CLOVER_UTIL_PRINTF_FORMAT_HPP 12 | -------------------------------------------------------------------------------- /code/source/visual/shadertech_particle.cpp: -------------------------------------------------------------------------------- 1 | #include "resources/cache.hpp" 2 | #include "shader.hpp" 3 | #include "shader_mgr.hpp" 4 | #include "shadertech_particle.hpp" 5 | 6 | namespace clover { 7 | namespace visual { 8 | 9 | void ParticleST::use() 10 | { 11 | WorldShaderTech::use(getShaderMgr().getShader("visual_particle")); 12 | } 13 | 14 | } // visual 15 | } // clover 16 | -------------------------------------------------------------------------------- /code/deps/common/libvorbis-1.3.4/lib/modes/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | EXTRA_DIST = floor_all.h psych_44.h residue_44.h setup_11.h setup_32.h \ 4 | setup_8.h psych_11.h psych_8.h residue_44u.h setup_16.h \ 5 | setup_44.h setup_X.h psych_16.h residue_16.h residue_8.h \ 6 | setup_22.h setup_44u.h setup_44p51.h residue_44p51.h 7 | -------------------------------------------------------------------------------- /code/source/audio/audiodevice.cpp: -------------------------------------------------------------------------------- 1 | #include "audiodevice.hpp" 2 | 3 | namespace clover { 4 | namespace audio { 5 | 6 | AudioDevice* gAudioDevice; 7 | 8 | AudioDevice::AudioDevice(){ 9 | if (!gAudioDevice) 10 | gAudioDevice= this; 11 | } 12 | 13 | AudioDevice::~AudioDevice(){ 14 | if (gAudioDevice == this) 15 | gAudioDevice= nullptr; 16 | } 17 | 18 | } // audio 19 | } // clover -------------------------------------------------------------------------------- /code/source/debug/log.cpp: -------------------------------------------------------------------------------- 1 | #include "log.hpp" 2 | 3 | namespace clover { 4 | namespace debug { 5 | 6 | Log::Log(){ 7 | file.open("debuglog.txt"); 8 | } 9 | 10 | Log::~Log(){ 11 | file.close(); 12 | } 13 | 14 | void Log::operator()(const char8 * msg){ 15 | if (file.good()){ 16 | file << msg << "\n"; 17 | file.flush(); 18 | } 19 | } 20 | 21 | } // debug 22 | } // clover 23 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "code/deps/common/box2d"] 2 | path = code/deps/common/box2d 3 | url = https://github.com/crafn/clover-box2d.git 4 | [submodule "code/deps/common/boost"] 5 | path = code/deps/common/boost 6 | url = https://github.com/crafn/clover-boost.git 7 | [submodule "code/deps/common/jsoncpp"] 8 | path = code/deps/common/jsoncpp 9 | url = https://github.com/crafn/clover-jsoncpp.git 10 | -------------------------------------------------------------------------------- /code/source/util/angle.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_UTIL_ANGLE_HPP 2 | #define CLOVER_UTIL_ANGLE_HPP 3 | 4 | #include "build.hpp" 5 | 6 | namespace clover { 7 | namespace util { 8 | 9 | /// @todo 10 | template 11 | class Angle { 12 | public: 13 | Angle(T v=0): value(v){ 14 | } 15 | 16 | private: 17 | T value; 18 | }; 19 | 20 | } // util 21 | } // clover 22 | 23 | #endif // CLOVER_UTIL_ANGLE_HPP -------------------------------------------------------------------------------- /code/source/global/file_impl_archive.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_GLOBAL_FILE_IMPL_ARCHIVE_HPP 2 | #define CLOVER_GLOBAL_FILE_IMPL_ARCHIVE_HPP 3 | 4 | namespace clover { 5 | namespace global { 6 | 7 | /// @todo implement 8 | class FileArchive { 9 | }; 10 | /* 11 | class ArchiveFileImpl : public FileImpl { 12 | };*/ 13 | 14 | } // global 15 | } // clover 16 | 17 | #endif // CLOVER_GLOBAL_FILE_IMPL_ARCHIVE_HPP 18 | -------------------------------------------------------------------------------- /code/source/gui/element_attributefield.cpp: -------------------------------------------------------------------------------- 1 | #include "element_attributefield.hpp" 2 | 3 | namespace clover { 4 | namespace gui { 5 | 6 | BaseAttributeFieldElement::BaseAttributeFieldElement() 7 | : Element(util::Coord::VF(0), util::Coord::VF({0.3, 0.04})){ 8 | elementType= AttributeField; 9 | } 10 | 11 | BaseAttributeFieldElement::~BaseAttributeFieldElement(){ 12 | } 13 | 14 | } // gui 15 | } // clover -------------------------------------------------------------------------------- /code/source/physics/joints.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_PHYSICS_JOINTS_HPP 2 | #define CLOVER_PHYSICS_JOINTS_HPP 3 | 4 | #include "joint_distance.hpp" 5 | #include "joint_friction.hpp" 6 | #include "joint_hardweld.hpp" 7 | #include "joint_prismatic.hpp" 8 | #include "joint_revolute.hpp" 9 | #include "joint_rope.hpp" 10 | #include "joint_weld.hpp" 11 | #include "joint_wheel.hpp" 12 | 13 | #endif // CLOVER_PHYSICS_JOINTS_HPP 14 | -------------------------------------------------------------------------------- /code/source/util/objectnodetraits.hpp: -------------------------------------------------------------------------------- 1 | #ifndef UTIL_OBJECTNODETRAITS_HPP 2 | #define UTIL_OBJECTNODETRAITS_HPP 3 | 4 | namespace clover { 5 | namespace util { 6 | 7 | /// Enable is used to switch traits on/off depending on T 8 | template 9 | struct ObjectNodeTraits; 10 | 11 | class ObjectNode; 12 | 13 | } // util 14 | } // clover 15 | 16 | #endif // UTIL_OBJECTNODE_TRAIT_HPP 17 | -------------------------------------------------------------------------------- /code/source/global/cvar.cpp: -------------------------------------------------------------------------------- 1 | #include "cvar.hpp" 2 | 3 | namespace clover { 4 | namespace global { 5 | 6 | CVar::CVar(const util::Str8& n, util::ObjectNode ob) 7 | : name(n) 8 | , value(std::move(ob)){ 9 | } 10 | 11 | util::Str8 CVar::generateString() const { 12 | return util::Str8("\"") + name + "\"" + " : " + get().generateText().endNewlineErased(); 13 | } 14 | 15 | } // global 16 | } // clover 17 | -------------------------------------------------------------------------------- /code/source/util/fh_types.def: -------------------------------------------------------------------------------- 1 | // FieldHolder types 2 | TYPE(tUint8, uint8) 3 | TYPE(tUint16, uint16) 4 | TYPE(tUint32, uint32) 5 | TYPE(tUint64, uint64) 6 | TYPE(tInt8, int8) 7 | TYPE(tInt16, int16) 8 | TYPE(tInt32, int32) 9 | TYPE(tInt64, int64) 10 | TYPE(tReal32, real32) 11 | TYPE(tReal64, real64) 12 | TYPE(tVec2f, Vec2f) 13 | TYPE(tVec2d, Vec2d) 14 | TYPE(tBool, bool) 15 | TYPE(tWeHandle, game::WeHandle) 16 | TYPE(tStr8, Str8) -------------------------------------------------------------------------------- /code/source/visual/shadertech_particle.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_VISUAL_SHADERTECH_PARTICLE_HPP 2 | #define CLOVER_VISUAL_SHADERTECH_PARTICLE_HPP 3 | 4 | #include "build.hpp" 5 | #include "shadertech.hpp" 6 | 7 | namespace clover { 8 | namespace visual { 9 | 10 | class ParticleST : public WorldShaderTech { 11 | public: 12 | void use(); 13 | }; 14 | 15 | } // visual 16 | } // clover 17 | 18 | #endif // CLOVER_VISUAL_SHADERTECH_PARTICLE_HPP 19 | -------------------------------------------------------------------------------- /code/source/util/typestringtraits.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_UTIL_TYPESTRINGTRAITS_HPP 2 | #define CLOVER_UTIL_TYPESTRINGTRAITS_HPP 3 | 4 | namespace clover { 5 | namespace util { 6 | 7 | /// @todo Replace with automatic tool 8 | template 9 | struct TypeStringTraits; /* 10 | static util::Str8 type(); 11 | static util::Str8 shortType(); 12 | };*/ 13 | 14 | } // util 15 | } // clover 16 | 17 | #endif // CLOVER_UTIL_TYPESTRINGTRAITS_HPP 18 | -------------------------------------------------------------------------------- /code/source/util/misc.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_UTIL_MISC_HPP 2 | #define CLOVER_UTIL_MISC_HPP 3 | 4 | #include "build.hpp" 5 | 6 | #include 7 | #include 8 | 9 | namespace clover { 10 | namespace util { 11 | 12 | /// @todo Move to debug namespace 13 | std::string getFilenameFromPath(const char8* s); 14 | std::string getReducedFunctionName(const char8* s); 15 | 16 | } // util 17 | } // clover 18 | 19 | #endif // CLOVER_UTIL_MISC_HPP 20 | -------------------------------------------------------------------------------- /code/source/gui/element_worldinterface.cpp: -------------------------------------------------------------------------------- 1 | #include "element_worldinterface.hpp" 2 | 3 | namespace clover { 4 | namespace gui { 5 | 6 | WorldInterfaceElement::WorldInterfaceElement(): 7 | Element(util::Coord(0, util::Coord::View_Stretch), util::Coord(50, util::Coord::View_Stretch)){//Tarpeeks iso (100x100 unittia) 8 | elementType= WorldInterface; 9 | } 10 | 11 | WorldInterfaceElement::~WorldInterfaceElement(){ 12 | } 13 | 14 | } // gui 15 | } // clover -------------------------------------------------------------------------------- /code/source/util/rawarchive.tpp: -------------------------------------------------------------------------------- 1 | template 2 | SizeType RawArchive::serializePod(uint8* buf, const T* ptr, SizeType count){ 3 | SizeType byte_count= sizeof(T)*count; 4 | memcpy(buf, ptr, byte_count); 5 | return byte_count; 6 | } 7 | 8 | template 9 | SizeType RawArchive::deserializePod(const uint8* buf, T* ptr, SizeType count){ 10 | SizeType byte_count= sizeof(T)*count; 11 | memcpy(ptr, buf, byte_count); 12 | return byte_count; 13 | } -------------------------------------------------------------------------------- /code/source/nodes/baseoutputslot.cpp: -------------------------------------------------------------------------------- 1 | #include "baseoutputslot.hpp" 2 | #include "baseinputslot.hpp" 3 | 4 | namespace clover { 5 | namespace nodes { 6 | 7 | BaseOutputSlot::BaseOutputSlot(SignalType t) 8 | : BaseSlot(t){ 9 | } 10 | 11 | BaseOutputSlot::~BaseOutputSlot(){ 12 | } 13 | 14 | void BaseOutputSlot::attach(SubSignalType from, SubSignalType to, BaseInputSlot& input){ 15 | inputs.pushBack({&input, from, to}); 16 | } 17 | 18 | } // nodes 19 | } // clover -------------------------------------------------------------------------------- /code/source/resources/exception.cpp: -------------------------------------------------------------------------------- 1 | #include "exception.hpp" 2 | 3 | namespace clover { 4 | namespace resources { 5 | 6 | ResourceException::ResourceException(const char* str, ...){ 7 | va_list args; 8 | va_start(args, str); 9 | global::Exception::constructor(str, args); 10 | va_end(args); 11 | } 12 | 13 | ResourceException::ResourceException(){} 14 | 15 | ResourceException::~ResourceException() throw() { 16 | 17 | } 18 | 19 | } // resources 20 | } // clover -------------------------------------------------------------------------------- /code/source/nodes/signaltypes.def: -------------------------------------------------------------------------------- 1 | SIGNAL(Real, 0) 2 | SIGNAL(Integer, 1) 3 | SIGNAL(String, 2) 4 | SIGNAL(Boolean, 3) 5 | SIGNAL(Vec2, 4) 6 | SIGNAL(RtTransform2, 5) 7 | SIGNAL(SrtTransform2, 6) 8 | SIGNAL(Event, 7) 9 | SIGNAL(EventType, 8) 10 | SIGNAL(Trigger, 9) 11 | SIGNAL(EventArray, 10) 12 | SIGNAL(Vec3, 11) 13 | SIGNAL(Quaternion, 12) 14 | SIGNAL(SrtTransform3, 13) 15 | SIGNAL(ArmaturePose, 14) 16 | SIGNAL(Shape, 15) 17 | SIGNAL(Vec4, 16) 18 | SIGNAL(WeHandle, 17) 19 | -------------------------------------------------------------------------------- /code/source/ui/nodes/signalvalue_ui_factory.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_SIGNALVALUE_UI_FACTORY_HPP 2 | #define CLOVER_SIGNALVALUE_UI_FACTORY_HPP 3 | 4 | #include "build.hpp" 5 | #include "signalvalue_ui.hpp" 6 | 7 | namespace clover { 8 | namespace ui { namespace nodes { 9 | 10 | class SignalValueUiFactory { 11 | public: 12 | static BaseSignalValueUi* create(SignalType S); 13 | }; 14 | 15 | }} // ui::nodes 16 | } // clover 17 | 18 | #endif // CLOVER_SIGNALVALUE_UI_FACTORY_HPP -------------------------------------------------------------------------------- /code/deps/common/utfcpp-2.3.2/doc/ReleaseNotes: -------------------------------------------------------------------------------- 1 | utf8 cpp library 2 | Release 2.3.2 3 | 4 | A bug fix release plus minor performance improvements. Thanks to all who reported bugs. 5 | 6 | Changes from version 2.3.1 7 | - Bug fix [3506114]: potential crash in replace_invalid 8 | - Bug fix [3426789]: documentation typo 9 | - Bug fix [3215839]: name clash with std::next 10 | 11 | Files included in the release: utf8.h, core.h, checked.h, unchecked.h, utf8cpp.html, ReleaseNotes 12 | -------------------------------------------------------------------------------- /code/source/util/math_constants.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_MATH_CONSTANTS_HPP 2 | #define CLOVER_MATH_CONSTANTS_HPP 3 | 4 | #include "build.hpp" 5 | 6 | namespace clover { 7 | namespace util { 8 | 9 | const real64 epsilon = 0.00000000001; 10 | const real32 epsilonf = 0.00001; 11 | 12 | const real64 pi= 3.1415926535; 13 | const real64 tau= 6.28318531; 14 | const real64 euler= 2.71828182845904523536; 15 | 16 | } // util 17 | } // clover 18 | 19 | #endif // CLOVER_MATH_CONSTANTS_HPP -------------------------------------------------------------------------------- /code/source/physics/b2_fixtureuserdata.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_PHYSICS_B2_FIXTUREUSERDATA_HPP 2 | #define CLOVER_PHYSICS_B2_FIXTUREUSERDATA_HPP 3 | 4 | #include "build.hpp" 5 | 6 | namespace clover { 7 | namespace physics { 8 | 9 | class Fixture; 10 | class RigidFixture; 11 | 12 | struct B2FixtureUserData { 13 | B2FixtureUserData():owner(nullptr){} 14 | Fixture* owner; 15 | }; 16 | 17 | } // physics 18 | } // clover 19 | 20 | #endif // CLOVER_PHYSICS_B2_FIXTUREUSERDATA_HPP 21 | -------------------------------------------------------------------------------- /code/source/ui/game/editor/common.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_UI_GAME_EDITOR_HPP 2 | #define CLOVER_UI_GAME_EDITOR_HPP 3 | 4 | namespace clover { 5 | namespace game { 6 | } // game 7 | } // clover 8 | 9 | namespace clover { 10 | namespace ui { namespace game { namespace editor { 11 | 12 | // Allow game::Foo to be searched from clover::game instead of ui::game 13 | namespace game= clover::game; 14 | 15 | }}} // ui::game::editor 16 | } // clover 17 | 18 | #endif // CLOVER_UI_GAME_EDITOR_HPP -------------------------------------------------------------------------------- /code/source/nodes/baseslot.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_NODES_BASESLOT_HPP 2 | #define CLOVER_NODES_BASESLOT_HPP 3 | 4 | #include "build.hpp" 5 | #include "signaltypetraits.hpp" 6 | 7 | namespace clover { 8 | namespace nodes { 9 | 10 | class ENGINE_API BaseSlot { 11 | public: 12 | BaseSlot(SignalType t); 13 | virtual ~BaseSlot(); 14 | 15 | SignalType getType() const; 16 | protected: 17 | SignalType type; 18 | }; 19 | 20 | } // nodes 21 | } // clover 22 | 23 | #endif // CLOVER_NODES_BASESLOT_HPP 24 | -------------------------------------------------------------------------------- /code/source/nodes/compositionnode_ui.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_NODES_COMPOSITIONNODE_UI_HPP 2 | #define CLOVER_NODES_COMPOSITIONNODE_UI_HPP 3 | 4 | #include "build.hpp" 5 | 6 | namespace clover { 7 | namespace nodes { 8 | 9 | class CompositionNodeType; 10 | 11 | class CompositionNodeUi { 12 | public: 13 | CompositionNodeUi(CompositionNodeType&); 14 | 15 | private: 16 | CompositionNodeType* type; 17 | }; 18 | 19 | } // nodes 20 | } // clover 21 | 22 | #endif // CLOVER_NODES_COMPOSITIONNODE_UI_HPP -------------------------------------------------------------------------------- /code/source/debug/log.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_DEBUGLOG_HPP 2 | #define CLOVER_DEBUGLOG_HPP 3 | 4 | #include "build.hpp" 5 | 6 | #include 7 | 8 | namespace clover { 9 | namespace debug { 10 | 11 | /// Performs logging to file 12 | class Log { 13 | public: 14 | Log(); 15 | virtual ~Log(); 16 | 17 | /// Appends row 18 | void operator()(const char8 * msg); 19 | 20 | private: 21 | std::ofstream file; 22 | }; 23 | 24 | } // debug 25 | } // clover 26 | 27 | #endif // CLOVER_DEBUGLOG_HPP 28 | -------------------------------------------------------------------------------- /code/source/resources/resource_id.cpp: -------------------------------------------------------------------------------- 1 | #include "resource_id.hpp" 2 | #include "resource.hpp" 3 | 4 | namespace clover { 5 | namespace resources { 6 | 7 | ResourceId::ResourceId(const Resource& res) 8 | : typeName(res.getResourceTypeName()) 9 | , identifier(res.getIdentifierAttribute().serialized()){ 10 | } 11 | 12 | ResourceId::ResourceId(util::Str8 type_name, const util::ObjectNode& id) 13 | : typeName(type_name) 14 | , identifier(id){ 15 | 16 | } 17 | 18 | } // resources 19 | } // clover -------------------------------------------------------------------------------- /code/deps/common/zlib-1.2.8/inffast.h: -------------------------------------------------------------------------------- 1 | /* inffast.h -- header to use inffast.c 2 | * Copyright (C) 1995-2003, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start)); 12 | -------------------------------------------------------------------------------- /code/source/gui/element_worldinterface.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_GUI_WORLDINTERFACE_HPP 2 | #define CLOVER_GUI_WORLDINTERFACE_HPP 3 | 4 | #include "build.hpp" 5 | #include "element.hpp" 6 | 7 | namespace clover { 8 | namespace gui { 9 | 10 | /// @todo This shuoldn't be part of gui 11 | class WorldInterfaceElement : public Element { 12 | public: 13 | WorldInterfaceElement(); 14 | virtual ~WorldInterfaceElement(); 15 | }; 16 | 17 | } // gui 18 | } // clover 19 | 20 | #endif // CLOVER_GUI_WORLDINTERFACE_HPP 21 | -------------------------------------------------------------------------------- /code/source/nodes/nodeevent_mgr.cpp: -------------------------------------------------------------------------------- 1 | #include "nodeevent_mgr.hpp" 2 | #include "util/profiling.hpp" 3 | 4 | namespace clover { 5 | namespace nodes { 6 | 7 | NodeEventMgr _gNodeEventMgr; 8 | NodeEventMgr* gNodeEventMgr= &_gNodeEventMgr; 9 | 10 | void NodeEventMgr::queue(NodeEvent& e){ 11 | events.pushBack(std::move(e)); 12 | } 13 | 14 | void NodeEventMgr::dispatch(){ 15 | PROFILE(); 16 | for (auto& m : events){ 17 | m.send(); 18 | } 19 | 20 | events.clear(); 21 | } 22 | 23 | } // nodes 24 | } // clover 25 | -------------------------------------------------------------------------------- /code/source/nodes/subsignaltypes.def: -------------------------------------------------------------------------------- 1 | SUBSIGNAL(X, 0) 2 | SUBSIGNAL(Y, 1) 3 | SUBSIGNAL(Z, 2) 4 | SUBSIGNAL(Translation2, 3) 5 | SUBSIGNAL(Translation3, 4) 6 | SUBSIGNAL(RotationZ, 5) 7 | SUBSIGNAL(RotationQ, 6) 8 | SUBSIGNAL(ScaleX, 7) 9 | SUBSIGNAL(ScaleY, 8) 10 | SUBSIGNAL(ScaleZ, 9) 11 | SUBSIGNAL(Scale2, 10) 12 | SUBSIGNAL(Scale3, 11) 13 | SUBSIGNAL(RtTransform2, 12) 14 | SUBSIGNAL(SrtTransform2, 13) 15 | SUBSIGNAL(SrtTransform3, 14) 16 | SUBSIGNAL(Trigger, 15) 17 | SUBSIGNAL(Resource, 16) 18 | SUBSIGNAL(W, 17) 19 | -------------------------------------------------------------------------------- /code/source/ui/nodes/signalvalue_ui_factory.cpp: -------------------------------------------------------------------------------- 1 | #include "signalvalue_ui_factory.hpp" 2 | 3 | namespace clover { 4 | namespace ui { namespace nodes { 5 | 6 | BaseSignalValueUi* SignalValueUiFactory::create(SignalType S){ 7 | switch(S){ 8 | #define SIGNAL(x, n) case SignalType::x: return new SignalValueUi; 9 | #include "nodes/signaltypes.def" 10 | #undef SIGNAL 11 | default:; 12 | } 13 | 14 | throw global::Exception("Invalid SignalType: %i", S); 15 | } 16 | 17 | }} // ui::nodes 18 | } // clover -------------------------------------------------------------------------------- /code/source/physics/friction.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_PHYSICS_FRICTION_HPP 2 | #define CLOVER_PHYSICS_FRICTION_HPP 3 | 4 | #include "build.hpp" 5 | 6 | namespace clover { 7 | namespace physics { 8 | 9 | class Object; 10 | 11 | /// Applies forces to bodies which drive them towards configuration 12 | /// in which they move like a single rigid body 13 | void applyFriction( Object& a, Object& b, 14 | real64 friction_mul, real64 dt); 15 | 16 | } // physics 17 | } // clover 18 | 19 | #endif // CLOVER_PHYSICS_FRICTION_HPP 20 | -------------------------------------------------------------------------------- /code/source/nodes/nodeevent_mgr.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_NODES_NODEEVENT_MGR_HPP 2 | #define CLOVER_NODES_NODEEVENT_MGR_HPP 3 | 4 | #include "build.hpp" 5 | #include "nodeevent.hpp" 6 | 7 | namespace clover { 8 | namespace nodes { 9 | 10 | class NodeEventMgr { 11 | public: 12 | 13 | void queue(NodeEvent& e); 14 | void dispatch(); 15 | 16 | private: 17 | util::DynArray events; 18 | }; 19 | 20 | extern NodeEventMgr* gNodeEventMgr; 21 | 22 | } // nodes 23 | } // clover 24 | 25 | #endif // CLOVER_NODES_NODEEVENT_MGR_HPP -------------------------------------------------------------------------------- /code/source/game/ingamelogic.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_GAME_INGAMELOGIC_HPP 2 | #define CLOVER_GAME_INGAMELOGIC_HPP 3 | 4 | #include "build.hpp" 5 | #include "game/world_mgr.hpp" 6 | 7 | namespace clover { 8 | namespace game { 9 | 10 | class InGameLogic { 11 | public: 12 | InGameLogic(); 13 | virtual ~InGameLogic(); 14 | 15 | void update(); 16 | void onQuit(); 17 | 18 | private: 19 | int32 temp; 20 | 21 | game::WorldMgr worldLogic; 22 | }; 23 | 24 | } // game 25 | } // clover 26 | 27 | #endif // CLOVER_GAME_INGAMELOGIC_HPP 28 | -------------------------------------------------------------------------------- /code/source/visual/subcache_mesh.cpp: -------------------------------------------------------------------------------- 1 | #include "subcache_mesh.hpp" 2 | 3 | namespace clover { 4 | namespace resources { 5 | 6 | MeshSubCache::~MeshSubCache(){ 7 | } 8 | 9 | void MeshSubCache::preLoad(){ 10 | SubCache::preLoad(); 11 | staticMesh.flush(); 12 | } 13 | 14 | MeshSubCache::MeshType& MeshSubCache::createNewResource(const util::Str8& key){ 15 | MeshType& mesh= SubCache::createNewResource(key); 16 | staticMesh.addSubMesh(mesh); 17 | return mesh; 18 | } 19 | 20 | } // resource 21 | } // clover -------------------------------------------------------------------------------- /code/source/hardware/dll.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_HARDWARE_DLL_HPP 2 | #define CLOVER_HARDWARE_DLL_HPP 3 | 4 | #include "build.hpp" 5 | 6 | namespace clover { 7 | namespace hardware { 8 | 9 | using DllHandle= void*; 10 | const DllHandle mainProgramHandle= nullptr; 11 | 12 | DllHandle loadDll(const char* path); 13 | void unloadDll(DllHandle dll); 14 | void* queryDllSym(DllHandle dll, const char* sym); 15 | const char* dllError(); 16 | const char* dllExt(); 17 | 18 | } // hardware 19 | } // clover 20 | 21 | #endif // CLOVER_HARDWARE_DLL_HPP 22 | -------------------------------------------------------------------------------- /code/source/net/exception.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_NET_EXCEPTIONS_HPP 2 | #define CLOVER_NET_EXCEPTIONS_HPP 3 | 4 | #include "build.hpp" 5 | #include "global/exception.hpp" 6 | 7 | namespace clover { 8 | namespace net { 9 | 10 | class NetException : public global::Exception { 11 | public: 12 | NetException(const char8* s, ...); 13 | virtual ~NetException() throw() {} 14 | 15 | protected: 16 | NetException(){} 17 | using global::Exception::constructor; 18 | }; 19 | 20 | } // net 21 | } // clover 22 | 23 | #endif // CLOVER_NET_EXCEPTIONS_HPP -------------------------------------------------------------------------------- /code/source/nodes/native_instances/nodeinstance_error.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_NODES_NODEINSTANCE_ERROR_HPP 2 | #define CLOVER_NODES_NODEINSTANCE_ERROR_HPP 3 | 4 | #include "build.hpp" 5 | #include "nodeinstance.hpp" 6 | 7 | namespace clover { 8 | namespace nodes { 9 | 10 | /// Used when NodeInstanceType has invalid NodeInstanceTypeImpl 11 | class ErrorNodeInstance : public NodeInstanceImpl { 12 | public: 13 | virtual ~ErrorNodeInstance(){} 14 | }; 15 | 16 | } // nodes 17 | } // clover 18 | 19 | #endif // CLOVER_NODES_NODEINSTANCE_ERROR_HPP -------------------------------------------------------------------------------- /code/source/audio/audiodevice.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_AUDIO_AUDIODEVICE_HPP 2 | #define CLOVER_AUDIO_AUDIODEVICE_HPP 3 | 4 | #include "build.hpp" 5 | 6 | namespace clover { 7 | namespace audio { 8 | 9 | class OutputStream; 10 | 11 | /// Outputs audio data from OutputStream 12 | class AudioDevice { 13 | public: 14 | AudioDevice(); 15 | virtual ~AudioDevice(); 16 | 17 | virtual OutputStream& getOutputStream()= 0; 18 | }; 19 | 20 | extern AudioDevice* gAudioDevice; 21 | 22 | } // audio 23 | } // clover 24 | 25 | #endif // CLOVER_AUDIO_AUDIODEVICE_HPP -------------------------------------------------------------------------------- /code/source/game/editor/editorextension_mgr.cpp: -------------------------------------------------------------------------------- 1 | #include "editorextension_mgr.hpp" 2 | #include "extensions/ee_blender.hpp" 3 | #include "global/cfg_mgr.hpp" 4 | 5 | namespace clover { 6 | namespace game { namespace editor { 7 | 8 | EditorExtensionMgr::EditorExtensionMgr(){ 9 | if (global::g_env.cfg->get("dev::enableEditorExtensions", false)) 10 | createExtension(); 11 | } 12 | 13 | void EditorExtensionMgr::update(){ 14 | for (auto& m : extensions){ 15 | m->update(); 16 | } 17 | } 18 | 19 | }} // game::editor 20 | } // clover -------------------------------------------------------------------------------- /code/source/global/global.hpp: -------------------------------------------------------------------------------- 1 | #error Documentation only 2 | 3 | /// 'global' namespace should contain things that most subsystems need and which 4 | /// don't have better place to go. 5 | /// 6 | /// Pulling from other namespaces to 'global' namespace with 'using' 7 | /// directive is preferred: 8 | /// When there's temptation to add something to 'global' namespace, think hard 9 | /// if it is _strictly_ project specific and if it could be put in 'util' instead. 10 | /// 11 | /// If an utility class uses some global manager it probably is project specific. 12 | -------------------------------------------------------------------------------- /code/source/net/net.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_NET_NET_HPP 2 | #define CLOVER_NET_NET_HPP 3 | 4 | /// Common header for network stuff 5 | 6 | #include "build.hpp" 7 | #include "global/exception.hpp" 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | namespace clover { 14 | namespace net { 15 | 16 | using boost::asio::ip::tcp; // Usage: net::tcp::socket 17 | namespace asio= boost::asio; // Usage: net::asio::io_service 18 | 19 | } // net 20 | } // clover 21 | 22 | #endif // CLOVER_NET_NET_HPP -------------------------------------------------------------------------------- /code/source/main.cpp: -------------------------------------------------------------------------------- 1 | #include "app.hpp" 2 | #include "build.hpp" 3 | #include "hardware/memory.hpp" 4 | #include "util/crashhandler.hpp" 5 | #include "util/profiler.hpp" 6 | 7 | #include 8 | 9 | int main(int, char *argv[]) 10 | { 11 | clover::hardware::createHeap(); 12 | clover::util::CrashHandler crashHandler; 13 | clover::util::tryEnableProfiling(); 14 | 15 | try { 16 | clover::App app(argv[0]); 17 | app.run(); 18 | } 19 | catch (const std::exception& e){ 20 | crashHandler.onUnhandledException(e); 21 | } 22 | 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /code/source/physics/ghostlydynamics.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_PHYSICS_GHOSTLYDYNAMICS_HPP 2 | #define CLOVER_PHYSICS_GHOSTLYDYNAMICS_HPP 3 | 4 | #include "build.hpp" 5 | #include "contact.hpp" 6 | #include "util/dyn_array.hpp" 7 | 8 | namespace clover { 9 | namespace physics { 10 | 11 | bool isGhostlyContact(const Contact& c); 12 | PostSolveContact onGhostlyContact(const Contact& c); 13 | void processGhostlyInteractions(const util::DynArray& contacts, real64 dt); 14 | 15 | } // physics 16 | } // clover 17 | 18 | #endif // CLOVER_PHYSICS_GHOSTLYDYNAMICS_HPP 19 | -------------------------------------------------------------------------------- /code/source/ui/hid/control.cpp: -------------------------------------------------------------------------------- 1 | #include "control.hpp" 2 | #include "device.hpp" 3 | 4 | namespace clover { 5 | namespace ui { namespace hid { 6 | 7 | void Control::addChannel(const ContextChannelName& channel_name){ 8 | additionalChannelNames.pushBack(channel_name); 9 | } 10 | 11 | Control::ContextChannelNames Control::getChannelNames() const { 12 | if (device) 13 | return util::duplicatesRemoved(device->getChannelNames().appended(additionalChannelNames)); 14 | else 15 | return additionalChannelNames; 16 | } 17 | 18 | }} // ui::hid 19 | } // clover 20 | -------------------------------------------------------------------------------- /code/source/util/referencecountable.cpp: -------------------------------------------------------------------------------- 1 | #include "referencecountable.hpp" 2 | #include "util/ensure.hpp" 3 | 4 | namespace clover { 5 | namespace util { 6 | 7 | ReferenceCountable::ReferenceCountable(): 8 | refCount(0){ 9 | } 10 | 11 | ReferenceCountable::~ReferenceCountable(){ 12 | ensure(refCount == 0); 13 | } 14 | 15 | void ReferenceCountable::incrementReferenceCount() const { 16 | ++refCount; 17 | } 18 | 19 | void ReferenceCountable::decrementReferenceCount() const { 20 | --refCount; 21 | ensure(refCount >= 0); 22 | } 23 | 24 | } // util 25 | } // clover -------------------------------------------------------------------------------- /code/source/nodes/nodeeventreceiverproxy.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_NODES_NODEEVENTRECEIVERPROXY_HPP 2 | #define CLOVER_NODES_NODEEVENTRECEIVERPROXY_HPP 3 | 4 | #include "build.hpp" 5 | 6 | namespace clover { 7 | namespace nodes { 8 | 9 | class NodeEvent; 10 | 11 | class NodeEventReceiverProxy { 12 | public: 13 | virtual ~NodeEventReceiverProxy(){} 14 | 15 | virtual void onEvent(const NodeEvent&)= 0; 16 | virtual NodeEventReceiverProxy* clone()= 0; 17 | private: 18 | }; 19 | 20 | } // nodes 21 | } // clover 22 | 23 | #endif // GAMELOGIC_FOUNDATIONS_NODES_NODEEVENTRECEIVERPROXY_HPP -------------------------------------------------------------------------------- /code/source/nodes/signaltype.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_NODES_SIGNALTYPE_HPP 2 | #define CLOVER_NODES_SIGNALTYPE_HPP 3 | 4 | #include "build.hpp" 5 | 6 | namespace clover { 7 | namespace nodes { 8 | 9 | enum class SignalType : int32 { 10 | None = -1, 11 | #define SIGNAL(x, n) x = n, 12 | #include "signaltypes.def" 13 | #undef SIGNAL 14 | }; 15 | 16 | enum class SubSignalType { 17 | None = -1, 18 | #define SUBSIGNAL(x, n) x = n, 19 | #include "subsignaltypes.def" 20 | #undef SUBSIGNAL 21 | }; 22 | 23 | } // nodes 24 | } // clover 25 | 26 | #endif // CLOVER_NODES_SIGNALTYPE_HPP -------------------------------------------------------------------------------- /code/source/gui/element_panel.cpp: -------------------------------------------------------------------------------- 1 | #include "element_panel.hpp" 2 | 3 | namespace clover { 4 | namespace gui { 5 | 6 | PanelElement::PanelElement(const util::Coord& offset, const util::Coord& rad): 7 | Element(offset, rad), 8 | visual(createVisualEntity(ElementVisualEntity::Type::Panel)){ 9 | elementType= Panel; 10 | } 11 | 12 | PanelElement::~PanelElement(){ 13 | } 14 | 15 | void PanelElement::spatialUpdate(){ 16 | Element::spatialUpdate(); 17 | 18 | visual->setPositionTarget(position); 19 | visual->setRadiusTarget(radius); 20 | } 21 | 22 | } // gui 23 | } // clover -------------------------------------------------------------------------------- /code/source/game/worldaudio_env.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_GAME_WORLDAUDIO_ENV_HPP 2 | #define CLOVER_GAME_WORLDAUDIO_ENV_HPP 3 | 4 | #include "build.hpp" 5 | #include "audio/soundinstancehandle.hpp" 6 | 7 | namespace clover { 8 | namespace game { 9 | 10 | class WorldAudioEnv { 11 | public: 12 | WorldAudioEnv(); 13 | virtual ~WorldAudioEnv(); 14 | 15 | void setAmbientTrack(const util::Str8& resource_name); 16 | 17 | private: 18 | void onAmbientEnd(const audio::SoundInstanceHandle& h) const; 19 | }; 20 | 21 | } // game 22 | } // clover 23 | 24 | #endif // CLOVER_GAME_WORLDAUDIO_ENV_HPP -------------------------------------------------------------------------------- /code/source/hardware/hid_devicefactory.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_HARDWARE_HID_DEVICE_FACTORY_HPP 2 | #define CLOVER_HARDWARE_HID_DEVICE_FACTORY_HPP 3 | 4 | #include "build.hpp" 5 | #include "ui/hid/device.hpp" 6 | 7 | namespace clover { 8 | namespace hardware { 9 | 10 | class HidDeviceFactory { 11 | public: 12 | using Device= ui::hid::Device; 13 | 14 | static Device::Ptr createDevice(const Device::ConstructInfo& info); 15 | static bool isDeviceTypeName(const Device::Name& type_name); 16 | }; 17 | 18 | } // hardware 19 | } // clover 20 | 21 | #endif // CLOVER_HARDWARE_HID_DEVICE_FACTORY_HPP -------------------------------------------------------------------------------- /code/source/util/fh_save.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_UTIL_FH_SAVE_HPP 2 | #define CLOVER_UTIL_FH_SAVE_HPP 3 | 4 | #include "build.hpp" 5 | #include "fieldholder.hpp" 6 | 7 | namespace clover { 8 | namespace util { 9 | 10 | /// @todo Get rid of this abomination 11 | class SaveFieldHolder : public FieldHolder { 12 | public: 13 | // Serialize 14 | const SaveFieldHolder& operator>>(util::RawPack& pack) const; 15 | 16 | // Deserialize 17 | SaveFieldHolder& operator<<(util::RawPack& pack); 18 | 19 | protected: 20 | }; 21 | 22 | } // util 23 | } // clover 24 | 25 | #endif // CLOVER_UTIL_FH_SAVE_HPP -------------------------------------------------------------------------------- /code/source/physics/joint_friction.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_PHYSICS_JOINT_FRICTION_HPP 2 | #define CLOVER_PHYSICS_JOINT_FRICTION_HPP 3 | 4 | #include "build.hpp" 5 | #include "b2_joint.hpp" 6 | 7 | namespace clover { 8 | namespace physics { 9 | 10 | class Object; 11 | 12 | /// Unused 13 | class ENGINE_API FrictionJoint : public B2Joint { 14 | public: 15 | void attach(Object& a, Object& b); 16 | 17 | void setMaxForce(real64 f); 18 | void setMaxTorque(real64 t); 19 | }; 20 | 21 | } // physics 22 | } // clover 23 | 24 | #endif // CLOVER_PHYSICS_JOINT_FRICTION_HPP 25 | -------------------------------------------------------------------------------- /code/source/resources/exception.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_RESOURCES_EXCEPTIONS_HPP 2 | #define CLOVER_RESOURCES_EXCEPTIONS_HPP 3 | 4 | #include "build.hpp" 5 | #include "global/exception.hpp" 6 | 7 | namespace clover { 8 | namespace resources { 9 | 10 | class ENGINE_API ResourceException : public global::Exception { 11 | public: 12 | ResourceException(const char8* s, ...); 13 | virtual ~ResourceException() throw(); 14 | 15 | protected: 16 | ResourceException(); 17 | using global::Exception::constructor; 18 | }; 19 | 20 | } // resources 21 | } // clover 22 | 23 | #endif // CLOVER_RESOURCES_EXCEPTIONS_HPP -------------------------------------------------------------------------------- /code/source/game/editor/editor.cpp: -------------------------------------------------------------------------------- 1 | #include "editor.hpp" 2 | #include "global/event.hpp" 3 | 4 | namespace clover { 5 | namespace game { namespace editor { 6 | 7 | Editor::Editor(){ 8 | global::Event e(global::Event::OnEditorCreate); 9 | e(global::Event::Object)= this; 10 | e.send(); 11 | 12 | views.resize(viewCount); 13 | } 14 | 15 | Editor::~Editor(){ 16 | views.clear(); 17 | 18 | global::Event e(global::Event::OnEditorDestroy); 19 | e(global::Event::Object)= this; 20 | e.send(); 21 | } 22 | 23 | void Editor::update(){ 24 | extensionMgr.update(); 25 | } 26 | 27 | }} // game::editor 28 | } // clover -------------------------------------------------------------------------------- /code/source/physics/jointtype.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_PHYSICS_JOINTTYPE_HPP 2 | #define CLOVER_PHYSICS_JOINTTYPE_HPP 3 | 4 | #include "build.hpp" 5 | #include "util/str8.hpp" 6 | 7 | namespace clover { 8 | namespace physics { 9 | 10 | enum class JointType { 11 | #define JOINT_TYPE(x) x, 12 | #include "jointtypes.def" 13 | #undef JOINT_TYPE 14 | Last 15 | }; 16 | 17 | struct RuntimeJointTypeTraits { 18 | static util::Str8 enumString(JointType t); 19 | static JointType jointTypeByString(const util::Str8& name); 20 | }; 21 | 22 | } // physics 23 | } // clover 24 | 25 | #endif // CLOVER_PHYSICS_JOINTTYPE_HPP 26 | -------------------------------------------------------------------------------- /code/source/util/class_preproc.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_UTIL_CLASS_PREPROC_HPP 2 | #define CLOVER_UTIL_CLASS_PREPROC_HPP 3 | 4 | #define DEFAULT_COPY(Class)\ 5 | Class(const Class&)= default;\ 6 | Class& operator=(const Class&)= default 7 | 8 | #define DELETE_COPY(Class)\ 9 | Class(const Class&)= delete;\ 10 | Class& operator=(const Class&)= delete 11 | 12 | #define DEFAULT_MOVE(Class)\ 13 | Class(Class&&)= default;\ 14 | Class& operator=(Class&&)= default 15 | 16 | #define DELETE_MOVE(Class)\ 17 | Class(Class&&)= delete;\ 18 | Class& operator=(Class&&)= delete 19 | 20 | #endif // CLOVER_UTIL_CLASS_PREPROC_HPP 21 | -------------------------------------------------------------------------------- /code/source/util/thread.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_UTIL_THREAD_HPP 2 | #define CLOVER_UTIL_THREAD_HPP 3 | 4 | #include "build.hpp" 5 | 6 | #include 7 | 8 | namespace clover { 9 | namespace util { 10 | 11 | using Thread= std::thread; 12 | 13 | enum class ThreadPriority { 14 | Idle, 15 | Low, 16 | Normal, 17 | High, 18 | Critical 19 | }; 20 | 21 | /// Sets priority of calling thread 22 | void setThreadPriority(ThreadPriority p); 23 | 24 | /// Sets priority of thread t 25 | void setThreadPriority(Thread& t, ThreadPriority p); 26 | 27 | } // util 28 | } // clover 29 | 30 | #endif // CLOVER_UTIL_THREAD_HPP 31 | -------------------------------------------------------------------------------- /code/source/visual/shadertech_shadowcaster.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_VISUAL_SHADERTECH_SHADOWCASTER_HPP 2 | #define CLOVER_VISUAL_SHADERTECH_SHADOWCASTER_HPP 3 | 4 | #include "build.hpp" 5 | #include "shadertech.hpp" 6 | 7 | namespace clover { 8 | namespace visual { 9 | 10 | class LightEntityLogic; 11 | class ShadowCasterST : public WorldShaderTech { 12 | public: 13 | void setLight(const LightEntityLogic& l); 14 | void setEntity(const visual::ModelEntityDef& re); 15 | 16 | void use(); 17 | private: 18 | uint32 texture; 19 | }; 20 | 21 | } // visual 22 | } // clover 23 | 24 | #endif // CLOVER_VISUAL_SHADERTECH_SHADOWCASTER_HPP 25 | -------------------------------------------------------------------------------- /code/source/collision/ray.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_COLLISION_RAY_HPP 2 | #define CLOVER_COLLISION_RAY_HPP 3 | 4 | #include "build.hpp" 5 | #include "util/vector.hpp" 6 | 7 | namespace clover { 8 | namespace collision { 9 | 10 | struct Ray { 11 | Ray(const util::Vec2d& start_pos, const util::Vec2d& end_offset): 12 | start(start_pos), endOffset(end_offset){} 13 | 14 | util::Vec2d start; 15 | util::Vec2d endOffset; 16 | }; 17 | 18 | struct RayCastResult { 19 | RayCastResult():fraction(-1){} 20 | 21 | util::Vec2d normal; 22 | real64 fraction; 23 | }; 24 | 25 | } // collision 26 | } // clover 27 | 28 | #endif // CLOVER_COLLISION_RAY_HPP -------------------------------------------------------------------------------- /code/source/util/set.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_UTIL_SET_HPP 2 | #define CLOVER_UTIL_SET_HPP 3 | 4 | #include "build.hpp" 5 | #include "hash.hpp" 6 | #include 7 | 8 | namespace clover { 9 | namespace util { 10 | 11 | template class Ator= std::allocator> 12 | using Set= std::set, Ator>; 13 | 14 | template 15 | struct Hash32> { 16 | uint32 operator()(const Set& value) const 17 | { 18 | uint32 h= 0; 19 | for (auto&& m : value) 20 | h += hash32(m); 21 | return h; 22 | } 23 | }; 24 | 25 | } // util 26 | } // clover 27 | 28 | #endif // CLOVER_UTIL_SET_HPP 29 | -------------------------------------------------------------------------------- /code/source/util/mem_chunk.cpp: -------------------------------------------------------------------------------- 1 | #include "mem_chunk.hpp" 2 | #include "ensure.hpp" 3 | 4 | namespace clover { 5 | namespace util { 6 | 7 | MemChunk::MemChunk(SizeType size, const char* tag) 8 | : memory(new uint8[size]) 9 | , sizeBytes(size) 10 | , acquired(false) 11 | , tag(tag) 12 | { } 13 | 14 | MemChunk::~MemChunk() 15 | { 16 | ensure(!acquired); 17 | delete [] memory.get(); 18 | } 19 | 20 | void MemChunk::acquire() 21 | { 22 | ensure(!acquired); 23 | ensure(memory); 24 | acquired= true; 25 | } 26 | 27 | void MemChunk::release() 28 | { 29 | ensure(acquired); 30 | acquired= false; 31 | } 32 | 33 | } // util 34 | } // clover 35 | -------------------------------------------------------------------------------- /code/source/global/eventqueue.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_GLOBAL_EVENTQUEUE_HPP 2 | #define CLOVER_GLOBAL_EVENTQUEUE_HPP 3 | 4 | #include "event.hpp" 5 | 6 | namespace clover { 7 | namespace global { 8 | 9 | /// @todo Remove this worthless class 10 | class EventQueue { 11 | public: 12 | /// Sends last and removes from queue 13 | bool sendLast(); 14 | 15 | global::Event& getLast(); 16 | void popLast(); 17 | 18 | int32 size(); 19 | 20 | /// Called by Event 21 | void queue(global::Event e); 22 | 23 | private: 24 | util::DynArray events; 25 | }; 26 | 27 | } // global 28 | } // clover 29 | 30 | #endif // CLOVER_GLOBAL_EVENTQUEUE_HPP 31 | -------------------------------------------------------------------------------- /code/source/gui/attributefieldelementfactory.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_GUI_ATTRIBUTEFIELDFACTORY_HPP 2 | #define CLOVER_GUI_ATTRIBUTEFIELDFACTORY_HPP 3 | 4 | #include "build.hpp" 5 | #include "resources/attribute_def.hpp" 6 | #include "element_attributefield.hpp" 7 | 8 | namespace clover { 9 | namespace gui { 10 | 11 | /// Creates AttributeFieldElements 12 | class AttributeFieldElementFactory { 13 | public: 14 | /// Dynamically allocated, store in smart pointer 15 | static BaseAttributeFieldElement* create(const resources::AttributeDef& def); 16 | 17 | private: 18 | }; 19 | 20 | } // gui 21 | } // clover 22 | 23 | #endif // CLOVER_GUI_ATTRIBUTEFIELDFACTORY_HPP -------------------------------------------------------------------------------- /code/source/mod/node_player_mgr.cpp: -------------------------------------------------------------------------------- 1 | #include "node_player_mgr.hpp" 2 | 3 | namespace clover { 4 | namespace mod { 5 | 6 | DEFINE_NODE(PlayerMgrNode) 7 | 8 | CompositionNodeLogic* PlayerMgrNode::compNode() 9 | { return new CompositionNodeLogic{}; } 10 | 11 | void PlayerMgrNode::create() 12 | { 13 | setUpdateNeeded(false); 14 | 15 | const int32 maxPlayerCount= 4; 16 | // Make every player character controllable 17 | for (int32 i= 0; i < maxPlayerCount; ++i) { 18 | util::Str8 player_name= util::Str8::format("player%i", i); 19 | tagEntries.pushBack(ui::hid::TagListEntry(player_name, "charCtrl")); 20 | } 21 | } 22 | 23 | } // mod 24 | } // clover 25 | -------------------------------------------------------------------------------- /code/source/collision/box2d.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_COLLISION_BOX2D_HPP 2 | #define CLOVER_COLLISION_BOX2D_HPP 3 | 4 | #include "util/vector.hpp" 5 | #include "util/transform.hpp" 6 | 7 | #include 8 | 9 | namespace clover { 10 | namespace collision { 11 | 12 | inline 13 | b2Vec2 toB2(util::Vec2d v){ return b2Vec2{v.x, v.y}; } 14 | 15 | inline 16 | util::Vec2d fromB2(b2Vec2 v){ return util::Vec2d{v.x, v.y}; } 17 | 18 | inline 19 | b2Transform toB2(util::RtTransform t) 20 | { return b2Transform{toB2(t.translation), b2Rot{t.rotation}}; } 21 | 22 | } // collision 23 | } // clover 24 | 25 | #endif // CLOVER_COLLISION_BOX2D_HPP 26 | -------------------------------------------------------------------------------- /code/source/visual/entitylogic_particlesource.cpp: -------------------------------------------------------------------------------- 1 | #include "entitylogic_particlesource.hpp" 2 | #include "global/event.hpp" 3 | 4 | namespace clover { 5 | namespace visual { 6 | 7 | ParticleSourceEntityLogic::ParticleSourceEntityLogic(const EntityDef& def) 8 | : EntityLogic(def){ 9 | } 10 | 11 | ParticleSourceEntityLogic::~ParticleSourceEntityLogic(){ 12 | } 13 | 14 | void ParticleSourceEntityLogic::update(){ 15 | } 16 | 17 | util::DynArray ParticleSourceEntityLogic::popSpawnData(){ 18 | util::DynArray ret= std::move(spawnData); 19 | spawnData.clear(); 20 | return (ret); 21 | } 22 | 23 | } // visual 24 | } // clover -------------------------------------------------------------------------------- /code/source/global/memory.cpp: -------------------------------------------------------------------------------- 1 | #include "memory.hpp" 2 | #include "util/mem_chunk.hpp" 3 | #include "util/unique_ptr.hpp" 4 | 5 | namespace clover { 6 | namespace global { 7 | 8 | static util::UniquePtr g_singleFrameMemChunk; 9 | 10 | void createMemoryPools(SizeType single_frame_mem_size){ 11 | g_singleFrameMemChunk= 12 | util::makeUniquePtr(single_frame_mem_size, "singleFrameMem"); 13 | SingleFrameStorage::value.setMemory(g_singleFrameMemChunk.get()); 14 | } 15 | 16 | void destroyMemoryPools(){ 17 | SingleFrameStorage::value.setMemory(nullptr); 18 | g_singleFrameMemChunk.reset(); 19 | } 20 | 21 | } // global 22 | } // clover 23 | -------------------------------------------------------------------------------- /code/source/gui/callback.tpp: -------------------------------------------------------------------------------- 1 | template 2 | Callback::Callback(): 3 | owner(0){ 4 | } 5 | 6 | template 7 | void Callback::assign(const CallbackFunction& f){ 8 | callback= f; 9 | } 10 | 11 | template 12 | void Callback::trigger(ElementType& element){ 13 | owner= &element; 14 | 15 | if (!callback) return; 16 | 17 | // Maybe direct call would be sufficient.. 18 | global::Event e(global::Event::OnGuiCallbackTrigger); 19 | e(global::Event::Object)= this; 20 | e.send(); 21 | } 22 | 23 | template 24 | void Callback::call(){ 25 | ensure(owner); 26 | ensure(callback); 27 | 28 | callback(*owner); 29 | } -------------------------------------------------------------------------------- /code/source/physics/joint_rope.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_PHYSICS_JOINT_ROPE_HPP 2 | #define CLOVER_PHYSICS_JOINT_ROPE_HPP 3 | 4 | #include "build.hpp" 5 | #include "b2_joint.hpp" 6 | 7 | namespace clover { 8 | namespace physics { 9 | 10 | class ENGINE_API RopeJoint : public B2Joint 11 | , public JointTypeCrtp { 12 | public: 13 | void attach(Object& a, Object& b, 14 | const WorldVec& anchor_a, const WorldVec& anchor_b); 15 | 16 | /// Sets the maximum distance between anchors 17 | void setLength(real64 d); 18 | }; 19 | 20 | } // physics 21 | } // clover 22 | 23 | #endif // CLOVER_PHYSICS_JOINT_ROPE_HPP 24 | -------------------------------------------------------------------------------- /code/source/util/mutex.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_UTIL_MUTEX_HPP 2 | #define CLOVER_UTIL_MUTEX_HPP 3 | 4 | #include "build.hpp" 5 | 6 | #include 7 | #include 8 | 9 | namespace clover { 10 | namespace util { 11 | 12 | using Mutex= std::mutex; 13 | using RecursiveMutex= std::recursive_mutex; 14 | 15 | template 16 | using LockGuard= std::lock_guard; 17 | 18 | template 19 | class InverseLockGuard { 20 | public: 21 | InverseLockGuard(T& mtx): mutex(mtx){ mutex.unlock(); } 22 | ~InverseLockGuard(){ mutex.lock(); } 23 | 24 | private: 25 | T& mutex; 26 | }; 27 | 28 | } // util 29 | } // clover 30 | 31 | #endif // CLOVER_UTIL_MUTEX_HPP -------------------------------------------------------------------------------- /code/source/global/file_stream.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_GLOBAL_FILE_STREAM_HPP 2 | #define CLOVER_GLOBAL_FILE_STREAM_HPP 3 | 4 | #include "build.hpp" 5 | #include "util/dyn_array.hpp" 6 | #include "util/unique_ptr.hpp" 7 | 8 | #include 9 | 10 | namespace clover { 11 | namespace global { 12 | 13 | class File; 14 | 15 | /// std::istream API for File 16 | /// @todo also implement ostream 17 | class FileStream : public std::istream { 18 | public: 19 | FileStream(File& file); 20 | ~FileStream(); 21 | 22 | private: 23 | class Buffer; 24 | util::UniquePtr buffer; 25 | }; 26 | 27 | } // global 28 | } // clover 29 | 30 | #endif // CLOVER_GLOBAL_FILE_STREAM_HPP 31 | -------------------------------------------------------------------------------- /code/source/game/worldentity_pack.cpp: -------------------------------------------------------------------------------- 1 | #include "worldentity_pack.hpp" 2 | #include "util/misc.hpp" 3 | #include "global/exception.hpp" 4 | #include "debug/print.hpp" 5 | 6 | namespace clover { 7 | namespace game { 8 | 9 | WEPack::WEPack() 10 | : id(0){ 11 | } 12 | 13 | void WEPack::set(util::RawPack& data_){ 14 | data= data_; 15 | 16 | data.setReadMode(); 17 | data.seekg(0); 18 | } 19 | 20 | void WEPack::reset(uint64 id_){ 21 | id= id_; 22 | data.clear(); 23 | } 24 | 25 | util::RawPack& WEPack::getVarPack(){ 26 | return data; 27 | } 28 | 29 | void WEPack::prepareVarBlockReading(){ 30 | data.setReadMode(true); 31 | data.seekg(0); 32 | } 33 | 34 | } // game 35 | } // clover -------------------------------------------------------------------------------- /code/source/game/basegamelogic.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_BASEGAMELOGIC_HPP 2 | #define CLOVER_BASEGAMELOGIC_HPP 3 | 4 | #include "build.hpp" 5 | 6 | namespace clover { 7 | namespace game { 8 | 9 | class InGameLogic; 10 | class DevLogic; 11 | 12 | /// Top of the game logic 13 | class BaseGameLogic { 14 | public: 15 | BaseGameLogic(); 16 | virtual ~BaseGameLogic(); 17 | 18 | void update(); 19 | void onQuit(); 20 | 21 | InGameLogic* getInGameLogic(){ return inGameLogic; } 22 | DevLogic* getDevLogic(){ return devLogic; } 23 | 24 | private: 25 | InGameLogic* inGameLogic; 26 | DevLogic* devLogic; 27 | }; 28 | 29 | } // game 30 | } // clover 31 | 32 | #endif // CLOVER_BASEGAMELOGIC_HPP 33 | -------------------------------------------------------------------------------- /code/source/nodes/nodeeventreceiverproxy_we.cpp: -------------------------------------------------------------------------------- 1 | #include "nodeeventreceiverproxy_we.hpp" 2 | #include "game/worldentity.hpp" 3 | #include "game/worldentity_set.hpp" 4 | 5 | namespace clover { 6 | namespace nodes { 7 | 8 | WeNodeEventReceiverProxy::WeNodeEventReceiverProxy(const game::WeHandle& h) 9 | : handle(h){ 10 | 11 | } 12 | 13 | WeNodeEventReceiverProxy::~WeNodeEventReceiverProxy(){ 14 | 15 | } 16 | 17 | void WeNodeEventReceiverProxy::onEvent(const NodeEvent& e){ 18 | if (handle) 19 | handle->onEvent(e); 20 | } 21 | 22 | WeNodeEventReceiverProxy* WeNodeEventReceiverProxy::clone(){ 23 | return new WeNodeEventReceiverProxy(*this); 24 | } 25 | 26 | } // nodes 27 | } // clover -------------------------------------------------------------------------------- /code/source/visual/subcache_mesh.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_VISUAL_SUBCACHE_MESH_HPP 2 | #define CLOVER_VISUAL_SUBCACHE_MESH_HPP 3 | 4 | #include "build.hpp" 5 | #include "resources/subcache.hpp" 6 | #include "visual/mesh_impl.hpp" 7 | 8 | namespace clover { 9 | namespace resources { 10 | 11 | class MeshSubCache : public SubCache { 12 | public: 13 | typedef visual::TriMesh MeshType; 14 | 15 | virtual ~MeshSubCache(); 16 | virtual void preLoad(); 17 | 18 | protected: 19 | virtual MeshType& createNewResource(const util::Str8& key); 20 | 21 | private: 22 | MeshType staticMesh; 23 | }; 24 | 25 | } // resources 26 | } // clover 27 | 28 | #endif // CLOVER_VISUAL_SUBCACHE_MESH_HPP -------------------------------------------------------------------------------- /code/source/game/editor/editor.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_GAMELOGIC_EDITOR_EDITOR_HPP 2 | #define CLOVER_GAMELOGIC_EDITOR_EDITOR_HPP 3 | 4 | #include "build.hpp" 5 | #include "editorview.hpp" 6 | #include "editorextension_mgr.hpp" 7 | #include "util/dyn_array.hpp" 8 | 9 | namespace clover { 10 | namespace game { namespace editor { 11 | 12 | /// Editor logic 13 | class Editor { 14 | public: 15 | static constexpr int32 viewCount= 4; 16 | 17 | Editor(); 18 | virtual ~Editor(); 19 | 20 | void update(); 21 | 22 | private: 23 | util::DynArray views; 24 | EditorExtensionMgr extensionMgr; 25 | }; 26 | 27 | }} // game::editor 28 | } // clover 29 | 30 | #endif // CLOVER_GAMELOGIC_EDITOR_EDITOR_HPP -------------------------------------------------------------------------------- /code/source/game/physics.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_GAME_PHYSICS_HPP 2 | #define CLOVER_GAME_PHYSICS_HPP 3 | 4 | #include "build.hpp" 5 | 6 | namespace clover { 7 | namespace physics { 8 | 9 | class Entity; 10 | class Object; 11 | 12 | } // physics 13 | namespace game { 14 | 15 | class WorldEntity; 16 | 17 | ENGINE_API void setOwnerWe(physics::Object& phys_obj, WorldEntity* entity); 18 | ENGINE_API void setOwnerWe(physics::Entity& phys_entity, WorldEntity* entity); 19 | 20 | ENGINE_API WorldEntity* getOwnerWe(const physics::Object& phys_obj); 21 | ENGINE_API WorldEntity* getOwnerWe(const physics::Entity& phys_entity); 22 | 23 | } // game 24 | } // clover 25 | 26 | #endif // CLOVER_GAME_PHYSICS_HPP 27 | -------------------------------------------------------------------------------- /code/source/util/scopefinalizer.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_UTIL_SCOPEFINALIZER_HPP 2 | #define CLOVER_UTIL_SCOPEFINALIZER_HPP 3 | 4 | #include "build.hpp" 5 | #include "util/class_preproc.hpp" 6 | 7 | #include 8 | 9 | namespace clover { 10 | namespace util { 11 | 12 | class ScopeFinalizer { 13 | public: 14 | using Callback= std::function; 15 | 16 | ScopeFinalizer(Callback cb) 17 | : callback(cb){} 18 | DELETE_COPY(ScopeFinalizer); 19 | DEFAULT_MOVE(ScopeFinalizer); 20 | ~ScopeFinalizer(){ 21 | if (callback) 22 | callback(); 23 | } 24 | 25 | private: 26 | Callback callback; 27 | }; 28 | 29 | } // util 30 | } // clover 31 | 32 | #endif // CLOVER_UTIL_SCOPEFINALIZER_HPP -------------------------------------------------------------------------------- /code/source/game/editor/components/ec_performance.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVE_GAME_EDITOR_EC_PERFORMANCE_HPP 2 | #define CLOVE_GAME_EDITOR_EC_PERFORMANCE_HPP 3 | 4 | #include "../editorcomponent.hpp" 5 | #include "build.hpp" 6 | 7 | namespace clover { 8 | namespace game { namespace editor { 9 | 10 | class PerformanceEc; 11 | 12 | template <> 13 | struct EditorComponentTraits { 14 | static const util::Str8 name(){ return "Performance"; } 15 | }; 16 | 17 | class PerformanceEc : public EditorComponent { 18 | public: 19 | DECLARE_EDITORCOMPONENT(PerformanceEc); 20 | virtual ~PerformanceEc(){} 21 | }; 22 | 23 | }} // game::editor 24 | } // clover 25 | 26 | #endif // CLOVE_GAME_EDITOR_EC_PERFORMANCE_HPP -------------------------------------------------------------------------------- /code/source/util/base_cb_listener.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_UTIL_BASE_CB_LISTENER_HPP 2 | #define CLOVER_UTIL_BASE_CB_LISTENER_HPP 3 | 4 | #include "build.hpp" 5 | 6 | namespace clover { 7 | namespace util { 8 | 9 | class BaseCallbacker; 10 | class BaseCbListener { 11 | public: 12 | 13 | virtual ~BaseCbListener(){} 14 | 15 | /// Stops listening 16 | virtual void clear() = 0; 17 | 18 | protected: 19 | friend class BaseCallbacker; 20 | 21 | template 22 | friend class SingleCallbacker; 23 | 24 | /// BaseCallbacker calls when moved 25 | virtual void setCallbacker(const BaseCallbacker& c) = 0; 26 | }; 27 | 28 | } // util 29 | } // clover 30 | 31 | #endif // CLOVER_UTIL_BASE_CB_LISTENER_HPP -------------------------------------------------------------------------------- /code/source/game/worldquery.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_GAME_WORLDQUERY_HPP 2 | #define CLOVER_GAME_WORLDQUERY_HPP 3 | 4 | #include "build.hpp" 5 | #include "util/time.hpp" 6 | #include "worldentity.hpp" 7 | 8 | namespace clover { 9 | namespace game { 10 | 11 | class WESet; 12 | class WeHandle; 13 | 14 | /// @todo This shouldn't be a class 15 | class WorldQuery { 16 | public: 17 | WorldQuery(); 18 | 19 | game::WESet getEntitiesInRadius(util::Vec2d pos, real32 radius, const util::Str8& type_name= ""); 20 | game::WeHandle getEntityById(game::WorldEntityId id); 21 | game::WorldEntity* getEntityPtrById(game::WorldEntityId id); 22 | }; 23 | 24 | } // game 25 | } // clover 26 | 27 | #endif // CLOVER_GAME_WORLDQUERY_HPP 28 | -------------------------------------------------------------------------------- /code/deps/common/libogg-1.3.2/include/ogg/config_types.h.in: -------------------------------------------------------------------------------- 1 | #ifndef __CONFIG_TYPES_H__ 2 | #define __CONFIG_TYPES_H__ 3 | 4 | /* these are filled in by configure */ 5 | #define INCLUDE_INTTYPES_H @INCLUDE_INTTYPES_H@ 6 | #define INCLUDE_STDINT_H @INCLUDE_STDINT_H@ 7 | #define INCLUDE_SYS_TYPES_H @INCLUDE_SYS_TYPES_H@ 8 | 9 | #if INCLUDE_INTTYPES_H 10 | # include 11 | #endif 12 | #if INCLUDE_STDINT_H 13 | # include 14 | #endif 15 | #if INCLUDE_SYS_TYPES_H 16 | # include 17 | #endif 18 | 19 | typedef @SIZE16@ ogg_int16_t; 20 | typedef @USIZE16@ ogg_uint16_t; 21 | typedef @SIZE32@ ogg_int32_t; 22 | typedef @USIZE32@ ogg_uint32_t; 23 | typedef @SIZE64@ ogg_int64_t; 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /code/source/util/uniform_uv.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_UTIL_UNIFORM_UV_HPP 2 | #define CLOVER_UTIL_UNIFORM_UV_HPP 3 | 4 | #include "build.hpp" 5 | #include "vector.hpp" 6 | #include "transform.hpp" 7 | 8 | namespace clover { 9 | namespace util { 10 | 11 | /// UV-information which helps setting uv coordinates of mesh 12 | class UniformUv { 13 | public: 14 | void setOrigo(util::Vec2f v){ uv.translation= v; } 15 | void setRotation(real32 r){ uv.rotation= r; } 16 | void setSize(util::Vec2f r){ uv.scale= r; }; 17 | 18 | util::Vec2f getUv(util::Vec2f pos) const; 19 | 20 | private: 21 | util::SrtTransform uv; 22 | }; 23 | 24 | } // util 25 | } // clover 26 | 27 | #endif // CLOVER_UTIL_UNIFORM_UV_HPP -------------------------------------------------------------------------------- /code/source/visual/font_mgr.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_VISUAL_FONT_MGR_HPP 2 | #define CLOVER_VISUAL_FONT_MGR_HPP 3 | 4 | #include "build.hpp" 5 | #include "visual/font.hpp" 6 | #include "util/hashmap.hpp" 7 | 8 | namespace clover { 9 | namespace visual { 10 | 11 | /// @todo Should be resource cache 12 | class FontMgr { 13 | public: 14 | FontMgr(); 15 | virtual ~FontMgr(); 16 | 17 | void createFont(const util::Str8& path, const util::Str8& name, int32 face_index=0); 18 | Font &getFont(const util::Str8& name); 19 | 20 | private: 21 | void* library; 22 | util::HashMap fonts; 23 | }; 24 | 25 | extern FontMgr* gFontMgr; 26 | 27 | } // visual 28 | } // clover 29 | 30 | #endif // CLOVER_VISUAL_FONT_MGR_HPP 31 | -------------------------------------------------------------------------------- /code/source/gui/element_attributefield_vector4.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_GUI_ATTRIBUTEFIELD_VECTOR4_HPP 2 | #define CLOVER_GUI_ATTRIBUTEFIELD_VECTOR4_HPP 3 | 4 | #include "build.hpp" 5 | #include "element_attributefield.hpp" 6 | 7 | namespace clover { 8 | namespace gui { 9 | 10 | /// @todo 11 | template <> 12 | class AttributeFieldElement : public AttributeFieldWrapElement { 13 | public: 14 | AttributeFieldElement(const resources::AttributeDef& def):AttributeFieldWrapElement(def){} 15 | virtual ~AttributeFieldElement(){} 16 | 17 | private: 18 | virtual void onValueSet(){} 19 | }; 20 | 21 | } // gui 22 | } // clover 23 | 24 | #endif // CLOVER_GUI_ATTRIBUTEFIELD_VECTOR4_HPP -------------------------------------------------------------------------------- /code/source/resources/attribute.cpp: -------------------------------------------------------------------------------- 1 | #include "attribute.hpp" 2 | #include "resource.hpp" 3 | 4 | namespace clover { 5 | namespace resources { 6 | 7 | void tryLaunchAttributeOnChangeCallbacks(const BaseAttribute::OnChangeCallback& cb, Resource* res){ 8 | Resource::State pre_state= Resource::State::Uninit; 9 | if (res) 10 | pre_state= res->getResourceState(); 11 | 12 | if (cb) 13 | cb(); // Launch change callback of the attribute 14 | 15 | // Launch callbacks added to resource only if state hasn't changed 16 | // onChange has already been called by resource if the state has changed 17 | if (res && pre_state == res->getResourceState()) 18 | ((util::OnChangeCb*)res)->trigger(); 19 | } 20 | 21 | } // resources 22 | } // clover -------------------------------------------------------------------------------- /code/source/util/bool_wrap.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_UTIL_BOOL_WRAP_HPP 2 | #define CLOVER_UTIL_BOOL_WRAP_HPP 3 | 4 | #include "build.hpp" 5 | 6 | namespace clover { 7 | namespace util { 8 | 9 | class BoolWrap { 10 | public: 11 | BoolWrap():b(false){} 12 | 13 | template 14 | BoolWrap(const T& t){ 15 | if (t){ 16 | b= true; 17 | } 18 | else b= false; 19 | } 20 | 21 | operator bool() const { return b; } 22 | 23 | typedef bool & boolref; 24 | operator boolref() { return b; } 25 | 26 | template 27 | bool operator=(const T& t){ 28 | b= (bool)t; 29 | 30 | return b; 31 | } 32 | 33 | private: 34 | bool b; 35 | }; 36 | 37 | } // util 38 | } // clover 39 | 40 | #endif // CLOVER_UTIL_BOOL_WRAP_HPP -------------------------------------------------------------------------------- /code/source/visual/entitylogic.cpp: -------------------------------------------------------------------------------- 1 | #include "entitylogic.hpp" 2 | 3 | namespace clover { 4 | namespace visual { 5 | 6 | EntityLogic::EntityLogic(const EntityDef& def) 7 | : definition(&def) 8 | , layer(Layer::World) 9 | , coordinateSpace(util::Coord::World) 10 | , scaleCoordinateSpace(util::Coord::None){ 11 | } 12 | 13 | EntityLogic::~EntityLogic(){ 14 | } 15 | 16 | const EntityDef& EntityLogic::getDef() const { 17 | ensure(definition); 18 | return *definition; 19 | } 20 | 21 | void EntityLogic::apply(const EntityLogic& other){ 22 | transform= other.transform; 23 | layer= other.layer; 24 | } 25 | 26 | void EntityLogic::setDef(const EntityDef& def){ 27 | definition= &def; 28 | } 29 | 30 | } // visual 31 | } // clover -------------------------------------------------------------------------------- /code/source/ui/game/editor/editorcomponent_ui_factory.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_UI_EDITOR_EDITORCOMPONENT_UI_FACTORY_HPP 2 | #define CLOVER_UI_EDITOR_EDITORCOMPONENT_UI_FACTORY_HPP 3 | 4 | #include "build.hpp" 5 | #include "common.hpp" 6 | #include "baseeditorcomponent_ui.hpp" 7 | 8 | #include 9 | 10 | namespace clover { 11 | namespace game { namespace editor { 12 | 13 | class EditorComponent; 14 | 15 | }} // game::editor 16 | namespace ui { namespace game { namespace editor { 17 | 18 | class EditorComponentUiFactory { 19 | public: 20 | static std::shared_ptr create(EditorComponent&); 21 | }; 22 | 23 | }}} // ui::game::editor 24 | } // clover 25 | 26 | #endif // CLOVER_UI_EDITOR_EDITORCOMPONENT_UI_FACTORY_HPP -------------------------------------------------------------------------------- /code/source/nodes/nodeeventreceiverproxy_we.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_NODES_NODEEVENTRECEIVERPROXY_WE_HPP 2 | #define CLOVER_NODES_NODEEVENTRECEIVERPROXY_WE_HPP 3 | 4 | #include "build.hpp" 5 | #include "game/worldentity_handle.hpp" 6 | #include "nodeeventreceiverproxy.hpp" 7 | 8 | namespace clover { 9 | namespace nodes { 10 | 11 | class WeNodeEventReceiverProxy : public NodeEventReceiverProxy { 12 | public: 13 | WeNodeEventReceiverProxy(const game::WeHandle& h); 14 | virtual ~WeNodeEventReceiverProxy(); 15 | 16 | virtual void onEvent(const NodeEvent&); 17 | virtual WeNodeEventReceiverProxy* clone(); 18 | private: 19 | game::WeHandle handle; 20 | }; 21 | 22 | } // nodes 23 | } // clover 24 | 25 | #endif // CLOVER_NODES_NODEEVENTRECEIVERPROXY_WE_HPP -------------------------------------------------------------------------------- /code/source/resources/attributeparseinfo.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_RESOURCES_ATTRIBUTEPARSEINFO_HPP 2 | #define CLOVER_RESOURCES_ATTRIBUTEPARSEINFO_HPP 3 | 4 | #include "build.hpp" 5 | 6 | namespace clover { 7 | namespace util { 8 | 9 | class ObjectNode; 10 | 11 | } // util 12 | namespace resources { 13 | 14 | struct AttributeParseInfo { 15 | AttributeParseInfo(const util::ObjectNode& val, const util::Str8& dir): 16 | object(val), 17 | resourceDirectory(dir){} 18 | 19 | const util::ObjectNode& object; // Json value of the attribute 20 | const util::Str8& resourceDirectory; // Path to directory of the .res file in which the attribute is 21 | }; 22 | 23 | } // resources 24 | } // clover 25 | 26 | #endif // CLOVER_RESOURCES_ATTRIBUTEPARSEINFO_HPP -------------------------------------------------------------------------------- /code/source/game/editor/editorextension.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_GAME_EDITOR_EDITOREXTENSION_HPP 2 | #define CLOVER_GAME_EDITOR_EDITOREXTENSION_HPP 3 | 4 | #include "build.hpp" 5 | 6 | namespace clover { 7 | namespace game { namespace editor { 8 | 9 | class EditorExtension { 10 | public: 11 | EditorExtension()= default; 12 | 13 | EditorExtension(const EditorExtension&)= delete; 14 | EditorExtension(EditorExtension&&)= delete; 15 | 16 | EditorExtension& operator=(const EditorExtension&)= delete; 17 | EditorExtension& operator==(EditorExtension&&)= delete; 18 | 19 | virtual ~EditorExtension()= default; 20 | 21 | virtual void update(){} 22 | }; 23 | 24 | }} // game::editor 25 | } // clover 26 | 27 | #endif // CLOVER_GAME_EDITOR_EDITOREXTENSION_HPP -------------------------------------------------------------------------------- /code/source/global/memory.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_GAME_MEMORY_HPP 2 | #define CLOVER_GAME_MEMORY_HPP 3 | 4 | #include "build.hpp" 5 | #include "util/mem_pool_linear.hpp" 6 | #include "util/ator_bound.hpp" 7 | 8 | namespace clover { 9 | namespace global { 10 | 11 | struct SingleFrameStorageTag; 12 | using SingleFrameStorage= 13 | util::BoundAtorStorage< util::LinearMemPool, 14 | SingleFrameStorageTag>; 15 | 16 | /// @usage util::DynArray array; 17 | template 18 | using SingleFrameAtor= util::BoundAtor; 19 | 20 | void createMemoryPools(SizeType single_frame_mem_size); 21 | void destroyMemoryPools(); 22 | 23 | } // global 24 | } // clover 25 | 26 | #endif // CLOVER_GAME_MEMORY_HPP 27 | -------------------------------------------------------------------------------- /code/source/gui/element_panel.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_GUI_PANEL_HPP 2 | #define CLOVER_GUI_PANEL_HPP 3 | 4 | #include "build.hpp" 5 | #include "element.hpp" 6 | #include "elementvisualentity.hpp" 7 | 8 | namespace clover { 9 | namespace gui { 10 | 11 | class PanelElement : public Element { 12 | public: 13 | PanelElement(const util::Coord& offset= util::Coord::VF(0), const util::Coord& rad= util::Coord::VF(0)); 14 | PanelElement(PanelElement&&)= default; 15 | virtual ~PanelElement(); 16 | 17 | // No graphics 18 | void setBgInvisible(){ /*autoREs.clear();*/ } 19 | 20 | virtual void spatialUpdate() override; 21 | 22 | protected: 23 | ElementVisualEntity* visual; 24 | }; 25 | 26 | } // gui 27 | } // clover 28 | 29 | #endif // CLOVER_GUI_PANEL_HPP -------------------------------------------------------------------------------- /code/source/nodes/nodeeventtype.cpp: -------------------------------------------------------------------------------- 1 | #include "nodeeventtype.hpp" 2 | 3 | namespace clover { 4 | namespace nodes { 5 | 6 | NodeEventType::NodeEventType() 7 | : INIT_RESOURCE_ATTRIBUTE(nameAttribute, "name", "") 8 | , INIT_RESOURCE_ATTRIBUTE(argumentsAttribute, "arguments", {}){ 9 | 10 | } 11 | 12 | NodeEventType::~NodeEventType(){ 13 | } 14 | 15 | void NodeEventType::resourceUpdate(bool load, bool force){ 16 | if (getResourceState() == State::Uninit || load){ 17 | setResourceState(State::Loaded); 18 | } 19 | else { 20 | setResourceState(State::Unloaded); 21 | } 22 | } 23 | 24 | void NodeEventType::createErrorResource(){ 25 | argumentsAttribute.get().clear(); 26 | setResourceState(State::Error); 27 | } 28 | 29 | } // nodes 30 | } // clover -------------------------------------------------------------------------------- /code/source/gui/element_attributefield_baseshape.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_GUI_ATTRIBUTEFIELD_BASESHAPE_HPP 2 | #define CLOVER_GUI_ATTRIBUTEFIELD_BASESHAPE_HPP 3 | 4 | #include "build.hpp" 5 | #include "element_attributefield.hpp" 6 | 7 | namespace clover { 8 | namespace gui { 9 | 10 | /// Editing in blender 11 | template <> 12 | class AttributeFieldElement : public AttributeFieldWrapElement { 13 | public: 14 | AttributeFieldElement(const resources::AttributeDef& def):AttributeFieldWrapElement(def){} 15 | virtual ~AttributeFieldElement(){} 16 | 17 | private: 18 | virtual void onValueSet(){} 19 | }; 20 | 21 | } // gui 22 | } // clover 23 | 24 | #endif // CLOVER_GUI_ATTRIBUTEFIELD_BASESHAPE_HPP -------------------------------------------------------------------------------- /code/source/gui/element_attributefield_string.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_GUI_ATTRIBUTEFIELD_STRING_HPP 2 | #define CLOVER_GUI_ATTRIBUTEFIELD_STRING_HPP 3 | 4 | #include "build.hpp" 5 | #include "element_attributefield.hpp" 6 | #include "element_textfield.hpp" 7 | 8 | namespace clover { 9 | namespace gui { 10 | 11 | template <> 12 | class AttributeFieldElement : public AttributeFieldWrapElement { 13 | public: 14 | AttributeFieldElement(const resources::AttributeDef& def); 15 | virtual ~AttributeFieldElement(); 16 | 17 | private: 18 | virtual void onValueSet(); 19 | 20 | gui::TextFieldElement textField; 21 | }; 22 | 23 | } // gui 24 | } // clover 25 | 26 | #endif // CLOVER_GUI_ATTRIBUTEFIELD_STRING_HPP -------------------------------------------------------------------------------- /code/source/mod/node_player_mgr.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_NODES_NODEINSTANCE_PLAYER_MGR_HPP 2 | #define CLOVER_NODES_NODEINSTANCE_PLAYER_MGR_HPP 3 | 4 | #include "nodes/nodeinstance.hpp" 5 | #include "build.hpp" 6 | #include "ui/hid/taglistentry.hpp" 7 | 8 | namespace clover { 9 | namespace mod { 10 | 11 | // I'm lazy 12 | using namespace clover::nodes; 13 | 14 | DECLARE_NODE(PlayerMgrNode) 15 | 16 | class PlayerMgrNode final : public NodeInstance { 17 | public: 18 | static CompositionNodeLogic* compNode(); 19 | 20 | virtual void create() override; 21 | void update_novirtual(){} 22 | 23 | private: 24 | util::DynArray tagEntries; 25 | }; 26 | 27 | } // nodes 28 | } // clover 29 | 30 | #endif // CLOVER_NODES_NODEINSTANCE_PLAYER_MGR_HPP 31 | -------------------------------------------------------------------------------- /code/source/nodes/baseinputslot.cpp: -------------------------------------------------------------------------------- 1 | #include "baseinputslot.hpp" 2 | #include "debug/print.hpp" 3 | #include "util/profiling.hpp" 4 | 5 | namespace clover { 6 | namespace nodes { 7 | 8 | BaseInputSlot::BaseInputSlot(SignalType t) 9 | : BaseSlot(t) 10 | , valueReceived(false) 11 | , onReceiveCallback(nullptr) 12 | { } 13 | 14 | BaseInputSlot::~BaseInputSlot(){ 15 | } 16 | 17 | void BaseInputSlot::update(NodeInstance& inst){ 18 | if (valueReceived && onReceiveCallback) { 19 | PROFILE(); 20 | (*onReceiveCallback)(&inst); 21 | } 22 | 23 | valueReceived= false; 24 | } 25 | 26 | void BaseInputSlot::setValueReceived(){ 27 | valueReceived= true; 28 | if (extValueReceived) 29 | *extValueReceived= true; 30 | } 31 | 32 | } // nodes 33 | } // clover 34 | -------------------------------------------------------------------------------- /code/source/ui/game/editor/editorcomponent_ui.cpp: -------------------------------------------------------------------------------- 1 | #include "editorcomponent_ui.hpp" 2 | 3 | #define EC_HEADERS 4 | #include "game/editor/components/components.def" 5 | #undef EC_HEADERS 6 | 7 | namespace clover { 8 | namespace ui { namespace game { namespace editor { 9 | 10 | util::Coord RuntimeEditorComponentUiTraits::defaultRadius(const util::Str8& comp_type){ 11 | #define EC(ui_type) \ 12 | if (EditorComponentTraits::name() == comp_type) \ 13 | return EditorComponentUiTraits::defaultRadius(); 14 | #include "game/editor/components/components.def" 15 | #undef EC 16 | 17 | throw global::Exception("Invalid EditorComponent type: %s", comp_type.cStr()); 18 | } 19 | 20 | }}} // ui::game::editor 21 | } // clover -------------------------------------------------------------------------------- /code/source/game/world_gen/worker.cpp: -------------------------------------------------------------------------------- 1 | #include "../world_mgr.hpp" 2 | #include "chunk_gen.hpp" 3 | #include "global/env.hpp" 4 | #include "resources/cache.hpp" 5 | #include "util/time.hpp" 6 | #include "worker.hpp" 7 | #include "workertype.hpp" 8 | 9 | namespace clover { 10 | namespace game { namespace world_gen { 11 | 12 | Worker::Worker(const util::Str8& type_, WorkerLocation loc_, real64 radius_) 13 | : type(&global::g_env.resCache->getResource(type_)) 14 | , location(loc_) 15 | , radius(radius_) 16 | , creationTime(global::g_env.worldMgr->getTime()) 17 | { } 18 | 19 | void Worker::work() const 20 | { 21 | ensure(type); 22 | type->callWork(location.getChunkGen().getWorldGen(), *this); 23 | } 24 | 25 | }} // game::world_gen 26 | } // clover 27 | -------------------------------------------------------------------------------- /code/source/gui/element_attributefield_boolean.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_GUI_ATTRIBUTEFIELD_BOOLEAN_HPP 2 | #define CLOVER_GUI_ATTRIBUTEFIELD_BOOLEAN_HPP 3 | 4 | #include "build.hpp" 5 | #include "element_attributefield.hpp" 6 | #include "element_checkbox.hpp" 7 | 8 | namespace clover { 9 | namespace gui { 10 | 11 | template <> 12 | class AttributeFieldElement : public AttributeFieldWrapElement { 13 | public: 14 | AttributeFieldElement(const resources::AttributeDef& def); 15 | virtual ~AttributeFieldElement(); 16 | 17 | private: 18 | virtual void onValueSet(); 19 | 20 | gui::CheckBoxElement checkBox; 21 | }; 22 | 23 | } // gui 24 | } // clover 25 | 26 | #endif // CLOVER_GUI_ATTRIBUTEFIELD_BOOLEAN_HPP -------------------------------------------------------------------------------- /code/source/physics/jointtype.cpp: -------------------------------------------------------------------------------- 1 | #include "jointtype.hpp" 2 | #include "global/exception.hpp" 3 | 4 | namespace clover { 5 | namespace physics { 6 | 7 | util::Str8 RuntimeJointTypeTraits::enumString(JointType t){ 8 | #define JOINT_TYPE(x) \ 9 | if (t == JointType::x) \ 10 | return #x; 11 | #include "jointtypes.def" 12 | #undef JOINT_TYPE 13 | 14 | throw global::Exception("Unexpected JointType: %i", (int)t); 15 | } 16 | 17 | JointType RuntimeJointTypeTraits::jointTypeByString(const util::Str8& name){ 18 | #define JOINT_TYPE(x) \ 19 | if (name == util::Str8(#x)) \ 20 | return JointType::x; 21 | #include "jointtypes.def" 22 | #undef JOINT_TYPE 23 | 24 | throw global::Exception("Invalid joint type: %s", name.cStr()); 25 | } 26 | 27 | } // clover 28 | } // physics -------------------------------------------------------------------------------- /code/source/gui/element_attributefield_path.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_GUI_ATTRIBUTEFIELD_PATH_HPP 2 | #define CLOVER_GUI_ATTRIBUTEFIELD_PATH_HPP 3 | 4 | #include "build.hpp" 5 | #include "element_attributefield.hpp" 6 | #include "element_textfield.hpp" 7 | 8 | namespace clover { 9 | namespace gui { 10 | 11 | template <> 12 | class AttributeFieldElement : public AttributeFieldWrapElement { 13 | public: 14 | AttributeFieldElement(const resources::AttributeDef& def); 15 | virtual ~AttributeFieldElement(); 16 | 17 | private: 18 | virtual void onValueSet(); 19 | void onValueChange(); 20 | 21 | gui::TextFieldElement textField; 22 | }; 23 | 24 | } // gui 25 | } // clover 26 | 27 | #endif // CLOVER_GUI_ATTRIBUTEFIELD_PATH_HPP -------------------------------------------------------------------------------- /code/source/hardware/memory.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_HARDWARE_MEMORY_HPP 2 | #define CLOVER_HARDWARE_MEMORY_HPP 3 | 4 | #include "build.hpp" 5 | 6 | /// Single object new is called by noexcept and array new operators in C++11 7 | void* operator new(size_t size); 8 | void operator delete(void* mem) noexcept; 9 | 10 | namespace clover { 11 | namespace hardware { 12 | 13 | // Heap can't be created at first allocation, because e.g. MinGW does some 14 | // allocations before main which are released by msvcrt free(), resulting to crash 15 | void createHeap(); 16 | 17 | // Allocate from heap 18 | void* heapAllocate(SizeType size); 19 | 20 | // Free from heap 21 | void heapDeallocate(void* mem); 22 | 23 | } // hardware 24 | } // clover 25 | 26 | #endif // CLOVER_HARDWARE_MEMORY_HPP 27 | -------------------------------------------------------------------------------- /code/source/util/mem_pool_linear.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_UTIL_MEM_POOL_LINEAR_HPP 2 | #define CLOVER_UTIL_MEM_POOL_LINEAR_HPP 3 | 4 | #include "build.hpp" 5 | #include "util/mem_pool.hpp" 6 | 7 | namespace clover { 8 | namespace util { 9 | 10 | /// Memory pool for linear allocation scheme 11 | class LinearMemPool : public MemPool { 12 | public: 13 | /// Memory allocator interface 14 | void* allocate(SizeType size, SizeType alignment); 15 | void deallocate(void* mem){} 16 | 17 | /// Frees allocated memory 18 | void clear(); 19 | 20 | protected: 21 | virtual void onMemoryAcquire() override; 22 | virtual void onMemoryRelease() override; 23 | 24 | private: 25 | uint8* head= nullptr; 26 | }; 27 | 28 | } // util 29 | } // clover 30 | 31 | #endif // CLOVER_UTIL_MEM_POOL_LINEAR_HPP -------------------------------------------------------------------------------- /code/source/util/graph.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_UTIL_GRAPH_HPP 2 | #define CLOVER_UTIL_GRAPH_HPP 3 | 4 | #include "build.hpp" 5 | #include "util/containeralgorithms.hpp" 6 | #include "util/set.hpp" 7 | 8 | namespace clover { 9 | namespace util { 10 | 11 | template 12 | C findGraphNodes( 13 | C starting_nodes, 14 | std::function get_connected){ 15 | C found; 16 | 17 | std::function recursion= [&] (C next){ 18 | for (const auto& node : next){ 19 | if (!contains(found, node)){ 20 | fastInsert(found, node); 21 | recursion(get_connected(node)); 22 | } 23 | } 24 | }; 25 | 26 | recursion(std::move(starting_nodes)); 27 | 28 | return found; 29 | } 30 | 31 | } // util 32 | } // clover 33 | 34 | #endif // CLOVER_UTIL_GRAPH_HPP -------------------------------------------------------------------------------- /code/source/global/eventqueue.cpp: -------------------------------------------------------------------------------- 1 | #include "eventqueue.hpp" 2 | 3 | namespace clover { 4 | namespace global { 5 | 6 | bool EventQueue::sendLast(){ 7 | if (events.size() == 0) 8 | throw global::Exception("EventQueue::sendLast(): zero events in queue"); 9 | 10 | if (events.back().getReceiverCount() == 0)return false; //Ei ketään kenelle lähettää 11 | 12 | events.back().send(); 13 | 14 | events.popBack(); 15 | 16 | return true; 17 | } 18 | 19 | global::Event& EventQueue::getLast(){ 20 | return events.back(); 21 | } 22 | 23 | void EventQueue::popLast(){ 24 | events.popBack(); 25 | } 26 | 27 | void EventQueue::queue(global::Event e){ 28 | events.pushBack(e); 29 | } 30 | 31 | int32 EventQueue::size(){ 32 | return events.size(); 33 | } 34 | 35 | } // global 36 | } // clover 37 | -------------------------------------------------------------------------------- /code/source/gui/element_attributefield_scalar.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_GUI_ATTRIBUTEFIELD_SCALAR_HPP 2 | #define CLOVER_GUI_ATTRIBUTEFIELD_SCALAR_HPP 3 | 4 | #include "build.hpp" 5 | #include "element_attributefield.hpp" 6 | #include "element_textfield.hpp" 7 | 8 | namespace clover { 9 | namespace gui { 10 | 11 | template <> 12 | class AttributeFieldElement : public AttributeFieldWrapElement { 13 | public: 14 | AttributeFieldElement(const resources::AttributeDef& def); 15 | virtual ~AttributeFieldElement(); 16 | 17 | private: 18 | virtual void onValueSet(); 19 | void onValueChange(); 20 | 21 | gui::TextFieldElement textField; 22 | }; 23 | 24 | } // gui 25 | } // clover 26 | 27 | #endif // CLOVER_GUI_ATTRIBUTEFIELD_SCALAR_HPP -------------------------------------------------------------------------------- /code/source/physics/joint_weld.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_PHYSICS_JOINT_WELD_HPP 2 | #define CLOVER_PHYSICS_JOINT_WELD_HPP 3 | 4 | #include "b2_joint.hpp" 5 | #include "build.hpp" 6 | #include "util/traits.hpp" 7 | 8 | namespace clover { 9 | namespace physics { 10 | 11 | class Object; 12 | 13 | class ENGINE_API WeldJoint : public B2Joint 14 | , public JointTypeCrtp { 15 | public: 16 | void attach(Object& a, Object& b); 17 | 18 | /// To background 19 | void attach(Object& a); 20 | 21 | void setFrequency(real64 f); 22 | 23 | /// 0 = no damping, 1 = critical damping 24 | void setDamping(real64 d); 25 | 26 | 27 | private: 28 | }; 29 | 30 | } // physics 31 | } // clover 32 | 33 | #endif // CLOVER_PHYSICS_JOINT_WELD_HPP 34 | -------------------------------------------------------------------------------- /code/source/game/worldentity_table.cpp: -------------------------------------------------------------------------------- 1 | #include "global/exception.hpp" 2 | #include "world_mgr.hpp" 3 | #include "worldentity_table.hpp" 4 | #include "worldentity_mgr.hpp" 5 | 6 | namespace clover { 7 | namespace game { 8 | 9 | WETable& getWeTable() 10 | { return global::g_env.worldMgr->getWeMgr().getWeTable(); } 11 | 12 | WETable::WETable():util::PtrTable(100000){ 13 | nextUniqueEntityId= 1; 14 | } 15 | 16 | game::WorldEntityId WETable::assignUniqueId(){ 17 | nextUniqueEntityId++; 18 | return nextUniqueEntityId-1; 19 | } 20 | 21 | game::WorldEntityId WETable::getNextUniqueId() const { 22 | return nextUniqueEntityId; 23 | } 24 | 25 | void WETable::setNextUniqueId(game::WorldEntityId id){ 26 | nextUniqueEntityId= id; 27 | } 28 | 29 | } // game 30 | } // clover 31 | -------------------------------------------------------------------------------- /code/source/gui/element_attributefield_resourcepair.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_GUI_ATTRIBUTEFIELD_RESOURCEPAIR_HPP 2 | #define CLOVER_GUI_ATTRIBUTEFIELD_RESOURCEPAIR_HPP 3 | 4 | #include "build.hpp" 5 | #include "element_attributefield.hpp" 6 | #include "element_textfield.hpp" 7 | 8 | namespace clover { 9 | namespace gui { 10 | 11 | template <> 12 | class AttributeFieldElement : public AttributeFieldWrapElement { 13 | public: 14 | AttributeFieldElement(const resources::AttributeDef& def); 15 | virtual ~AttributeFieldElement(); 16 | 17 | private: 18 | virtual void onValueSet(); 19 | 20 | gui::TextFieldElement textField; 21 | }; 22 | 23 | } // gui 24 | } // clover 25 | 26 | #endif // CLOVER_GUI_ATTRIBUTEFIELD_RESOURCEPAIR_HPP -------------------------------------------------------------------------------- /code/source/gui/element_attributefield_resource.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_GUI_ATTRIBUTEFIELD_RESOURCE_HPP 2 | #define CLOVER_GUI_ATTRIBUTEFIELD_RESOURCE_HPP 3 | 4 | #include "build.hpp" 5 | #include "element_attributefield.hpp" 6 | #include "element_textfield.hpp" 7 | 8 | namespace clover { 9 | namespace gui { 10 | 11 | template <> 12 | class AttributeFieldElement : public AttributeFieldWrapElement { 13 | public: 14 | AttributeFieldElement(const resources::AttributeDef& def); 15 | virtual ~AttributeFieldElement(); 16 | 17 | private: 18 | virtual void onValueSet(); 19 | void onValueChange(); 20 | 21 | gui::TextFieldElement textField; 22 | }; 23 | 24 | } // gui 25 | } // clover 26 | 27 | #endif // CLOVER_GUI_ATTRIBUTEFIELD_RESOURCE_HPP -------------------------------------------------------------------------------- /code/source/nodes/signaltypetraits.tpp: -------------------------------------------------------------------------------- 1 | template 2 | void RuntimeSignalTypeTraits::serializeValue(SignalType S, Archive& ar, const uint32 ver, util::Any& value){ 3 | #define SIGNAL(x,n) \ 4 | if (SignalType::x == S){ \ 5 | /* If value.empty(): Put some rubbish (of the correct type) in the archive so that deserialization won't break */ \ 6 | SignalTypeTraits::Value v= SignalTypeTraits::defaultInitValue(); \ 7 | if (value.empty()) \ 8 | value= v; \ 9 | ar & util::anyCast::Value&>(value); \ 10 | return; \ 11 | } 12 | #include "signaltypes.def" 13 | #undef SIGNAL 14 | 15 | throw global::Exception("RuntimeSignalTypeTraits::serializeValue(..): Invalid SignalType: %i", S); 16 | } 17 | -------------------------------------------------------------------------------- /code/source/game/editor/extensions/ee_blender.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_GAME_EDITOR_EXTENSIONS_BLENDER_HPP 2 | #define CLOVER_GAME_EDITOR_EXTENSIONS_BLENDER_HPP 3 | 4 | #include "../editorextension.hpp" 5 | #include "net/protocol_msg/server.hpp" 6 | #include "build.hpp" 7 | #include "global/eventreceiver.hpp" 8 | 9 | namespace clover { 10 | namespace game { namespace editor { 11 | 12 | /// Blender EditorExtension 13 | class BlenderEE : public EditorExtension, public global::EventReceiver { 14 | public: 15 | BlenderEE(); 16 | virtual ~BlenderEE(){} 17 | 18 | virtual void onEvent(global::Event& e) override; 19 | virtual void update() override; 20 | 21 | private: 22 | net::msg::Server server; 23 | }; 24 | 25 | }} // game::editor 26 | } // clover 27 | 28 | #endif // CLOVER_GAME_EDITOR_EXTENSIONS_BLENDER_HPP -------------------------------------------------------------------------------- /code/source/gui/element_attributefield_vector2.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_GUI_ATTRIBUTEFIELD_VECTOR2_HPP 2 | #define CLOVER_GUI_ATTRIBUTEFIELD_VECTOR2_HPP 3 | 4 | #include "build.hpp" 5 | #include "element_attributefield.hpp" 6 | #include "element_textfieldarray.hpp" 7 | 8 | namespace clover { 9 | namespace gui { 10 | 11 | template <> 12 | class AttributeFieldElement : public AttributeFieldWrapElement { 13 | public: 14 | AttributeFieldElement(const resources::AttributeDef& def); 15 | virtual ~AttributeFieldElement(); 16 | 17 | private: 18 | virtual void onValueSet(); 19 | void onValueChange(); 20 | 21 | gui::TextFieldArrayElement fieldArray; 22 | }; 23 | 24 | } // gui 25 | } // clover 26 | 27 | #endif // CLOVER_GUI_ATTRIBUTEFIELD_VECTOR2_HPP -------------------------------------------------------------------------------- /code/source/physics/joint_target.hpp: -------------------------------------------------------------------------------- 1 | #ifndef PHYSICS_JOINT_TARGET_HPP 2 | #define PHYSICS_JOINT_TARGET_HPP 3 | 4 | #include "build.hpp" 5 | #include "b2_joint.hpp" 6 | #include "util/vector.hpp" 7 | 8 | #include 9 | 10 | namespace clover { 11 | namespace physics { 12 | 13 | /// A springlike joint between a point and object 14 | /// @warning Use only for testing, lacks functionality of normal joints 15 | class ENGINE_API TargetJoint : public B2Joint { 16 | public: 17 | void attach(Object& o, WorldVec world_anchor_pos); 18 | 19 | void setMaxForce(real64 force); 20 | void setFrequency(real64 f); 21 | void setDamping(real64 d); 22 | void setTarget(util::Vec2d t); 23 | }; 24 | 25 | } // physics 26 | } // clover 27 | 28 | #endif // PHYSICS_JOINT_TARGET_HPP 29 | -------------------------------------------------------------------------------- /code/deps/common/zlib-1.2.8/gzclose.c: -------------------------------------------------------------------------------- 1 | /* gzclose.c -- zlib gzclose() function 2 | * Copyright (C) 2004, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | #include "gzguts.h" 7 | 8 | /* gzclose() is in a separate file so that it is linked in only if it is used. 9 | That way the other gzclose functions can be used instead to avoid linking in 10 | unneeded compression or decompression routines. */ 11 | int ZEXPORT gzclose(file) 12 | gzFile file; 13 | { 14 | #ifndef NO_GZCOMPRESS 15 | gz_statep state; 16 | 17 | if (file == NULL) 18 | return Z_STREAM_ERROR; 19 | state = (gz_statep)file; 20 | 21 | return state->mode == GZ_READ ? gzclose_r(file) : gzclose_w(file); 22 | #else 23 | return gzclose_r(file); 24 | #endif 25 | } 26 | -------------------------------------------------------------------------------- /code/deps/common/libogg-1.3.2/src/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include 4 | 5 | lib_LTLIBRARIES = libogg.la 6 | 7 | libogg_la_SOURCES = framing.c bitwise.c 8 | libogg_la_LDFLAGS = -no-undefined -version-info @LIB_CURRENT@:@LIB_REVISION@:@LIB_AGE@ 9 | 10 | # build and run the self tests on 'make check' 11 | 12 | noinst_PROGRAMS = test_bitwise test_framing 13 | 14 | test_bitwise_SOURCES = bitwise.c 15 | test_bitwise_CFLAGS = -D_V_SELFTEST 16 | 17 | test_framing_SOURCES = framing.c 18 | test_framing_CFLAGS = -D_V_SELFTEST 19 | 20 | check: $(noinst_PROGRAMS) 21 | ./test_bitwise$(EXEEXT) 22 | ./test_framing$(EXEEXT) 23 | 24 | debug: 25 | $(MAKE) all CFLAGS="@DEBUG@" 26 | 27 | profile: 28 | $(MAKE) all CFLAGS="@PROFILE@" 29 | -------------------------------------------------------------------------------- /code/source/audio/audiostream.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_AUDIO_AUDIOSTREAM_HPP 2 | #define CLOVER_AUDIO_AUDIOSTREAM_HPP 3 | 4 | #include "build.hpp" 5 | #include "util/dyn_array.hpp" 6 | 7 | namespace clover { 8 | namespace audio { 9 | 10 | /// Internal class of the audiosystem 11 | /// Decodes/streams one channel from.. a source 12 | class AudioStream { 13 | public: 14 | struct Sample { 15 | real32 amplitude; 16 | }; 17 | 18 | struct ChannelData { 19 | util::DynArray samples; 20 | }; 21 | 22 | AudioStream(); 23 | virtual ~AudioStream(); 24 | 25 | virtual ChannelData getNextSamples(SizeType request_count)= 0; 26 | 27 | /// True if no more data to read 28 | bool hasEnded() const; 29 | 30 | protected: 31 | bool eos; 32 | }; 33 | 34 | } // audio 35 | } // clover 36 | 37 | #endif // CLOVER_AUDIO_AUDIOSTREAM_HPP -------------------------------------------------------------------------------- /code/source/game/worldentity_pack.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_GAME_WORLDENTITY_PACK_HPP 2 | #define CLOVER_GAME_WORLDENTITY_PACK_HPP 3 | 4 | #include "build.hpp" 5 | #include "util/pack.hpp" 6 | 7 | namespace clover { 8 | namespace game { 9 | 10 | /// Serialization of one object 11 | /// @todo Remove and use some common binary serialization 12 | class WEPack { 13 | public: 14 | WEPack(); 15 | 16 | void reset(uint64 id); 17 | 18 | void set(util::RawPack& data); 19 | 20 | uint64 getId(){ return id; } 21 | 22 | uint32 getVarBlockSize(){ return data.size(); } 23 | 24 | void prepareVarBlockReading(); 25 | 26 | util::RawPack& getVarPack(); 27 | 28 | protected: 29 | uint64 id; // Id of WorldEntity 30 | util::RawPack data; 31 | }; 32 | 33 | } // game 34 | } // clover 35 | 36 | #endif // CLOVER_GAME_WORLDENTITY_PACK_HPP -------------------------------------------------------------------------------- /code/source/util/exception.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_UTIL_EXCEPTION_HPP 2 | #define CLOVER_UTIL_EXCEPTION_HPP 3 | 4 | #include "build.hpp" 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | namespace clover { 11 | namespace util { 12 | 13 | class ENGINE_API Exception : public virtual std::exception 14 | , public virtual boost::exception { 15 | public: 16 | 17 | Exception(const char8* s, ...); 18 | Exception(const char8* s, va_list arglist); 19 | 20 | virtual ~Exception() throw(); 21 | virtual const char* what() const throw(); 22 | 23 | protected: 24 | Exception(); 25 | void constructor(const char8* s, va_list arglist); 26 | 27 | private: 28 | const char8* error; 29 | 30 | }; 31 | 32 | } // util 33 | } // clover 34 | 35 | #endif // CLOVER_UTIL_EXCEPTION_HPP 36 | -------------------------------------------------------------------------------- /code/source/nodes/compositionnodeslothandle.cpp: -------------------------------------------------------------------------------- 1 | #include "compositionnodeslothandle.hpp" 2 | #include "compositionnodelogic.hpp" 3 | #include "compositionnodeslot.hpp" 4 | 5 | namespace clover { 6 | namespace nodes { 7 | 8 | CompositionNodeSlotHandle::CompositionNodeSlotHandle(CompositionNodeSlot& slot) 9 | : owner(&slot.getOwner()) 10 | , identifier(slot.getIdentifier()){ 11 | ensure(owner); 12 | } 13 | 14 | CompositionNodeSlotHandle::operator bool() const { 15 | return owner->hasSlot(identifier); 16 | } 17 | 18 | CompositionNodeSlot* CompositionNodeSlotHandle::get() const { 19 | if (*this) 20 | return &owner->getSlot(identifier); 21 | return nullptr; 22 | } 23 | 24 | CompositionNodeSlot* CompositionNodeSlotHandle::operator->() const { 25 | return &owner->getSlot(identifier); 26 | } 27 | 28 | } // nodes 29 | } // clover -------------------------------------------------------------------------------- /code/source/ui/game/editor/editor_ui.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_UI_EDITOR_EDITOR_UI_HPP 2 | #define CLOVER_UI_EDITOR_EDITOR_UI_HPP 3 | 4 | #include "build.hpp" 5 | #include "common.hpp" 6 | #include "global/eventreceiver.hpp" 7 | #include "editorview_ui.hpp" 8 | 9 | namespace clover { 10 | namespace ui { namespace game { namespace editor { 11 | 12 | class Editor; 13 | 14 | class EditorUi : public global::EventReceiver { 15 | public: 16 | EditorUi(Editor& editor); 17 | virtual ~EditorUi(); 18 | 19 | virtual void onEvent(global::Event&); 20 | 21 | void update(); 22 | 23 | bool hasActiveView(); 24 | 25 | private: 26 | Editor* editor; 27 | util::DynArray> viewUis; 28 | util::Timer performanceTimer; 29 | }; 30 | 31 | }}} // ui::game::editor 32 | } // clover 33 | 34 | #endif // CLOVER_UI_EDITOR_EDITOR_UI_HPP -------------------------------------------------------------------------------- /code/source/animation/joint.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_ANIMATION_JOINT_HPP 2 | #define CLOVER_ANIMATION_JOINT_HPP 3 | 4 | #include "build.hpp" 5 | #include "jointpose.hpp" 6 | #include "util/string.hpp" 7 | 8 | namespace clover { 9 | namespace animation { 10 | 11 | /// Joint of Armature 12 | class Joint { 13 | public: 14 | Joint(const util::Str8& name, const JointPose& bind_pose, JointId id, JointId super_id= JointIdNone); 15 | 16 | const util::Str8& getName() const { return name; } 17 | JointId getId() const { return id; } 18 | JointId getSuperId() const { return superId; } 19 | const JointPose& getBindPose() const { return bindPose; } 20 | 21 | private: 22 | JointPose bindPose; 23 | 24 | util::Str8 name; 25 | JointId id; 26 | JointId superId; 27 | }; 28 | 29 | } // animation 30 | } // clover 31 | 32 | #endif // CLOVER_ANIMATION_JOINT_HPP -------------------------------------------------------------------------------- /code/source/visual/shadertech_shadowmap.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_VISUAL_SHADERTECH_SHADOWMAP_HPP 2 | #define CLOVER_VISUAL_SHADERTECH_SHADOWMAP_HPP 3 | 4 | #include "shadertech.hpp" 5 | #include "framebuffer.hpp" 6 | #include "mesh.hpp" 7 | #include "hardware/glstate.hpp" 8 | 9 | namespace clover { 10 | namespace visual { 11 | 12 | class ShadowMapST : public ShaderTech { 13 | public: 14 | ShadowMapST(); 15 | void generate(hardware::GlState::TexDId castermap, Framebuffer& result); 16 | 17 | protected: 18 | enum class Phase { 19 | distort= 0, 20 | reduction8, 21 | reduction2, 22 | drawShadows, 23 | horBlur, 24 | verBlur 25 | }; 26 | 27 | Framebuffer temp; 28 | util::DynArray reduced; 29 | 30 | TriMesh mapQuad; 31 | }; 32 | 33 | } // visual 34 | } // clover 35 | 36 | #endif // CLOVER_VISUAL_SHADERTECH_SHADOWMAP_HPP 37 | -------------------------------------------------------------------------------- /code/source/visual/shader_mgr.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_VISUAL_SHADER_MGR_HPP 2 | #define CLOVER_VISUAL_SHADER_MGR_HPP 3 | 4 | #include "build.hpp" 5 | #include "shader.hpp" 6 | #include "util/hashmap.hpp" 7 | 8 | namespace clover { 9 | namespace visual { 10 | 11 | class ShaderOptions; 12 | 13 | /// Manages individual shaders 14 | class ShaderMgr { 15 | public: 16 | using ShaderId= uint32; 17 | 18 | /// @note Can perform shader compilation 19 | /// @warning Don't keep pointer to return value 20 | Shader& getShader(const util::Str8& name); 21 | Shader& getShader(const util::Str8& name, const ShaderOptions& options); 22 | 23 | SizeType getShaderCount() const { return shaders.size(); } 24 | 25 | private: 26 | util::HashMap shaders; 27 | }; 28 | 29 | } // visual 30 | } // clover 31 | 32 | #endif // CLOVER_VISUAL_SHADER_MGR_HPP 33 | -------------------------------------------------------------------------------- /code/source/visual/bitmap.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_VISUAL_BITMAP_HPP 2 | #define CLOVER_VISUAL_BITMAP_HPP 3 | 4 | #include "build.hpp" 5 | #include "util/math.hpp" 6 | #include "visual/texture.hpp" 7 | 8 | namespace clover { 9 | namespace visual { 10 | 11 | class Bitmap { 12 | public: 13 | Bitmap(util::Vec2i size= util::Vec2i{0,0}); 14 | virtual ~Bitmap(); 15 | 16 | void create(util::Vec2i size); 17 | 18 | /// @param pos lower left corner 19 | /// @param font_conversion will make rect white*alpha 20 | void blitBW(const uint8 * rect, util::Vec2i size, util::Vec2i pos, bool font_conversion=true); 21 | 22 | Texture createTexture(bool font_mode=true); 23 | 24 | void destroy(); 25 | 26 | private: 27 | uint8 *buffer; 28 | int32 bufLen; 29 | 30 | util::Vec2i dim; 31 | }; 32 | 33 | } // visual 34 | } // clover 35 | 36 | #endif // CLOVER_VISUAL_BITMAP_HPP -------------------------------------------------------------------------------- /code/source/resources/attribute_def.tpp: -------------------------------------------------------------------------------- 1 | template 2 | auto AttributeDefImpl>::deserialized(const AttributeParseInfo& a) -> Value { 3 | if (!a.object.isArray()) 4 | throw ResourceException("Wrong json value type for attribute type Array"); 5 | 6 | Value ret; 7 | for (SizeType i=0; i 17 | util::ObjectNode AttributeDefImpl>::serialized(const Value& v){ 18 | util::ObjectNode ret(util::ObjectNode::Value::Array); 19 | for (auto m : v){ 20 | ret.append(ElementDefType::serialized(m)); 21 | } 22 | return ret; 23 | } -------------------------------------------------------------------------------- /code/source/gui/element_layout_radial.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_GUI_LAYOUT_RADIAL_HPP 2 | #define CLOVER_GUI_LAYOUT_RADIAL_HPP 3 | 4 | #include "build.hpp" 5 | #include "element_layout.hpp" 6 | 7 | namespace clover { 8 | namespace gui { 9 | 10 | class RadialLayoutElement : public LayoutElement> { 11 | using LayoutElement::Node; 12 | typedef LayoutElement> BaseType; 13 | public: 14 | RadialLayoutElement(const util::Coord& pos, const util::Coord& rad); 15 | RadialLayoutElement(RadialLayoutElement&&)= default; 16 | RadialLayoutElement(const RadialLayoutElement&)= delete; 17 | virtual ~RadialLayoutElement(); 18 | 19 | virtual void preUpdate(); 20 | 21 | private: 22 | void updateNodes(); 23 | virtual void spatialUpdate() override; 24 | }; 25 | 26 | } // gui 27 | } // clover 28 | 29 | #endif // CLOVER_GUI_LAYOUT_RADIAL_HPP -------------------------------------------------------------------------------- /code/source/animation/joint_def.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_ANIMATION_JOINT_DEF_HPP 2 | #define CLOVER_ANIMATION_JOINT_DEF_HPP 3 | 4 | #include "build.hpp" 5 | #include "jointpose.hpp" 6 | #include "util/objectnodetraits.hpp" 7 | #include "util/string.hpp" 8 | 9 | namespace clover { 10 | namespace animation { 11 | 12 | /// Resource attribute which defines joint of Armature 13 | struct JointDef { 14 | util::Str8 name; 15 | util::Str8 superJointName; 16 | JointPose::Transform transform; 17 | }; 18 | 19 | } // animation 20 | namespace util { 21 | 22 | template <> 23 | struct ObjectNodeTraits { 24 | typedef animation::JointDef Value; 25 | static util::ObjectNode serialized(const Value& value); 26 | static Value deserialized(const util::ObjectNode& ob_node); 27 | }; 28 | 29 | } // util 30 | } // clover 31 | 32 | #endif // CLOVER_ANIMATION_JOINT_DEF_HPP 33 | -------------------------------------------------------------------------------- /code/source/audio/audioreceiverhandle.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_AUDIO_AUDIORECEIVERHANDLE_HPP 2 | #define CLOVER_AUDIO_AUDIORECEIVERHANDLE_HPP 3 | 4 | #include "build.hpp" 5 | #include "audioreceiver.hpp" 6 | #include "global/eventreceiver.hpp" 7 | #include "util/countedpointer.hpp" 8 | 9 | namespace clover { 10 | namespace audio { 11 | 12 | class AudioReceiverHandle : public global::EventReceiver { 13 | public: 14 | AudioReceiverHandle(AudioReceiver* recv= nullptr); 15 | virtual ~AudioReceiverHandle(); 16 | 17 | virtual void onEvent(global::Event& e); 18 | void assignNewReceiver(); 19 | explicit operator bool() const { return audioReceiver.get(); } 20 | void setPosition(const util::Vec2d& pos); 21 | 22 | private: 23 | util::CountedPointer audioReceiver; 24 | }; 25 | 26 | } // audio 27 | } // clover 28 | 29 | #endif // CLOVER_AUDIO_AUDIORECEIVERHANDLE_HPP -------------------------------------------------------------------------------- /code/source/animation/joint_def.cpp: -------------------------------------------------------------------------------- 1 | #include "joint_def.hpp" 2 | #include "util/objectnode.hpp" 3 | 4 | namespace clover { 5 | namespace util { 6 | 7 | util::ObjectNode ObjectNodeTraits::serialized(const Value& value){ 8 | util::ObjectNode ob_node; 9 | ob_node["name"].setValue(value.name); 10 | ob_node["superJoint"].setValue(value.superJointName); 11 | ob_node["transform"].setValue(value.transform); 12 | return ob_node; 13 | } 14 | 15 | auto ObjectNodeTraits::deserialized(const util::ObjectNode& ob_node) -> Value { 16 | Value value; 17 | value.name= ob_node.get("name").getValue(); 18 | value.superJointName= ob_node.get("superJoint").getValue(); 19 | value.transform= ob_node.get("transform").getValue(); 20 | return value; 21 | } 22 | 23 | } // util 24 | } // clover 25 | -------------------------------------------------------------------------------- /code/source/build.cpp: -------------------------------------------------------------------------------- 1 | #include "build.hpp" 2 | 3 | namespace clover { 4 | 5 | #if ARCHITECTURE == ARCHITECTURE_32 6 | #define BUILD_ARCHITECTURE_STR "32bit" 7 | #else 8 | #define BUILD_ARCHITECTURE_STR "64bit" 9 | #endif 10 | 11 | #if OS == OS_LINUX 12 | #define BUILD_OS_STR "Linux" 13 | #elif OS == OS_WINDOWS 14 | #define BUILD_OS_STR "Windows" 15 | #elif OS == OS_MACOSX 16 | #define BUILD_OS_STR "MacOSX" 17 | #endif 18 | 19 | #if defined(DEBUG) 20 | #define BUILD_MODE_STR "debug" 21 | #elif defined(RELEASE) 22 | #define BUILD_MODE_STR "release" 23 | #else 24 | #define BUILD_MODE_STR "development" 25 | #endif 26 | 27 | const char* getBuildStr(){ 28 | return BUILD_ARCHITECTURE_STR " " BUILD_OS_STR " " BUILD_MODE_STR " build, " __DATE__ " " __TIME__; 29 | } 30 | 31 | #undef BUILD_ARCHITECTURE_STR 32 | #undef BUILD_OS_STR 33 | #undef BUILD_MODE_STR 34 | 35 | } // clover 36 | -------------------------------------------------------------------------------- /code/source/util/referencecountable.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_UTIL_REFERENCECOUNTABLE_HPP 2 | #define CLOVER_UTIL_REFERENCECOUNTABLE_HPP 3 | 4 | #include "build.hpp" 5 | 6 | namespace clover { 7 | namespace util { 8 | 9 | template 10 | class CountedPointer; 11 | 12 | /// Inherit from this if reference counting is needed for a type 13 | /// An object must be then referenced by a Reference -class 14 | class ReferenceCountable { 15 | public: 16 | ReferenceCountable(); 17 | virtual ~ReferenceCountable(); 18 | 19 | int32 getReferenceCount() const { return refCount; } 20 | 21 | private: 22 | template 23 | friend class CountedPointer; 24 | void incrementReferenceCount() const; 25 | void decrementReferenceCount() const; 26 | 27 | mutable int32 refCount; 28 | }; 29 | 30 | } // util 31 | } // clover 32 | 33 | #endif // CLOVER_UTIL_REFERENCECOUNTABLE_HPP -------------------------------------------------------------------------------- /code/source/ui/hid/controls/control_text.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_UI_HID_CONTROLS_CONTROL_TEXT_HPP 2 | #define CLOVER_UI_HID_CONTROLS_CONTROL_TEXT_HPP 3 | 4 | #include "../control.hpp" 5 | #include "build.hpp" 6 | #include "util/string.hpp" 7 | 8 | namespace clover { 9 | namespace ui { namespace hid { 10 | 11 | /// Manages written text 12 | class TextControl : public Control { 13 | public: 14 | virtual ~TextControl(){} 15 | 16 | void append(uint32 unicode){ 17 | newText += unicode; 18 | } 19 | 20 | virtual void update() override { 21 | triggerEvent("delta", newText); 22 | if (!newText.empty()) 23 | triggerEvent("new", newText); 24 | 25 | newText.clear(); 26 | } 27 | 28 | private: 29 | util::Str8 newText; 30 | }; 31 | 32 | }} // ui::hid 33 | } // clover 34 | 35 | #endif // CLOVER_UI_HID_CONTROLS_CONTROL_TEXT_HPP -------------------------------------------------------------------------------- /code/source/game/editor/components/ec_console.cpp: -------------------------------------------------------------------------------- 1 | #include "ec_console.hpp" 2 | #include "debug/print.hpp" 3 | 4 | namespace clover { 5 | namespace game { namespace editor { 6 | 7 | ConsoleEc::~ConsoleEc(){ 8 | } 9 | 10 | void ConsoleEc::setVerbosity(debug::Vb v){ 11 | global::g_env.debugPrint->setVerbosity(v); 12 | } 13 | 14 | debug::Vb ConsoleEc::getVerbosity() const { 15 | return global::g_env.debugPrint->getVerbosity(); 16 | } 17 | 18 | void ConsoleEc::setChannelActive(debug::Ch id, bool b){ 19 | global::g_env.debugPrint->setChannelActive(id, b); 20 | } 21 | 22 | bool ConsoleEc::isChannelActive(debug::Ch id) const { 23 | return global::g_env.debugPrint->isChannelActive(id); 24 | } 25 | 26 | void ConsoleEc::tryExecute(const util::Str8& string){ 27 | print(debug::Ch::Dev, debug::Vb::Critical, "@todo Reimplement console"); 28 | } 29 | 30 | }} // game::editor 31 | } // clover 32 | -------------------------------------------------------------------------------- /code/source/nodes/native_instances/nodeinstance_add_real.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_NODES_NODEINSTANCE_ADD_REAL_HPP 2 | #define CLOVER_NODES_NODEINSTANCE_ADD_REAL_HPP 3 | 4 | #include "../nodeinstance.hpp" 5 | #include "build.hpp" 6 | 7 | namespace clover { 8 | namespace nodes { 9 | 10 | class RealAddNodeInstance final : public NodeInstance { 11 | public: 12 | static CompositionNodeLogic* compNode(); 13 | 14 | virtual void create() override; 15 | 16 | private: 17 | InputSlot* input1; 18 | InputSlot* input2; 19 | OutputSlot* realOut; 20 | }; 21 | 22 | } // nodes 23 | namespace util { 24 | 25 | template <> 26 | struct TypeStringTraits { 27 | static util::Str8 type(){ return "::RealAddNodeInstance"; } 28 | }; 29 | 30 | } // util 31 | } // clover 32 | 33 | #endif // CLOVER_NODES_NODEINSTANCE_ADD_REAL_HPP 34 | -------------------------------------------------------------------------------- /code/source/ui/hid/action.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_UI_HID_ACTION_HPP 2 | #define CLOVER_UI_HID_ACTION_HPP 3 | 4 | #include "build.hpp" 5 | #include "nodes/signaltypetraits.hpp" 6 | #include "util/callbacker.hpp" 7 | #include "util/string.hpp" 8 | 9 | namespace clover { 10 | namespace ui { namespace hid { 11 | 12 | class Action { 13 | public: 14 | using Name= util::Str8; 15 | 16 | Action(const Name& name_, const nodes::SignalValue& v): name(name_), value(v){} 17 | 18 | const util::Str8& getName() const { return name; } 19 | 20 | template 21 | void setValue(const typename nodes::SignalTypeTraits::Value& v){ value.set(S, v); } 22 | 23 | const nodes::SignalValue& getValue() const { return value; } 24 | 25 | private: 26 | util::Str8 name; 27 | nodes::SignalValue value; 28 | }; 29 | 30 | }} // ui::hid 31 | } // clover 32 | 33 | #endif // CLOVER_UI_HID_ACTION_HPP -------------------------------------------------------------------------------- /code/source/nodes/signalargument.cpp: -------------------------------------------------------------------------------- 1 | #include "signalargument.hpp" 2 | #include "nodes/signaltypetraits.hpp" 3 | #include "util/objectnode.hpp" 4 | 5 | namespace clover { 6 | namespace util { 7 | 8 | util::ObjectNode ObjectNodeTraits::serialized(const Value& value){ 9 | util::ObjectNode ret; 10 | 11 | ret["Name"].setValue(value.name); 12 | ret["SignalType"].setValue(nodes::RuntimeSignalTypeTraits::enumString(value.signalType)); 13 | 14 | return (ret); 15 | } 16 | 17 | auto ObjectNodeTraits::deserialized(const util::ObjectNode& ob_node) -> Value { 18 | Value ret; 19 | ret.name= ob_node.get("Name").getValue(); 20 | ret.signalType= nodes::RuntimeSignalTypeTraits::signalTypeFromEnumString(ob_node.get("SignalType").getValue()); 21 | 22 | return (ret); 23 | } 24 | 25 | } // util 26 | } // clover 27 | -------------------------------------------------------------------------------- /code/source/ui/game/inventory_ui.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_INVENTORY_UI_HPP 2 | #define CLOVER_INVENTORY_UI_HPP 3 | 4 | #include "build.hpp" 5 | #include "global/eventreceiver.hpp" 6 | #include "inventory_gui.hpp" 7 | 8 | namespace clover { 9 | namespace game { 10 | 11 | class Inventory; 12 | 13 | } // game 14 | namespace ui { namespace game { 15 | 16 | /// User interface for player's inventory 17 | /// @todo Reconsider reason for existence 18 | class InventoryUi : public global::EventReceiver { 19 | public: 20 | InventoryUi(game::Inventory& i); 21 | 22 | virtual void onEvent(global::Event& e); 23 | 24 | void update(); 25 | 26 | void toggleGui(); 27 | bool isGuiActive(); 28 | 29 | game::WeHandle getTriggeredWE(); 30 | 31 | private: 32 | game::Inventory& inventory; 33 | InventoryGui inventoryGui; 34 | }; 35 | 36 | }} // ui::game 37 | } // clover 38 | 39 | #endif // CLOVER_INVENTORY_UI_HPP -------------------------------------------------------------------------------- /code/source/nodes/native_instances/nodeinstance_pow_real.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_NODES_NODEINSTANCE_POW_REAL_HPP 2 | #define CLOVER_NODES_NODEINSTANCE_POW_REAL_HPP 3 | 4 | #include "../nodeinstance.hpp" 5 | #include "build.hpp" 6 | 7 | namespace clover { 8 | namespace nodes { 9 | 10 | class RealPowNodeInstance final : public NodeInstance { 11 | public: 12 | static CompositionNodeLogic* compNode(); 13 | 14 | virtual void create() override; 15 | 16 | private: 17 | InputSlot* baseInput; 18 | InputSlot* exponentInput; 19 | OutputSlot* realOut; 20 | }; 21 | 22 | } // nodes 23 | namespace util { 24 | 25 | template <> 26 | struct TypeStringTraits { 27 | static util::Str8 type(){ return "::RealPowNodeInstance"; } 28 | }; 29 | 30 | } // util 31 | } // clover 32 | 33 | #endif // CLOVER_NODES_NODEINSTANCE_POW_REAL_HPP 34 | -------------------------------------------------------------------------------- /code/source/game/worldentity_table.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_GAME_WORLDENTITY_TABLE_HPP 2 | #define CLOVER_GAME_WORLDENTITY_TABLE_HPP 3 | 4 | #include "build.hpp" 5 | #include "util/dyn_array.hpp" 6 | #include "util/ptrtable.hpp" 7 | 8 | namespace clover { 9 | namespace game { 10 | 11 | class WorldEntity; 12 | 13 | typedef uint64 WorldEntityId; 14 | 15 | /// @todo Remove. Ids should be managed by WeMgr 16 | class ENGINE_API WETable : public util::PtrTable { 17 | public: 18 | WETable(); 19 | 20 | game::WorldEntityId assignUniqueId(); 21 | 22 | game::WorldEntityId getNextUniqueId() const; 23 | void setNextUniqueId(game::WorldEntityId); 24 | 25 | private: 26 | game::WorldEntityId nextUniqueEntityId; 27 | }; 28 | 29 | /// @return WETable of global::g_env.worldMgr->weMgr 30 | WETable& getWeTable(); 31 | 32 | } // game 33 | } // clover 34 | 35 | #endif // CLOVER_GAME_WORLDENTITY_TABLE_HPP 36 | -------------------------------------------------------------------------------- /code/source/global/eventreceiver.cpp: -------------------------------------------------------------------------------- 1 | #include "env.hpp" 2 | #include "eventreceiver.hpp" 3 | #include "event_mgr.hpp" 4 | 5 | namespace clover { 6 | namespace global { 7 | 8 | EventReceiver::EventReceiver() 9 | : listenCount(0){ 10 | } 11 | 12 | EventReceiver::EventReceiver(EventReceiver&& other) 13 | : listenCount(0){ 14 | global::g_env.eventMgr->replaceReceiver(other, *this); 15 | } 16 | 17 | EventReceiver::~EventReceiver(){ 18 | if (listenCount > 0) 19 | global::g_env.eventMgr->unregisterReceiver(*this); 20 | } 21 | 22 | void EventReceiver::listenForEvent(global::Event::EType t){ 23 | global::g_env.eventMgr->registerReceiver(*this, t); 24 | ++listenCount; 25 | } 26 | 27 | void EventReceiver::unlistenForEvent(global::Event::EType t){ 28 | ensure(listenCount > 0); 29 | global::g_env.eventMgr->unregisterReceiver(*this, t); 30 | --listenCount; 31 | } 32 | 33 | } // global 34 | } // clover 35 | -------------------------------------------------------------------------------- /code/source/net/protocol_msg/msg.tpp: -------------------------------------------------------------------------------- 1 | template 2 | void Msg::setValue(const Value& value){ 3 | try { 4 | util::ObjectNode ob= util::ObjectNode::create(value); 5 | util::Str8 str= std::move(ob.generateText()); 6 | 7 | rawValue.clear(); 8 | for (SizeType i= 0; i < str.sizeBytes(); ++i) 9 | rawValue.pushBack(str[i]); 10 | } 11 | catch(const std::exception& e){ 12 | throw NetException("Error serializing a value for Msg %s: %s", getName().data(), e.what()); 13 | } 14 | } 15 | 16 | template 17 | Value Msg::getValue() const { 18 | try { 19 | util::Str8 str; 20 | for (const auto& m : rawValue) 21 | str += m; 22 | 23 | util::ObjectNode ob; 24 | ob.parseText(str); 25 | return (ob.getValue()); 26 | } 27 | catch(const std::exception& e){ 28 | throw NetException("Error deserializing a value for Msg %s: %s", getName().data(), e.what()); 29 | } 30 | } -------------------------------------------------------------------------------- /code/source/nodes/native_instances/nodeinstance_worldclock.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_NODES_NODEINSTANCE_WORLDCLOCK_HPP 2 | #define CLOVER_NODES_NODEINSTANCE_WORLDCLOCK_HPP 3 | 4 | #include "../nodeinstance.hpp" 5 | #include "build.hpp" 6 | 7 | namespace clover { 8 | namespace nodes { 9 | 10 | class WorldClockNodeInstance final : public NodeInstance { 11 | public: 12 | static CompositionNodeLogic* compNode(); 13 | 14 | virtual void create() override; 15 | virtual void update() override; 16 | 17 | private: 18 | OutputSlot* dayPhaseOut; 19 | OutputSlot* daynessOut; 20 | }; 21 | 22 | } // nodes 23 | namespace util { 24 | 25 | template <> 26 | struct TypeStringTraits { 27 | static util::Str8 type(){ return "::WorldClockNodeInstance"; } 28 | }; 29 | 30 | } // util 31 | } // clover 32 | 33 | #endif // CLOVER_NODES_NODEINSTANCE_WORLDCLOCK_HPP 34 | -------------------------------------------------------------------------------- /code/source/game/editor/editorextension_mgr.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_GAME_EDITOR_EXTENSION_MGR_HPP 2 | #define CLOVER_GAME_EDITOR_EXTENSION_MGR_HPP 3 | 4 | #include "build.hpp" 5 | #include "editorextension.hpp" 6 | #include "util/dyn_array.hpp" 7 | #include "util/unique_ptr.hpp" 8 | 9 | namespace clover { 10 | namespace game { namespace editor { 11 | 12 | /// Handles connections to other programs (like Blender) 13 | class EditorExtensionMgr { 14 | public: 15 | EditorExtensionMgr(); 16 | 17 | void update(); 18 | 19 | private: 20 | using ExtensionPtr= util::UniquePtr; 21 | 22 | template 23 | EditorExtension& createExtension(){ 24 | extensions.pushBack(ExtensionPtr(new T)); 25 | return *extensions.back(); 26 | } 27 | 28 | util::DynArray extensions; 29 | }; 30 | 31 | }} // game::editor 32 | } // clover 33 | 34 | #endif // CLOVER_GAME_EDITOR_EXTENSION_MGR_HPP 35 | -------------------------------------------------------------------------------- /code/source/global/eventreceiver.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_GLOBAL_EVENTRECEIVER_HPP 2 | #define CLOVER_GLOBAL_EVENTRECEIVER_HPP 3 | 4 | #include "build.hpp" 5 | #include "event.hpp" 6 | 7 | namespace clover { 8 | namespace global { 9 | 10 | class BaseEventForwarder; 11 | 12 | class EventReceiver { 13 | public: 14 | EventReceiver(); 15 | /// @todo Implement listen-state copying 16 | EventReceiver(const EventReceiver&)= default; 17 | EventReceiver(EventReceiver&&); 18 | virtual ~EventReceiver(); 19 | 20 | EventReceiver& operator=(const EventReceiver&)= default; 21 | EventReceiver& operator=(EventReceiver&&)= default; 22 | 23 | virtual void onEvent(global::Event&){}; 24 | 25 | void listenForEvent(global::Event::EType t); 26 | void unlistenForEvent(global::Event::EType t); 27 | 28 | private: 29 | uint32 listenCount; 30 | }; 31 | 32 | } // global 33 | } // clover 34 | 35 | #endif // CLOVER_GLOBAL_EVENTRECEIVER_HPP -------------------------------------------------------------------------------- /code/source/gui/element_attributefield_boolean.cpp: -------------------------------------------------------------------------------- 1 | #include "element_attributefield_boolean.hpp" 2 | 3 | namespace clover { 4 | namespace gui { 5 | 6 | AttributeFieldElement::AttributeFieldElement(const resources::AttributeDef& def) 7 | : AttributeFieldWrapElement(def) 8 | , checkBox("", util::Coord::VF(0), util::Coord::VF(0.03)){ 9 | addSubElement(checkBox); 10 | 11 | checkBox.setOnValueModifyCallback([=] (gui::CheckBoxElement& caller) { 12 | value= caller.isChecked(); 13 | OnValueModify(*this); 14 | }); 15 | } 16 | 17 | AttributeFieldElement::~AttributeFieldElement(){ 18 | } 19 | 20 | void AttributeFieldElement::onValueSet(){ 21 | checkBox.setChecked(value); 22 | //print(debug::Ch::Gui, debug::Vb::Trivial, "GuiAttriuteField::onValueSet(): value %i", value); 23 | } 24 | 25 | } // gui 26 | } // clover -------------------------------------------------------------------------------- /code/source/nodes/native_instances/nodeinstance_multiply_real.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_NODES_NODEINSTANCE_MULTIPLY_REAL_HPP 2 | #define CLOVER_NODES_NODEINSTANCE_MULTIPLY_REAL_HPP 3 | 4 | #include "../nodeinstance.hpp" 5 | #include "build.hpp" 6 | 7 | namespace clover { 8 | namespace nodes { 9 | 10 | class RealMultiplyNodeInstance final : public NodeInstance { 11 | public: 12 | static CompositionNodeLogic* compNode(); 13 | 14 | virtual void create() override; 15 | 16 | private: 17 | InputSlot* input1; 18 | InputSlot* input2; 19 | OutputSlot* realOut; 20 | }; 21 | 22 | } // nodes 23 | namespace util { 24 | 25 | template <> 26 | struct TypeStringTraits { 27 | static util::Str8 type(){ return "::RealMultiplyNodeInstance"; } 28 | }; 29 | 30 | } // util 31 | } // clover 32 | 33 | #endif // CLOVER_NODES_NODEINSTANCE_MULTIPLY_REAL_HPP 34 | -------------------------------------------------------------------------------- /code/source/util/rawarchive.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_UTIL_RAWARCHIVE_HPP 2 | #define CLOVER_UTIL_RAWARCHIVE_HPP 3 | 4 | #include "build.hpp" 5 | #include "serialization.hpp" 6 | 7 | #include 8 | 9 | namespace clover { 10 | namespace util { 11 | 12 | /// Binary archive which contains minimum data of serialized objects 13 | /// i.e. no field names 14 | /// @todo Worry about endianness and floats 15 | /// @todo Implementation 16 | class RawArchive { 17 | public: 18 | 19 | /// @return Serialized byte count 20 | template 21 | static SizeType serializePod(uint8* buf, const T* ptr, SizeType count= 1); 22 | 23 | /// @return Deserialized byte count 24 | template 25 | static SizeType deserializePod(const uint8* buf, T* ptr, SizeType count= 1); 26 | 27 | private: 28 | }; 29 | 30 | #include "rawarchive.tpp" 31 | 32 | } // util 33 | } // clover 34 | 35 | #endif // CLOVER_UTIL_RAWARCHIVE_HPP 36 | -------------------------------------------------------------------------------- /code/source/game/worldchunktask.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_GAME_WORLDCHUNKTASK_HPP 2 | #define CLOVER_GAME_WORLDCHUNKTASK_HPP 3 | 4 | #include "build.hpp" 5 | #include "worldgrid.hpp" 6 | 7 | namespace clover { 8 | namespace game { 9 | 10 | /// Chunk operation sliced over multiple frames 11 | class WorldChunkTask { 12 | public: 13 | WorldChunkTask(ChunkVec chunk_pos): chunkPosition(chunk_pos){} 14 | virtual ~WorldChunkTask(){} 15 | 16 | enum class UpdateState { 17 | Finished, /// Task has done everything it is supposed to 18 | Unfinished, /// More updates needed to finish 19 | Blocking /// Not finished, but waiting for some resource which is not available yet 20 | }; 21 | 22 | virtual UpdateState update()= 0; 23 | 24 | ChunkVec getChunkPosition() const { return chunkPosition; } 25 | 26 | private: 27 | ChunkVec chunkPosition; 28 | }; 29 | 30 | } // game 31 | } // clover 32 | 33 | #endif // CLOVER_GAME_WORLDCHUNKTASK_HPP -------------------------------------------------------------------------------- /code/source/gui/elementvisualentity_custom.cpp: -------------------------------------------------------------------------------- 1 | #include "elementvisualentity_custom.hpp" 2 | 3 | namespace clover { 4 | namespace gui { 5 | 6 | CustomElementVisualEntity::~CustomElementVisualEntity(){ 7 | } 8 | 9 | void CustomElementVisualEntity::setPositionTarget(const util::Coord& pos){ 10 | entity.setCoordinateSpace(pos.getType()); 11 | entity.setPosition(pos.getValue().xyz()); 12 | } 13 | 14 | util::Coord CustomElementVisualEntity::getPosition() const { 15 | return util::Coord(entity.getPosition().xy(), entity.getCoordinateSpace()); 16 | } 17 | 18 | void CustomElementVisualEntity::setRadiusTarget(const util::Coord& rad){ 19 | entity.setScaleCoordinateSpace(rad.getType()); 20 | entity.setScale(rad.getValue().xyz()); 21 | } 22 | 23 | util::Coord CustomElementVisualEntity::getRadius() const { 24 | return util::Coord(entity.getScale().xy(), entity.getScaleCoordinateSpace(), true);; 25 | } 26 | 27 | } // gui 28 | } // clover -------------------------------------------------------------------------------- /code/source/util/mem_pool.cpp: -------------------------------------------------------------------------------- 1 | #include "mem_pool.hpp" 2 | #include "util/ensure.hpp" 3 | 4 | namespace clover { 5 | namespace util { 6 | 7 | SizeType alignedMemAdjustment( uint8* addr, 8 | SizeType alignment){ 9 | SizeType mask= (alignment - 1); 10 | SizeType misalignment= 11 | reinterpret_cast(addr) & mask; 12 | SizeType adjustment= alignment - misalignment; 13 | 14 | debug_ensure(misalignment <= alignment); 15 | 16 | if (misalignment == 0) 17 | return 0; 18 | else 19 | return adjustment; 20 | } 21 | 22 | void MemPool::setMemory(MemChunk* chunk){ 23 | if (memChunk){ 24 | onMemoryRelease(); 25 | memChunk->release(); 26 | } 27 | 28 | memChunk= chunk; 29 | 30 | if (memChunk){ 31 | memChunk->acquire(); 32 | onMemoryAcquire(); 33 | } 34 | } 35 | 36 | const MemChunk& MemPool::memory() const { 37 | debug_ensure(memChunk); 38 | return *memChunk; 39 | } 40 | 41 | } // util 42 | } // clover -------------------------------------------------------------------------------- /code/source/util/poolview.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_UTIL_POOLVIEW_HPP 2 | #define CLOVER_UTIL_POOLVIEW_HPP 3 | 4 | #include "build.hpp" 5 | #include "util/ensure.hpp" 6 | #include "util/mem_pool_chunk.hpp" 7 | 8 | namespace clover { 9 | namespace util { 10 | 11 | /// View for memory pool 12 | /// @note Make sure that every type allocated in the pool is T 13 | template 14 | class PoolView { 15 | public: 16 | PoolView(ChunkMemPool& pool) 17 | : pool(&pool){ 18 | debug_ensure(pool.getChunkSize() == sizeof(T)); 19 | } 20 | 21 | T* operator[](SizeType i) const { 22 | return static_cast(pool->isUsed(i) ? pool->getPtr(i) : nullptr); 23 | } 24 | 25 | SizeType allocatedCount() const { return pool->getAllocatedCount(); } 26 | SizeType size() const { return pool->getChunkCount(); } 27 | 28 | private: 29 | ChunkMemPool* pool; 30 | }; 31 | 32 | } // util 33 | } // clover 34 | 35 | #endif // CLOVER_UTIL_POOLVIEW_HPP -------------------------------------------------------------------------------- /code/source/physics/chunk_util.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_PHYSICS_CHUNK_UTIL_HPP 2 | #define CLOVER_PHYSICS_CHUNK_UTIL_HPP 3 | 4 | #include "build.hpp" 5 | #include "util/vector.hpp" 6 | 7 | namespace clover { 8 | namespace physics { 9 | 10 | inline 11 | util::Vec2i chunkVec(util::Vec2d world_pos, real64 chunk_size) 12 | { return (world_pos/chunk_size).discretized(); } 13 | 14 | inline 15 | util::Vec2f asChunkOffset(util::Vec2d world_pos, real64 chunk_size) 16 | { 17 | util::Vec2d chunk_pos= (chunkVec(world_pos, chunk_size)*chunk_size). 18 | casted(); 19 | return (world_pos - chunk_pos).casted(); 20 | } 21 | 22 | inline 23 | util::Vec2d worldVec(util::Vec2f chunk_offset, util::Vec2i chunk_pos, real64 chunk_size) 24 | { return chunk_offset.casted() + chunk_pos.casted()*chunk_size; } 25 | 26 | } // physics 27 | } // clover 28 | 29 | #endif // CLOVER_PHYSICS_CHUNK_UTIL_HPP 30 | -------------------------------------------------------------------------------- /code/source/nodes/native_instances/nodeinstance_guiinput.cpp: -------------------------------------------------------------------------------- 1 | #include "gui/cursor.hpp" 2 | #include "gui/gui_mgr.hpp" 3 | #include "nodeinstance_guiinput.hpp" 4 | 5 | namespace clover { 6 | namespace nodes { 7 | 8 | CompositionNodeLogic* GuiInputNodeInstance::compNode() 9 | { 10 | auto n= new CompositionNodeLogic{}; 11 | n->addInputSlot("channelName", SignalType::String, util::Str8("host")); 12 | n->addOutputSlot("cursorPos_world", SignalType::Vec2); 13 | return n; 14 | } 15 | 16 | void GuiInputNodeInstance::create() 17 | { 18 | channelNameIn= addInputSlot("channelName"); 19 | cursorPos_world= addOutputSlot("cursorPos_world"); 20 | setUpdateNeeded(true); 21 | } 22 | 23 | void GuiInputNodeInstance::update() 24 | { 25 | cursorPos_world->send( 26 | global::g_env.guiMgr->getCursor().getPosition(). 27 | converted(util::Coord::World).getValue()); 28 | } 29 | 30 | } // nodes 31 | } // clover 32 | -------------------------------------------------------------------------------- /code/source/util/exception.cpp: -------------------------------------------------------------------------------- 1 | #include "exception.hpp" 2 | #include "debug/print.hpp" 3 | #include "util/string.hpp" 4 | 5 | namespace clover { 6 | namespace util { 7 | 8 | Exception::Exception(const char* s, ...){ 9 | va_list argList; 10 | va_start(argList, s); 11 | 12 | constructor(s, argList); 13 | 14 | va_end(argList); 15 | } 16 | 17 | Exception::Exception(const char8* s, va_list arglist){ 18 | constructor(s, arglist); 19 | } 20 | 21 | Exception::Exception(){ 22 | } 23 | 24 | void Exception::constructor(const char8* s, va_list arglist){ 25 | /// @todo This is bad 26 | static util::Str8 er; 27 | er.setFormattedArgList(s, arglist); 28 | error= er.cStr(); 29 | 30 | print(debug::Ch::General, debug::Vb::Critical, "Exception thrown: %s", error); 31 | } 32 | 33 | Exception::~Exception() throw() { 34 | } 35 | 36 | const char* Exception::what() const throw() { 37 | return error; 38 | } 39 | 40 | } // util 41 | } // clover 42 | -------------------------------------------------------------------------------- /code/source/audio/audiostream_raw.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_AUDIO_AUDIOSTREAM_RAW_HPP 2 | #define CLOVER_AUDIO_AUDIOSTREAM_RAW_HPP 3 | 4 | #include "build.hpp" 5 | #include "audiostream.hpp" 6 | 7 | namespace clover { 8 | namespace audio { 9 | 10 | /// A stream of floating point samples 11 | class RawAudioStream : public AudioStream { 12 | public: 13 | /// @param samples_begin Pointer (iterator) to the begin of sample-array 14 | /// @param samples_begin Pointer (iterator) to the end of sample-array 15 | /// @param accessMutex Mutex to prevent reading in feed thread when sound is changing 16 | RawAudioStream(const real32* samples_begin, const real32* samples_end); 17 | virtual ~RawAudioStream(); 18 | 19 | virtual ChannelData getNextSamples(SizeType request_count); 20 | 21 | private: 22 | const real32* begin, 23 | * end, 24 | * current; 25 | }; 26 | 27 | } // audio 28 | } // clover 29 | 30 | #endif // CLOVER_AUDIO_AUDIOSTREAM_RAW_HPP -------------------------------------------------------------------------------- /code/source/physics/potentialfield.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_PHYSICS_POTENTIALFIELD_HPP 2 | #define CLOVER_PHYSICS_POTENTIALFIELD_HPP 3 | 4 | #include "build.hpp" 5 | #include "fluidparticle.hpp" 6 | #include "visual/framebuffer.hpp" 7 | #include "visual/mesh.hpp" 8 | #include "visual/shader.hpp" 9 | 10 | namespace clover { 11 | namespace physics { 12 | 13 | /// Potential field for fluids 14 | /// @note Uses OpenGL for calculations 15 | class PotentialField { 16 | public: 17 | PotentialField(uint32 chunk_reso, uint32 chunks); 18 | void update(uint32 chunk_size, 19 | const visual::PointMesh& particles, 20 | hardware::GlState::TexDId chunk_info_tex); 21 | 22 | const visual::Framebuffer& getFbo() const { return fbo; } 23 | 24 | private: 25 | visual::Shader shader; 26 | visual::Framebuffer fbo; 27 | uint32 chunkCount; 28 | }; 29 | 30 | } // physics 31 | } // clover 32 | 33 | #endif // CLOVER_PHYSICS_POTENTIALFIELD_HPP 34 | -------------------------------------------------------------------------------- /code/source/util/crashhandler.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_UTIL_CRASHHANDLER_HPP 2 | #define CLOVER_UTIL_CRASHHANDLER_HPP 3 | 4 | #include "build.hpp" 5 | 6 | #if OS == OS_LINUX 7 | #include 8 | #endif 9 | 10 | #include 11 | #include 12 | 13 | namespace clover { 14 | namespace util { 15 | 16 | class CrashHandler { 17 | public: 18 | CrashHandler(); 19 | ~CrashHandler(); 20 | 21 | void onUnhandledException(const std::exception& e); 22 | 23 | static std::string getBacktrace(uint32 frames_to_skip= 0); 24 | 25 | private: 26 | static std::string getOutputFilePath(); 27 | 28 | void registerSignalHandler(); 29 | 30 | // Platform specific stuff 31 | #if OS == OS_WINDOWS 32 | static void onSignal(int sig); 33 | #elif OS == OS_LINUX 34 | static void onSignal(int sig, siginfo_t* info, void* secret); 35 | #endif 36 | }; 37 | 38 | } // util 39 | } // clover 40 | 41 | #endif // CLOVER_UTIL_CRASHHANDLER_HPP 42 | -------------------------------------------------------------------------------- /code/source/util/mem_chunk.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_UTIL_MEM_CHUNK_HPP 2 | #define CLOVER_UTIL_MEM_CHUNK_HPP 3 | 4 | #include "build.hpp" 5 | #include "util/class_preproc.hpp" 6 | #include "util/tidy_ptr.hpp" 7 | 8 | namespace clover { 9 | namespace util { 10 | 11 | /// Contiguous block of memory for memory pools 12 | class MemChunk { 13 | public: 14 | MemChunk(SizeType size, const char* tag); 15 | DELETE_COPY(MemChunk); 16 | DEFAULT_MOVE(MemChunk); 17 | ~MemChunk(); 18 | 19 | void acquire(); 20 | void release(); 21 | 22 | uint8* begin() const { return memory.get(); } 23 | uint8* end() const { return memory.get() + size(); } 24 | SizeType size() const { return sizeBytes; } 25 | 26 | const char* getTag() const { return tag; } 27 | 28 | private: 29 | TidyPtr memory; 30 | SizeType sizeBytes; 31 | bool acquired; 32 | const char* tag; 33 | }; 34 | 35 | } // util 36 | } // clover 37 | 38 | #endif // CLOVER_UTIL_MEM_CHUNK_HPP 39 | -------------------------------------------------------------------------------- /code/source/game/editor/editorview.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_GAME_EDITOR_EDITORVIEW_HPP 2 | #define CLOVER_GAME_EDITOR_EDITORVIEW_HPP 3 | 4 | #include "build.hpp" 5 | #include "editorcomponent.hpp" 6 | #include "util/dyn_array.hpp" 7 | 8 | #include 9 | 10 | namespace clover { 11 | namespace game { namespace editor { 12 | 13 | /// A screenful of editor 14 | class EditorView { 15 | public: 16 | EditorView(); 17 | EditorView(const EditorView&)= delete; 18 | EditorView(EditorView&&)= default; 19 | virtual ~EditorView(); 20 | 21 | void setActive(bool b=true); 22 | 23 | EditorComponent& createComponent(const util::Str8& name); 24 | void destroyComponent(EditorComponent& comp); 25 | 26 | bool hasComponent(const util::Str8& type_name); 27 | 28 | private: 29 | bool active; 30 | util::DynArray> components; 31 | }; 32 | 33 | }} // game::editor 34 | } // clover 35 | 36 | #endif // CLOVER_GAME_EDITOR_EDITORVIEW_HPP -------------------------------------------------------------------------------- /code/source/game/world_gen/workerlocation.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_GAME_WORLD_GEN_WORKERLOCATION_HPP 2 | #define CLOVER_GAME_WORLD_GEN_WORKERLOCATION_HPP 3 | 4 | #include "build.hpp" 5 | #include "game/worldgrid.hpp" 6 | #include "util/vector.hpp" 7 | 8 | namespace clover { 9 | namespace game { namespace world_gen { 10 | 11 | class ChunkGen; 12 | 13 | class WorkerLocation { 14 | public: 15 | WorkerLocation()= default; 16 | WorkerLocation(WorldVec pos, real64 t, ChunkGen* c) 17 | : position(pos), time(t), chunkGen(c){} 18 | 19 | WorldVec getPosition() const { return position; } 20 | real64 getTime() const { return time; } 21 | ChunkGen& getChunkGen() const { ensure(chunkGen); return *chunkGen; } 22 | 23 | private: 24 | friend class ChunkGen; 25 | WorldVec position; 26 | real64 time= 0.0; 27 | ChunkGen* chunkGen= nullptr; 28 | }; 29 | 30 | }} // game::world_gen 31 | } // clover 32 | 33 | #endif // CLOVER_GAME_WORLD_GEN_WORKERLOCATION_HPP 34 | -------------------------------------------------------------------------------- /code/source/audio/audioreceiver.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_AUDIORECEIVER_HPP 2 | #define CLOVER_AUDIORECEIVER_HPP 3 | 4 | #include "build.hpp" 5 | #include "util/math.hpp" 6 | #include "util/mutex.hpp" 7 | #include "util/referencecountable.hpp" 8 | 9 | namespace clover { 10 | namespace audio { 11 | 12 | /// Internal class of the audiosystem 13 | /// Needed for output of spatial sounds 14 | class AudioReceiver : public util::ReferenceCountable { 15 | public: 16 | AudioReceiver(); 17 | AudioReceiver(AudioReceiver&& other); 18 | virtual ~AudioReceiver(); 19 | 20 | void create(); 21 | void destroy(); 22 | 23 | void setPosition(const util::Vec2d& pos); 24 | 25 | // Called asynchronously 26 | util::Vec2d getPosition() const; 27 | 28 | private: 29 | bool created; 30 | util::Vec2d position; 31 | real32 lowpass; 32 | 33 | mutable util::Mutex accessMutex; 34 | }; 35 | 36 | } // audio 37 | } // clover 38 | 39 | #endif // CLOVER_AUDIORECEIVER_HPP 40 | -------------------------------------------------------------------------------- /code/source/nodes/native_instances/nodeinstance_add_real.cpp: -------------------------------------------------------------------------------- 1 | #include "nodeinstance_add_real.hpp" 2 | 3 | namespace clover { 4 | namespace nodes { 5 | 6 | CompositionNodeLogic* RealAddNodeInstance::compNode() 7 | { 8 | auto n= new CompositionNodeLogic{}; 9 | n->addInputSlot("input1", SignalType::Real, 0.0); 10 | n->addInputSlot("input2", SignalType::Real, 0.0); 11 | n->addOutputSlot("result", SignalType::Real); 12 | return n; 13 | } 14 | 15 | void RealAddNodeInstance::create() 16 | { 17 | input1= addInputSlot("input1"); 18 | input2= addInputSlot("input2"); 19 | realOut= addOutputSlot("result"); 20 | 21 | auto recv= +[] (RealAddNodeInstance* self) 22 | { self->realOut->send(self->input1->get() + self->input2->get()); }; 23 | 24 | input1->setOnReceiveCallback(recv); 25 | input2->setOnReceiveCallback(recv); 26 | 27 | setUpdateNeeded(false); 28 | } 29 | 30 | } // nodes 31 | } // clover 32 | -------------------------------------------------------------------------------- /code/source/nodes/native_instances/nodeinstance_guiinput.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_NODES_NODEINSTANCE_GUIINPUT_HPP 2 | #define CLOVER_NODES_NODEINSTANCE_GUIINPUT_HPP 3 | 4 | #include "../nodeinstance.hpp" 5 | #include "build.hpp" 6 | 7 | namespace clover { 8 | namespace nodes { 9 | 10 | /// Provides information of gui interactions 11 | class GuiInputNodeInstance final : public NodeInstance { 12 | public: 13 | static CompositionNodeLogic* compNode(); 14 | 15 | virtual void create() override; 16 | virtual void update() override; 17 | 18 | private: 19 | InputSlot* channelNameIn; 20 | OutputSlot* cursorPos_world; 21 | }; 22 | 23 | } // nodes 24 | namespace util { 25 | 26 | template <> 27 | struct TypeStringTraits { 28 | static util::Str8 type(){ return "::GuiInputNodeInstance"; } 29 | }; 30 | 31 | } // util 32 | } // clover 33 | 34 | #endif // CLOVER_NODES_NODEINSTANCE_GUIIINPUT_HPP 35 | -------------------------------------------------------------------------------- /code/source/util/parallel_queue.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_UTIL_PARALLER_QUEUE_HPP 2 | #define CLOVER_UTIL_PARALLER_QUEUE_HPP 3 | 4 | #include "build.hpp" 5 | #include "hardware/clstate.hpp" 6 | 7 | namespace clover { 8 | namespace util { 9 | 10 | class ParallelKernel; 11 | class ParallelBuffer; 12 | 13 | class ParallelQueue { 14 | public: 15 | ParallelQueue(); 16 | ParallelQueue(const ParallelQueue&)= delete; 17 | ParallelQueue(ParallelQueue&&); 18 | virtual ~ParallelQueue(); 19 | 20 | ParallelQueue& operator=(ParallelQueue&&); 21 | ParallelQueue& operator=(const ParallelQueue&)= delete; 22 | 23 | void flush(); 24 | void finish(); 25 | 26 | protected: 27 | friend class util::ParallelKernel; 28 | friend class util::ParallelBuffer; 29 | 30 | void enqueue(const hardware::ClState::Work& w); 31 | 32 | private: 33 | hardware::ClState::CommandQueue queue; 34 | }; 35 | 36 | } // util 37 | } // clover 38 | 39 | #endif // CLOVER_UTIL_PARALLER_QUEUE_HPP -------------------------------------------------------------------------------- /code/source/visual/entity_def.cpp: -------------------------------------------------------------------------------- 1 | #include "entity_def.hpp" 2 | #include "entitylogic.hpp" 3 | 4 | namespace clover { 5 | namespace visual { 6 | 7 | EntityDef::EntityDef() 8 | : type(Type::None) 9 | , INIT_RESOURCE_ATTRIBUTE(nameAttribute, "name", "") 10 | , INIT_RESOURCE_ATTRIBUTE(offsetAttribute, "offset", util::SrtTransform3d()){ 11 | } 12 | 13 | EntityDef::~EntityDef(){ 14 | } 15 | 16 | EntityDef::Type EntityDef::getType() const { 17 | return type; 18 | } 19 | 20 | EntityLogic* EntityDef::createLogic() const { 21 | return new EntityLogic(*this); 22 | } 23 | 24 | void EntityDef::resourceUpdate(bool load, bool force){ 25 | 26 | if (load || getResourceState() == State::Uninit){ 27 | /// @todo 28 | setResourceState(State::Loaded); 29 | } 30 | else { 31 | setResourceState(State::Unloaded); 32 | } 33 | } 34 | 35 | void EntityDef::createErrorResource(){ 36 | setResourceState(State::Error); 37 | } 38 | 39 | } // visual 40 | } // clover -------------------------------------------------------------------------------- /code/source/game/world_gen/worker.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_GAME_WORLD_GEN_WORKER_HPP 2 | #define CLOVER_GAME_WORLD_GEN_WORKER_HPP 3 | 4 | #include "build.hpp" 5 | #include "workerlocation.hpp" 6 | 7 | namespace clover { 8 | namespace game { namespace world_gen { 9 | 10 | class ChunkGen; 11 | class WorkerType; 12 | 13 | class Worker { 14 | public: 15 | Worker(const util::Str8& type, WorkerLocation loc, real64 radius); 16 | 17 | /// @todo Remove, just have getPosition etc. directly here 18 | const WorkerLocation& getLocation() const { return location; } 19 | real64 getRadius() const { return radius; } 20 | real64 getCreationTime() const { return creationTime; } 21 | 22 | void work() const; 23 | 24 | private: 25 | friend class ChunkGen; 26 | const WorkerType* type; 27 | WorkerLocation location; 28 | real64 radius; 29 | real64 creationTime; 30 | }; 31 | 32 | }} // game::world_gen 33 | } // clover 34 | 35 | #endif // CLOVER_GAME_WORLD_GEN_WORKER_HPP 36 | -------------------------------------------------------------------------------- /code/source/gui/element_attributefield_signalargument.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_GUI_ATTRIBUTEFIELD_SIGNALARGUMENT_HPP 2 | #define CLOVER_GUI_ATTRIBUTEFIELD_SIGNALARGUMENT_HPP 3 | 4 | #include "build.hpp" 5 | #include "element_attributefield.hpp" 6 | #include "element_combobox.hpp" 7 | #include "element_layout_linear.hpp" 8 | #include "element_textfield.hpp" 9 | 10 | namespace clover { 11 | namespace gui { 12 | 13 | template <> 14 | class AttributeFieldElement : public AttributeFieldWrapElement { 15 | public: 16 | AttributeFieldElement(const resources::AttributeDef& def); 17 | virtual ~AttributeFieldElement(){} 18 | 19 | private: 20 | virtual void onValueSet() override; 21 | 22 | LinearLayoutElement layout; 23 | ComboBoxElement typeCombo; 24 | TextFieldElement nameField; 25 | }; 26 | 27 | } // gui 28 | } // clover 29 | 30 | #endif // CLOVER_GUI_ATTRIBUTEFIELD_SIGNALARGUMENT_HPP -------------------------------------------------------------------------------- /code/source/nodes/native_instances/nodeinstance_logicor.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_NODES_NODEINSTANCE_LOGICOR_HPP 2 | #define CLOVER_NODES_NODEINSTANCE_LOGICOR_HPP 3 | 4 | #include "../nodeinstance.hpp" 5 | #include "build.hpp" 6 | 7 | namespace clover { 8 | namespace nodes { 9 | 10 | class LogicOrNodeInstance final : public NodeInstance { 11 | public: 12 | static CompositionNodeLogic* compNode(); 13 | 14 | virtual ~LogicOrNodeInstance(){} 15 | 16 | virtual void create(); 17 | virtual void update(); 18 | 19 | private: 20 | InputSlot* input1; 21 | InputSlot* input2; 22 | OutputSlot* output; 23 | 24 | }; 25 | 26 | } // nodes 27 | namespace util { 28 | 29 | template <> 30 | struct TypeStringTraits { 31 | static util::Str8 type(){ return "::LogicOrNodeInstance"; } 32 | }; 33 | 34 | } // util 35 | } // clover 36 | 37 | #endif // CLOVER_NODES_NODEINSTANCE_LOGICOR_HPP 38 | -------------------------------------------------------------------------------- /code/source/physics/fixture.cpp: -------------------------------------------------------------------------------- 1 | #include "fixture.hpp" 2 | #include "resources/cache.hpp" 3 | 4 | namespace clover { 5 | namespace physics { 6 | 7 | util::LinkedList FixtureDef::fixtureDefs; 8 | 9 | FixtureDef::FixtureDef(){ 10 | fixtureDefs.pushBack(this); 11 | fixtureIt= --fixtureDefs.end(); 12 | } 13 | 14 | FixtureDef::FixtureDef(FixtureDef&& other): 15 | material(std::move(other.material)){ 16 | 17 | fixtureIt= other.fixtureIt; 18 | *fixtureIt= this; 19 | other.fixtureIt= fixtureDefs.end(); 20 | } 21 | 22 | FixtureDef::FixtureDef(const FixtureDef& other): 23 | material(other.material){ 24 | 25 | fixtureDefs.pushBack(this); 26 | fixtureIt= --fixtureDefs.end(); 27 | } 28 | 29 | FixtureDef::~FixtureDef(){ 30 | if (fixtureIt != fixtureDefs.end()){ 31 | fixtureDefs.erase(fixtureIt); 32 | } 33 | } 34 | 35 | void FixtureDef::setMaterial(const physics::Material& mat){ 36 | material= &mat; 37 | } 38 | 39 | } // physics 40 | } // clover -------------------------------------------------------------------------------- /code/source/game/basegamelogic.cpp: -------------------------------------------------------------------------------- 1 | #include "basegamelogic.hpp" 2 | #include "ingamelogic.hpp" 3 | #include "devlogic.hpp" 4 | #include "global/cfg_mgr.hpp" 5 | #include "global/env.hpp" 6 | #include "util/profiling.hpp" 7 | #include "util/time.hpp" 8 | 9 | namespace clover { 10 | namespace game { 11 | 12 | BaseGameLogic::BaseGameLogic(){ 13 | if (!global::g_env.gameLogic) 14 | global::g_env.gameLogic= this; 15 | 16 | inGameLogic= new InGameLogic(); 17 | devLogic= new DevLogic(); 18 | } 19 | 20 | BaseGameLogic::~BaseGameLogic(){ 21 | delete inGameLogic; 22 | delete devLogic; 23 | 24 | if (global::g_env.gameLogic == this) 25 | global::g_env.gameLogic= nullptr; 26 | } 27 | 28 | void BaseGameLogic::update(){ 29 | PROFILE(); 30 | 31 | devLogic->update(); 32 | 33 | if (inGameLogic) 34 | inGameLogic->update(); 35 | } 36 | 37 | void BaseGameLogic::onQuit(){ 38 | if (inGameLogic) 39 | inGameLogic->onQuit(); 40 | } 41 | 42 | } // game 43 | } // clover 44 | -------------------------------------------------------------------------------- /code/source/game/editor/components/ec_console.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_GAME_EDITOR_EC_CONSOLE_HPP 2 | #define CLOVER_GAME_EDITOR_EC_CONSOLE_HPP 3 | 4 | #include "../editorcomponent.hpp" 5 | #include "build.hpp" 6 | #include "debug/print.hpp" 7 | 8 | namespace clover { 9 | namespace game { namespace editor { 10 | 11 | class ConsoleEc; 12 | 13 | template <> 14 | struct EditorComponentTraits { 15 | static const util::Str8 name(){ return "Console"; } 16 | }; 17 | 18 | class ConsoleEc : public EditorComponent { 19 | public: 20 | DECLARE_EDITORCOMPONENT(ConsoleEc); 21 | virtual ~ConsoleEc(); 22 | 23 | void setVerbosity(debug::Vb v); 24 | debug::Vb getVerbosity() const; 25 | 26 | void setChannelActive(debug::Ch id, bool b); 27 | bool isChannelActive(debug::Ch id) const; 28 | 29 | void tryExecute(const util::Str8& string); 30 | 31 | private: 32 | }; 33 | 34 | }} // game::editor 35 | } // clover 36 | 37 | #endif // CLOVER_GAME_EDITOR_EC_CONSOLE_HPP 38 | -------------------------------------------------------------------------------- /code/source/gui/element_2dcontroller.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_GUI_2DCONTROLLER_HPP 2 | #define CLOVER_GUI_2DCONTROLLER_HPP 3 | 4 | #include "build.hpp" 5 | #include "element.hpp" 6 | #include "element_button.hpp" 7 | #include "visual/entity_def_model.hpp" 8 | 9 | namespace clover { 10 | namespace gui { 11 | 12 | /// 2d area with moveable point 13 | class Controller2dElement : public Element { 14 | public: 15 | Controller2dElement(const util::Coord& pos, const util::Coord& rad); 16 | virtual ~Controller2dElement(); 17 | 18 | virtual void postUpdate(); 19 | 20 | /// @return [(-1,-1), (1,1)] 21 | util::Vec2d getValue(){ return value; } 22 | 23 | void setCircleBoundary(bool b=true){ circleBoundary= b; } 24 | 25 | protected: 26 | void updateRE(); 27 | 28 | util::Vec2d value; 29 | bool circleBoundary; 30 | 31 | //visual::ModelEntity* bgRE; 32 | //visual::ModelEntity* pointRE; 33 | }; 34 | 35 | } // gui 36 | } // clover 37 | 38 | #endif // CLOVER_GUI_2DCONTROLLER_HPP -------------------------------------------------------------------------------- /code/source/nodes/native_instances/nodeinstance_lerp_vec2.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_NODES_NODEINSTANCE_LERP_VEC2_HPP 2 | #define CLOVER_NODES_NODEINSTANCE_LERP_VEC2_HPP 3 | 4 | #include "../nodeinstance.hpp" 5 | #include "build.hpp" 6 | 7 | namespace clover { 8 | namespace nodes { 9 | 10 | class Vec2LerpNodeInstance final : public NodeInstance { 11 | public: 12 | static CompositionNodeLogic* compNode(); 13 | 14 | virtual void create() override; 15 | virtual void update() override; 16 | 17 | private: 18 | InputSlot* in1; 19 | InputSlot* in2; 20 | InputSlot* factorIn; 21 | OutputSlot* resultOut; 22 | }; 23 | 24 | } // nodes 25 | namespace util { 26 | 27 | template <> 28 | struct TypeStringTraits { 29 | static util::Str8 type(){ return "::Vec2LerpNodeInstance"; } 30 | }; 31 | 32 | } // util 33 | } // clover 34 | 35 | #endif // CLOVER_NODES_NODEINSTANCE_LERP_VEC2_HPP 36 | -------------------------------------------------------------------------------- /code/source/util/pair.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_UTIL_PAIR_HPP 2 | #define CLOVER_UTIL_PAIR_HPP 3 | 4 | #include "build.hpp" 5 | #include "hash.hpp" 6 | #include "key.hpp" 7 | 8 | #include 9 | 10 | namespace clover { 11 | namespace util { 12 | 13 | template 14 | using Pair= std::pair; 15 | 16 | template 17 | Pair::type, typename std::decay::type> 18 | makePair(A&& a, B&& b){ 19 | return std::make_pair(std::forward(a), std::forward(b)); 20 | } 21 | 22 | template 23 | struct Hash32> { 24 | uint32 operator()(const Pair& value) const 25 | { return hash32(value.first) + hash32(value.second)*65536; } 26 | }; 27 | 28 | namespace detail { 29 | 30 | template 31 | struct Key> { 32 | using Type= K; 33 | }; 34 | 35 | } // detail 36 | } // util 37 | } // clover 38 | 39 | #endif // CLOVER_UTIL_PAIR_HPP 40 | -------------------------------------------------------------------------------- /code/deps/common/freetype-2.5.3/src/gzip/infcodes.h: -------------------------------------------------------------------------------- 1 | /* infcodes.h -- header to use infcodes.c 2 | * Copyright (C) 1995-2002 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | #ifndef _INFCODES_H 12 | #define _INFCODES_H 13 | 14 | struct inflate_codes_state; 15 | typedef struct inflate_codes_state FAR inflate_codes_statef; 16 | 17 | local inflate_codes_statef *inflate_codes_new OF(( 18 | uInt, uInt, 19 | inflate_huft *, inflate_huft *, 20 | z_streamp )); 21 | 22 | local int inflate_codes OF(( 23 | inflate_blocks_statef *, 24 | z_streamp , 25 | int)); 26 | 27 | local void inflate_codes_free OF(( 28 | inflate_codes_statef *, 29 | z_streamp )); 30 | 31 | #endif /* _INFCODES_H */ 32 | -------------------------------------------------------------------------------- /code/source/nodes/native_instances/nodeinstance_multiply_real.cpp: -------------------------------------------------------------------------------- 1 | #include "nodeinstance_multiply_real.hpp" 2 | 3 | namespace clover { 4 | namespace nodes { 5 | 6 | CompositionNodeLogic* RealMultiplyNodeInstance::compNode() 7 | { 8 | auto n= new CompositionNodeLogic{}; 9 | n->addInputSlot("input1", SignalType::Real, 0.0); 10 | n->addInputSlot("input2", SignalType::Real, 0.0); 11 | n->addOutputSlot("result", SignalType::Real); 12 | return n; 13 | } 14 | 15 | void RealMultiplyNodeInstance::create() 16 | { 17 | input1= addInputSlot("input1"); 18 | input2= addInputSlot("input2"); 19 | realOut= addOutputSlot("result"); 20 | 21 | auto recv= +[] (RealMultiplyNodeInstance* self) 22 | { self->realOut->send(self->input1->get()*self->input2->get()); }; 23 | 24 | input1->setOnReceiveCallback(recv); 25 | input2->setOnReceiveCallback(recv); 26 | 27 | setUpdateNeeded(false); 28 | } 29 | 30 | } // nodes 31 | } // clover 32 | -------------------------------------------------------------------------------- /code/source/ui/game/inventory_gui.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_GUI_INVENTORY_HPP 2 | #define CLOVER_GUI_INVENTORY_HPP 3 | 4 | #include "build.hpp" 5 | #include "gui/element_panel.hpp" 6 | #include "gui/element_layout_grid.hpp" 7 | #include "gui/element_we_icon.hpp" 8 | #include "game/worldentity_handle.hpp" 9 | 10 | namespace clover { 11 | namespace ui { namespace game { 12 | 13 | using namespace clover::game; 14 | 15 | class InventoryGui : public gui::Element { 16 | public: 17 | InventoryGui(); 18 | virtual ~InventoryGui(); 19 | 20 | /// @return Returns true if adding succeeded 21 | void add(const game::WeHandle& h); 22 | void remove(const game::WeHandle& h); 23 | 24 | void toggle(); 25 | 26 | gui::WeIconElement* getTriggeredIcon(); 27 | 28 | protected: 29 | gui::PanelElement bgPanel; 30 | gui::GridLayoutElement gridLayout; 31 | 32 | util::LinkedList items; 33 | }; 34 | 35 | }} // ui::game 36 | } // clover 37 | 38 | #endif // CLOVER_GUI_INVENTORY_HPP -------------------------------------------------------------------------------- /code/source/visual/vertexattribute.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_VISUAL_VERTEXATTRIBUTE_HPP 2 | #define CLOVER_VISUAL_VERTEXATTRIBUTE_HPP 3 | 4 | #include "build.hpp" 5 | #include "hardware/glstate.hpp" 6 | #include "util/string.hpp" 7 | 8 | namespace clover { 9 | namespace visual { 10 | 11 | struct VertexAttribute { 12 | /// Offset from beginning of the struct (in bytes) 13 | uint32 offset= 0; 14 | 15 | /// Type of a single element (e.g. hardware::GlState::Type::Real32 for util::Vec2f) 16 | hardware::GlState::Type elemType= hardware::GlState::Type::Real32; 17 | 18 | /// Numer of elements (e.g. 2 for util::Vec2f) 19 | uint32 elemCount= 0; 20 | 21 | /// Number of values in an array (e.g. 1 for util::Vec2f) 22 | uint32 arraySize= 1; 23 | 24 | /// @see OpenGL spec for glVertexAttribPointer 25 | bool normalized= false; 26 | 27 | /// Name in shader 28 | util::Str8 name; 29 | }; 30 | 31 | } // visual 32 | } // clover 33 | 34 | #endif // CLOVER_VISUAL_VERTEXATTRIBUTE_HPP 35 | -------------------------------------------------------------------------------- /code/source/nodes/native_instances/nodeinstance_pow_real.cpp: -------------------------------------------------------------------------------- 1 | #include "nodeinstance_pow_real.hpp" 2 | 3 | namespace clover { 4 | namespace nodes { 5 | 6 | CompositionNodeLogic* RealPowNodeInstance::compNode() 7 | { 8 | auto n= new CompositionNodeLogic{}; 9 | n->addInputSlot("base", SignalType::Real, 0.0); 10 | n->addInputSlot("exponent", SignalType::Real, 0.0); 11 | n->addOutputSlot("output", SignalType::Real); 12 | return n; 13 | } 14 | 15 | void RealPowNodeInstance::create() 16 | { 17 | baseInput= addInputSlot("base"); 18 | exponentInput= addInputSlot("exponent"); 19 | 20 | realOut= addOutputSlot("output"); 21 | 22 | auto recv= +[] (RealPowNodeInstance* self) 23 | { self->realOut->send(pow(self->baseInput->get(), self->exponentInput->get())); }; 24 | baseInput->setOnReceiveCallback(recv); 25 | exponentInput->setOnReceiveCallback(recv); 26 | 27 | setUpdateNeeded(false); 28 | } 29 | 30 | } // nodes 31 | } // clover 32 | -------------------------------------------------------------------------------- /code/source/audio/audiodevice_dummy.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_AUDIO_AUDIODEVICE_DUMMY_HPP 2 | #define CLOVER_AUDIO_AUDIODEVICE_DUMMY_HPP 3 | 4 | #include "audiodevice.hpp" 5 | #include "build.hpp" 6 | #include "outputstream.hpp" 7 | 8 | /// @todo Replace with util::Thread 9 | #include 10 | 11 | namespace clover { 12 | namespace audio { 13 | 14 | /// Doesn't output anything, used when audio is disabled 15 | class DummyAudioDevice : public AudioDevice { 16 | public: 17 | DummyAudioDevice(); 18 | virtual ~DummyAudioDevice(); 19 | 20 | OutputStream& getOutputStream(){ return outputStream; } 21 | 22 | private: 23 | /// Reads outputStream like normal audio device, but doesn't output any audio 24 | /// Runs in outputSimulatorThread 25 | void outputSimulator(); 26 | 27 | OutputStream outputStream; 28 | std::atomic runSimulatorThread; 29 | std::thread outputSimulatorThread; 30 | }; 31 | 32 | } // audio 33 | } // clover 34 | 35 | #endif // CLOVER_AUDIO_AUDIODEVICE_DUMMY_HPP 36 | -------------------------------------------------------------------------------- /code/source/ui/game/editor/editorcomponent_ui_factory.cpp: -------------------------------------------------------------------------------- 1 | #include "editorcomponent_ui_factory.hpp" 2 | #include "game/editor/editorcomponent.hpp" 3 | #include "editorcomponent_ui.hpp" 4 | 5 | #define EC_HEADERS 6 | #include "game/editor/components/components.def" 7 | #undef EC_HEADERS 8 | 9 | namespace clover { 10 | namespace ui { namespace game { namespace editor { 11 | 12 | std::shared_ptr EditorComponentUiFactory::create(EditorComponent& comp){ 13 | 14 | #define EC(ui_type) \ 15 | if (comp.getName() == ui_type::getComponentName()){ \ 16 | ui_type::ComponentType* ptr= dynamic_cast(&comp); \ 17 | ensure(ptr); \ 18 | return (std::shared_ptr(new ui_type(*ptr))); \ 19 | } 20 | #include "game/editor/components/components.def" 21 | #undef EC 22 | 23 | throw global::Exception("Corresponding EditorComponentUi not found for component %s", comp.getName().cStr()); 24 | } 25 | 26 | }}} // ui::game::editor 27 | } // clover -------------------------------------------------------------------------------- /code/source/util/key.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_UTIL_KEY_HPP 2 | #define CLOVER_UTIL_KEY_HPP 3 | 4 | #include "build.hpp" 5 | #include "dyn_array.hpp" 6 | 7 | namespace clover { 8 | namespace util { 9 | namespace detail { 10 | 11 | template 12 | struct Key; 13 | 14 | template 15 | struct Key { using Type= typename Key::Type; }; 16 | template 17 | struct Key { using Type= typename Key::Type; }; 18 | template 19 | struct Key { using Type= typename Key::Type; }; 20 | 21 | } // detail 22 | 23 | /// Type of key of container C 24 | template 25 | using Key= typename detail::Key::Type; 26 | 27 | /// Keys of container C 28 | template 29 | auto keys(const C& c) 30 | -> DynArray> 31 | { 32 | DynArray> ret; 33 | for (auto&& pair : c) { 34 | ret.pushBack(pair.first); 35 | } 36 | return ret; 37 | } 38 | 39 | } // clover 40 | } // util 41 | 42 | #endif // CLOVER_UTIL_KEY_HPP 43 | -------------------------------------------------------------------------------- /code/source/ui/game/ingame_ui.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_UI_GAME_INGAME_UI_HPP 2 | #define CLOVER_UI_GAME_INGAME_UI_HPP 3 | 4 | #include "audio/audioreceiverhandle.hpp" 5 | #include "build.hpp" 6 | #include "global/eventreceiver.hpp" 7 | #include "gui/element_worldinterface.hpp" 8 | #include "visual/camera.hpp" 9 | 10 | namespace clover { 11 | namespace ui { namespace game { 12 | 13 | /// Handles all ingame-related user interface stuff 14 | class InGameUi : public global::EventReceiver { 15 | public: 16 | InGameUi(); 17 | 18 | virtual void onEvent(global::Event&); 19 | 20 | void update(); 21 | 22 | gui::WorldInterfaceElement& getWorldElement(){ return worldElement; } 23 | util::DynArray getPlayerStrings() const; 24 | 25 | private: 26 | void updateCamera(); 27 | 28 | gui::WorldInterfaceElement worldElement; 29 | visual::Camera camera; 30 | audio::AudioReceiverHandle audioRecv; 31 | }; 32 | 33 | }} // ui::game 34 | } // clover 35 | 36 | #endif // CLOVER_UI_GAME_INGAME_UI_HPP 37 | -------------------------------------------------------------------------------- /code/source/visual/particle_mgr.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_VISUAL_PARTICLE_MGR_HPP 2 | #define CLOVER_VISUAL_PARTICLE_MGR_HPP 3 | 4 | #include "build.hpp" 5 | #include "visual/particlemanifold.hpp" 6 | #include "visual/particletype.hpp" 7 | #include "global/eventreceiver.hpp" 8 | #include "util/hashmap.hpp" 9 | 10 | namespace clover { 11 | namespace visual { 12 | 13 | class ParticleSourceEntityLogic; 14 | 15 | /// @class ParticleMgr Manages particle manifolds, sources and types 16 | class ParticleMgr : public global::EventReceiver { 17 | public: 18 | ParticleMgr(); 19 | 20 | virtual void onEvent(global::Event& e); 21 | 22 | void update(); 23 | 24 | ParticleManifold& getManifold(const util::Str8& name); 25 | 26 | private: 27 | util::DynArray sources; 28 | 29 | util::HashMap typeMap; 30 | util::HashMap manifoldMap; 31 | }; 32 | 33 | } // visual 34 | } // clover 35 | 36 | #endif // CLOVER_VISUAL_PARTICLE_MGR_HPP -------------------------------------------------------------------------------- /code/source/physics/joint_friction.cpp: -------------------------------------------------------------------------------- 1 | #include "box2d.hpp" 2 | #include "joint_friction.hpp" 3 | #include "object_rigid.hpp" 4 | #include "phys_mgr.hpp" 5 | 6 | namespace clover { 7 | namespace physics { 8 | 9 | void FrictionJoint::attach(Object& a, Object& b){ 10 | ensure( a.getTypeId() == Object::TypeId::Rigid && 11 | b.getTypeId() == Object::TypeId::Rigid); 12 | 13 | detach(); 14 | 15 | b2Body* aa= static_cast(&a)->getB2Body(), 16 | * bb= static_cast(&b)->getB2Body(); 17 | ensure(aa && bb); 18 | 19 | def.Initialize(aa, bb, toB2(a.getPosition())); 20 | 21 | addObject(a); 22 | addObject(b); 23 | createB2Joint(); 24 | OnAttachCb::trigger(); 25 | } 26 | 27 | void FrictionJoint::setMaxForce(real64 f){ 28 | def.maxForce= f; 29 | if (joint) 30 | joint->SetMaxForce(f); 31 | } 32 | 33 | void FrictionJoint::setMaxTorque(real64 t){ 34 | def.maxTorque= t; 35 | if (joint) 36 | joint->SetMaxTorque(t); 37 | } 38 | 39 | } // physics 40 | } // clover 41 | -------------------------------------------------------------------------------- /code/source/visual/armatureattachment_def.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_VISUAL_ARMATUREATTACHMENT_DEF_HPP 2 | #define CLOVER_VISUAL_ARMATUREATTACHMENT_DEF_HPP 3 | 4 | #include "build.hpp" 5 | #include "util/objectnodetraits.hpp" 6 | #include "util/optional.hpp" 7 | #include "util/transform.hpp" 8 | #include "util/string.hpp" 9 | 10 | namespace clover { 11 | namespace visual { 12 | 13 | struct ArmatureAttachmentDef { 14 | using Transform= util::SrtTransform; 15 | 16 | util::Str8 entityName; 17 | util::Str8 jointName; 18 | util::Optional offset; 19 | }; 20 | 21 | } // visual 22 | 23 | namespace util { 24 | 25 | template <> 26 | struct ObjectNodeTraits{ 27 | using Value= visual::ArmatureAttachmentDef; 28 | static util::ObjectNode serialized(const Value& value); 29 | static Value deserialized(const util::ObjectNode& ob); 30 | }; 31 | 32 | } // util 33 | } // clover 34 | 35 | #endif // CLOVER_VISUAL_ARMATUREATTACHMENT_DEF_HPP 36 | -------------------------------------------------------------------------------- /code/source/global/file_impl.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_GLOBAL_FILE_IMPL_HPP 2 | #define CLOVER_GLOBAL_FILE_IMPL_HPP 3 | 4 | #include "build.hpp" 5 | #include "util/string.hpp" 6 | #include "util/unique_ptr.hpp" 7 | 8 | namespace clover { 9 | namespace global { 10 | 11 | class FileImpl { 12 | public: 13 | FileImpl(const util::Str8& name, bool readOnly); 14 | virtual ~FileImpl(); 15 | 16 | virtual void remove() = 0; 17 | virtual uint64 getSize() const = 0; 18 | 19 | virtual std::size_t readSome(void* buffer, std::size_t bufferSize) = 0; 20 | 21 | virtual std::size_t writeSome(const void* buffer, std::size_t bufferSize) = 0; 22 | 23 | const util::Str8& getName() const { return name; } 24 | virtual util::Str8 getDirname() const = 0; 25 | 26 | bool isReadOnly() const { return read_only; } 27 | 28 | private: 29 | util::Str8 name; 30 | bool read_only; 31 | }; 32 | 33 | typedef util::UniquePtr FileImplPtr; 34 | 35 | } // global 36 | } // clover 37 | 38 | #endif // CLOVER_GLOBAL_FILE_IMPL_HPP 39 | -------------------------------------------------------------------------------- /code/source/physics/joint_distance.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_JOINT_DISTANCE_HPP 2 | #define CLOVER_JOINT_DISTANCE_HPP 3 | 4 | #include "build.hpp" 5 | #include "b2_joint.hpp" 6 | 7 | namespace clover { 8 | namespace physics { 9 | 10 | class Object; 11 | 12 | class ENGINE_API DistanceJoint : public B2Joint 13 | , public JointTypeCrtp< DistanceJoint, 14 | JointType::Distance> { 15 | public: 16 | void attach(Object& a, Object& b, 17 | const WorldVec& anchor_a, const WorldVec& anchor_b); 18 | 19 | /// To background 20 | void attach(Object& a, 21 | const WorldVec& anchor_a, const WorldVec& anchor_background); 22 | 23 | /// Sets the distance between anchors manually (use carefully) 24 | void setDistance(real64 d); 25 | 26 | void setFrequency(real64 f); 27 | 28 | /// 0 = no damping, 1 = critical damping 29 | void setDamping(real64 d); 30 | 31 | }; 32 | 33 | } // physics 34 | } // clover 35 | 36 | #endif // CLOVER_JOINT_DISTANCE_HPP 37 | -------------------------------------------------------------------------------- /code/deps/common/portaudio-19/src/hostapi/wasapi/mingw-include/ksguid.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file has no copyright assigned and is placed in the Public Domain. 3 | * This file is part of the w64 mingw-runtime package. 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. 5 | */ 6 | #define INITGUID 7 | #include 8 | 9 | #ifndef DECLSPEC_SELECTANY 10 | #define DECLSPEC_SELECTANY __declspec(selectany) 11 | #endif 12 | 13 | #ifdef DEFINE_GUIDEX 14 | #undef DEFINE_GUIDEX 15 | #endif 16 | 17 | #ifdef __cplusplus 18 | #define DEFINE_GUIDEX(name) EXTERN_C const CDECL GUID DECLSPEC_SELECTANY name = { STATICGUIDOF(name) } 19 | #else 20 | #define DEFINE_GUIDEX(name) const CDECL GUID DECLSPEC_SELECTANY name = { STATICGUIDOF(name) } 21 | #endif 22 | #ifndef STATICGUIDOF 23 | #define STATICGUIDOF(guid) STATIC_##guid 24 | #endif 25 | 26 | #ifndef DEFINE_WAVEFORMATEX_GUID 27 | #define DEFINE_WAVEFORMATEX_GUID(x) (USHORT)(x),0x0000,0x0010,0x80,0x00,0x00,0xaa,0x00,0x38,0x9b,0x71 28 | #endif 29 | -------------------------------------------------------------------------------- /code/deps/common/portaudio-19/src/hostapi/wasapi/mingw-include/propkeydef.h: -------------------------------------------------------------------------------- 1 | #ifndef PID_FIRST_USABLE 2 | #define PID_FIRST_USABLE 2 3 | #endif 4 | 5 | #ifndef REFPROPERTYKEY 6 | #ifdef __cplusplus 7 | #define REFPROPERTYKEY const PROPERTYKEY & 8 | #else // !__cplusplus 9 | #define REFPROPERTYKEY const PROPERTYKEY * __MIDL_CONST 10 | #endif // __cplusplus 11 | #endif //REFPROPERTYKEY 12 | 13 | #ifdef DEFINE_PROPERTYKEY 14 | #undef DEFINE_PROPERTYKEY 15 | #endif 16 | 17 | #ifdef INITGUID 18 | #define DEFINE_PROPERTYKEY(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8, pid) EXTERN_C const PROPERTYKEY DECLSPEC_SELECTANY name = { { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }, pid } 19 | #else 20 | #define DEFINE_PROPERTYKEY(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8, pid) EXTERN_C const PROPERTYKEY name 21 | #endif // INITGUID 22 | 23 | #ifndef IsEqualPropertyKey 24 | #define IsEqualPropertyKey(a, b) (((a).pid == (b).pid) && IsEqualIID((a).fmtid, (b).fmtid) ) 25 | #endif // IsEqualPropertyKey 26 | 27 | -------------------------------------------------------------------------------- /code/source/gui/gui_mgr.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_GUI_MGR_HPP 2 | #define CLOVER_GUI_MGR_HPP 3 | 4 | #include "build.hpp" 5 | #include "audio/audiosourcehandle.hpp" 6 | #include "global/eventreceiver.hpp" 7 | #include "cursor.hpp" 8 | #include "callback.hpp" 9 | 10 | namespace clover { 11 | namespace gui { 12 | 13 | /// @todo Gui system needs to be redesigned 14 | 15 | class Element; 16 | 17 | class GuiMgr : public global::EventReceiver { 18 | public: 19 | GuiMgr(); 20 | virtual ~GuiMgr(); 21 | 22 | virtual void onEvent(global::Event&); 23 | 24 | void update(); 25 | 26 | void destroyTree(Element& e); 27 | void destroySubTree(Element& e); 28 | 29 | Cursor& getCursor(); 30 | 31 | /// GuiElement calls 32 | void onDestroy(const Element& e); 33 | private: 34 | util::DynArray accumulatedCallbacks; 35 | 36 | Cursor guiCursor; 37 | 38 | // Gui audio source 39 | audio::AudioSourceHandle audioSource; 40 | }; 41 | 42 | } // gui 43 | } // clover 44 | 45 | #endif // CLOVER_GUI_MGR_HPP 46 | -------------------------------------------------------------------------------- /code/source/nodes/native_instances/nodeinstance_delayedtrigger.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_NODES_NODEINSTANCE_DELAYEDTRIGGER_HPP 2 | #define CLOVER_NODES_NODEINSTANCE_DELAYEDTRIGGER_HPP 3 | 4 | #include "../nodeinstance.hpp" 5 | #include "build.hpp" 6 | 7 | namespace clover { 8 | namespace nodes { 9 | 10 | class DelayedTriggerNodeInstance final : public NodeInstance { 11 | public: 12 | static CompositionNodeLogic* compNode(); 13 | 14 | virtual void create() override; 15 | virtual void update() override; 16 | 17 | private: 18 | InputSlot* triggerIn; 19 | InputSlot* timeIn; 20 | 21 | OutputSlot* triggerOut; 22 | 23 | real64 timer; 24 | }; 25 | 26 | } // nodes 27 | namespace util { 28 | 29 | template <> 30 | struct TypeStringTraits { 31 | static util::Str8 type(){ return "::DelayedTriggerNodeInstance"; } 32 | }; 33 | 34 | } // util 35 | } // clover 36 | 37 | #endif // CLOVER_NODES_NODEINSTANCE_DELAYEDTRIGGER_HPP 38 | -------------------------------------------------------------------------------- /code/source/audio/audiostream_raw.cpp: -------------------------------------------------------------------------------- 1 | #include "audiostream_raw.hpp" 2 | #include "util/ensure.hpp" 3 | 4 | namespace clover { 5 | namespace audio { 6 | 7 | RawAudioStream::RawAudioStream(const real32* samples_begin, const real32* samples_end) 8 | : begin(samples_begin) 9 | , end(samples_end) 10 | , current(samples_begin){ 11 | } 12 | 13 | RawAudioStream::~RawAudioStream(){ 14 | } 15 | 16 | AudioStream::ChannelData RawAudioStream::getNextSamples(SizeType request_count){ 17 | ChannelData ret; 18 | 19 | SizeType read_count= request_count; 20 | ensure(end >= current); 21 | if (read_count > (SizeType)(end - current)) 22 | read_count= end - current; 23 | 24 | ret.samples.resize(read_count); 25 | 26 | for (SizeType i=0; i < request_count; ++i){ 27 | if (current == end){ 28 | eos= true; 29 | break; 30 | } 31 | 32 | Sample s; 33 | s.amplitude= *current; 34 | 35 | ret.samples[i]= s; 36 | ++current; 37 | } 38 | 39 | return (ret); 40 | 41 | } 42 | 43 | } // audio 44 | } // clover -------------------------------------------------------------------------------- /code/source/physics/entityjoint_def.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_PHYSICS_ENTITYJOINT_DEF_HPP 2 | #define CLOVER_PHYSICS_ENTITYJOINT_DEF_HPP 3 | 4 | #include "build.hpp" 5 | #include "jointtype.hpp" 6 | #include "util/objectnodetraits.hpp" 7 | #include "util/vector.hpp" 8 | 9 | namespace clover { 10 | namespace physics { 11 | 12 | /// Helper class for EntityDef 13 | /// @todo Limits and motors 14 | struct EntityJointDef { 15 | JointType type= JointType::None; 16 | util::DynArray objects; 17 | util::DynArray anchors; 18 | real64 frequency= 1.0; 19 | real64 damping= 0.5; 20 | real64 friction= 0.0; 21 | }; 22 | 23 | } // physics 24 | namespace util { 25 | 26 | template <> 27 | struct ObjectNodeTraits { 28 | typedef physics::EntityJointDef Value; 29 | static util::ObjectNode serialized(const Value& value); 30 | static Value deserialized(const util::ObjectNode& ob_node); 31 | }; 32 | 33 | } // util 34 | } // clover 35 | 36 | #endif // CLOVER_PHYSICS_ENTITYJOINT_DEF_HPP 37 | -------------------------------------------------------------------------------- /code/source/hardware/hid_devicefactory.cpp: -------------------------------------------------------------------------------- 1 | #include "hid_devicefactory.hpp" 2 | #include "hid_device_gamepad.hpp" 3 | #include "hid_device_keyboard.hpp" 4 | #include "hid_device_mouse.hpp" 5 | 6 | namespace clover { 7 | namespace hardware { 8 | 9 | ui::hid::Device::Ptr HidDeviceFactory::createDevice(const ui::hid::Device::ConstructInfo& info){ 10 | /// @todo Support real uuids 11 | 12 | if (info.uuid == "defaultMouse") 13 | return MouseHidDevice::create(info); 14 | else if (info.uuid == "defaultKeyboard") 15 | return KeyboardHidDevice::create(info); 16 | else if (info.uuid == "defaultGamepad") 17 | return GamepadHidDevice::create(info); 18 | 19 | throw global::Exception("Unsupported device %s, %s", info.name.cStr(), info.uuid.cStr()); 20 | } 21 | 22 | bool HidDeviceFactory::isDeviceTypeName(const Device::Name& type_name){ 23 | if (type_name == "Mouse" || type_name == "Keyboard" || type_name == "Gamepad") 24 | return true; 25 | else 26 | return false; 27 | } 28 | 29 | } // hardware 30 | } // clover 31 | -------------------------------------------------------------------------------- /code/source/visual/armatureattachment_def.cpp: -------------------------------------------------------------------------------- 1 | #include "armatureattachment_def.hpp" 2 | #include "global/exception.hpp" 3 | #include "util/objectnode.hpp" 4 | 5 | namespace clover { 6 | namespace util { 7 | 8 | util::ObjectNode ObjectNodeTraits:: 9 | serialized(const Value& value){ 10 | util::ObjectNode ob; 11 | ob["entity"].setValue(value.entityName); 12 | ob["joint"].setValue(value.jointName); 13 | ob["offset"].setValue(value.offset); 14 | 15 | return ob; 16 | } 17 | 18 | auto ObjectNodeTraits:: 19 | deserialized(const util::ObjectNode& ob) -> Value { 20 | if (!ob.isObject()) 21 | throw global::Exception("Invalid ArmatureAttachmentDef"); 22 | 23 | Value value; 24 | value.entityName= ob.get("entity").getValue(); 25 | value.jointName= ob.get("joint").getValue(); 26 | value.offset= ob.get("offset").getValue(); 27 | 28 | return value; 29 | } 30 | 31 | } // util 32 | } // clover 33 | -------------------------------------------------------------------------------- /code/source/ui/nodes/basesignalvalue_ui.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_UI_NODES_BASESIGNALVALUE_UI_HPP 2 | #define CLOVER_UI_NODES_BASESIGNALVALUE_UI_HPP 3 | 4 | #include "build.hpp" 5 | #include "gui/element.hpp" 6 | 7 | namespace clover { 8 | namespace ui { namespace nodes { 9 | 10 | class BaseSignalValueUi { 11 | public: 12 | virtual ~BaseSignalValueUi(){} 13 | 14 | virtual gui::Element& getViewGuiElement()= 0; 15 | virtual void showEditControls(bool b)= 0; 16 | virtual bool isEditControlsShowing() const = 0; 17 | 18 | virtual void setValue(const util::Any& v, bool only_edit= false) = 0; 19 | virtual util::Any getValue() const = 0; 20 | 21 | typedef std::function Callback; 22 | void setOnValueModifyCallback(const Callback& c){ onValueModify= c; } 23 | void setOnValueUnsetCallback(const Callback& c){ onValueUnset= c; } 24 | 25 | protected: 26 | 27 | Callback onValueModify; 28 | Callback onValueUnset; 29 | }; 30 | 31 | }} // ui::nodes 32 | } // clover 33 | 34 | #endif // CLOVER_UI_NODES_BASESIGNALVALUE_UI_HPP -------------------------------------------------------------------------------- /code/source/physics/material.cpp: -------------------------------------------------------------------------------- 1 | #include "material.hpp" 2 | #include "global/event.hpp" 3 | 4 | namespace clover { 5 | namespace physics { 6 | 7 | Material::Material(): 8 | density(1.0), 9 | friction(0.5), 10 | restitution(0.5), 11 | toughness(-1.0){ 12 | } 13 | 14 | Material::Material(real32 d, real32 f, real32 r, real32 t): 15 | density(d), 16 | friction(f), 17 | restitution(r), 18 | toughness(t){ 19 | 20 | } 21 | 22 | void Material::setDensity(real32 d){ 23 | density= d; 24 | onChange(); 25 | } 26 | 27 | void Material::setFriction(real32 f){ 28 | friction= f; 29 | onChange(); 30 | } 31 | 32 | void Material::setRestitution(real32 r){ 33 | restitution= r; 34 | onChange(); 35 | } 36 | 37 | void Material::setToughness(real32 t){ 38 | toughness= t; 39 | onChange(); 40 | } 41 | 42 | void Material::onChange(){ 43 | if (getReferenceCount() > 0){ 44 | global::Event e(global::Event::OnPhysMaterialChange); 45 | e(global::Event::Material)= this; 46 | e.send(); 47 | } 48 | } 49 | 50 | } // physics 51 | } // clover -------------------------------------------------------------------------------- /code/source/audio/soundinstancehandle.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_AUDIO_SOUNDINSTANCEHANDLE_HPP 2 | #define CLOVER_AUDIO_SOUNDINSTANCEHANDLE_HPP 3 | 4 | #include "build.hpp" 5 | #include "soundinstance.hpp" 6 | #include "global/eventreceiver.hpp" 7 | #include "util/countedpointer.hpp" 8 | 9 | namespace clover { 10 | namespace audio { 11 | 12 | class AudioSourceHandle; 13 | 14 | class SoundInstanceHandle : public global::EventReceiver { 15 | public: 16 | SoundInstanceHandle(SoundInstance* sound_instance= nullptr); 17 | virtual ~SoundInstanceHandle(); 18 | 19 | virtual void onEvent(global::Event& e); 20 | 21 | void setVolume(real32 mul); 22 | void setOnEndCallback(const SoundInstance::OnEndCallbackType& cb); 23 | const Sound& getSound() const; 24 | AudioSourceHandle getSource() const; 25 | 26 | explicit operator bool() const { return soundInstance.get(); } 27 | 28 | private: 29 | util::CountedPointer soundInstance; 30 | }; 31 | 32 | } // audio 33 | } // clover 34 | 35 | #endif // CLOVER_AUDIO_SOUNDINSTANCEHANDLE_HPP -------------------------------------------------------------------------------- /code/source/game/physics.cpp: -------------------------------------------------------------------------------- 1 | #include "physics.hpp" 2 | #include "physics/entity.hpp" 3 | #include "physics/object.hpp" 4 | #include "worldentity.hpp" 5 | 6 | namespace clover { 7 | namespace game { 8 | 9 | void setOwnerWe(physics::Object& phys_obj, WorldEntity* entity) 10 | { 11 | phys_obj.getProperties().set("we", WeHandle{entity}); 12 | } 13 | 14 | void setOwnerWe(physics::Entity& phys_entity, WorldEntity* entity) 15 | { 16 | phys_entity.getProperties().set("we", WeHandle{entity}); 17 | } 18 | 19 | WorldEntity* getOwnerWe(const physics::Object& phys_obj) 20 | { 21 | physics::Entity* phys_entity= phys_obj.getEntity(); 22 | if (phys_entity) 23 | return getOwnerWe(*phys_entity); 24 | 25 | const WeHandle* h= phys_obj.getProperties().find("we"); 26 | return h ? h->get() : nullptr; 27 | } 28 | 29 | WorldEntity* getOwnerWe(const physics::Entity& phys_entity) 30 | { 31 | const WeHandle* h= phys_entity.getProperties().find("we"); 32 | return h ? h->get() : nullptr; 33 | } 34 | 35 | } // game 36 | } // clover 37 | -------------------------------------------------------------------------------- /code/source/ui/hid/baseactionlistener.cpp: -------------------------------------------------------------------------------- 1 | #include "baseactionlistener.hpp" 2 | 3 | namespace clover { 4 | namespace ui { namespace hid { 5 | 6 | BaseActionListener::ListenerMap BaseActionListener::outsideActionListeners; 7 | 8 | BaseActionListener::BaseActionListener() 9 | : listening(false){} 10 | 11 | void BaseActionListener::onActionListeningStart(const BaseActionListener& listener){ 12 | ensure(!listening); 13 | outsideActionListeners[listener.getListenerKey()].pushBack(&listener); 14 | listening= true; 15 | } 16 | 17 | void BaseActionListener::onActionListeningStop(const BaseActionListener& listener){ 18 | ensure(listening); 19 | 20 | auto& listener_array= outsideActionListeners[listener.getListenerKey()]; 21 | 22 | for (auto it= listener_array.begin(); it != listener_array.end(); ++it){ 23 | if (*it == &listener){ 24 | listener_array.erase(it); 25 | listening= false; 26 | return; 27 | } 28 | } 29 | 30 | throw global::Exception("ActionListener not found"); 31 | } 32 | 33 | }} // ui::hid 34 | } // clover -------------------------------------------------------------------------------- /code/source/util/mem_pool.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_UTIL_MEM_POOL_HPP 2 | #define CLOVER_UTIL_MEM_POOL_HPP 3 | 4 | #include "build.hpp" 5 | #include "util/class_preproc.hpp" 6 | #include "util/tidy_ptr.hpp" 7 | #include "util/mem_chunk.hpp" 8 | 9 | namespace clover { 10 | namespace util { 11 | 12 | /// @return How much address should be adjusted forward in 13 | /// memory to be correctly aligned 14 | SizeType alignedMemAdjustment( uint8* addr, 15 | SizeType alignment); 16 | 17 | /// Base class for memory pools 18 | /// @todo Emergency heap allocations in dev build to prevent crashes 19 | class ENGINE_API MemPool { 20 | public: 21 | MemPool()= default; 22 | DELETE_COPY(MemPool); 23 | DEFAULT_MOVE(MemPool); 24 | 25 | void setMemory(MemChunk* chunk); 26 | 27 | protected: 28 | virtual void onMemoryAcquire(){} 29 | virtual void onMemoryRelease(){} 30 | 31 | const MemChunk& memory() const; 32 | 33 | private: 34 | TidyPtr memChunk; 35 | }; 36 | 37 | } // util 38 | } // clover 39 | 40 | #endif // CLOVER_UTIL_MEM_POOL_HPP -------------------------------------------------------------------------------- /code/source/nodes/compositionnodeslottemplategrouphandle.cpp: -------------------------------------------------------------------------------- 1 | #include "compositionnodeslottemplategrouphandle.hpp" 2 | #include "compositionnodelogic.hpp" 3 | #include "compositionnodeslottemplategroup.hpp" 4 | 5 | namespace clover { 6 | namespace nodes { 7 | 8 | CompositionNodeSlotTemplateGroupHandle::CompositionNodeSlotTemplateGroupHandle(CompositionNodeSlotTemplateGroup* group) 9 | : owner(nullptr){ 10 | if (group){ 11 | owner= &group->getOwner(); 12 | name= group->getName(); 13 | } 14 | } 15 | 16 | CompositionNodeSlotTemplateGroupHandle::operator bool() const { 17 | if (!owner) return false; 18 | return owner->hasSlotTemplateGroup(name); 19 | } 20 | 21 | CompositionNodeSlotTemplateGroup* CompositionNodeSlotTemplateGroupHandle::get() const { 22 | if (*this) 23 | return &owner->getSlotTemplateGroup(name); 24 | return nullptr; 25 | } 26 | 27 | CompositionNodeSlotTemplateGroup* CompositionNodeSlotTemplateGroupHandle::operator->() const { 28 | return &owner->getSlotTemplateGroup(name); 29 | } 30 | 31 | } // nodes 32 | } // clover -------------------------------------------------------------------------------- /code/source/physics/b2_joint.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_PHYSICS_B2_JOINT_HPP 2 | #define CLOVER_PHYSICS_B2_JOINT_HPP 3 | 4 | #include "build.hpp" 5 | #include "joint.hpp" 6 | #include "world.hpp" 7 | #include "util/vector.hpp" 8 | 9 | namespace clover { 10 | namespace physics { 11 | 12 | /// Internal class of the physics system 13 | template 14 | class B2Joint : public Joint { 15 | public: 16 | virtual ~B2Joint(){ detach(); } 17 | virtual bool isAttached() const override { return joint; } 18 | virtual void detach(); 19 | 20 | virtual WorldVec getAnchor(SizeType i) const override; 21 | 22 | JointType* getB2Joint() const { return joint; } 23 | 24 | protected: 25 | DefType def; 26 | JointType* joint= nullptr; 27 | 28 | /// Object calls 29 | virtual void recreate() override; 30 | 31 | virtual void createB2Joint(); 32 | virtual void destroyB2Joint(); 33 | 34 | private: 35 | b2Body* getB2Body(SizeType i) const; 36 | }; 37 | 38 | } // physics 39 | } // clover 40 | 41 | #endif // CLOVER_PHYSICS_B2_JOINT_HPP -------------------------------------------------------------------------------- /code/source/visual/camera_mgr.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_VISUAL_CAMERA_MGR_HPP 2 | #define CLOVER_VISUAL_CAMERA_MGR_HPP 3 | 4 | #include "build.hpp" 5 | #include "global/eventreceiver.hpp" 6 | #include "util/dyn_array.hpp" 7 | 8 | namespace clover { 9 | namespace visual { 10 | 11 | class Camera; 12 | 13 | class CameraMgr : public global::EventReceiver { 14 | public: 15 | CameraMgr(); 16 | Camera& getSelectedCamera(); 17 | 18 | const util::DynArray& getCameras(); 19 | const util::DynArray& getActiveCameras(); 20 | 21 | void update(); 22 | void onEvent(global::Event&); 23 | 24 | private: 25 | util::DynArray cameras; 26 | util::DynArray activeCameras; 27 | Camera* selectedCamera; 28 | 29 | friend class Camera; 30 | 31 | void onCameraAdd(Camera& c); 32 | void onCameraRemove(Camera& c); 33 | 34 | void onCameraActivate(Camera& c); 35 | void onCameraDeactivate(Camera& c); 36 | 37 | void onCameraSelect(Camera& c); 38 | }; 39 | 40 | } // visual 41 | } // clover 42 | 43 | #endif // CLOVER_VISUAL_CAMERA_MGR_HPP -------------------------------------------------------------------------------- /code/source/visual/visual_mgr.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_VISUAL_MGR_HPP 2 | #define CLOVER_VISUAL_MGR_HPP 3 | 4 | #include "build.hpp" 5 | #include "util/class_preproc.hpp" 6 | #include "util/mem_chunk.hpp" 7 | 8 | namespace clover { 9 | namespace visual { 10 | 11 | class ShaderMgr; 12 | class EntityMgr; 13 | class CameraMgr; 14 | class ParticleMgr; 15 | 16 | class VisualMgr { 17 | public: 18 | 19 | VisualMgr(); 20 | DELETE_MOVE(VisualMgr); 21 | DELETE_COPY(VisualMgr); 22 | virtual ~VisualMgr(); 23 | 24 | void renderFrame(); 25 | 26 | ShaderMgr& getShaderMgr(){ return *shaderMgr; } 27 | EntityMgr& getEntityMgr(){ return *entityMgr; } 28 | CameraMgr& getCameraMgr(){ return *cameraMgr; } 29 | ParticleMgr& getParticleMgr(){ return *particleMgr; } 30 | 31 | private: 32 | ShaderMgr* shaderMgr; 33 | EntityMgr* entityMgr; 34 | CameraMgr* cameraMgr; 35 | ParticleMgr* particleMgr; 36 | 37 | //util::MemChunk modelDefMem; 38 | //util::MemChunk modelLogicMem; 39 | }; 40 | 41 | } // visual 42 | } // clover 43 | 44 | #endif // CLOVER_VISUAL_MGR_HPP 45 | -------------------------------------------------------------------------------- /code/deps/common/glfw-3.0.3/COPYING.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2002-2006 Marcus Geelnard 2 | Copyright (c) 2006-2010 Camilla Berglund 3 | 4 | This software is provided 'as-is', without any express or implied 5 | warranty. In no event will the authors be held liable for any damages 6 | arising from the use of this software. 7 | 8 | Permission is granted to anyone to use this software for any purpose, 9 | including commercial applications, and to alter it and redistribute it 10 | freely, subject to the following restrictions: 11 | 12 | 1. The origin of this software must not be misrepresented; you must not 13 | claim that you wrote the original software. If you use this software 14 | in a product, an acknowledgment in the product documentation would 15 | be appreciated but is not required. 16 | 17 | 2. Altered source versions must be plainly marked as such, and must not 18 | be misrepresented as being the original software. 19 | 20 | 3. This notice may not be removed or altered from any source 21 | distribution. 22 | 23 | -------------------------------------------------------------------------------- /code/source/global/file_mgr.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_GLOBAL_FILE_MGR_HPP 2 | #define CLOVER_GLOBAL_FILE_MGR_HPP 3 | 4 | #include "file_impl.hpp" 5 | #include "util/str8.hpp" 6 | 7 | #include 8 | 9 | namespace clover { 10 | namespace global { 11 | 12 | class FileArchive; 13 | 14 | class FileMgr { 15 | public: 16 | FileMgr(); 17 | ~FileMgr(); 18 | 19 | void add(const util::Str8& path, bool readOnly, int priority); 20 | FileImplPtr findFile(const util::Str8& path, bool needWriteAccess) const; 21 | 22 | /// For any writing happening outside File class, this path is the 23 | /// default output resource directory root for writing new files 24 | const util::Str8& getDefaultOutputPath() const; 25 | 26 | FileImplPtr create(const util::Str8& path) const; 27 | 28 | 29 | private: 30 | struct Path { 31 | util::Str8 path; 32 | bool readOnly; 33 | std::shared_ptr archive; 34 | }; 35 | 36 | std::multimap> paths; 37 | }; 38 | 39 | } // global 40 | } // clover 41 | 42 | #endif // CLOVER_GLOBAL_FILE_MGR_HPP 43 | -------------------------------------------------------------------------------- /code/source/nodes/updateline.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_NODES_UPDATELINE_HPP 2 | #define CLOVER_NODES_UPDATELINE_HPP 3 | 4 | #include "build.hpp" 5 | #include "util/class_preproc.hpp" 6 | #include "util/dyn_array.hpp" 7 | 8 | namespace clover { 9 | namespace nodes { 10 | 11 | class NodeInstance; 12 | class NodeInstanceGroup; 13 | 14 | /// Manages updating and batching of nodes from several NodeInstanceGroups 15 | class UpdateLine { 16 | public: 17 | using RawList= util::DynArray; 18 | 19 | UpdateLine()= default; 20 | UpdateLine(RawList nodes, const NodeInstanceGroup& group); 21 | DEFAULT_COPY(UpdateLine); 22 | DEFAULT_MOVE(UpdateLine); 23 | 24 | void append(UpdateLine other); 25 | 26 | /// Makes batching happen 27 | void sort(); 28 | 29 | /// Updates every node 30 | void run(); 31 | 32 | private: 33 | struct NodeInfo { 34 | NodeInstance* node; 35 | int32 priority; 36 | }; 37 | 38 | using List= util::DynArray; 39 | List list; 40 | }; 41 | 42 | } // nodes 43 | } // clover 44 | 45 | #endif // CLOVER_NODES_UPDATELINE_HPP 46 | -------------------------------------------------------------------------------- /code/source/game/worldentity_set.cpp: -------------------------------------------------------------------------------- 1 | #include "worldentity_set.hpp" 2 | #include "worldentity.hpp" 3 | 4 | namespace clover { 5 | namespace game { 6 | 7 | WESet::WESet(){ 8 | } 9 | 10 | WESet::~WESet(){ 11 | 12 | } 13 | 14 | WESet::Iter WESet::begin(){ 15 | return handles.begin(); 16 | } 17 | 18 | WESet::Iter WESet::end(){ 19 | return handles.end(); 20 | } 21 | 22 | WESet::cIter WESet::begin() const { 23 | return handles.begin(); 24 | } 25 | 26 | WESet::cIter WESet::end() const { 27 | return handles.end(); 28 | } 29 | 30 | int32 WESet::size(){ 31 | return handles.size(); 32 | } 33 | 34 | void WESet::clear(){ 35 | handles.clear(); 36 | } 37 | 38 | void WESet::add(const game::WorldEntity& we){ 39 | handles.pushBack(game::WeHandle(&we)); 40 | } 41 | 42 | void WESet::add(const game::WeHandle& h){ 43 | handles.pushBack(h); 44 | } 45 | 46 | void WESet::add(const WESet& s){ 47 | handles.insert(handles.end(), s.begin(), s.end()); 48 | } 49 | 50 | void WESet::remove(const game::WeHandle& h){ 51 | handles.remove(h); 52 | } 53 | 54 | } // game 55 | } // clover -------------------------------------------------------------------------------- /code/source/gui/element_attributefield_string.cpp: -------------------------------------------------------------------------------- 1 | #include "element_attributefield_string.hpp" 2 | 3 | namespace clover { 4 | namespace gui { 5 | 6 | AttributeFieldElement::AttributeFieldElement(const resources::AttributeDef& def): 7 | AttributeFieldWrapElement(def), 8 | textField(TextFieldElement::Type::Dev){ 9 | 10 | addSubElement(textField); 11 | textField.setStretchable(); 12 | resizeElements.pushBack(&textField); 13 | 14 | textField.setTextColorMul(util::Color{0.4, 0.8, 0.6, 1.0}); 15 | 16 | textField.setOnEditingStateChangeCallback([=] (gui::TextFieldElement& caller){ 17 | if (!caller.isEditing()) 18 | OnValueModify(*this); 19 | }); 20 | 21 | textField.setOnTextModifyCallback([=] (gui::TextFieldElement& caller) { 22 | value= caller.getText(); 23 | }); 24 | } 25 | 26 | AttributeFieldElement::~AttributeFieldElement(){ 27 | } 28 | 29 | void AttributeFieldElement::onValueSet(){ 30 | textField.setText(value); 31 | } 32 | 33 | } // gui 34 | } // clover -------------------------------------------------------------------------------- /code/source/audio/audiosourcehandle.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_AUDIO_AUDIOSOURCEHANDLE_HPP 2 | #define CLOVER_AUDIO_AUDIOSOURCEHANDLE_HPP 3 | 4 | #include "build.hpp" 5 | #include "audiosource.hpp" 6 | #include "global/eventreceiver.hpp" 7 | #include "util/countedpointer.hpp" 8 | 9 | namespace clover { 10 | namespace audio { 11 | 12 | class Sound; 13 | class SoundInstanceHandle; 14 | 15 | class AudioSourceHandle : public global::EventReceiver { 16 | public: 17 | AudioSourceHandle(AudioSource* audio_source= nullptr); 18 | 19 | virtual void onEvent(global::Event& e); 20 | 21 | void assignNewSource(AudioSource::Type type); 22 | 23 | void setPosition(const util::Vec2d& pos); 24 | void setVolume(real32 vol); 25 | 26 | SoundInstanceHandle playSound(const Sound& s); 27 | SoundInstanceHandle playSound(const util::Str8& soundname); 28 | 29 | explicit operator bool() const { return audioSource.get(); } 30 | 31 | private: 32 | util::CountedPointer audioSource; 33 | }; 34 | 35 | } // audio 36 | } // clover 37 | 38 | #endif // CLOVER_AUDIO_AUDIOSOURCEHANDLE_HPP -------------------------------------------------------------------------------- /code/source/nodes/native_instances/nodeinstance_triggertosignal.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_NODES_NODEINSTANCE_TRIGGERTOSIGNAL_HPP 2 | #define CLOVER_NODES_NODEINSTANCE_TRIGGERTOSIGNAL_HPP 3 | 4 | #include "../nodeinstance.hpp" 5 | #include "build.hpp" 6 | 7 | namespace clover { 8 | namespace nodes { 9 | 10 | class TriggerToSignalNodeInstance final : public NodeInstance { 11 | public: 12 | static CompositionNodeLogic* compNode(); 13 | 14 | virtual void create() override; 15 | virtual void update() override; 16 | 17 | private: 18 | InputSlot* triggerIn; 19 | InputSlot* onValueIn; 20 | InputSlot* offValueIn; 21 | 22 | OutputSlot* signalOut; 23 | 24 | bool triggerReceived; 25 | }; 26 | 27 | } // nodes 28 | namespace util { 29 | 30 | template <> 31 | struct TypeStringTraits { 32 | static util::Str8 type(){ return "::TriggerToSignalNodeInstance"; } 33 | }; 34 | 35 | } // util 36 | } // clover 37 | 38 | #endif // CLOVER_NODES_NODEINSTANCE_TRIGGERTOSIGNAL_HPP 39 | -------------------------------------------------------------------------------- /code/source/physics/joint_rope.cpp: -------------------------------------------------------------------------------- 1 | #include "box2d.hpp" 2 | #include "joint_rope.hpp" 3 | #include "object_rigid.hpp" 4 | #include "phys_mgr.hpp" 5 | 6 | namespace clover { 7 | namespace physics { 8 | 9 | void RopeJoint::attach( Object& a, Object& b, 10 | const WorldVec& anchor_a, const WorldVec& anchor_b){ 11 | ensure( a.getTypeId() == Object::TypeId::Rigid && 12 | b.getTypeId() == Object::TypeId::Rigid); 13 | 14 | b2Body* aa= static_cast(&a)->getB2Body(), 15 | * bb= static_cast(&b)->getB2Body(); 16 | ensure(aa && bb); 17 | 18 | detach(); 19 | addObject(a); 20 | addObject(b); 21 | 22 | def.bodyA= aa; 23 | def.bodyB= bb; 24 | def.localAnchorA= aa->GetLocalPoint(toB2(anchor_a)); 25 | def.localAnchorB= bb->GetLocalPoint(toB2(anchor_b)); 26 | def.maxLength= (anchor_b - anchor_a).length(); 27 | createB2Joint(); 28 | 29 | OnAttachCb::trigger(); 30 | } 31 | 32 | void RopeJoint::setLength(real64 d){ 33 | def.maxLength= d; 34 | if (joint) 35 | joint->SetMaxLength(d); 36 | } 37 | 38 | } // physics 39 | } // clover 40 | -------------------------------------------------------------------------------- /code/source/animation/clipchannel.hpp: -------------------------------------------------------------------------------- 1 | #ifndef ANIMATION_CLIPCHANNEL_HPP 2 | #define ANIMATION_CLIPCHANNEL_HPP 3 | 4 | #include "build.hpp" 5 | #include "util/dyn_array.hpp" 6 | #include "util/objectnodetraits.hpp" 7 | #include "util/str8.hpp" 8 | #include "util/vector.hpp" 9 | 10 | namespace clover { 11 | namespace animation { 12 | 13 | enum class ClipChannelType { 14 | translation, 15 | rotation, 16 | scale 17 | }; 18 | 19 | struct ClipChannel { 20 | ClipChannelType type; 21 | util::Str8 joint; 22 | struct Key { 23 | real32 time; 24 | /// For translation: XYZ_ 25 | /// For rotation: XYZR 26 | /// For scale: S___ 27 | real32 value[4]; 28 | }; 29 | util::DynArray keys; 30 | }; 31 | 32 | } // animation 33 | namespace util { 34 | 35 | template <> 36 | struct ObjectNodeTraits { 37 | typedef animation::ClipChannel Value; 38 | static util::ObjectNode serialized(const Value& value); 39 | static Value deserialized(const util::ObjectNode& ob_node); 40 | }; 41 | 42 | } // animation 43 | } // util 44 | 45 | #endif // ANIMATION_CLIPCHANNEL_HPP 46 | -------------------------------------------------------------------------------- /code/source/util/bit.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_UTIL_BIT_HPP 2 | #define CLOVER_UTIL_BIT_HPP 3 | 4 | #include "build.hpp" 5 | #include "util/ensure.hpp" 6 | 7 | namespace clover { 8 | namespace util { 9 | 10 | constexpr SizeType bitsInByte= 8; 11 | 12 | template 13 | constexpr SizeType bitSize() { return sizeof(T)*bitsInByte; } 14 | 15 | template 16 | T bitRotatedLeft(T t, uint32 shift) 17 | { 18 | shift= shift % bitSize(); 19 | return (t << shift) | (t >> (bitSize() - shift)); 20 | } 21 | 22 | template 23 | T bitRotatedRight(T t, uint32 shift) 24 | { 25 | shift= shift % bitSize(); 26 | return (t >> shift) | (t << (bitSize() - shift)); 27 | } 28 | 29 | /// @param shift Positive for right-shifting 30 | template 31 | T bitRotated(T t, int32 shift) 32 | { 33 | shift= shift % bitSize(); 34 | if (shift > 0) 35 | return bitRotatedRight(t, static_cast(shift)); 36 | else 37 | return bitRotatedLeft(t, static_cast(-shift)); 38 | } 39 | 40 | } // util 41 | } // clover 42 | 43 | #endif // CLOVER_UTIL_BIT_HPP 44 | -------------------------------------------------------------------------------- /code/source/game/worldcontactlistener.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_GAME_WORLDCOLLISIONLISTENER_HPP 2 | #define CLOVER_GAME_WORLDCOLLISIONLISTENER_HPP 3 | 4 | #include "build.hpp" 5 | #include "audio/sound.hpp" 6 | #include "physics/contactlistener.hpp" 7 | #include "util/string.hpp" 8 | #include "util/map.hpp" 9 | 10 | namespace clover { 11 | namespace game { 12 | 13 | class WorldContactListener : public physics::BaseContactListener { 14 | public: 15 | virtual void onBeginContact(const physics::Contact&); 16 | virtual void onEndContact(const physics::Contact&); 17 | virtual void onPreSolveContact(const physics::Contact&); 18 | virtual void onPostSolveContact(const physics::PostSolveContact&); 19 | 20 | private: 21 | struct RecentSoundInfo { 22 | real64 time; 23 | real64 amplitude; 24 | }; 25 | 26 | util::Map recentSounds; 27 | 28 | bool canBePlayed(const audio::Sound& sound, real64 amplitude); 29 | void notifyPlaying(const audio::Sound& sound, real64 amplitude); 30 | }; 31 | 32 | } // game 33 | } // clover 34 | 35 | #endif // CLOVER_GAME_WORLDCOLLISIONLISTENER_HPP -------------------------------------------------------------------------------- /code/source/nodes/native_instances/nodeinstance_exp_release_real.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_NODES_NODEINSTANCE_EXP_RELEASE_REAL_HPP 2 | #define CLOVER_NODES_NODEINSTANCE_EXP_RELEASE_REAL_HPP 3 | 4 | #include "../nodeinstance.hpp" 5 | #include "build.hpp" 6 | 7 | namespace clover { 8 | namespace nodes { 9 | 10 | class RealExpReleaseNodeInstance final : public NodeInstance { 11 | public: 12 | static CompositionNodeLogic* compNode(); 13 | 14 | virtual void create() override; 15 | virtual void update() override; 16 | 17 | private: 18 | InputSlot* realLimitIn; 19 | InputSlot* accumIn; 20 | InputSlot* targetIn; 21 | InputSlot* halfValueTime; 22 | 23 | OutputSlot* valueOut; 24 | 25 | real64 value; 26 | }; 27 | 28 | } // nodes 29 | namespace util { 30 | 31 | template <> 32 | struct TypeStringTraits { 33 | static util::Str8 type(){ return "::RealExpReleaseNodeInstance"; } 34 | }; 35 | 36 | } // util 37 | } // clover 38 | 39 | #endif // CLOVER_NODES_NODEINSTANCE_EXP_RELEASE_REAL 40 | -------------------------------------------------------------------------------- /code/source/nodes/native_instances/nodeinstance_lerp_pose.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_NODES_NODEINSTANCE_LERP_POSE_HPP 2 | #define CLOVER_NODES_NODEINSTANCE_LERP_POSE_HPP 3 | 4 | #include "../nodeinstance.hpp" 5 | #include "build.hpp" 6 | 7 | namespace clover { 8 | namespace nodes { 9 | 10 | class PoseLerpNodeInstance final : public NodeInstance { 11 | public: 12 | static CompositionNodeLogic* compNode(); 13 | 14 | virtual ~PoseLerpNodeInstance(){} 15 | 16 | virtual void create() override; 17 | virtual void update() override; 18 | 19 | private: 20 | InputSlot* input1; 21 | InputSlot* input2; 22 | InputSlot* factorIn; 23 | InputSlot* limitFactorIn; 24 | 25 | OutputSlot* resultOut; 26 | }; 27 | 28 | } // nodes 29 | namespace util { 30 | 31 | template <> 32 | struct TypeStringTraits { 33 | static util::Str8 type(){ return "::PoseLerpNodeInstance"; } 34 | }; 35 | 36 | } // util 37 | } // clover 38 | 39 | #endif // CLOVER_NODES_NODEINSTANCE_LERP_POSE_HPP 40 | -------------------------------------------------------------------------------- /code/source/nodes/native_instances/nodeinstance_worldclock.cpp: -------------------------------------------------------------------------------- 1 | #include "game/world_mgr.hpp" 2 | #include "global/env.hpp" 3 | #include "nodeinstance_worldclock.hpp" 4 | 5 | namespace clover { 6 | namespace nodes { 7 | 8 | CompositionNodeLogic* WorldClockNodeInstance::compNode() 9 | { 10 | auto n= new CompositionNodeLogic{}; 11 | // Midnight: 0, morning: 0.15, midday: 0.5, evening: 0.75 12 | n->addOutputSlot("dayPhase", SignalType::Real); 13 | 14 | // Midnight: 0, midday: 1.0 15 | n->addOutputSlot("dayness", SignalType::Real); 16 | return n; 17 | } 18 | 19 | void WorldClockNodeInstance::create() 20 | { 21 | dayPhaseOut= addOutputSlot("dayPhase"); 22 | daynessOut= addOutputSlot("dayness"); 23 | setUpdateNeeded(true); 24 | } 25 | 26 | void WorldClockNodeInstance::update() 27 | { 28 | real64 day_phase= global::g_env.worldMgr->getDayPhase(); 29 | dayPhaseOut->send(day_phase); 30 | 31 | real64 dayness= day_phase*2.0; 32 | if (dayness > 1.0) 33 | dayness= 2.0 - dayness; 34 | 35 | daynessOut->send(dayness); 36 | } 37 | 38 | } // nodes 39 | } // clover 40 | -------------------------------------------------------------------------------- /code/source/game/editor/components/ec_nodes.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_GAME_EDITOR_EC_NODES_HPP 2 | #define CLOVER_GAME_EDITOR_EC_NODES_HPP 3 | 4 | #include "build.hpp" 5 | #include "ec_resource.hpp" 6 | #include "nodes/compositionnodelogicgroup.hpp" 7 | #include "nodes/nodeinstancegroup.hpp" 8 | 9 | namespace clover { 10 | namespace game { namespace editor { 11 | 12 | class NodesEc; 13 | 14 | template <> 15 | struct EditorComponentTraits { 16 | static const util::Str8 name(){ return "Nodes"; } 17 | }; 18 | 19 | class NodesEc : public ResourceEc { 20 | public: 21 | DECLARE_EDITORCOMPONENT(NodesEc); 22 | 23 | virtual ~NodesEc(){} 24 | 25 | util::UniquePtr instantiateNodeGroup(); 26 | 27 | util::DynArray getNodeTypes(); 28 | 29 | nodes::CompositionNodeLogic& addCompositionNodeLogic(const util::Str8& logic_name); 30 | void removeCompositionNodeLogic(const nodes::CompositionNodeLogic& node); 31 | 32 | private: 33 | 34 | }; 35 | 36 | }} // game::editor 37 | } // clover 38 | 39 | #endif // CLOVER_GAME_EDITOR_EC_NODES_HPP 40 | -------------------------------------------------------------------------------- /code/source/game/worldaudio_env.cpp: -------------------------------------------------------------------------------- 1 | #include "worldaudio_env.hpp" 2 | #include "resources/cache.hpp" 3 | #include "audio/audiosourcehandle.hpp" 4 | #include "audio/soundinstancehandle.hpp" 5 | 6 | namespace clover { 7 | namespace game { 8 | 9 | WorldAudioEnv::WorldAudioEnv(){ 10 | } 11 | 12 | WorldAudioEnv::~WorldAudioEnv(){ 13 | } 14 | 15 | void WorldAudioEnv::setAmbientTrack(const util::Str8& resource_name){ 16 | audio::AudioSourceHandle source; 17 | source.assignNewSource(audio::AudioSource::Type::Global); 18 | auto sound_instance= source.playSound(resource_name); 19 | 20 | // Loop 21 | if (sound_instance) 22 | sound_instance.setOnEndCallback(std::bind(&WorldAudioEnv::onAmbientEnd, this, std::placeholders::_1)); 23 | } 24 | 25 | void WorldAudioEnv::onAmbientEnd(const audio::SoundInstanceHandle& h) const { 26 | if (h && h.getSource()){ 27 | auto sound_instance= h.getSource().playSound(h.getSound()); 28 | if (sound_instance){ 29 | sound_instance.setOnEndCallback(std::bind(&WorldAudioEnv::onAmbientEnd, this, std::placeholders::_1)); 30 | } 31 | } 32 | } 33 | 34 | } // game 35 | } // clover -------------------------------------------------------------------------------- /code/source/hardware/hid_device_gamepad.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_HARDWARE_HID_DEVICE_GAMEPAD_HPP 2 | #define CLOVER_HARDWARE_HID_DEVICE_GAMEPAD_HPP 3 | 4 | #include "build.hpp" 5 | #include "ui/hid/controls/control_bidirectional.hpp" 6 | #include "ui/hid/controls/control_button.hpp" 7 | #include "ui/hid/controls/control_directional.hpp" 8 | #include "ui/hid/device.hpp" 9 | #include "util/dyn_array.hpp" 10 | 11 | namespace clover { 12 | namespace hardware { 13 | 14 | class GamepadHidDevice : public ui::hid::Device { 15 | public: 16 | static Ptr create(const ConstructInfo& info) 17 | { return Ptr{new GamepadHidDevice{info}}; } 18 | 19 | virtual void update() override; 20 | virtual util::Str8 getTypeName() const override { return "Gamepad"; } 21 | 22 | private: 23 | GamepadHidDevice(const ConstructInfo& info); 24 | 25 | int id; 26 | util::DynArray buttons; 27 | util::DynArray axes; 28 | util::DynArray biAxes; 29 | }; 30 | 31 | } // hardware 32 | } // clover 33 | 34 | #endif // CLOVER_HARDWARE_HID_DEVICE_GAMEPAD_HPP 35 | -------------------------------------------------------------------------------- /code/source/visual/shadertech_generic.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_VISUAL_SHADERTECH_GENERIC_HPP 2 | #define CLOVER_VISUAL_SHADERTECH_GENERIC_HPP 3 | 4 | #include "build.hpp" 5 | #include "shadertech.hpp" 6 | #include "resources/cache.hpp" 7 | 8 | namespace clover { 9 | namespace visual { 10 | 11 | class LightEntityLogic; 12 | class ModelEntityLogic; 13 | 14 | class GenericST : public WorldShaderTech { 15 | public: 16 | void setLightCount(int32 lights); 17 | void setEntity(const visual::ModelEntityDef& re, const visual::ModelEntityLogic& logic_cfg); 18 | void setLights(const util::DynArray& lights); 19 | 20 | virtual void use(); 21 | 22 | private: 23 | uint32 colorMap= 0; 24 | uint32 normalMap= 0; 25 | uint32 envShadowMap= 0; 26 | bool sway= false; 27 | bool disableEnv= false; 28 | 29 | real32 lightAlphaAdd= 0.0; 30 | util::Color colorMul; 31 | real32 swayPhaseMul= 0.0; 32 | real32 swayScale= 0.0; 33 | 34 | const util::DynArray* lights= nullptr; 35 | int32 lightCount= 0; 36 | }; 37 | 38 | } // visual 39 | } // clover 40 | 41 | #endif // CLOVER_VISUAL_SHADERTECH_GENERIC_HPP 42 | -------------------------------------------------------------------------------- /code/source/game/editor/components/ec_we_tools.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CLOVER_GAME_EDITOR_COMPONENTS_EC_WE_TOOLS_HPP 2 | #define CLOVER_GAME_EDITOR_COMPONENTS_EC_WE_TOOLS_HPP 3 | 4 | #include "../editorcomponent.hpp" 5 | #include "build.hpp" 6 | 7 | namespace clover { 8 | namespace game { namespace editor { 9 | 10 | class WeToolsEc; 11 | 12 | template <> 13 | struct EditorComponentTraits { 14 | static const util::Str8 name(){ return "WeTools"; } 15 | }; 16 | 17 | class WeToolsEc : public EditorComponent { 18 | public: 19 | DECLARE_EDITORCOMPONENT(WeToolsEc); 20 | 21 | WeToolsEc(); 22 | virtual ~WeToolsEc(){} 23 | 24 | void spawn(uint32 name_id); 25 | void setDebugDrawActive(bool b= true); 26 | bool isDebugDrawActive() const; 27 | 28 | /// Controls saving/loading 29 | void setChunksLocked(bool b= true); 30 | bool isChunksLocked() const; 31 | 32 | util::DynArray getWeNames() const; 33 | 34 | static void eraseTerrain(util::Vec2d pos); 35 | static void deleteWe(util::Vec2d pos); 36 | 37 | }; 38 | 39 | }} // game::editor 40 | } // clover 41 | 42 | #endif // CLOVER_GAME_EDITOR_COMPONENTS_EC_WE_TOOLS_HPP --------------------------------------------------------------------------------