Merge branch 'main' of https://github.com/geode-sdk/geode into main

This commit is contained in:
HJfod 2023-03-12 18:55:51 +02:00
commit baa9f1f034
3 changed files with 22 additions and 13 deletions

View file

@ -1234,6 +1234,8 @@ class EditorUI : cocos2d::CCLayer, FLAlertLayerProtocol, ColorSelectDelegate, GJ
void zoomIn(cocos2d::CCObject* sender) = mac 0xc0c0, win 0x877c0;
void zoomOut(cocos2d::CCObject* sender) = mac 0xc120, win 0x87830;
void rotateObjects(cocos2d::CCArray* objects, float angle, cocos2d::CCPoint center) = mac 0x236a0, win 0x8ee80;
void flipObjectsX(cocos2d::CCArray* objects) = win 0x8e550;
void flipObjectsY(cocos2d::CCArray* objects) = win 0x8e9e0;
void updateGridNodeSize() = mac 0x1c8a0, win 0x78f60;
void updateSpecialUIElements() = win 0x87030;
void constrainGameLayerPosition(float x, float y) = mac 0x18890, win 0x8f920;

View file

@ -682,19 +682,12 @@ namespace geode::cocos {
return res;
}
// template<typename K, typename V,
// typename = std::enable_if_t<std::is_same_v<K, std::string> || std::is_same_v<K, intptr_t>> >
// static std::map<K, V> ccDictToMap(cocos2d::CCDictionary* dict) {
// auto res = std::map<K, V>();
// cocos2d::CCDictElement* element = nullptr;
// CCDICT_FOREACH(dict, element) {
// if constexpr (std::is_same_v<K, std::string>)
// res[element->getStrKey()] = element->getObject();
// if constexpr (std::is_same_v<K, intptr_t>)
// res[element->getIntKey()] = element->getObject();
// }
// return res;
// }
/**
* Gets the mouse position in cocos2d coordinates.
* On mobile platforms this will probably return (0, 0)
* @returns The mouse position
*/
GEODE_DLL cocos2d::CCPoint getMousePos();
}
// std specializations

View file

@ -330,6 +330,20 @@ CCScene* geode::cocos::switchToScene(CCLayer* layer) {
return scene;
}
CCPoint geode::cocos::getMousePos() {
#ifdef GEODE_IS_WINDOWS
auto* director = CCDirector::get();
auto* gl = director->getOpenGLView();
auto winSize = director->getWinSize();
auto frameSize = gl->getFrameSize();
auto mouse = gl->getMousePosition() / frameSize;
return ccp(mouse.x, 1.f - mouse.y) * winSize;
#else
// TODO: implement this for mac
return ccp(0, 0);
#endif
}
static CreateLayerFunc LOADING_FINISHED_SCENE = nullptr;
void geode::cocos::reloadTextures(CreateLayerFunc returnTo) {