libscratchcpp
A library for C++ based Scratch project players
Loading...
Searching...
No Matches
target.h
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2
3#pragma once
4
5#include <vector>
7
8#include "drawable.h"
9#include "rect.h"
10#include "sound.h"
11
12namespace libscratchcpp
13{
14
15class Variable;
16class List;
17class Block;
18class Comment;
19class Costume;
20class Sound;
21class Sprite;
22class TextBubble;
23class IGraphicsEffect;
24class TargetPrivate;
25
28{
29 public:
30 Target();
31 Target(const Target &) = delete;
32 virtual ~Target();
33
34 bool isTarget() const override final;
35
37 virtual bool isStage() const { return false; }
38
39 const std::string &name() const;
40 void setName(const std::string &name);
41
42 const std::vector<std::shared_ptr<Variable>> &variables() const;
43 int addVariable(std::shared_ptr<Variable> variable);
44 std::shared_ptr<Variable> variableAt(int index) const;
45 int findVariable(const std::string &variableName) const;
46 int findVariableById(const std::string &id) const;
47
48 ValueData **variableData();
49
50 const std::vector<std::shared_ptr<List>> &lists() const;
51 int addList(std::shared_ptr<List> list);
52 std::shared_ptr<List> listAt(int index) const;
53 int findList(const std::string &listName) const;
54 int findListById(const std::string &id) const;
55
56 List **listData();
57
58 const std::vector<std::shared_ptr<Block>> &blocks() const;
59 int addBlock(std::shared_ptr<Block> block);
60 std::shared_ptr<Block> blockAt(int index) const;
61 int findBlock(const std::string &id) const;
62 std::vector<std::shared_ptr<Block>> greenFlagBlocks() const;
63
64 const std::vector<std::shared_ptr<Comment>> &comments() const;
65 int addComment(std::shared_ptr<Comment> comment);
66 std::shared_ptr<Comment> commentAt(int index) const;
67 int findComment(const std::string &id) const;
68
69 int costumeIndex() const;
70 virtual void setCostumeIndex(int newCostumeIndex);
71
72 std::shared_ptr<Costume> currentCostume() const;
73 virtual int currentCostumeWidth() const;
74 virtual int currentCostumeHeight() const;
75
76 const std::vector<std::shared_ptr<Costume>> &costumes() const;
77 int addCostume(std::shared_ptr<Costume> costume);
78 std::shared_ptr<Costume> costumeAt(int index) const;
79 int findCostume(const std::string &costumeName) const;
80
81 const std::vector<std::shared_ptr<Sound>> &sounds() const;
82 int addSound(std::shared_ptr<Sound> sound);
83 std::shared_ptr<Sound> soundAt(int index) const;
84 int findSound(const std::string &soundName) const;
85
86 double volume() const;
87 void setVolume(double newVolume);
88
89 virtual double soundEffectValue(Sound::Effect effect) const;
90 virtual void setSoundEffectValue(Sound::Effect effect, double value);
91
92 virtual void clearSoundEffects();
93
94 virtual Rect boundingRect() const;
95 virtual Rect fastBoundingRect() const;
96
97 bool touchingSprite(Sprite *sprite) const;
98 virtual bool touchingPoint(double x, double y) const;
99 bool touchingEdge() const;
100 virtual bool touchingColor(Rgb color) const;
101 virtual bool touchingColor(Rgb color, Rgb mask) const;
102
103 double graphicsEffectValue(IGraphicsEffect *effect) const;
104 virtual void setGraphicsEffectValue(IGraphicsEffect *effect, double value);
105
106 virtual void clearGraphicsEffects();
107
108 TextBubble *bubble();
109 const TextBubble *bubble() const;
110
111 void setEngine(IEngine *engine) override final;
112
113 protected:
115 virtual Target *dataSource() const { return nullptr; }
116
118 virtual bool touchingClones(const std::vector<Sprite *> &clones) const { return false; }
119
120 private:
121 spimpl::unique_impl_ptr<TargetPrivate> impl;
122};
123
124} // namespace libscratchcpp
The Block class represents a Scratch block.
Definition block.h:24
The Comment class represents a comment in the code area.
Definition comment.h:15
The Costume class represents a Scratch costume.
Definition costume.h:17
Drawable()
Definition drawable.cpp:10
The IEngine interface provides an API for running Scratch projects.
Definition iengine.h:41
The IGraphicsEffects class is an interface for custom graphics effects.
Definition igraphicseffect.h:14
The List class represents a Scratch list.
Definition list.h:27
Definition rect.h:15
The Sound class represents a Scratch sound.
Definition sound.h:17
Effect
Definition sound.h:20
The Sprite class represents a Scratch sprite.
Definition sprite.h:18
virtual bool touchingClones(const std::vector< Sprite * > &clones) const
Definition target.h:118
Target(const Target &)=delete
Target()
Definition target.cpp:26
virtual bool isStage() const
Definition target.h:37
bool isTarget() const override final
Definition target.cpp:43
virtual Target * dataSource() const
Definition target.h:115
The TextBubble class represents a text bubble created using say or think block.
Definition textbubble.h:16
The Variable class represents a Scratch variable.
Definition variable.h:18
#define LIBSCRATCHCPP_EXPORT
Definition global.h:17
The main namespace of the library.
Definition asset.h:10
unsigned int Rgb
Definition value_functions.h:11
The ValueData struct holds the data of Value. It's used in compiled Scratch code for better performan...
Definition valuedata.h:26