Skip to content

Commit

Permalink
fixed handling of iphone controls in the compilation process
Browse files Browse the repository at this point in the history
  • Loading branch information
davewx7 committed Nov 21, 2012
1 parent 78da4cc commit 4ab8095
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
7 changes: 7 additions & 0 deletions compile-objects.cfg
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,7 @@
//this file configures custom query scripts that are run at the end of the
//compile objects utility to massage the final content.
{
query: [
["./modules/frogatto/data/compiled/gui/iphone_controls.cfg", "map(animation, if(strstr(value.id, 'android'), set(value.scale, '@eval min( SCREEN_WIDTH * 0.23 / 79, SCREEN_HEIGHT * 0.4 / 111 )')))"]
]
}
18 changes: 17 additions & 1 deletion src/utility_object_compiler.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include "variant_utils.hpp" #include "variant_utils.hpp"
#include "IMG_savepng.h" #include "IMG_savepng.h"


void UTILITY_query(const std::vector<std::string>& args);

namespace { namespace {
const int TextureImageSize = 1024; const int TextureImageSize = 1024;


Expand Down Expand Up @@ -179,7 +181,7 @@ UTILITY(compile_objects)
continue; continue;
} }


gui_nodes[gui] = json::parse_from_file("data/gui/" + gui, json::JSON_NO_PREPROCESSOR); gui_nodes[gui] = json::parse_from_file("data/gui/" + gui);
animation_containing_nodes.push_back(gui_nodes[gui]); animation_containing_nodes.push_back(gui_nodes[gui]);
if(gui_nodes[gui].has_key("no_compile_image")) { if(gui_nodes[gui].has_key("no_compile_image")) {
std::vector<std::string> images = util::split(gui_nodes[gui][variant("no_compile_image")].as_string()); std::vector<std::string> images = util::split(gui_nodes[gui][variant("no_compile_image")].as_string());
Expand Down Expand Up @@ -427,4 +429,18 @@ UTILITY(compile_objects)
i != gui_nodes.end(); ++i) { i != gui_nodes.end(); ++i) {
module::write_file("data/compiled/gui/" + i->first, i->second.write_json()); module::write_file("data/compiled/gui/" + i->first, i->second.write_json());
} }

if(sys::file_exists("./compile-objects.cfg")) {
variant script = json::parse(sys::read_file("./compile-objects.cfg"));
if(script["query"].is_list()) {
foreach(variant query, script["query"].as_list()) {
std::vector<std::string> args;
foreach(variant arg, query.as_list()) {
args.push_back(arg.as_string());
}

UTILITY_query(args);
}
}
}
} }

0 comments on commit 4ab8095

Please sign in to comment.