void SurfaceObject::load(const std::string & filename) { if (selected_image == NULL) return; Color old_trans = selected_image->transparent; selected_image->reset(); selected_image->transparent = Color(255, 0, 255); // old_trans; std::string path = convert_path(filename); Image * image = NULL; #ifdef CHOWDREN_USE_CAPTURE if (!CaptureObject::filename.empty() && CaptureObject::filename == path) { image = &CaptureObject::image; } #endif if (image == NULL) image = get_image_cache(path, 0, 0, 0, 0, selected_image->transparent); selected_image->set_image(image); if (image == NULL) load_failed = true; set_edit_image(selected_index); }
void TextBlitter::load(const std::string & filename) { Image * new_image = get_image_cache(filename, 0, 0, 0, 0, transparent_color); if (new_image == NULL) { std::cout << "Could not load Text Blitter image " << filename << std::endl; return; } image = new_image; }
void Active::load(const chowstring & filename, int anim, int dir, int frame, int hot_x, int hot_y, int action_x, int action_y, TransparentColor transparent_color) { if (anim >= animations->count) return; if (dir < 0 || dir >= 32) return; Animation * animation = animations->items[anim]; Direction * direction = animation->dirs[dir]; if (frame >= direction->frame_count) return; Image * new_image = get_image_cache(convert_path(filename), 0, 0, 0, 0, transparent_color); if (new_image == NULL) { std::cout << "Could not load image " << filename << std::endl; return; } new_image->hotspot_x = get_active_load_point(hot_x, new_image->width); new_image->hotspot_y = get_active_load_point(hot_y, new_image->height); new_image->action_x = get_active_load_point(action_x, new_image->width); new_image->action_y = get_active_load_point(action_y, new_image->height); #ifdef CHOWDREN_ACTIVE_LOAD_SINGLE image = new_image; direction_data = direction; current_animation = forced_animation = anim; forced_frame = frame; #else Image * old_image = direction->frames[frame]; if (old_image == new_image) return; old_image->destroy(); new_image->upload_texture(); direction->frames[frame] = new_image; // update the frame for all actives of this type // this may break in the future, maybe ObjectList::iterator it; ObjectList & list = this->frame->instances.items[id]; for (it = list.begin(); it != list.end(); ++it) { Active * obj = (Active*)it->obj; obj->image = NULL; obj->update_frame(); } #endif }
void Image::replace(const std::string & path) { Image * other = get_image_cache(path, 0, 0, 0, 0, TransparentColor()); other->upload_texture(); if (other->width != width || other->height != height) { std::cout << "Dimensions do not match: " << path << std::endl; width = other->width; height = other->height; } unload(); tex = other->tex; #ifndef CHOWDREN_IS_WIIU alpha = other->alpha; #endif }
void SurfaceObject::load(const std::string & filename, const std::string & ignore_ext) { if (selected_image == NULL) return; Color old_trans = selected_image->transparent; selected_image->reset(); selected_image->transparent = Color(255, 0, 255); // old_trans; std::string path = convert_path(filename); Image * image = get_image_cache(path, 0, 0, 0, 0, selected_image->transparent); selected_image->set_image(image); if (image == NULL) load_failed = true; set_edit_image(selected_index); }
void CharacterImageObject::load(int alias, const std::string & c, const std::string & path, int x_hotspot, int y_hotspot) { Image * new_image = get_image_cache(convert_path(path), 0, 0, 0, 0, TransparentColor()); if (new_image == NULL) { std::cout << "Could not load image " << path << std::endl; return; } new_image->hotspot_x = get_load_point(x_hotspot, new_image->width); new_image->hotspot_y = get_load_point(y_hotspot, new_image->height); CharacterImageAlias & a = aliases[alias]; unsigned char cc = (unsigned char)c[0]; a.charmap[cc].image = new_image; }