| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
- //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
- #include "Wrappers/BsScriptPlatformInfo.h"
- #include "BsScriptMeta.h"
- #include "BsMonoField.h"
- #include "BsMonoClass.h"
- #include "BsMonoManager.h"
- #include "BsMonoMethod.h"
- #include "BsMonoUtil.h"
- #include "Wrappers/BsScriptPrefab.h"
- #include "Wrappers/BsScriptRRefBase.h"
- #include "BsScriptResourceManager.h"
- namespace bs
- {
- ScriptPlatformInfoBase::ScriptPlatformInfoBase(MonoObject* instance)
- :ScriptObjectBase(instance)
- { }
- ScriptPlatformInfo::ScriptPlatformInfo(MonoObject* instance)
- : ScriptObject(instance)
- {
- }
- void ScriptPlatformInfo::initRuntimeData()
- {
- metaData.scriptClass->addInternalCall("Internal_GetType", (void*)&ScriptPlatformInfo::internal_GetType);
- metaData.scriptClass->addInternalCall("Internal_GetDefines", (void*)&ScriptPlatformInfo::internal_GetDefines);
- metaData.scriptClass->addInternalCall("Internal_SetDefines", (void*)&ScriptPlatformInfo::internal_SetDefines);
- metaData.scriptClass->addInternalCall("Internal_GetMainScene", (void*)&ScriptPlatformInfo::internal_GetMainScene);
- metaData.scriptClass->addInternalCall("Internal_SetMainScene", (void*)&ScriptPlatformInfo::internal_SetMainScene);
- metaData.scriptClass->addInternalCall("Internal_GetFullscreen", (void*)&ScriptPlatformInfo::internal_GetFullscreen);
- metaData.scriptClass->addInternalCall("Internal_SetFullscreen", (void*)&ScriptPlatformInfo::internal_SetFullscreen);
- metaData.scriptClass->addInternalCall("Internal_GetResolution", (void*)&ScriptPlatformInfo::internal_GetResolution);
- metaData.scriptClass->addInternalCall("Internal_SetResolution", (void*)&ScriptPlatformInfo::internal_SetResolution);
- metaData.scriptClass->addInternalCall("Internal_GetDebug", (void*)&ScriptPlatformInfo::internal_GetDebug);
- metaData.scriptClass->addInternalCall("Internal_SetDebug", (void*)&ScriptPlatformInfo::internal_SetDebug);
- }
- MonoObject* ScriptPlatformInfo::create(const SPtr<PlatformInfo>& platformInfo)
- {
- switch (platformInfo->type)
- {
- case PlatformType::Windows:
- return ScriptWinPlatformInfo::create(std::static_pointer_cast<WinPlatformInfo>(platformInfo));
- default:
- break;
- }
- return nullptr;
- }
- PlatformType ScriptPlatformInfo::internal_GetType(ScriptPlatformInfoBase* thisPtr)
- {
- return thisPtr->getPlatformInfo()->type;
- }
- MonoString* ScriptPlatformInfo::internal_GetDefines(ScriptPlatformInfoBase* thisPtr)
- {
- return MonoUtil::stringToMono(thisPtr->getPlatformInfo()->defines);
- }
- void ScriptPlatformInfo::internal_SetDefines(ScriptPlatformInfoBase* thisPtr, MonoString* value)
- {
- thisPtr->getPlatformInfo()->defines = MonoUtil::monoToString(value);
- }
- MonoObject* ScriptPlatformInfo::internal_GetMainScene(ScriptPlatformInfoBase* thisPtr)
- {
- HPrefab prefab = thisPtr->getPlatformInfo()->mainScene;
-
- if (prefab != nullptr)
- {
- ScriptRRefBase* scriptRRef = ScriptResourceManager::instance().getScriptRRef(prefab);
- if(scriptRRef)
- return scriptRRef->getManagedInstance();
- }
- return nullptr;
- }
- void ScriptPlatformInfo::internal_SetMainScene(ScriptPlatformInfoBase* thisPtr, ScriptRRefBase* prefabRef)
- {
- HPrefab prefab;
- if (prefabRef != nullptr)
- prefab = static_resource_cast<Prefab>(prefabRef->getHandle());
- thisPtr->getPlatformInfo()->mainScene = prefab;
- }
- bool ScriptPlatformInfo::internal_GetFullscreen(ScriptPlatformInfoBase* thisPtr)
- {
- return thisPtr->getPlatformInfo()->fullscreen;
- }
- void ScriptPlatformInfo::internal_SetFullscreen(ScriptPlatformInfoBase* thisPtr, bool fullscreen)
- {
- thisPtr->getPlatformInfo()->fullscreen = fullscreen;
- }
- void ScriptPlatformInfo::internal_GetResolution(ScriptPlatformInfoBase* thisPtr, UINT32* width, UINT32* height)
- {
- *width = thisPtr->getPlatformInfo()->windowedWidth;
- *height = thisPtr->getPlatformInfo()->windowedHeight;
- }
- void ScriptPlatformInfo::internal_SetResolution(ScriptPlatformInfoBase* thisPtr, UINT32 width, UINT32 height)
- {
- thisPtr->getPlatformInfo()->windowedWidth = width;
- thisPtr->getPlatformInfo()->windowedHeight = height;
- }
- bool ScriptPlatformInfo::internal_GetDebug(ScriptPlatformInfoBase* thisPtr)
- {
- return thisPtr->getPlatformInfo()->debug;
- }
- void ScriptPlatformInfo::internal_SetDebug(ScriptPlatformInfoBase* thisPtr, bool debug)
- {
- thisPtr->getPlatformInfo()->debug = debug;
- }
- ScriptWinPlatformInfo::ScriptWinPlatformInfo(MonoObject* instance)
- :ScriptObject(instance)
- {
- mPlatformInfo = bs_shared_ptr_new<WinPlatformInfo>();
- }
- void ScriptWinPlatformInfo::initRuntimeData()
- {
- metaData.scriptClass->addInternalCall("Internal_GetIcon", (void*)&ScriptWinPlatformInfo::internal_GetIcon);
- metaData.scriptClass->addInternalCall("Internal_SetIcon", (void*)&ScriptWinPlatformInfo::internal_SetIcon);
- metaData.scriptClass->addInternalCall("Internal_GetTitleText", (void*)&ScriptWinPlatformInfo::internal_GetTitleText);
- metaData.scriptClass->addInternalCall("Internal_SetTitleText", (void*)&ScriptWinPlatformInfo::internal_SetTitleText);
- }
- SPtr<WinPlatformInfo> ScriptWinPlatformInfo::getWinPlatformInfo() const
- {
- return std::static_pointer_cast<WinPlatformInfo>(mPlatformInfo);
- }
- MonoObject* ScriptWinPlatformInfo::create(const SPtr<WinPlatformInfo>& platformInfo)
- {
- MonoObject* managedInstance = metaData.scriptClass->createInstance();
- ScriptWinPlatformInfo* scriptObj = new (bs_alloc<ScriptWinPlatformInfo>()) ScriptWinPlatformInfo(managedInstance);
- scriptObj->mPlatformInfo = platformInfo;
- return managedInstance;
- }
- MonoObject* ScriptWinPlatformInfo::internal_GetIcon(ScriptWinPlatformInfo* thisPtr)
- {
- HTexture icon = thisPtr->getWinPlatformInfo()->icon;
- if (icon != nullptr)
- {
- ScriptRRefBase* scriptRRef = ScriptResourceManager::instance().getScriptRRef(icon);
- if(scriptRRef)
- return scriptRRef->getManagedInstance();
- }
- return nullptr;
- }
- void ScriptWinPlatformInfo::internal_SetIcon(ScriptWinPlatformInfo* thisPtr, ScriptRRefBase* textureRef)
- {
- HTexture icon;
- if (textureRef != nullptr)
- icon = static_resource_cast<Texture>(textureRef->getHandle());
- thisPtr->getWinPlatformInfo()->icon = icon;
- }
- MonoString* ScriptWinPlatformInfo::internal_GetTitleText(ScriptWinPlatformInfo* thisPtr)
- {
- WString titleText = thisPtr->getWinPlatformInfo()->titlebarText;
- return MonoUtil::wstringToMono(titleText);
- }
- void ScriptWinPlatformInfo::internal_SetTitleText(ScriptWinPlatformInfo* thisPtr, MonoString* text)
- {
- WString titleText = MonoUtil::monoToWString(text);
- thisPtr->getWinPlatformInfo()->titlebarText = titleText;
- }
- }
|