Giter Club home page Giter Club logo

Comments (5)

ericoporto avatar ericoporto commented on August 30, 2024

Btw, if one could just pass a sprite to the save function, they could just pass a pre-made asset to the save function instead for that specific game area. In theory one could even pass the room background but I don't think it is accessible currently as a sprite directly - one needs to get it as a drawing surface and then draw it in another drawing surface of a dynamic sprite to be able to then get that sprite.

from ags.

ivan-mogilko avatar ivan-mogilko commented on August 30, 2024

Btw, if one could just pass a sprite to the save function,

Hm, that's actually a very good idea, might be done on its own, regardless of the screenshot feature.

EDIT: so like

SaveGameSlot (int slot, const string description, DynamicSprite *image);

or

SaveGameSlot (int slot, const string description, int sprite);

The issue here will be to "lock" or copy this dynamic sprite into some temp storage, because save is done after function exits, and if sprite is a local variable, then it may get disposed.

from ags.

ericoporto avatar ericoporto commented on August 30, 2024

Ah things that sounds easy in my head and become hell to implement...

I may try the second approach, and use a sprite slot and some static bitmap object that holds a copy of whatever it was in the slot and frees it after writing.

But not sure how do deal with existing behavior, maybe it's better to give a new function name like SaveGameSlotWithGraphic?

The other approach is to have a global dynamic sprite that you set and then the SaveGameSlot uses it if it's set, and then holding the memory becomes part of this global holding this reference. Something like Game.SaveGameSlotSprite. I think this is uglier but just thought to mention.

from ags.

ivan-mogilko avatar ivan-mogilko commented on August 30, 2024

I do not think it's overly hard, there may be only 1 scheduled Save call in a function, but indeed the sprite has to be scheduled along somehow.

The function may remain same, the new argument will be optional and have a default value 0, in which case the screenshot is made if global settings tell to.

Well, that's the first thought, I might need to investigate this closer in order to find any potential problems.

from ags.

ivan-mogilko avatar ivan-mogilko commented on August 30, 2024

So, apparently, there are following changes involved here:

  1. Creating a screenshot with only selected layers (with DynamicSprite.CreateFromScreenShot);
  2. Passing an arbitrary sprite to SaveGameSlot.
  3. Telling how to make a automatic screenshot for the save (same settings are in p1).

I suppose that being able to pass any sprite to SaveGameSlot is a more suitable for individual function parameter than a screenshot layer selection, which is better set as a game option once (i.e. using SetGameOption).

Screenshot layers may be a combination of flags. For starters these could be only "cursor", "gui layer" and "room layer". More may be added later if there will be a need to filter specific sublayers (like make a screenshot of room background without objects), but these seem less useful (?).

In regards to implementation, graphic renderers already support tagging batches with a "layer" constant, and then filtering them out when redrawing last frame. Currently this is done for the purpose of fade-in and out effects, where mouse cursor should not be present.
As seen here, for example:

ags/Engine/ac/draw.cpp

Lines 2806 to 2807 in 203a76d

// Exclusive sub-batch for mouse cursor, to let filter it out (CHECKME later?)
gfxDriver->BeginSpriteBatch(Rect(), SpriteTransform(), kFlip_None, nullptr, RENDER_BATCH_MOUSE_CURSOR);

from ags.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.