Skip to content

Commit

Permalink
Bunch of things
Browse files Browse the repository at this point in the history
  • Loading branch information
Daivuk committed Mar 5, 2017
1 parent 8cd0766 commit 264b057
Show file tree
Hide file tree
Showing 14 changed files with 289 additions and 26 deletions.
5 changes: 5 additions & 0 deletions JSStandAlone/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ void initSettings()
value = onut::toUpper(value);
oSettings->setShowOnScreenLog(value == "TRUE" || value == "1" || value == "ON");
}
else if (what == "EDITORMODE")
{
value = onut::toUpper(value);
oSettings->setIsEditorMode(value == "TRUE" || value == "1" || value == "ON");
}
}
fic.close();
}
Expand Down
8 changes: 2 additions & 6 deletions include/micropather/micropather.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,8 @@ distribution.


#if defined( _DEBUG )
# if defined( _MSC_VER )
# define MPASSERT( x ) if ( !(x)) { _asm { int 3 } }
# else
# include <assert.h>
# define MPASSERT assert
# endif
# include <assert.h>
# define MPASSERT assert
#else
# define MPASSERT( x ) {}
#endif
Expand Down
5 changes: 3 additions & 2 deletions include/onut/ParticleSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,14 +229,15 @@ namespace onut
Textures textures;
sPfxValue<float> spread = 0;
Vector3 dir = Vector3(0, 0, 0);
sPfxRange<float> speed = 0;
sPfxValue<float> speed = 0;
sPfxValue<Color> color = Color::White;
sPfxValue<float> angle = 0;
sPfxValue<float> size = 1;
sPfxValue<unsigned int> image_index = 0;
sPfxRange<float> life = 1;
sPfxRange<float> delay = 0;
sPfxRange<Vector3> position = Vector3(0, 0, 0);
Vector3 gravity = Vector3(0, 0, 0);
sPfxValue<Vector3> gravity = Vector3(0, 0, 0);
sPfxRange<float> duration = 0;
sPfxValue<float> rotation = 0;
sPfxValue<float> radialAccel = 0;
Expand Down
3 changes: 3 additions & 0 deletions include/onut/TiledMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ namespace onut
Object *pObjects = nullptr;
};

static OTiledMapRef create(int width, int height, int tileSize);
static OTiledMapRef createFromFile(const std::string &filename, const OContentManagerRef& pContentManager = nullptr);

~TiledMap();
Expand All @@ -86,13 +87,15 @@ namespace onut

TileSet* getTileSet(int index) const;
TileSet* getTileSet(const std::string& name) const;
TileSet* addTileSet(const OTextureRef& pTexture, const std::string& name);

int getLayerCount() const { return m_layerCount; }
Layer* getLayer(int index) const { return m_layers[index]; }
Layer* getLayer(const std::string &name) const;
int getLayerIndex(const std::string &name) const;
bool* generateCollisions(const std::string &collisionLayerName);
bool* getCollisionTiles() const { return m_pCollisionTiles; }
Layer* addLayer(const std::string &name);

const OTextureRef& getMinimap();

Expand Down
6 changes: 6 additions & 0 deletions include/onut/onut.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
#ifndef ONUT_H_INCLUDED
#define ONUT_H_INCLUDED

#include <functional>
#include <string>
#include <vector>

namespace onut
{
void run(std::function<void()> initCallback,
std::function<void()> updateCallback,
std::function<void()> renderCallback,
std::function<void()> postRenderCallback);
void quit();
}

extern std::vector<std::string> OArguments;

#define ORun onut::run
#define OQuit onut::quit

#endif
87 changes: 87 additions & 0 deletions project/win/onut.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,18 @@
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\..\ggj16\Box2D\Box2D.h" />
Expand Down Expand Up @@ -70,7 +78,9 @@
<ClInclude Include="..\..\include\onut\Camera2DComponent.h" />
<ClInclude Include="..\..\include\onut\Cloud.h">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="..\..\include\onut\Collider2DComponent.h" />
<ClInclude Include="..\..\include\onut\Color.h" />
Expand Down Expand Up @@ -205,7 +215,9 @@
<ClInclude Include="..\..\src\braincloud\ServiceOperation.h" />
<ClInclude Include="..\..\src\CloudBrainCloud.h">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="..\..\src\dirent\dirent.h" />
<ClInclude Include="..\..\src\duktape\duktape.h" />
Expand Down Expand Up @@ -310,11 +322,15 @@
<ClCompile Include="..\..\src\Camera2DComponent.cpp" />
<ClCompile Include="..\..\src\Cloud.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\CloudBrainCloud.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\Collider2DComponent.cpp" />
<ClCompile Include="..\..\src\Color.cpp" />
Expand Down Expand Up @@ -443,22 +459,41 @@
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
Expand All @@ -485,6 +520,30 @@
</AdditionalLibraryDirectories>
</Lib>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>ONUT_SHOW_FPS;NOMINMAX;ONUT;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../../include;../../src;../../include/rapidjson</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<MinimalRebuild>false</MinimalRebuild>
<DisableSpecificWarnings>4005</DisableSpecificWarnings>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>d3d11.lib;dxgi.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Lib>
<AdditionalDependencies>D3DCompiler.lib;Winhttp.lib;Mfplat.lib;dxgi.lib;d3d11.lib;xinput.lib;dinput8.lib;dxguid.lib;msxml6.lib;comsuppwd.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>
</AdditionalLibraryDirectories>
</Lib>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
Expand Down Expand Up @@ -513,6 +572,34 @@
</AdditionalLibraryDirectories>
</Lib>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NOMINMAX;ONUT;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../../include;../../src;../../include/rapidjson</AdditionalIncludeDirectories>
<DisableSpecificWarnings>4005</DisableSpecificWarnings>
<TreatWarningAsError>false</TreatWarningAsError>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>d3d11.lib;dxgi.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Lib>
<AdditionalDependencies>D3DCompiler.lib;Winhttp.lib;Mfplat.lib;dxgi.lib;d3d11.lib;xinput.lib;dinput8.lib;dxguid.lib;msxml6.lib;comsuppwd.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>
</AdditionalLibraryDirectories>
</Lib>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
Expand Down
77 changes: 77 additions & 0 deletions src/JSBindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,15 @@ namespace onut

std::unordered_map<std::string, JSComponentDefinitionRef> jsComponentDefinitions;

void updateViewport()
{
auto& pRenderTarget = oRenderer->renderStates.renderTarget.get();
Point resolution;
if (pRenderTarget) resolution = pRenderTarget->getSize();
else resolution = oRenderer->getTrueResolution();
oRenderer->renderStates.viewport = iRect{0, 0, resolution.x, resolution.y};
}

// Helpers
#define FLOAT_PROP(__name__, __index__) \
auto __name__ = 0.0f; \
Expand Down Expand Up @@ -4313,12 +4322,58 @@ namespace onut
}, 1);
duk_put_prop_string(ctx, -2, "getLayerIndex");

// addLayer
duk_push_c_function(ctx, [](duk_context *ctx)->duk_ret_t
{
duk_push_this(ctx);
duk_get_prop_string(ctx, -1, "\xff""\xff""data");
auto ppTiledMap = (OTiledMapRef*)duk_to_pointer(ctx, -1);
if (ppTiledMap)
{
duk_pop(ctx);
auto pTiledMap = ppTiledMap->get();
if (pTiledMap)
{
pTiledMap->addLayer(JS_STRING(0));
}
}
return 0;
}, 1);
duk_put_prop_string(ctx, -2, "addLayer");

// addTileSet
duk_push_c_function(ctx, [](duk_context *ctx)->duk_ret_t
{
duk_push_this(ctx);
duk_get_prop_string(ctx, -1, "\xff""\xff""data");
auto ppTiledMap = (OTiledMapRef*)duk_to_pointer(ctx, -1);
if (ppTiledMap)
{
duk_pop(ctx);
auto pTiledMap = ppTiledMap->get();
if (pTiledMap)
{
pTiledMap->addTileSet(JS_TEXTURE(0), "");
}
}
return 0;
}, 1);
duk_put_prop_string(ctx, -2, "addTileSet");

// Done with the object
pTiledMapPrototype = duk_get_heapptr(ctx, -1);
duk_put_prop_string(ctx, -2, "prototype");

// createFromFile(filename)
duk_push_c_function(ctx, [](duk_context *ctx)->duk_ret_t
{
newTiledMap(ctx, OTiledMap::create(JS_INT(0), JS_INT(1), JS_INT(2)));
return 1;
}, 3);
duk_put_prop_string(ctx, -2, "create");

// create(filename)
duk_push_c_function(ctx, [](duk_context *ctx)->duk_ret_t
{
newTiledMap(ctx, OGetTiledMap(duk_get_string(ctx, 0)));
return 1;
Expand Down Expand Up @@ -8818,19 +8873,22 @@ namespace onut
{
auto pTexture = JS_TEXTURE(0);
oRenderer->renderStates.renderTarget = pTexture;
updateViewport();
return 0;
}
JS_INTERFACE_FUNCTION_END("setRenderTarget", 1);
JS_INTERFACE_FUNCTION_BEGIN
{
auto pTexture = JS_TEXTURE(0);
oRenderer->renderStates.renderTarget.push(pTexture);
updateViewport();
return 0;
}
JS_INTERFACE_FUNCTION_END("pushRenderTarget", 1);
JS_INTERFACE_FUNCTION_BEGIN
{
oRenderer->renderStates.renderTarget.pop();
updateViewport();
return 0;
}
JS_INTERFACE_FUNCTION_END("popRenderTarget", 0);
Expand Down Expand Up @@ -9363,6 +9421,25 @@ namespace onut
}
JS_INTERFACE_END("PrimitiveBatch");

JS_INTERFACE_BEGIN();
{
JS_INTERFACE_FUNCTION_BEGIN
{
srand((unsigned int)JS_UINT(0));
return 0;
}
JS_INTERFACE_FUNCTION_END("seed", 1);
JS_INTERFACE_FUNCTION_BEGIN
{
int mod = JS_INT(0);
duk_double_t val = (duk_double_t)((int)rand() % mod);
duk_push_number(ctx, val);
return 1;
}
JS_INTERFACE_FUNCTION_END("getNext", 1);
}
JS_INTERFACE_END("Random");

// oInput
JS_INTERFACE_BEGIN();
{
Expand Down
Loading

0 comments on commit 264b057

Please sign in to comment.