| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- //
- // eninge_test_xc.mm
- // pokemon_test_xc
- //
- // Created by Sam Jaffe on 12/22/18.
- // Copyright © 2018 Sam Jaffe. All rights reserved.
- //
- #import <Foundation/Foundation.h>
- #include <string>
- @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/json.h>
- 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) {}
|