// // eninge_test_xc.mm // pokemon_test_xc // // Created by Sam Jaffe on 12/22/18. // Copyright © 2018 Sam Jaffe. All rights reserved. // #import #include @interface engine_test_xc : NSObject -(NSString*) getResourceDir; @end @implementation engine_test_xc -(NSString*) getResourceDir { NSBundle* bundle = [NSBundle bundleForClass:[self class]]; NSDictionary* infoDict = [bundle infoDictionary]; return [infoDict objectForKey:@"Resource Directory"]; } @end std::string resource_dir() { engine_test_xc * test = [[engine_test_xc alloc] init]; return [[test getResourceDir] UTF8String]; } std::string resource(std::string const & rel_path) { return resource_dir() + "/" + rel_path; } #include "../test/stub_config.h" #include Json::Value construct_test_config(std::string const & dir = "") { Json::Value json; json["resource_path"] = dir.empty() ? resource_dir() : resource(dir); json["properties"]["object"] = "@resource/object"; return json; } Config Config::from_dir(std::string const & dir) { return Config(construct_test_config(dir)); } Config::Config() : engine::env::Config(construct_test_config()) {} Config::Config(std::string const & filename) : engine::env::Config(Config().resource(filename)) {} Config::Config(Json::Value const & properties) : engine::env::Config(properties) {}