From 1d518a54914531d7a4fab3a6835b75de85bd7bc7 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Wed, 9 Jul 2014 19:18:31 +0000 Subject: Initial support for multi-layered materials, requires shaders files in the new format. --- src/client/savegamemenu.cc | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) (limited to 'src/client') diff --git a/src/client/savegamemenu.cc b/src/client/savegamemenu.cc index 8efd746..78cf56f 100644 --- a/src/client/savegamemenu.cc +++ b/src/client/savegamemenu.cc @@ -218,7 +218,7 @@ void SaveGameMenu::refresh() listitem->set_label("new"); listitem->set_sortkey("[new]"); listitem->set_font(ui::root()->font_tiny()); - listitem->set_height(listitem->font()->height() * 2.0f); + listitem->set_height(listitem->font()->height() * 3.0f); savegamemenu_savebutton->set_text("Save"); if (!core::localcontrol()) { @@ -275,10 +275,17 @@ void SaveGameMenu::hide() Window::hide(); model::Material *screenshotmaterial = model::Material::find("ui/screenshot"); - if (screenshotmaterial && screenshotmaterial->texture().size()) { - render::Textures::unload(screenshotmaterial->texture()); - screenshotmaterial->set_texture(""); + if (screenshotmaterial) { + for (model::Material::Layers::const_iterator lit = screenshotmaterial->layers().begin(); lit != screenshotmaterial->layers().end(); ++lit) { + if ((*lit)->texture().size()) { + render::Textures::unload((*lit)->texture()); + (*lit)->set_texture(""); + } + } + } + + savegamemenu_screenshot->set_texture(""); } void SaveGameMenu::show() @@ -323,15 +330,26 @@ void SaveGameMenu::show_file_info() model::Material *screenshotmaterial = model::Material::find("ui/screenshot"); if (!screenshotmaterial) { screenshotmaterial = new model::Material("ui/screenshot"); - model::Material::add(screenshotmaterial); - screenshotmaterial ->set_flags(model::Material::FlagTexture); - screenshotmaterial ->set_flags(model::Material::FlagBright); - } else if (screenshotmaterial->texture().size()) { - render::Textures::unload(screenshotmaterial->texture()); + model::Material::registry()["ui/screenshot"] = screenshotmaterial; + } + + model::Layer *screenshotlayer = 0; + if (screenshotmaterial->layers().size() > 0) { + screenshotlayer = (*screenshotmaterial->layers().begin()); + } else { + screenshotlayer = new model::Layer(); + screenshotmaterial->layers().push_back(screenshotlayer); + screenshotlayer->set_bright(true); + } + if (screenshotlayer->texture().size()) { + render::Textures::unload(screenshotlayer->texture()); + screenshotlayer->set_texture(""); } std::string screenshotfilename("savegames/" + savename); - screenshotmaterial->set_texture(screenshotfilename); + screenshotlayer->set_texture(screenshotfilename); + render::Textures::image_loader(screenshotlayer); + screenshotmaterial->set_size(screenshotlayer->size()); savegamemenu_screenshot->set_texture("ui/screenshot"); savegamemenu_screenshot->show(); -- cgit v1.2.3