InfoTree SpokePreferencesTree()
{
	InfoTree root;
	
	for (size_t i = 0; i < kNumInt32Attributes; ++i)
		root.put_attr(sAttributeStrings[i], *(sAttributeDestinations[i]));
	root.put_attr("adjust_timing", sSpokePreferences.mAdjustTiming);
	
	return root;
}
Example #2
0
void WadImageCache::save_cache()
{
	if (!m_cache_dirty)
		return;
	
	InfoTree pt;
	
	for (cache_iter_t it = m_used.begin(); it != m_used.end(); ++it)
	{
		std::string name = it->second.first;
		WadImageDescriptor desc = boost::tuples::get<0>(it->first);
		
		pt.put(name + ".path", desc.file.GetPath());
		pt.put(name + ".checksum", desc.checksum);
		pt.put(name + ".index", desc.index);
		pt.put(name + ".tag", desc.tag);
		pt.put(name + ".width", boost::tuples::get<1>(it->first));
		pt.put(name + ".height", boost::tuples::get<2>(it->first));
		pt.put(name + ".filesize", it->second.second);
	}
	
	FileSpecifier info;
	info.SetToImageCacheDir();
	info.AddPart("Cache.ini");
	try {
		pt.save_ini(info);
		m_cache_dirty = false;
	} catch (InfoTree::ini_error e) {
		logError("Could not save image cache to %s (%s)", info.GetPath(), e.what());
		return;
	}
}
void parse_mml_opengl_txtr_clear(const InfoTree& root)
{
	int16 coll;
	if (root.read_indexed("coll", coll, NUMBER_OF_COLLECTIONS))
		TODelete(coll);
	else
		TODelete_All();
}
Example #4
0
static void parse_bounding_box(const InfoTree& root, Model3D& Model)
{
	float x_size = 0;
	float y_size = 0;
	float z_size = 0;
	float x_offset = 0;
	float y_offset = 0;
	float z_offset = 0;
	
	std::string tempstr;
	if (root.read_attr("size", tempstr))
		sscanf(tempstr.c_str(), "%f,%f,%f", &x_size, &y_size, &z_size);
	if (root.read_attr("offset", tempstr))
		sscanf(tempstr.c_str(), "%f,%f,%f", &x_offset, &y_offset, &z_offset);
	root.read_attr("x_size", x_size);
	root.read_attr("y_size", x_size);
	root.read_attr("z_size", x_size);
	root.read_attr("x_offset", x_offset);
	root.read_attr("y_offset", y_offset);
	root.read_attr("z_offset", z_offset);
	
	Model.BoundingBox[0][0] = x_offset - x_size/2;
	Model.BoundingBox[0][1] = y_offset - y_size;
	Model.BoundingBox[0][2] = z_offset - z_size/2;
	
	Model.BoundingBox[1][0] = x_offset + x_size/2;
	Model.BoundingBox[1][1] = y_offset;
	Model.BoundingBox[1][2] = z_offset + z_size/2;
}
void SpokeParsePreferencesTree(InfoTree prefs, std::string version)
{
	for (size_t i = 0; i < kNumInt32Attributes; ++i)
	{
		int32 value = *(sAttributeDestinations[i]);
		if (prefs.read_attr(sAttributeStrings[i], value))
		{
			int32 min = INT32_MIN;
			switch (i) {
				case kPregameTicksBeforeNetDeathAttribute:
				case kInGameTicksBeforeNetDeathAttribute:
				case kRecoverySendPeriodAttribute:
				case kTimingWindowSizeAttribute:
					min = 1;
					break;
				case kTimingNthElementAttribute:
					min = 0;
					break;
			}
			if (value < min)
				logWarning("improper value %d for attribute %s of <spoke>; must be at least %d. using default of %d", value, sAttributeStrings[i], min, *(sAttributeDestinations[i]));
			else
				*(sAttributeDestinations[i]) = value;
		}
	}

	prefs.read_attr("adjust_timing", sSpokePreferences.mAdjustTiming);
	
	
	// The checks above are not sufficient to catch all bad cases; if user specified a window size
	// smaller than default, this is our only chance to deal with it.
	if(sSpokePreferences.mTimingNthElement >= sSpokePreferences.mTimingWindowSize)
	{
		logWarning("value for <spoke> attribute %s (%d) must be less than value for %s (%d).  using %d", sAttributeStrings[kTimingNthElementAttribute], sSpokePreferences.mTimingNthElement, sAttributeStrings[kTimingWindowSizeAttribute], sSpokePreferences.mTimingWindowSize, sSpokePreferences.mTimingWindowSize - 1);
		
		sSpokePreferences.mTimingNthElement = sSpokePreferences.mTimingWindowSize - 1;
	}
}
Example #6
0
bool
Gui::display(movie_root* m)
{
    assert(m == _stage); // why taking this arg ??

    assert(_started);
    
    InvalidatedRanges changed_ranges;
    bool redraw_flag;
    
    // Should the frame be rendered completely, even if it did not change?
#ifdef FORCE_REDRAW
    redraw_flag = true;
#else	
    redraw_flag = _redraw_flag || want_redraw();
#endif	
    
    // reset class member if we do a redraw now
    if (redraw_flag) _redraw_flag=false;
    
    // Find out the surrounding frame of all characters which
    // have been updated. This just checks what region of the stage has changed
    // due to ActionScript code, the timeline or user events. The GUI can still
    // choose to render a different part of the stage. 
    //
    if (!redraw_flag) {
        
        // choose snapping ranges factor 
        changed_ranges.setSnapFactor(1.3f);  
	
        // Use multi ranges only when GUI/Renderer supports it
        // (Useless CPU overhead, otherwise)
        changed_ranges.setSingleMode(!want_multiple_regions());
        
        // scan through all sprites to compute invalidated bounds  
        m->add_invalidated_bounds(changed_ranges, false);
	
        // grow ranges by a 2 pixels to avoid anti-aliasing issues		
        changed_ranges.growBy(40.0f / _xscale);
	
        // optimize ranges
        changed_ranges.combineRanges();	
    }
    
    // TODO: Remove this and want_redraw to avoid confusion!?
    if (redraw_flag)  {
        changed_ranges.setWorld();
    }
    
    // DEBUG ONLY:
    // This is a good place to inspect the invalidated bounds state. Enable
    // the following block (and parts of it) if you need to. 
#if 0
    {
        // This may print a huge amount of information, but is useful to analyze
        // the (visible) object structure of the movie and the flags of the
        // characters. For example, a characters should have set the 
        // m_child_invalidated flag if at least one of it's childs has the
        // invalidated flag set.
        log_debug("DUMPING CHARACTER TREE"); 
        
        InfoTree tr;
        InfoTree::iterator top = tr.begin();
        _stage->getMovieInfo(tr, top);
        
        for (InfoTree::iterator i = tr.begin(), e = tr.end();
             i != e; ++i) {
            std::cout << std::string(tr.depth(i) * 2, ' ') << i->first << ": " << 
                i->second << std::endl;
        }
        
        
        // less verbose, and often necessary: see the exact coordinates of the
        // invalidated bounds (mainly to see if it's NULL or something else).	
        std::cout << "Calculated changed ranges: " << changed_ranges << "\n";
    }
#endif
    
    // Avoid drawing of stopped movies
    if ( ! changed_ranges.isNull() ) { // use 'else'?
        // Tell the GUI(!) that we only need to update this
        // region. Note the GUI can do whatever it wants with
        // this information. It may simply ignore the bounds
        // (which will normally lead into a complete redraw),
        // or it may extend or shrink the bounds as it likes. So,
        // by calling set_invalidated_bounds we have no guarantee
        // that only this part of the stage is rendered again.
#ifdef REGION_UPDATES_DEBUGGING_FULL_REDRAW
        // redraw the full screen so that only the
        // *new* invalidated region is visible
        // (helps debugging)
        InvalidatedRanges world_ranges;
        world_ranges.setWorld();
        setInvalidatedRegions(world_ranges);
#else
        setInvalidatedRegions(changed_ranges);
#endif
        
        // TODO: should this be called even if we're late ?
        beforeRendering();
        
        // Render the frame, if not late.
        // It's up to the GUI/renderer combination
        // to do any clipping, if desired.     
        m->display();
        
        // show invalidated region using a red rectangle
        // (Flash debug style)
        IF_DEBUG_REGION_UPDATES (
            if (_renderer.get() && !changed_ranges.isWorld()) {
                for (size_t rno = 0; rno < changed_ranges.size(); rno++) {
                    const geometry::Range2d<int>& bounds = 
                        changed_ranges.getRange(rno);
                    
                    float xmin = bounds.getMinX();
                    float xmax = bounds.getMaxX();
                    float ymin = bounds.getMinY();
                    float ymax = bounds.getMaxY();
                    
                    const std::vector<point> box = {
                        point(xmin, ymin),
                        point(xmax, ymin),
                        point(xmax, ymax),
                        point(xmin, ymax)
                    };
                    
                    _renderer->draw_poly(box, rgba(0,0,0,0), rgba(255,0,0,255),
                                         SWFMatrix(), false);
                    
                }
            }
        );
Example #7
0
void Navigator::insertInfoDocs( NavigatorItem *topItem )
{
  InfoTree *infoTree = new InfoTree( this );
  infoTree->build( topItem );
}
Example #8
0
void WadImageCache::initialize_cache()
{
	FileSpecifier info;
	info.SetToImageCacheDir();
	info.AddPart("Cache.ini");
	if (!info.Exists())
		return;
	
	InfoTree pt;
	try {
		pt = InfoTree::load_ini(info);
	} catch (InfoTree::ini_error e) {
		logError("Could not read image cache from %s (%s)", info.GetPath(), e.what());
	}
	
	for (InfoTree::iterator it = pt.begin(); it != pt.end(); ++it)
	{
		std::string name = it->first;
		InfoTree ptc = it->second;
		
		WadImageDescriptor desc;
		
		std::string path;
		ptc.read("path", path);
		desc.file = FileSpecifier(path);
		
		ptc.read("checksum", desc.checksum);
		ptc.read("index", desc.index);
		ptc.read("tag", desc.tag);
		
		int width = 0;
		ptc.read("width", width);
		int height = 0;
		ptc.read("height", height);
		size_t filesize = 0;
		ptc.read("filesize", filesize);
		
		cache_key_t key = cache_key_t(desc, width, height);
		cache_value_t val = cache_value_t(name, filesize);
		m_used.push_front(cache_pair_t(key, val));
		m_cacheinfo[key] = m_used.begin();
		m_cachesize += filesize;
	}
}
void parse_mml_opengl_texture(const InfoTree& root)
{
	int16 coll;
	if (!root.read_indexed("coll", coll, NUMBER_OF_COLLECTIONS))
		return;
	
	int16 bitmap;
	if (!root.read_indexed("bitmap", bitmap, INT16_MAX+1))
		return;
	
	int16 clut = ALL_CLUTS;
	root.read_attr_bounded<int16>("clut", clut, ALL_CLUTS, SILHOUETTE_BITMAP_SET);
	
	int16 clut_variant = CLUT_VARIANT_NORMAL;
	root.read_attr_bounded<int16>("clut_variant", clut_variant, ALL_CLUT_VARIANTS, NUMBER_OF_CLUT_VARIANTS-1);

	// translate deprecated clut options
	if (clut == INFRAVISION_BITMAP_SET)
	{
		clut = ALL_CLUTS;
		clut_variant = CLUT_VARIANT_INFRAVISION;
	}
	else if (clut == SILHOUETTE_BITMAP_SET)
	{
		clut = ALL_CLUTS;
		clut_variant = CLUT_VARIANT_SILHOUETTE;
	}
	
	// loop so we can apply "all variants" mode if needed
	for (short var = CLUT_VARIANT_NORMAL; var < NUMBER_OF_CLUT_VARIANTS; var++)
	{
		if (clut_variant != ALL_CLUT_VARIANTS && clut_variant != var)
			continue;
		
		// translate clut+variant to internal clut number
		short actual_clut = clut;
		if (var == CLUT_VARIANT_INFRAVISION)
		{
			if (clut == ALL_CLUTS)
				actual_clut = INFRAVISION_BITMAP_SET;
			else
				actual_clut = INFRAVISION_BITMAP_CLUTSPECIFIC + clut;
		}
		else if (var == CLUT_VARIANT_SILHOUETTE)
		{
			if (clut == ALL_CLUTS)
				actual_clut = SILHOUETTE_BITMAP_SET;
			else
				actual_clut = SILHOUETTE_BITMAP_CLUTSPECIFIC + clut;
		}
		
		TOHash::iterator it = Collections[coll].find(TOKey(actual_clut, bitmap));
		if (it == Collections[coll].end())
		{
			Collections[coll][TOKey(actual_clut, bitmap)] = DefaultTextureOptions;
			it = Collections[coll].find(TOKey(actual_clut, bitmap));
		}
		
		OGL_TextureOptions& def = it->second;
		root.read_indexed("opac_type", def.OpacityType, OGL_NUMBER_OF_OPACITY_TYPES);
		root.read_attr("opac_scale", def.OpacityScale);
		root.read_attr("opac_shift", def.OpacityShift);
		root.read_attr("void_visible", def.VoidVisible);
		root.read_path("normal_image", def.NormalColors);
		root.read_path("offset_image", def.OffsetMap);
		root.read_path("normal_mask", def.NormalMask);
		root.read_path("glow_image", def.GlowColors);
		root.read_path("glow_mask", def.GlowMask);
		root.read_indexed("normal_blend", def.NormalBlend, OGL_NUMBER_OF_BLEND_TYPES);
		root.read_indexed("glow_blend", def.GlowBlend, OGL_NUMBER_OF_BLEND_TYPES);
		root.read_attr("actual_height", def.actual_height);
		root.read_attr("actual_width", def.actual_width);
		root.read_attr("type", def.Type);
		root.read_attr("normal_premultiply", def.NormalIsPremultiplied);
		root.read_attr("glow_premultiply", def.GlowIsPremultiplied);
		root.read_attr("normal_bloom_scale", def.BloomScale);
		root.read_attr("normal_bloom_shift", def.BloomShift);
		root.read_attr("glow_bloom_scale", def.GlowBloomScale);
		root.read_attr("glow_bloom_shift", def.GlowBloomShift);
		root.read_attr("landscape_bloom", def.LandscapeBloom);
		root.read_attr("minimum_glow_intensity", def.MinGlowIntensity);
	}
}